Loading fs/ext2/ext2.h +3 −4 Original line number Original line Diff line number Diff line Loading @@ -283,8 +283,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags) /* /* * ioctl commands * ioctl commands */ */ #define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS #define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) Loading @@ -293,8 +291,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags) /* /* * ioctl commands in 32 bit emulation * ioctl commands in 32 bit emulation */ */ #define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS #define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION Loading Loading @@ -772,6 +768,9 @@ extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len); u64 start, u64 len); /* ioctl.c */ /* ioctl.c */ extern int ext2_fileattr_get(struct dentry *dentry, struct fileattr *fa); extern int ext2_fileattr_set(struct user_namespace *mnt_userns, struct dentry *dentry, struct fileattr *fa); extern long ext2_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); Loading fs/ext2/file.c +2 −0 Original line number Original line Diff line number Diff line Loading @@ -204,4 +204,6 @@ const struct inode_operations ext2_file_inode_operations = { .get_acl = ext2_get_acl, .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .set_acl = ext2_set_acl, .fiemap = ext2_fiemap, .fiemap = ext2_fiemap, .fileattr_get = ext2_fileattr_get, .fileattr_set = ext2_fileattr_set, }; }; fs/ext2/ioctl.c +32 −56 Original line number Original line Diff line number Diff line Loading @@ -16,69 +16,51 @@ #include <linux/mount.h> #include <linux/mount.h> #include <asm/current.h> #include <asm/current.h> #include <linux/uaccess.h> #include <linux/uaccess.h> #include <linux/fileattr.h> int ext2_fileattr_get(struct dentry *dentry, struct fileattr *fa) long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { { struct inode *inode = file_inode(filp); struct ext2_inode_info *ei = EXT2_I(d_inode(dentry)); struct ext2_inode_info *ei = EXT2_I(inode); unsigned int flags; unsigned short rsv_window_size; int ret; ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); fileattr_fill_flags(fa, ei->i_flags & EXT2_FL_USER_VISIBLE); switch (cmd) { case EXT2_IOC_GETFLAGS: flags = ei->i_flags & EXT2_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT2_IOC_SETFLAGS: { unsigned int oldflags; ret = mnt_want_write_file(filp); if (ret) return ret; if (!inode_owner_or_capable(&init_user_ns, inode)) { return 0; ret = -EACCES; goto setflags_out; } } if (get_user(flags, (int __user *) arg)) { int ext2_fileattr_set(struct user_namespace *mnt_userns, ret = -EFAULT; struct dentry *dentry, struct fileattr *fa) goto setflags_out; { } struct inode *inode = d_inode(dentry); struct ext2_inode_info *ei = EXT2_I(inode); flags = ext2_mask_flags(inode->i_mode, flags); if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; inode_lock(inode); /* Is it quota file? Do not allow user to mess with it */ /* Is it quota file? Do not allow user to mess with it */ if (IS_NOQUOTA(inode)) { if (IS_NOQUOTA(inode)) inode_unlock(inode); return -EPERM; ret = -EPERM; goto setflags_out; } oldflags = ei->i_flags; ret = vfs_ioc_setflags_prepare(inode, oldflags, flags); if (ret) { inode_unlock(inode); goto setflags_out; } flags = flags & EXT2_FL_USER_MODIFIABLE; ei->i_flags = (ei->i_flags & ~EXT2_FL_USER_MODIFIABLE) | flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE; (fa->flags & EXT2_FL_USER_MODIFIABLE); ei->i_flags = flags; ext2_set_inode_flags(inode); ext2_set_inode_flags(inode); inode->i_ctime = current_time(inode); inode->i_ctime = current_time(inode); inode_unlock(inode); mark_inode_dirty(inode); mark_inode_dirty(inode); setflags_out: mnt_drop_write_file(filp); return 0; return ret; } } long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct inode *inode = file_inode(filp); struct ext2_inode_info *ei = EXT2_I(inode); unsigned short rsv_window_size; int ret; ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); switch (cmd) { case EXT2_IOC_GETVERSION: case EXT2_IOC_GETVERSION: return put_user(inode->i_generation, (int __user *) arg); return put_user(inode->i_generation, (int __user *) arg); case EXT2_IOC_SETVERSION: { case EXT2_IOC_SETVERSION: { Loading Loading @@ -163,12 +145,6 @@ long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { { /* These are just misnamed, they actually get/put from/to user an int */ /* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) { switch (cmd) { case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break; case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break; case EXT2_IOC32_GETVERSION: case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; cmd = EXT2_IOC_GETVERSION; break; break; Loading fs/ext2/namei.c +2 −0 Original line number Original line Diff line number Diff line Loading @@ -427,6 +427,8 @@ const struct inode_operations ext2_dir_inode_operations = { .get_acl = ext2_get_acl, .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .set_acl = ext2_set_acl, .tmpfile = ext2_tmpfile, .tmpfile = ext2_tmpfile, .fileattr_get = ext2_fileattr_get, .fileattr_set = ext2_fileattr_set, }; }; const struct inode_operations ext2_special_inode_operations = { const struct inode_operations ext2_special_inode_operations = { Loading Loading
fs/ext2/ext2.h +3 −4 Original line number Original line Diff line number Diff line Loading @@ -283,8 +283,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags) /* /* * ioctl commands * ioctl commands */ */ #define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS #define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) Loading @@ -293,8 +291,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags) /* /* * ioctl commands in 32 bit emulation * ioctl commands in 32 bit emulation */ */ #define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS #define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION Loading Loading @@ -772,6 +768,9 @@ extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len); u64 start, u64 len); /* ioctl.c */ /* ioctl.c */ extern int ext2_fileattr_get(struct dentry *dentry, struct fileattr *fa); extern int ext2_fileattr_set(struct user_namespace *mnt_userns, struct dentry *dentry, struct fileattr *fa); extern long ext2_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); Loading
fs/ext2/file.c +2 −0 Original line number Original line Diff line number Diff line Loading @@ -204,4 +204,6 @@ const struct inode_operations ext2_file_inode_operations = { .get_acl = ext2_get_acl, .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .set_acl = ext2_set_acl, .fiemap = ext2_fiemap, .fiemap = ext2_fiemap, .fileattr_get = ext2_fileattr_get, .fileattr_set = ext2_fileattr_set, }; };
fs/ext2/ioctl.c +32 −56 Original line number Original line Diff line number Diff line Loading @@ -16,69 +16,51 @@ #include <linux/mount.h> #include <linux/mount.h> #include <asm/current.h> #include <asm/current.h> #include <linux/uaccess.h> #include <linux/uaccess.h> #include <linux/fileattr.h> int ext2_fileattr_get(struct dentry *dentry, struct fileattr *fa) long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { { struct inode *inode = file_inode(filp); struct ext2_inode_info *ei = EXT2_I(d_inode(dentry)); struct ext2_inode_info *ei = EXT2_I(inode); unsigned int flags; unsigned short rsv_window_size; int ret; ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); fileattr_fill_flags(fa, ei->i_flags & EXT2_FL_USER_VISIBLE); switch (cmd) { case EXT2_IOC_GETFLAGS: flags = ei->i_flags & EXT2_FL_USER_VISIBLE; return put_user(flags, (int __user *) arg); case EXT2_IOC_SETFLAGS: { unsigned int oldflags; ret = mnt_want_write_file(filp); if (ret) return ret; if (!inode_owner_or_capable(&init_user_ns, inode)) { return 0; ret = -EACCES; goto setflags_out; } } if (get_user(flags, (int __user *) arg)) { int ext2_fileattr_set(struct user_namespace *mnt_userns, ret = -EFAULT; struct dentry *dentry, struct fileattr *fa) goto setflags_out; { } struct inode *inode = d_inode(dentry); struct ext2_inode_info *ei = EXT2_I(inode); flags = ext2_mask_flags(inode->i_mode, flags); if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; inode_lock(inode); /* Is it quota file? Do not allow user to mess with it */ /* Is it quota file? Do not allow user to mess with it */ if (IS_NOQUOTA(inode)) { if (IS_NOQUOTA(inode)) inode_unlock(inode); return -EPERM; ret = -EPERM; goto setflags_out; } oldflags = ei->i_flags; ret = vfs_ioc_setflags_prepare(inode, oldflags, flags); if (ret) { inode_unlock(inode); goto setflags_out; } flags = flags & EXT2_FL_USER_MODIFIABLE; ei->i_flags = (ei->i_flags & ~EXT2_FL_USER_MODIFIABLE) | flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE; (fa->flags & EXT2_FL_USER_MODIFIABLE); ei->i_flags = flags; ext2_set_inode_flags(inode); ext2_set_inode_flags(inode); inode->i_ctime = current_time(inode); inode->i_ctime = current_time(inode); inode_unlock(inode); mark_inode_dirty(inode); mark_inode_dirty(inode); setflags_out: mnt_drop_write_file(filp); return 0; return ret; } } long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct inode *inode = file_inode(filp); struct ext2_inode_info *ei = EXT2_I(inode); unsigned short rsv_window_size; int ret; ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); switch (cmd) { case EXT2_IOC_GETVERSION: case EXT2_IOC_GETVERSION: return put_user(inode->i_generation, (int __user *) arg); return put_user(inode->i_generation, (int __user *) arg); case EXT2_IOC_SETVERSION: { case EXT2_IOC_SETVERSION: { Loading Loading @@ -163,12 +145,6 @@ long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { { /* These are just misnamed, they actually get/put from/to user an int */ /* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) { switch (cmd) { case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break; case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break; case EXT2_IOC32_GETVERSION: case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; cmd = EXT2_IOC_GETVERSION; break; break; Loading
fs/ext2/namei.c +2 −0 Original line number Original line Diff line number Diff line Loading @@ -427,6 +427,8 @@ const struct inode_operations ext2_dir_inode_operations = { .get_acl = ext2_get_acl, .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .set_acl = ext2_set_acl, .tmpfile = ext2_tmpfile, .tmpfile = ext2_tmpfile, .fileattr_get = ext2_fileattr_get, .fileattr_set = ext2_fileattr_set, }; }; const struct inode_operations ext2_special_inode_operations = { const struct inode_operations ext2_special_inode_operations = { Loading