[Ocfs2-tools-devel] [PATCH]ocfs2-tools: use open64() when open large file, v2

Coly Li coly.li at suse.de
Sat Mar 7 05:11:14 PST 2009


After discussed with Tristan and Joel, when open large files (e.g. device file
for harddisk, or file exceeded 2GB limit), open64() could be used to replace
open(). This patch does the replacement where __LARGEFILE64_SOURCE is defined.

The v2 patch removes libocfs2/ismounted.c and ocfs2console/blkid/getsize.c from
the modification. Thanks to Joel's advice.

Signed-off-by: Coly Li <coly.li at suse.de>
---
 libocfs2/blockcheck.c     |    2 +-
 libocfs2/checkhb.c        |    2 +-
 mount.ocfs2/mount.ocfs2.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libocfs2/blockcheck.c b/libocfs2/blockcheck.c
index f76051e..cb26e47 100644
--- a/libocfs2/blockcheck.c
+++ b/libocfs2/blockcheck.c
@@ -901,7 +901,7 @@ static void get_file(char *filename, char **buf, int *size)
 		exit(1);
 	}

-	fd = open(filename, O_RDONLY);
+	fd = open64(filename, O_RDONLY);
 	if (fd < 0) {
 		fprintf(stderr, "Unable to open \"%s\": %s\n", filename,
 			strerror(errno));
diff --git a/libocfs2/checkhb.c b/libocfs2/checkhb.c
index 4d48bd6..c171d6c 100644
--- a/libocfs2/checkhb.c
+++ b/libocfs2/checkhb.c
@@ -132,7 +132,7 @@ errcode_t ocfs2_get_ocfs1_label(char *device, uint8_t
*label, uint16_t label_len
 	char buf[512];
 	struct ocfs1_vol_label *v1_lbl;

-	fd = open(device, O_RDONLY);
+	fd = open64(device, O_RDONLY);
 	if (fd == -1)
 		goto bail;

diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index e3217c6..f820a30 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -200,7 +200,7 @@ static int check_dev_readonly(const char *dev, int *dev_ro)
 	int fd;
 	int ret;

-	fd = open(dev, O_RDONLY);
+	fd = open64(dev, O_RDONLY);
 	if (fd < 0)
 		return errno;

-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list