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

Coly Li coly.li at suse.de
Fri Feb 27 00:26:13 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.

Signed-off-by: Coly Li <coly.li at suse.de>
---
 libocfs2/blockcheck.c        |    2 +-
 libocfs2/checkhb.c           |    2 +-
 libocfs2/ismounted.c         |    2 +-
 mount.ocfs2/mount.ocfs2.c    |    2 +-
 ocfs2console/blkid/getsize.c |    2 +-
 5 files changed, 5 insertions(+), 5 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/libocfs2/ismounted.c b/libocfs2/ismounted.c
index 83b4d83..f45ac18 100644
--- a/libocfs2/ismounted.c
+++ b/libocfs2/ismounted.c
@@ -325,7 +325,7 @@ errcode_t ocfs2_check_mount_point(const char *device, int *mount_flags,
 	if ((stat(device, &st_buf) != 0) ||
 	    !S_ISBLK(st_buf.st_mode))
 		return 0;
-	fd = open(device, O_RDONLY | O_EXCL);
+	fd = open64(device, O_RDONLY | O_EXCL);
 	if (fd < 0) {
 		if (errno == EBUSY)
 			*mount_flags |= OCFS2_MF_BUSY;
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;

diff --git a/ocfs2console/blkid/getsize.c b/ocfs2console/blkid/getsize.c
index d45e1c2..1fce39a 100644
--- a/ocfs2console/blkid/getsize.c
+++ b/ocfs2console/blkid/getsize.c
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
 		return 1;
 	}

-	if ((fd = open(argv[1], O_RDONLY)) < 0)
+	if ((fd = open64(argv[1], O_RDONLY)) < 0)
 		perror(argv[0]);

 	bytes = blkid_get_dev_size(fd);
-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list