10 #include <linux/slab.h>
11 #include <asm/current.h>
13 #include <linux/kernel.h>
16 #include <linux/capability.h>
18 #include <linux/types.h>
50 sb->
s_qcop->quota_sync(sb, *(
int *)arg);
53 static int quota_sync_all(
int type)
65 static int quota_quotaon(
struct super_block *sb,
int type,
int cmd,
qid_t id,
70 if (sb->
s_qcop->quota_on_meta)
71 return sb->
s_qcop->quota_on_meta(sb, type,
id);
74 return sb->
s_qcop->quota_on(sb, type,
id, path);
77 static int quota_getfmt(
struct super_block *sb,
int type,
void __user *
addr)
82 if (!sb_has_quota_active(sb, type)) {
83 up_read(&sb_dqopt(sb)->dqptr_sem);
86 fmt = sb_dqopt(sb)->info[
type].dqi_format->qf_fmt_id;
87 up_read(&sb_dqopt(sb)->dqptr_sem);
93 static int quota_getinfo(
struct super_block *sb,
int type,
void __user *addr)
106 static int quota_setinfo(
struct super_block *sb,
int type,
void __user *addr)
112 if (!sb->
s_qcop->set_info)
138 if (!sb->
s_qcop->get_dqblk)
143 ret = sb->
s_qcop->get_dqblk(sb,
qid, &fdq);
146 copy_to_if_dqblk(&idq, &fdq);
187 if (!sb->
s_qcop->set_dqblk)
192 copy_from_if_dqblk(&fdq, &idq);
193 return sb->
s_qcop->set_dqblk(sb,
qid, &fdq);
196 static int quota_setxstate(
struct super_block *sb,
int cmd,
void __user *addr)
202 if (!sb->
s_qcop->set_xstate)
204 return sb->
s_qcop->set_xstate(sb, flags, cmd);
207 static int quota_getxstate(
struct super_block *sb,
void __user *addr)
212 if (!sb->
s_qcop->get_xstate)
214 ret = sb->
s_qcop->get_xstate(sb, &fqs);
228 if (!sb->
s_qcop->set_dqblk)
233 return sb->
s_qcop->set_dqblk(sb,
qid, &fdq);
243 if (!sb->
s_qcop->get_dqblk)
248 ret = sb->
s_qcop->get_dqblk(sb,
qid, &fdq);
256 void __user *addr,
struct path *path)
265 ret = check_quotactl_permission(sb, type, cmd,
id);
271 return quota_quotaon(sb, type, cmd,
id, path);
273 if (!sb->
s_qcop->quota_off)
275 return sb->
s_qcop->quota_off(sb, type);
277 return quota_getfmt(sb, type, addr);
279 return quota_getinfo(sb, type, addr);
281 return quota_setinfo(sb, type, addr);
283 return quota_getquota(sb, type,
id, addr);
285 return quota_setquota(sb, type,
id, addr);
287 if (!sb->
s_qcop->quota_sync)
289 return sb->
s_qcop->quota_sync(sb, type);
293 return quota_setxstate(sb, cmd, addr);
295 return quota_getxstate(sb, addr);
297 return quota_setxquota(sb, type,
id, addr);
299 return quota_getxquota(sb, type,
id, addr);
311 static int quotactl_cmd_write(
int cmd)
329 static struct super_block *quotactl_block(
const char __user *special,
int cmd)
337 return ERR_CAST(tmp);
341 return ERR_CAST(bdev);
342 if (quotactl_cmd_write(cmd))
363 qid_t,
id,
void __user *, addr)
367 struct path path, *pathp =
NULL;
380 return quota_sync_all(type);
392 pathp = ERR_PTR(ret);
397 sb = quotactl_block(special, cmds);
403 ret = do_quotactl(sb, type, cmds,
id, addr, pathp);
407 if (pathp && !IS_ERR(pathp))