Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
| 9 | #include <linux/namei.h> |
| 10 | #include <linux/slab.h> |
| 11 | #include <asm/current.h> |
| 12 | #include <asm/uaccess.h> |
| 13 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/security.h> |
| 15 | #include <linux/syscalls.h> |
| 16 | #include <linux/buffer_head.h> |
Randy Dunlap | 16f7e0f | 2006-01-11 12:17:46 -0800 | [diff] [blame] | 17 | #include <linux/capability.h> |
Adrian Bunk | be586ba | 2005-11-07 00:59:35 -0800 | [diff] [blame] | 18 | #include <linux/quotaops.h> |
Vasily Tarasov | b716395 | 2007-07-15 23:41:12 -0700 | [diff] [blame] | 19 | #include <linux/types.h> |
Christoph Hellwig | 8c4e4ac | 2010-02-16 03:44:51 -0500 | [diff] [blame] | 20 | #include <linux/writeback.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Christoph Hellwig | c988afb | 2010-02-16 03:44:50 -0500 | [diff] [blame] | 22 | static int check_quotactl_permission(struct super_block *sb, int type, int cmd, |
| 23 | qid_t id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { |
Christoph Hellwig | c988afb | 2010-02-16 03:44:50 -0500 | [diff] [blame] | 25 | switch (cmd) { |
| 26 | /* these commands do not require any special privilegues */ |
| 27 | case Q_GETFMT: |
| 28 | case Q_SYNC: |
| 29 | case Q_GETINFO: |
| 30 | case Q_XGETQSTAT: |
| 31 | case Q_XQUOTASYNC: |
| 32 | break; |
| 33 | /* allow to query information for dquots we "own" */ |
| 34 | case Q_GETQUOTA: |
| 35 | case Q_XGETQUOTA: |
| 36 | if ((type == USRQUOTA && current_euid() == id) || |
| 37 | (type == GRPQUOTA && in_egroup_p(id))) |
| 38 | break; |
| 39 | /*FALLTHROUGH*/ |
| 40 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | if (!capable(CAP_SYS_ADMIN)) |
| 42 | return -EPERM; |
| 43 | } |
| 44 | |
Christoph Hellwig | c988afb | 2010-02-16 03:44:50 -0500 | [diff] [blame] | 45 | return security_quotactl(cmd, type, id, sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Al Viro | 01a05b3 | 2010-03-23 06:06:58 -0400 | [diff] [blame] | 48 | static void quota_sync_one(struct super_block *sb, void *arg) |
| 49 | { |
| 50 | if (sb->s_qcop && sb->s_qcop->quota_sync) |
| 51 | sb->s_qcop->quota_sync(sb, *(int *)arg, 1); |
| 52 | } |
| 53 | |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 54 | static int quota_sync_all(int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 56 | int ret; |
| 57 | |
| 58 | if (type >= MAXQUOTAS) |
| 59 | return -EINVAL; |
| 60 | ret = security_quotactl(Q_SYNC, type, 0, NULL); |
Al Viro | 01a05b3 | 2010-03-23 06:06:58 -0400 | [diff] [blame] | 61 | if (!ret) |
| 62 | iterate_supers(quota_sync_one, &type); |
| 63 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 66 | static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id, |
| 67 | void __user *addr) |
| 68 | { |
| 69 | char *pathname; |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 70 | int ret = -ENOSYS; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 71 | |
| 72 | pathname = getname(addr); |
| 73 | if (IS_ERR(pathname)) |
| 74 | return PTR_ERR(pathname); |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 75 | if (sb->s_qcop->quota_on) |
Christoph Hellwig | 307ae18 | 2010-05-19 07:16:43 -0400 | [diff] [blame] | 76 | ret = sb->s_qcop->quota_on(sb, type, id, pathname); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 77 | putname(pathname); |
| 78 | return ret; |
| 79 | } |
| 80 | |
| 81 | static int quota_getfmt(struct super_block *sb, int type, void __user *addr) |
| 82 | { |
| 83 | __u32 fmt; |
| 84 | |
| 85 | down_read(&sb_dqopt(sb)->dqptr_sem); |
| 86 | if (!sb_has_quota_active(sb, type)) { |
| 87 | up_read(&sb_dqopt(sb)->dqptr_sem); |
| 88 | return -ESRCH; |
| 89 | } |
| 90 | fmt = sb_dqopt(sb)->info[type].dqi_format->qf_fmt_id; |
| 91 | up_read(&sb_dqopt(sb)->dqptr_sem); |
| 92 | if (copy_to_user(addr, &fmt, sizeof(fmt))) |
| 93 | return -EFAULT; |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | static int quota_getinfo(struct super_block *sb, int type, void __user *addr) |
| 98 | { |
| 99 | struct if_dqinfo info; |
| 100 | int ret; |
| 101 | |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 102 | if (!sb->s_qcop->get_info) |
| 103 | return -ENOSYS; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 104 | ret = sb->s_qcop->get_info(sb, type, &info); |
| 105 | if (!ret && copy_to_user(addr, &info, sizeof(info))) |
| 106 | return -EFAULT; |
| 107 | return ret; |
| 108 | } |
| 109 | |
| 110 | static int quota_setinfo(struct super_block *sb, int type, void __user *addr) |
| 111 | { |
| 112 | struct if_dqinfo info; |
| 113 | |
| 114 | if (copy_from_user(&info, addr, sizeof(info))) |
| 115 | return -EFAULT; |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 116 | if (!sb->s_qcop->set_info) |
| 117 | return -ENOSYS; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 118 | return sb->s_qcop->set_info(sb, type, &info); |
| 119 | } |
| 120 | |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 121 | static void copy_to_if_dqblk(struct if_dqblk *dst, struct fs_disk_quota *src) |
| 122 | { |
| 123 | dst->dqb_bhardlimit = src->d_blk_hardlimit; |
| 124 | dst->dqb_bsoftlimit = src->d_blk_softlimit; |
| 125 | dst->dqb_curspace = src->d_bcount; |
| 126 | dst->dqb_ihardlimit = src->d_ino_hardlimit; |
| 127 | dst->dqb_isoftlimit = src->d_ino_softlimit; |
| 128 | dst->dqb_curinodes = src->d_icount; |
| 129 | dst->dqb_btime = src->d_btimer; |
| 130 | dst->dqb_itime = src->d_itimer; |
| 131 | dst->dqb_valid = QIF_ALL; |
| 132 | } |
| 133 | |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 134 | static int quota_getquota(struct super_block *sb, int type, qid_t id, |
| 135 | void __user *addr) |
| 136 | { |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 137 | struct fs_disk_quota fdq; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 138 | struct if_dqblk idq; |
| 139 | int ret; |
| 140 | |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 141 | if (!sb->s_qcop->get_dqblk) |
| 142 | return -ENOSYS; |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 143 | ret = sb->s_qcop->get_dqblk(sb, type, id, &fdq); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 144 | if (ret) |
| 145 | return ret; |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 146 | copy_to_if_dqblk(&idq, &fdq); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 147 | if (copy_to_user(addr, &idq, sizeof(idq))) |
| 148 | return -EFAULT; |
| 149 | return 0; |
| 150 | } |
| 151 | |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 152 | static void copy_from_if_dqblk(struct fs_disk_quota *dst, struct if_dqblk *src) |
| 153 | { |
| 154 | dst->d_blk_hardlimit = src->dqb_bhardlimit; |
| 155 | dst->d_blk_softlimit = src->dqb_bsoftlimit; |
| 156 | dst->d_bcount = src->dqb_curspace; |
| 157 | dst->d_ino_hardlimit = src->dqb_ihardlimit; |
| 158 | dst->d_ino_softlimit = src->dqb_isoftlimit; |
| 159 | dst->d_icount = src->dqb_curinodes; |
| 160 | dst->d_btimer = src->dqb_btime; |
| 161 | dst->d_itimer = src->dqb_itime; |
| 162 | |
| 163 | dst->d_fieldmask = 0; |
| 164 | if (src->dqb_valid & QIF_BLIMITS) |
| 165 | dst->d_fieldmask |= FS_DQ_BSOFT | FS_DQ_BHARD; |
| 166 | if (src->dqb_valid & QIF_SPACE) |
| 167 | dst->d_fieldmask |= FS_DQ_BCOUNT; |
| 168 | if (src->dqb_valid & QIF_ILIMITS) |
| 169 | dst->d_fieldmask |= FS_DQ_ISOFT | FS_DQ_IHARD; |
| 170 | if (src->dqb_valid & QIF_INODES) |
| 171 | dst->d_fieldmask |= FS_DQ_ICOUNT; |
| 172 | if (src->dqb_valid & QIF_BTIME) |
| 173 | dst->d_fieldmask |= FS_DQ_BTIMER; |
| 174 | if (src->dqb_valid & QIF_ITIME) |
| 175 | dst->d_fieldmask |= FS_DQ_ITIMER; |
| 176 | } |
| 177 | |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 178 | static int quota_setquota(struct super_block *sb, int type, qid_t id, |
| 179 | void __user *addr) |
| 180 | { |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 181 | struct fs_disk_quota fdq; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 182 | struct if_dqblk idq; |
| 183 | |
| 184 | if (copy_from_user(&idq, addr, sizeof(idq))) |
| 185 | return -EFAULT; |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 186 | if (!sb->s_qcop->set_dqblk) |
| 187 | return -ENOSYS; |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 188 | copy_from_if_dqblk(&fdq, &idq); |
| 189 | return sb->s_qcop->set_dqblk(sb, type, id, &fdq); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) |
| 193 | { |
| 194 | __u32 flags; |
| 195 | |
| 196 | if (copy_from_user(&flags, addr, sizeof(flags))) |
| 197 | return -EFAULT; |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 198 | if (!sb->s_qcop->set_xstate) |
| 199 | return -ENOSYS; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 200 | return sb->s_qcop->set_xstate(sb, flags, cmd); |
| 201 | } |
| 202 | |
| 203 | static int quota_getxstate(struct super_block *sb, void __user *addr) |
| 204 | { |
| 205 | struct fs_quota_stat fqs; |
| 206 | int ret; |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 207 | |
| 208 | if (!sb->s_qcop->get_xstate) |
| 209 | return -ENOSYS; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 210 | ret = sb->s_qcop->get_xstate(sb, &fqs); |
| 211 | if (!ret && copy_to_user(addr, &fqs, sizeof(fqs))) |
| 212 | return -EFAULT; |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | static int quota_setxquota(struct super_block *sb, int type, qid_t id, |
| 217 | void __user *addr) |
| 218 | { |
| 219 | struct fs_disk_quota fdq; |
| 220 | |
| 221 | if (copy_from_user(&fdq, addr, sizeof(fdq))) |
| 222 | return -EFAULT; |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 223 | if (!sb->s_qcop->set_dqblk) |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 224 | return -ENOSYS; |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 225 | return sb->s_qcop->set_dqblk(sb, type, id, &fdq); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | static int quota_getxquota(struct super_block *sb, int type, qid_t id, |
| 229 | void __user *addr) |
| 230 | { |
| 231 | struct fs_disk_quota fdq; |
| 232 | int ret; |
| 233 | |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 234 | if (!sb->s_qcop->get_dqblk) |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 235 | return -ENOSYS; |
Christoph Hellwig | b9b2dd3 | 2010-05-06 17:04:58 -0400 | [diff] [blame] | 236 | ret = sb->s_qcop->get_dqblk(sb, type, id, &fdq); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 237 | if (!ret && copy_to_user(addr, &fdq, sizeof(fdq))) |
| 238 | return -EFAULT; |
| 239 | return ret; |
| 240 | } |
| 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* Copy parameters and call proper function */ |
Jan Kara | 268157b | 2009-01-27 15:47:22 +0100 | [diff] [blame] | 243 | static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, |
| 244 | void __user *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
Christoph Hellwig | c988afb | 2010-02-16 03:44:50 -0500 | [diff] [blame] | 246 | int ret; |
| 247 | |
| 248 | if (type >= (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS)) |
| 249 | return -EINVAL; |
| 250 | if (!sb->s_qcop) |
| 251 | return -ENOSYS; |
| 252 | |
| 253 | ret = check_quotactl_permission(sb, type, cmd, id); |
| 254 | if (ret < 0) |
| 255 | return ret; |
| 256 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | switch (cmd) { |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 258 | case Q_QUOTAON: |
| 259 | return quota_quotaon(sb, type, cmd, id, addr); |
| 260 | case Q_QUOTAOFF: |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 261 | if (!sb->s_qcop->quota_off) |
| 262 | return -ENOSYS; |
Christoph Hellwig | 307ae18 | 2010-05-19 07:16:43 -0400 | [diff] [blame] | 263 | return sb->s_qcop->quota_off(sb, type); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 264 | case Q_GETFMT: |
| 265 | return quota_getfmt(sb, type, addr); |
| 266 | case Q_GETINFO: |
| 267 | return quota_getinfo(sb, type, addr); |
| 268 | case Q_SETINFO: |
| 269 | return quota_setinfo(sb, type, addr); |
| 270 | case Q_GETQUOTA: |
| 271 | return quota_getquota(sb, type, id, addr); |
| 272 | case Q_SETQUOTA: |
| 273 | return quota_setquota(sb, type, id, addr); |
| 274 | case Q_SYNC: |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 275 | if (!sb->s_qcop->quota_sync) |
| 276 | return -ENOSYS; |
Christoph Hellwig | 5fb324a | 2010-02-16 03:44:52 -0500 | [diff] [blame] | 277 | return sb->s_qcop->quota_sync(sb, type, 1); |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 278 | case Q_XQUOTAON: |
| 279 | case Q_XQUOTAOFF: |
| 280 | case Q_XQUOTARM: |
| 281 | return quota_setxstate(sb, cmd, addr); |
| 282 | case Q_XGETQSTAT: |
| 283 | return quota_getxstate(sb, addr); |
| 284 | case Q_XSETQLIM: |
| 285 | return quota_setxquota(sb, type, id, addr); |
| 286 | case Q_XGETQUOTA: |
| 287 | return quota_getxquota(sb, type, id, addr); |
| 288 | case Q_XQUOTASYNC: |
Christoph Hellwig | 8c4e4ac | 2010-02-16 03:44:51 -0500 | [diff] [blame] | 289 | /* caller already holds s_umount */ |
| 290 | if (sb->s_flags & MS_RDONLY) |
| 291 | return -EROFS; |
| 292 | writeback_inodes_sb(sb); |
| 293 | return 0; |
Christoph Hellwig | c411e5f | 2010-02-16 03:44:47 -0500 | [diff] [blame] | 294 | default: |
Christoph Hellwig | f450d4f | 2010-02-16 03:44:48 -0500 | [diff] [blame] | 295 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | /* |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 300 | * look up a superblock on which quota ops will be performed |
| 301 | * - use the name of a block device to find the superblock thereon |
| 302 | */ |
Jan Kara | 7a2435d | 2009-01-27 01:47:11 +0100 | [diff] [blame] | 303 | static struct super_block *quotactl_block(const char __user *special) |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 304 | { |
| 305 | #ifdef CONFIG_BLOCK |
| 306 | struct block_device *bdev; |
| 307 | struct super_block *sb; |
| 308 | char *tmp = getname(special); |
| 309 | |
| 310 | if (IS_ERR(tmp)) |
David Howells | e231c2e | 2008-02-07 00:15:26 -0800 | [diff] [blame] | 311 | return ERR_CAST(tmp); |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 312 | bdev = lookup_bdev(tmp); |
| 313 | putname(tmp); |
| 314 | if (IS_ERR(bdev)) |
David Howells | e231c2e | 2008-02-07 00:15:26 -0800 | [diff] [blame] | 315 | return ERR_CAST(bdev); |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 316 | sb = get_super(bdev); |
| 317 | bdput(bdev); |
| 318 | if (!sb) |
| 319 | return ERR_PTR(-ENODEV); |
| 320 | |
| 321 | return sb; |
| 322 | #else |
| 323 | return ERR_PTR(-ENODEV); |
| 324 | #endif |
| 325 | } |
| 326 | |
| 327 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | * This is the system call interface. This communicates with |
| 329 | * the user-level programs. Currently this only supports diskquota |
| 330 | * calls. Maybe we need to add the process quotas etc. in the future, |
| 331 | * but we probably should use rlimits for that. |
| 332 | */ |
Heiko Carstens | 3cdad42 | 2009-01-14 14:14:22 +0100 | [diff] [blame] | 333 | SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, |
| 334 | qid_t, id, void __user *, addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | { |
| 336 | uint cmds, type; |
| 337 | struct super_block *sb = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | int ret; |
| 339 | |
| 340 | cmds = cmd >> SUBCMDSHIFT; |
| 341 | type = cmd & SUBCMDMASK; |
| 342 | |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 343 | /* |
| 344 | * As a special case Q_SYNC can be called without a specific device. |
| 345 | * It will iterate all superblocks that have quota enabled and call |
| 346 | * the sync action on each of them. |
| 347 | */ |
| 348 | if (!special) { |
| 349 | if (cmds == Q_SYNC) |
| 350 | return quota_sync_all(type); |
| 351 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 354 | sb = quotactl_block(special); |
| 355 | if (IS_ERR(sb)) |
| 356 | return PTR_ERR(sb); |
| 357 | |
Christoph Hellwig | c988afb | 2010-02-16 03:44:50 -0500 | [diff] [blame] | 358 | ret = do_quotactl(sb, type, cmds, id, addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Christoph Hellwig | 6ae0957 | 2010-02-16 03:44:49 -0500 | [diff] [blame] | 360 | drop_super(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | return ret; |
| 362 | } |