[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140910200901.GD10507@quack.suse.cz>
Date: Wed, 10 Sep 2014 22:09:01 +0200
From: Jan Kara <jack@...e.cz>
To: Li Xi <pkuelelixi@...il.com>
Cc: "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
Ext4 Developers List <linux-ext4@...r.kernel.org>,
Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger@...ger.ca>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
"hch@...radead.org" <hch@...radead.org>, Jan Kara <jack@...e.cz>,
Dmitry Monakhov <dmonakhov@...nvz.org>
Subject: Re: [PATCH v3 4/4] quota: add project quota support
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@...r.kernel.org 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@...e.cz>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists