diff mbox

[V2] mke2fs: use ext2fs_open_file() in check_plausibility()

Message ID 537CE6C0.1050800@redhat.com
State Accepted, archived
Headers show

Commit Message

Eric Sandeen May 21, 2014, 5:47 p.m. UTC
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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

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 ...





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

Comments

Darrick Wong May 21, 2014, 6 p.m. UTC | #1
On Wed, May 21, 2014 at 12:47:44PM -0500, Eric Sandeen wrote:
> 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
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> 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
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D
> 
> 
> 
> diff --git a/misc/util.c b/misc/util.c
> index 1c0818f..7e91509 100644
> --- a/misc/util.c
> +++ b/misc/util.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o May 22, 2014, 5:56 p.m. UTC | #2
On Wed, May 21, 2014 at 12:47:44PM -0500, Eric Sandeen wrote:
> 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
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/util.c b/misc/util.c
index 1c0818f..7e91509 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -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);
 	}