Re: [PATCH v3 4/4] quota: add project quota support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 10-09-14 11:54:54, Li Xi wrote:
> Adds ioctl interface support for ext4 project
> 
> This patch adds ioctl interface for setting/getting project of ext4.
> 
> Signed-off-by: Li Xi <lixi <at> ddn.com>
  Please CC linux-api@xxxxxxxxxxxxxxx for this patch so that people caring
about kernel API know about the change.

...
> ---
> Index: linux.git/fs/ext4/ioctl.c
> ===================================================================
> --- linux.git.orig/fs/ext4/ioctl.c
> +++ linux.git/fs/ext4/ioctl.c
> @@ -14,6 +14,8 @@
>  #include <linux/compat.h>
>  #include <linux/mount.h>
>  #include <linux/file.h>
> +#include <linux/quotaops.h>
> +#include <linux/quota.h>
>  #include <asm/uaccess.h>
>  #include "ext4_jbd2.h"
>  #include "ext4.h"
> @@ -611,6 +613,104 @@ resizefs_out:
>      case EXT4_IOC_PRECACHE_EXTENTS:
>          return ext4_ext_precache(inode);
> 
> +    case EXT4_IOC_GETPROJECT:
> +    {
> +#ifdef CONFIG_QUOTA_PROJECT
> +        __u32 projid;
> +
> +        if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
> +            EXT4_FEATURE_RO_COMPAT_PROJECT)) {
> +            ext4_msg(sb, KERN_ERR,
> +                 "get project not supported without "
> +                 "project feature");
  Please no messages into kernel log for failed ioctl(). Userspace could
easily flood logs with them.

> +            return -ENOTSUPP;
  This should be -EOPNOTSUPP I think.

> +        }
> +
> +        projid = (__u32)from_kprojid(&init_user_ns,
> +                         EXT4_I(inode)->i_projid);
> +        return put_user(projid, (__u32 __user *) arg);
> +#else
> +        ext4_msg(sb, KERN_ERR,
> +             "get project not supported without "
> +             "CONFIG_QUOTA_PROJECT");
> +        return -ENOTSUPP;
> +#endif
> +    }
> +    case EXT4_IOC_SETPROJECT:
> +    {
> +#ifdef CONFIG_QUOTA_PROJECT
> +        __u32 projid;
> +        int err;
> +        handle_t *handle;
> +        kprojid_t kprojid;
> +
> +        struct dquot *transfer_to[MAXQUOTAS] = { };
> +
> +        if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
> +            EXT4_FEATURE_RO_COMPAT_PROJECT)) {
> +            ext4_msg(sb, KERN_ERR,
> +                 "set project not supported without "
> +                 "project feature");
> +            return -ENOTSUPP;
  Same comments as for GETPROJECT apply here...

> +        }
> +
> +        /* Make sure caller can change project. */
> +        if (!capable(CAP_SYS_ADMIN))
> +            return -EACCES;
> +
> +        if (get_user(projid, (__u32 __user *) arg))
> +            return -EFAULT;
> +
> +        kprojid = make_kprojid(&init_user_ns, (projid_t)projid);
> +
> +        if (projid_eq(kprojid, EXT4_I(inode)->i_projid))
> +            return 0;
> +
  You should check whether project id fits into an inode here...

							Honza
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux