Separate FMODE_PREAD/FMODE_PWRITE into separate flags
PATCH 1/1 Separate FMODE_PREAD/FMODE_PWRITE into separate flags
Separate FMODE_PREAD and FMODE_PWRITE into separate flags to reflect the reality that the read and write paths may have independent restrictions.
A git grep verifies that these flags are always cleared together so this new behavior will only apply to interfaces that change to clear flags individually.
--- include/linux/fs.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
include/linux/fs.h +7 -6
@@ -60,18 +60,19 @@ struct inodes_stat_t {#define FMODE_WRITE ((__force fmode_t)2)/* file is seekable */ #define FMODE_LSEEK ((__force fmode_t)4) -/* file can be accessed using pread/pwrite */ +/* file can be accessed using pread */ #define FMODE_PREAD ((__force fmode_t)8) -#define FMODE_PWRITE FMODE_PREAD/* These go hand in hand */ +/* file can be accessed using pwrite */ +#define FMODE_PWRITE ((__force fmode_t)16)/* File is opened for execution with sys_execve / sys_uselib */ -#define FMODE_EXEC ((__force fmode_t)16) +#define FMODE_EXEC ((__force fmode_t)32)/* File is opened with O_NDELAY (only set for block devices) */ -#define FMODE_NDELAY ((__force fmode_t)32) +#define FMODE_NDELAY ((__force fmode_t)64)/* File is opened with O_EXCL (only set for block devices) */ -#define FMODE_EXCL ((__force fmode_t)64) +#define FMODE_EXCL ((__force fmode_t)128)/* File is opened using open(.., 3, ..) and is writeable only for ioctls (specialy hack for floppy.c) */ -#define FMODE_WRITE_IOCTL ((__force fmode_t)128) +#define FMODE_WRITE_IOCTL ((__force fmode_t)256)/* * Don't update ctime and mtime.
Signature · 1 line
1.5.4.5
(fix typo on Eric's email address)
Quoted 50 lines · Paul Turner
Separate
FMODE_PREADandFMODE_PWRITEinto separate flags to reflect the reality that the read and write paths may have independent restrictions.A git grep verifies that these flags are always cleared together so this new behavior will only apply to interfaces that change to clear flags individually.
Signed-off-by Paul Turner <[email protected]>--- include/linux/fs.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)include/linux/fs.h +7
-7@@ -60,18 +60,19 @@ struct inodes_stat_t {#define FMODE_WRITE ((__force fmode_t)2)/* file is seekable */ #define FMODE_LSEEK ((__force fmode_t)4) -/* file can be accessed using pread/pwrite */ +/* file can be accessed using pread */ #define FMODE_PREAD ((__force fmode_t)8) -#define FMODE_PWRITE FMODE_PREAD/* These go hand in hand */ +/* file can be accessed using pwrite */ +#define FMODE_PWRITE ((__force fmode_t)16)/* File is opened for execution with sys_execve / sys_uselib */ -#define FMODE_EXEC ((__force fmode_t)16) +#define FMODE_EXEC ((__force fmode_t)32)/* File is opened with O_NDELAY (only set for block devices) */ -#define FMODE_NDELAY ((__force fmode_t)32) +#define FMODE_NDELAY ((__force fmode_t)64)/* File is opened with O_EXCL (only set for block devices) */ -#define FMODE_EXCL ((__force fmode_t)64) +#define FMODE_EXCL ((__force fmode_t)128)/* File is opened using open(.., 3, ..) and is writeable only for ioctls (specialy hack for floppy.c) */ -#define FMODE_WRITE_IOCTL ((__force fmode_t)128) +#define FMODE_WRITE_IOCTL ((__force fmode_t)256)/* * Don't update ctime and mtime. -- 1.5.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
(cc's restored)
Quoted 31 lines · On Wed, 4 Feb 2009 18:06:11 -0800 (PST) Paul Turner <[email protected]> wrote:
Separate
FMODE_PREADandFMODE_PWRITEinto separate flags to reflect the reality that the read and write paths may have independent restrictions.A git grep verifies that these flags are always cleared together so this new behavior will only apply to interfaces that change to clear flags individually.
Signed-off-by Paul Turner <[email protected]>--- include/linux/fs.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)include/linux/fs.h +5
-4@@ -60,18 +60,19 @@ struct inodes_stat_t {#define FMODE_WRITE ((__force fmode_t)2)/* file is seekable */ #define FMODE_LSEEK ((__force fmode_t)4) -/* file can be accessed using pread/pwrite */ +/* file can be accessed using pread */ #define FMODE_PREAD ((__force fmode_t)8) -#define FMODE_PWRITE FMODE_PREAD/* These go hand in hand */ +/* file can be accessed using pwrite */ +#define FMODE_PWRITE ((__force fmode_t)16)/* File is opened for execution with sys_execve / sys_uselib */ -#define FMODE_EXEC ((__force fmode_t)16) +#define FMODE_EXEC ((__force fmode_t)32)/* File is opened with O_NDELAY (only set for block devices) */ -#define FMODE_NDELAY ((__force fmode_t)32) +#define FMODE_NDELAY ((__force fmode_t)64)
include/linux/fs.h struct inodes_stat_t { · line 78
Quoted 10 lines
include/linux/fs.h +2
-2/* File is opened with O_EXCL (only set for block devices) */ -#define FMODE_EXCL ((__force fmode_t)64) +#define FMODE_EXCL ((__force fmode_t)128)/* File is opened using open(.., 3, ..) and is writeable only for ioctls (specialy hack for floppy.c) */ -#define FMODE_WRITE_IOCTL ((__force fmode_t)128) +#define FMODE_WRITE_IOCTL ((__force fmode_t)256)/* * Don't update ctime and mtime.
Seems OK.
I augmented the changelog to
Separate FMODE_PREAD and FMODE_PWRITE into separate flags to reflect the reality that the read and write paths may have independent restrictions.
A git grep verifies that these flags are always cleared together so this new behavior will only apply to interfaces that change to clear flags individually.
+ This is required for "seq_file: properly cope with pread", a
+ post-2.6.25 regression fix.
and added this comment:
include/linux/fs.h renamed from include/linux/fs.h~vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags-fix +5 -0
@@ -54,6 +54,11 @@ struct inodes_stat_t {#define MAY_ACCESS 16#define MAY_OPEN 32 +/* +* flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond +* to O_WRONLY and O_RDWR via the strange trick in __dentry_open() +*/ +/* file is open for reading */ #define FMODE_READ ((__force fmode_t)1)/* file is open for writing */
_
Quoted 34 lines · On Wed, 4 Feb 2009 19:36:15 -0800 Andrew Morton <[email protected]>…
Quoted 2 lines
/*
* Don't update ctime and mtime.Seems OK.
I augmented the changelog to
Separate
FMODE_PREADandFMODE_PWRITEinto separate flags to reflect the reality that the read and write paths may have independent restrictions.A git grep verifies that these flags are always cleared together so this new behavior will only apply to interfaces that change to clear flags individually.
+ This is required for "
seq_file: properly cope with pread", a
+ post-2.6.25 regression fix.and added this comment:
include/linux/fs.h renamed from include/linux/fs.h~vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags-fix +5
-0@@ -54,6 +54,11 @@ struct inodes_stat_t {#define MAY_ACCESS 16#define MAY_OPEN 32 +/* +* flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond +* to O_WRONLY and O_RDWR via the strange trick in __dentry_open() +*/ +/* file is open for reading */ #define FMODE_READ ((__force fmode_t)1)/* file is open for writing */
Quoted 2 lines
_
And I updated seq_file-properly-cope-with-pread.patch thusly:
fs/seq_file.c renamed from fs/seq_file.c~seq_file-properly-cope-with-pread-fix +10 -0
@@ -48,6 +48,16 @@ int seq_open(struct file *file, const st*/ file->f_version =0 ; +/* +* seq_files support lseek() and pread(). They do not implement +* write() at all, but we clear FMODE_PWRITE here for historical +* reasons. +* +* If a client of seq_files a) implements file.write() and b) wishes to +* support pwrite() then that client will need to implement its own +* file.open() which calls seq_open() and then sets FMODE_WRITE. +*/ + file->f_mode &= ~FMODE_PWRITE ;return 0 ; }EXPORT_SYMBOL (seq_open);
diff -puN include/linux/seq_file.h~seq_file-properly-cope-with-pread-fix include/linux/seq_file.h _
Quoted 6 lines · On Wed, 4 Feb 2009 19:42:03 -0800 Andrew Morton <[email protected]>…
And I updated seq_file-properly-cope-with-pread.patch thusly:
fs/seq_file.c renamed from fs/seq_file.c~seq_file-properly-cope-with-pread-fix +0
-0@@ -48,6 +48,16 @@ int seq_open(struct file *file, const st*/
fs/seq_file.c int seq_open(struct file *file, const st · line 58
Quoted 10 lines
fs/seq_file.c renamed from fs/seq_file.c~seq_file-properly-cope-with-pread-fix +8
-0file->f_version =0 ; +/* +* seq_files support lseek() and pread(). They do not implement +* write() at all, but we clear FMODE_PWRITE here for historical +* reasons. +* +* If a client of seq_files a) implements file.write() and b) wishes to +* support pwrite() then that client will need to implement its own +* file.open() which calls seq_open() and then sets FMODE_WRITE.
^P
Quoted 5 lines
fs/seq_file.c renamed from fs/seq_file.c~seq_file-properly-cope-with-pread-fix +2
-0+*/ + file->f_mode &= ~FMODE_PWRITE ;return 0 ; }EXPORT_SYMBOL (seq_open);