1 From: Andreas Gruenbacher <agruen@suse.de>
2 Subject: Allow filesystems to handle MAY_APPEND
4 The MS_WITHAPPEND super_block flag tells the vfs that the permission
5 inode operation understands the MAY_APPEND flag. This is required for
6 implementing permission models which go beyond the traditional UNIX
9 If a filesystem does not set the flag, the behavior is unchanged.
11 Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
15 include/linux/fs.h | 2 ++
16 2 files changed, 7 insertions(+), 1 deletion(-)
20 @@ -230,6 +230,7 @@ int generic_permission(struct inode *ino
21 int inode_permission(struct inode *inode, int mask)
26 if (mask & MAY_WRITE) {
27 umode_t mode = inode->i_mode;
28 @@ -248,9 +249,12 @@ int inode_permission(struct inode *inode
32 + if (!IS_WITHAPPEND(inode))
33 + submask &= ~MAY_APPEND;
35 /* Ordinary permission routines do not understand MAY_APPEND. */
36 if (inode->i_op && inode->i_op->permission) {
37 - retval = inode->i_op->permission(inode, mask);
38 + retval = inode->i_op->permission(inode, submask);
41 * Exec permission on a regular file is denied if none
42 --- a/include/linux/fs.h
43 +++ b/include/linux/fs.h
44 @@ -133,6 +133,7 @@ extern int dir_notify_enable;
45 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
46 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
47 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
48 +#define MS_WITHAPPEND (1<<24) /* iop->permission() understands MAY_APPEND */
49 #define MS_ACTIVE (1<<30)
50 #define MS_NOUSER (1<<31)
52 @@ -183,6 +184,7 @@ extern int dir_notify_enable;
53 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
54 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
55 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
56 +#define IS_WITHAPPEND(inode) __IS_FLG(inode, MS_WITHAPPEND)
58 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
59 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)