aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/quota.c')
-rw-r--r--fs/quota.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/fs/quota.c b/fs/quota.c
index d6a2be826e29..b9dae76a0b6e 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -338,6 +338,34 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
338} 338}
339 339
340/* 340/*
341 * look up a superblock on which quota ops will be performed
342 * - use the name of a block device to find the superblock thereon
343 */
344static inline struct super_block *quotactl_block(const char __user *special)
345{
346#ifdef CONFIG_BLOCK
347 struct block_device *bdev;
348 struct super_block *sb;
349 char *tmp = getname(special);
350
351 if (IS_ERR(tmp))
352 return ERR_PTR(PTR_ERR(tmp));
353 bdev = lookup_bdev(tmp);
354 putname(tmp);
355 if (IS_ERR(bdev))
356 return ERR_PTR(PTR_ERR(bdev));
357 sb = get_super(bdev);
358 bdput(bdev);
359 if (!sb)
360 return ERR_PTR(-ENODEV);
361
362 return sb;
363#else
364 return ERR_PTR(-ENODEV);
365#endif
366}
367
368/*
341 * This is the system call interface. This communicates with 369 * This is the system call interface. This communicates with
342 * the user-level programs. Currently this only supports diskquota 370 * the user-level programs. Currently this only supports diskquota
343 * calls. Maybe we need to add the process quotas etc. in the future, 371 * calls. Maybe we need to add the process quotas etc. in the future,
@@ -347,25 +375,15 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_t
347{ 375{
348 uint cmds, type; 376 uint cmds, type;
349 struct super_block *sb = NULL; 377 struct super_block *sb = NULL;
350 struct block_device *bdev;
351 char *tmp;
352 int ret; 378 int ret;
353 379
354 cmds = cmd >> SUBCMDSHIFT; 380 cmds = cmd >> SUBCMDSHIFT;
355 type = cmd & SUBCMDMASK; 381 type = cmd & SUBCMDMASK;
356 382
357 if (cmds != Q_SYNC || special) { 383 if (cmds != Q_SYNC || special) {
358 tmp = getname(special); 384 sb = quotactl_block(special);
359 if (IS_ERR(tmp)) 385 if (IS_ERR(sb))
360 return PTR_ERR(tmp); 386 return PTR_ERR(sb);
361 bdev = lookup_bdev(tmp);
362 putname(tmp);
363 if (IS_ERR(bdev))
364 return PTR_ERR(bdev);
365 sb = get_super(bdev);
366 bdput(bdev);
367 if (!sb)
368 return -ENODEV;
369 } 387 }
370 388
371 ret = check_quotactl_valid(sb, type, cmds, id); 389 ret = check_quotactl_valid(sb, type, cmds, id);