diff options
author | Chandra Seetharaman <sekharan@us.ibm.com> | 2013-08-06 17:27:07 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-20 16:53:58 -0500 |
commit | af30cb446dd5f4ad5b93d7d4188c49a864c0d643 (patch) | |
tree | 44e7d582ecffbcb91310a271ba80b218efdce9eb /fs/quota | |
parent | c2bfbc9b485a750b6af4a97ff3ad22b576e74d20 (diff) | |
download | linux-af30cb446dd5f4ad5b93d7d4188c49a864c0d643.tar.gz linux-af30cb446dd5f4ad5b93d7d4188c49a864c0d643.tar.bz2 linux-af30cb446dd5f4ad5b93d7d4188c49a864c0d643.zip |
quota: Add a new quotactl command Q_XGETQSTATV
XFS now supports three types of quotas (user, group and project).
Current version of Q_XGETSTAT has support for only two types of quotas.
In order to support three types of quotas, the interface, specifically
struct fs_quota_stat, need to be expanded. Current version of fs_quota_stat
does not allow expansion without breaking backward compatibility.
So, a quotactl command and new fs_quota_stat structure need to be added.
This patch adds a new command Q_XGETQSTATV to quotactl() which takes
a new data structure fs_quota_statv. This new data structure provides
support for future expansion and backward compatibility.
Callers of the new quotactl command have to set the version of the data
structure being passed, and kernel will fill as much data as requested.
If the kernel does not support the user-space provided version, EINVAL
will be returned. User-space can reduce the version number and call the same
quotactl again.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
[v2: Applied rjohnston's suggestions as per Chandra's request. -bpm]
Diffstat (limited to 'fs/quota')
-rw-r--r-- | fs/quota/quota.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c index c7314f1771f5..dea86e8967ee 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c @@ -27,6 +27,7 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd, case Q_SYNC: case Q_GETINFO: case Q_XGETQSTAT: + case Q_XGETQSTATV: case Q_XQUOTASYNC: break; /* allow to query information for dquots we "own" */ @@ -217,6 +218,31 @@ static int quota_getxstate(struct super_block *sb, void __user *addr) return ret; } +static int quota_getxstatev(struct super_block *sb, void __user *addr) +{ + struct fs_quota_statv fqs; + int ret; + + if (!sb->s_qcop->get_xstatev) + return -ENOSYS; + + memset(&fqs, 0, sizeof(fqs)); + if (copy_from_user(&fqs, addr, 1)) /* Just read qs_version */ + return -EFAULT; + + /* If this kernel doesn't support user specified version, fail */ + switch (fqs.qs_version) { + case FS_QSTATV_VERSION1: + break; + default: + return -EINVAL; + } + ret = sb->s_qcop->get_xstatev(sb, &fqs); + if (!ret && copy_to_user(addr, &fqs, sizeof(fqs))) + return -EFAULT; + return ret; +} + static int quota_setxquota(struct super_block *sb, int type, qid_t id, void __user *addr) { @@ -293,6 +319,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, return quota_setxstate(sb, cmd, addr); case Q_XGETQSTAT: return quota_getxstate(sb, addr); + case Q_XGETQSTATV: + return quota_getxstatev(sb, addr); case Q_XSETQLIM: return quota_setxquota(sb, type, id, addr); case Q_XGETQUOTA: @@ -317,6 +345,7 @@ static int quotactl_cmd_write(int cmd) case Q_GETINFO: case Q_SYNC: case Q_XGETQSTAT: + case Q_XGETQSTATV: case Q_XGETQUOTA: case Q_XQUOTASYNC: return 0; |