Skip to contentSkip to conversation

mke2fs: use ext2fs_open_file() in check_plausibility()

PATCH Superseded Eric Sandeen 3 participants 4 messages May 21, 2014 – May 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mke2fs: use ext2fs_open_file() in check_plausibility()

The commit:

802146c mke2fs: create a regular file if necessary

caused a regression on 32-bit machines; the open() fails if the file size is > 4G.

Using ext2fs_open_file() fixes it.

Resolves: Red Hat Bugzilla #1099892

---

TBH I don't know if this should be using ext2fs_open_file(), or some other magic like O_LARGEFILE, but this works for me, and we use the stat/fstat wrapper here too, so ...

misc/util.c +1 -1
index f85942e..d638625 100644
@@ -94,7 +94,7 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev)
 	if (flags & CREATE_FILE)
 		fl |= O_CREAT;
 
-	fd = open(device, fl, 0666);
+	fd = ext2fs_open_file(device, fl, 0666);
 	if (fd < 0) {
 		fprintf(stderr, _("Could not open %s: %s\n"),
 			device, error_message(errno));
#1 lore raw

PATCH v2 1/1 mke2fs: use ext2fs_open_file() in check_plausibility()

The commit:

802146c mke2fs: create a regular file if necessary

caused a regression on 32-bit machines; the open() fails if the file size is > 4G.

Using ext2fs_open_file() fixes it.

Resolves: Red Hat Bugzilla #1099892

---

V2: against master! Sorry, first patch was against the bisection point.

TBH I don't know if this should be using ext2fs_open_file(), or some other magic like O_LARGEFILE, but this works for me, and we use the stat/fstat wrapper here too, so ...

misc/util.c +2 -2
index 1c0818f..7e91509 100644
@@ -194,10 +194,10 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev)
 	char *fs_type = NULL;
 	char *fs_label = NULL;
 
-	fd = open(device, fl, 0666);
+	fd = ext2fs_open_file(device, fl, 0666);
 	if ((fd < 0) && (errno == ENOENT) && (flags & CREATE_FILE)) {
 		fl |= O_CREAT;
-		fd = open(device, fl, 0666);
+		fd = ext2fs_open_file(device, fl, 0666);
 		if (fd >= 0 && (flags & VERBOSE_CREATE))
 			printf(_("Creating regular file %s\n"), device);
 	}
Reviewed-by on v2 1/1
#2 lore raw
Quoted 12 lines · Eric Sandeen

The commit:

802146c mke2fs: create a regular file if necessary

caused a regression on 32-bit machines; the open() fails if the file size is > 4G.

Using ext2fs_open_file() fixes it.

Resolves: Red Hat Bugzilla #1099892

Quoted 8 lines

---

V2: against master! Sorry, first patch was against the bisection point.

TBH I don't know if this should be using ext2fs_open_file(), or some other magic like O_LARGEFILE, but this works for me, and we use the stat/fstat wrapper here too, so ...

/me suspects do_write_internal() in create_inode.c should use this too.

As for the patch itself, looks good, so

--D

Quoted 26 lines
misc/util.c +2 -3
index 1c0818f..7e91509 100644
@@ -194,10 +194,10 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev)
 	char *fs_type = NULL;
 	char *fs_label = NULL;
 
-	fd = open(device, fl, 0666);
+	fd = ext2fs_open_file(device, fl, 0666);
 	if ((fd < 0) && (errno == ENOENT) && (flags & CREATE_FILE)) {
 		fl |= O_CREAT;
-		fd = open(device, fl, 0666);
+		fd = ext2fs_open_file(device, fl, 0666);
 		if (fd >= 0 && (flags & VERBOSE_CREATE))
 			printf(_("Creating regular file %s\n"), device);
 	}
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

The commit:

802146c mke2fs: create a regular file if necessary

Quoted 8 lines

caused a regression on 32-bit machines; the open() fails if the file size is > 4G.

Using ext2fs_open_file() fixes it.

Resolves: Red Hat Bugzilla #1099892

Applied, thanks.

- Ted