quota.c (fb0b82b32ce17564bc64cede50bf4a3204eecc60) quota.c (4b217ed9e30f94b6e8e5e262020ef0ceab6113af)
1/*
2 * Quota code necessary even when VFS quota support is not compiled
3 * into the kernel. The interesting stuff is over in dquot.c, here
4 * we have symbols for initial quotactl(2) handling, the sysctl(2)
5 * variables, etc - things needed even when quota support disabled.
6 */
7
8#include <linux/fs.h>

--- 268 unchanged lines hidden (view full) ---

277 return quota_setxstate(sb, cmd, addr);
278 case Q_XGETQSTAT:
279 return quota_getxstate(sb, addr);
280 case Q_XSETQLIM:
281 return quota_setxquota(sb, type, id, addr);
282 case Q_XGETQUOTA:
283 return quota_getxquota(sb, type, id, addr);
284 case Q_XQUOTASYNC:
1/*
2 * Quota code necessary even when VFS quota support is not compiled
3 * into the kernel. The interesting stuff is over in dquot.c, here
4 * we have symbols for initial quotactl(2) handling, the sysctl(2)
5 * variables, etc - things needed even when quota support disabled.
6 */
7
8#include <linux/fs.h>

--- 268 unchanged lines hidden (view full) ---

277 return quota_setxstate(sb, cmd, addr);
278 case Q_XGETQSTAT:
279 return quota_getxstate(sb, addr);
280 case Q_XSETQLIM:
281 return quota_setxquota(sb, type, id, addr);
282 case Q_XGETQUOTA:
283 return quota_getxquota(sb, type, id, addr);
284 case Q_XQUOTASYNC:
285 /* caller already holds s_umount */
286 if (sb->s_flags & MS_RDONLY)
287 return -EROFS;
285 if (sb->s_flags & MS_RDONLY)
286 return -EROFS;
288 writeback_inodes_sb(sb, WB_REASON_SYNC);
287 /* XFS quotas are fully coherent now, making this call a noop */
289 return 0;
290 default:
291 return -EINVAL;
292 }
293}
294
288 return 0;
289 default:
290 return -EINVAL;
291 }
292}
293
295/* Return 1 if 'cmd' will block on frozen filesystem */
296static int quotactl_cmd_write(int cmd)
297{
298 switch (cmd) {
299 case Q_GETFMT:
300 case Q_GETINFO:
301 case Q_SYNC:
302 case Q_XGETQSTAT:
303 case Q_XGETQUOTA:
304 case Q_XQUOTASYNC:
305 return 0;
306 }
307 return 1;
308}
309
310/*
311 * look up a superblock on which quota ops will be performed
312 * - use the name of a block device to find the superblock thereon
313 */
294/*
295 * look up a superblock on which quota ops will be performed
296 * - use the name of a block device to find the superblock thereon
297 */
314static struct super_block *quotactl_block(const char __user *special, int cmd)
298static struct super_block *quotactl_block(const char __user *special)
315{
316#ifdef CONFIG_BLOCK
317 struct block_device *bdev;
318 struct super_block *sb;
319 char *tmp = getname(special);
320
321 if (IS_ERR(tmp))
322 return ERR_CAST(tmp);
323 bdev = lookup_bdev(tmp);
324 putname(tmp);
325 if (IS_ERR(bdev))
326 return ERR_CAST(bdev);
299{
300#ifdef CONFIG_BLOCK
301 struct block_device *bdev;
302 struct super_block *sb;
303 char *tmp = getname(special);
304
305 if (IS_ERR(tmp))
306 return ERR_CAST(tmp);
307 bdev = lookup_bdev(tmp);
308 putname(tmp);
309 if (IS_ERR(bdev))
310 return ERR_CAST(bdev);
327 if (quotactl_cmd_write(cmd))
328 sb = get_super_thawed(bdev);
329 else
330 sb = get_super(bdev);
311 sb = get_super(bdev);
331 bdput(bdev);
332 if (!sb)
333 return ERR_PTR(-ENODEV);
334
335 return sb;
336#else
337 return ERR_PTR(-ENODEV);
338#endif

--- 35 unchanged lines hidden (view full) ---

374 if (cmds == Q_QUOTAON) {
375 ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
376 if (ret)
377 pathp = ERR_PTR(ret);
378 else
379 pathp = &path;
380 }
381
312 bdput(bdev);
313 if (!sb)
314 return ERR_PTR(-ENODEV);
315
316 return sb;
317#else
318 return ERR_PTR(-ENODEV);
319#endif

--- 35 unchanged lines hidden (view full) ---

355 if (cmds == Q_QUOTAON) {
356 ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
357 if (ret)
358 pathp = ERR_PTR(ret);
359 else
360 pathp = &path;
361 }
362
382 sb = quotactl_block(special, cmds);
363 sb = quotactl_block(special);
383 if (IS_ERR(sb)) {
384 ret = PTR_ERR(sb);
385 goto out;
386 }
387
388 ret = do_quotactl(sb, type, cmds, id, addr, pathp);
389
390 drop_super(sb);
391out:
392 if (pathp && !IS_ERR(pathp))
393 path_put(pathp);
394 return ret;
395}
364 if (IS_ERR(sb)) {
365 ret = PTR_ERR(sb);
366 goto out;
367 }
368
369 ret = do_quotactl(sb, type, cmds, id, addr, pathp);
370
371 drop_super(sb);
372out:
373 if (pathp && !IS_ERR(pathp))
374 path_put(pathp);
375 return ret;
376}