All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags
@ 2009-02-05  2:06 Paul Turner
  2009-02-05  2:13 ` Paul Turner
  2009-02-05  3:36 ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Turner @ 2009-02-05  2:06 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan, ebierderm

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.

Signed-off-by: Paul Turner <pjt@google.com>
---
 include/linux/fs.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6022f44..d6a51d9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags
  2009-02-05  2:06 [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags Paul Turner
@ 2009-02-05  2:13 ` Paul Turner
  2009-02-05  3:36 ` Andrew Morton
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Turner @ 2009-02-05  2:13 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan, ebiederm

(fix typo on Eric's email address)

On Wed, Feb 4, 2009 at 6:06 PM, Paul Turner <pjt@google.com> wrote:
> 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.
>
> Signed-off-by: Paul Turner <pjt@google.com>
> ---
>  include/linux/fs.h |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 6022f44..d6a51d9 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags
  2009-02-05  2:06 [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags Paul Turner
  2009-02-05  2:13 ` Paul Turner
@ 2009-02-05  3:36 ` Andrew Morton
  2009-02-05  3:42   ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2009-02-05  3:36 UTC (permalink / raw)
  To: Paul Turner
  Cc: linux-kernel, adobriyan, ebierderm, stable, Al Viro,
	Linus Torvalds

(cc's restored)

On Wed, 4 Feb 2009 18:06:11 -0800 (PST) Paul Turner <pjt@google.com> wrote:

> 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.
> 
> Signed-off-by: Paul Turner <pjt@google.com>
> ---
>  include/linux/fs.h |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 6022f44..d6a51d9 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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.

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:

--- a/include/linux/fs.h~vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags-fix
+++ a/include/linux/fs.h
@@ -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 */
_


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags
  2009-02-05  3:36 ` Andrew Morton
@ 2009-02-05  3:42   ` Andrew Morton
  2009-02-05  3:43     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2009-02-05  3:42 UTC (permalink / raw)
  To: Paul Turner, linux-kernel, adobriyan, ebierderm, stable, Al Viro,
	Linus Torvalds

On Wed, 4 Feb 2009 19:36:15 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:

> >  /*
> >   * 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:
> 
> --- a/include/linux/fs.h~vfs-separate-fmode_pread-fmode_pwrite-into-separate-flags-fix
> +++ a/include/linux/fs.h
> @@ -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 */
> _
> 

And I updated seq_file-properly-cope-with-pread.patch thusly:

--- a/fs/seq_file.c~seq_file-properly-cope-with-pread-fix
+++ a/fs/seq_file.c
@@ -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
_


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags
  2009-02-05  3:42   ` Andrew Morton
@ 2009-02-05  3:43     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2009-02-05  3:43 UTC (permalink / raw)
  To: Paul Turner, linux-kernel, adobriyan, ebierderm, stable, Al Viro,
	Linus Torvalds

On Wed, 4 Feb 2009 19:42:03 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:

> And I updated seq_file-properly-cope-with-pread.patch thusly:
> 
> --- a/fs/seq_file.c~seq_file-properly-cope-with-pread-fix
> +++ a/fs/seq_file.c
> @@ -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.
                                                                  ^P
> +	 */
> +	file->f_mode &= ~FMODE_PWRITE;
>  	return 0;
>  }
>  EXPORT_SYMBOL(seq_open);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-05  3:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05  2:06 [PATCH] Separate FMODE_PREAD/FMODE_PWRITE into separate flags Paul Turner
2009-02-05  2:13 ` Paul Turner
2009-02-05  3:36 ` Andrew Morton
2009-02-05  3:42   ` Andrew Morton
2009-02-05  3:43     ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.