quota.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. #include <linux/fs.h>
  8. #include <linux/namei.h>
  9. #include <linux/slab.h>
  10. #include <asm/current.h>
  11. #include <asm/uaccess.h>
  12. #include <linux/compat.h>
  13. #include <linux/kernel.h>
  14. #include <linux/security.h>
  15. #include <linux/syscalls.h>
  16. #include <linux/buffer_head.h>
  17. #include <linux/capability.h>
  18. #include <linux/quotaops.h>
  19. #include <linux/types.h>
  20. #include <net/netlink.h>
  21. #include <net/genetlink.h>
  22. /* Check validity of generic quotactl commands */
  23. static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
  24. qid_t id)
  25. {
  26. if (type >= MAXQUOTAS)
  27. return -EINVAL;
  28. if (!sb && cmd != Q_SYNC)
  29. return -ENODEV;
  30. /* Is operation supported? */
  31. if (sb && !sb->s_qcop)
  32. return -ENOSYS;
  33. switch (cmd) {
  34. case Q_GETFMT:
  35. break;
  36. case Q_QUOTAON:
  37. if (!sb->s_qcop->quota_on)
  38. return -ENOSYS;
  39. break;
  40. case Q_QUOTAOFF:
  41. if (!sb->s_qcop->quota_off)
  42. return -ENOSYS;
  43. break;
  44. case Q_SETINFO:
  45. if (!sb->s_qcop->set_info)
  46. return -ENOSYS;
  47. break;
  48. case Q_GETINFO:
  49. if (!sb->s_qcop->get_info)
  50. return -ENOSYS;
  51. break;
  52. case Q_SETQUOTA:
  53. if (!sb->s_qcop->set_dqblk)
  54. return -ENOSYS;
  55. break;
  56. case Q_GETQUOTA:
  57. if (!sb->s_qcop->get_dqblk)
  58. return -ENOSYS;
  59. break;
  60. case Q_SYNC:
  61. if (sb && !sb->s_qcop->quota_sync)
  62. return -ENOSYS;
  63. break;
  64. default:
  65. return -EINVAL;
  66. }
  67. /* Is quota turned on for commands which need it? */
  68. switch (cmd) {
  69. case Q_GETFMT:
  70. case Q_GETINFO:
  71. case Q_SETINFO:
  72. case Q_SETQUOTA:
  73. case Q_GETQUOTA:
  74. /* This is just an informative test so we are satisfied
  75. * without the lock */
  76. if (!sb_has_quota_active(sb, type))
  77. return -ESRCH;
  78. }
  79. /* Check privileges */
  80. if (cmd == Q_GETQUOTA) {
  81. if (((type == USRQUOTA && current_euid() != id) ||
  82. (type == GRPQUOTA && !in_egroup_p(id))) &&
  83. !capable(CAP_SYS_ADMIN))
  84. return -EPERM;
  85. }
  86. else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
  87. if (!capable(CAP_SYS_ADMIN))
  88. return -EPERM;
  89. return 0;
  90. }
  91. /* Check validity of XFS Quota Manager commands */
  92. static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd,
  93. qid_t id)
  94. {
  95. if (type >= XQM_MAXQUOTAS)
  96. return -EINVAL;
  97. if (!sb)
  98. return -ENODEV;
  99. if (!sb->s_qcop)
  100. return -ENOSYS;
  101. switch (cmd) {
  102. case Q_XQUOTAON:
  103. case Q_XQUOTAOFF:
  104. case Q_XQUOTARM:
  105. if (!sb->s_qcop->set_xstate)
  106. return -ENOSYS;
  107. break;
  108. case Q_XGETQSTAT:
  109. if (!sb->s_qcop->get_xstate)
  110. return -ENOSYS;
  111. break;
  112. case Q_XSETQLIM:
  113. if (!sb->s_qcop->set_xquota)
  114. return -ENOSYS;
  115. break;
  116. case Q_XGETQUOTA:
  117. if (!sb->s_qcop->get_xquota)
  118. return -ENOSYS;
  119. break;
  120. case Q_XQUOTASYNC:
  121. if (!sb->s_qcop->quota_sync)
  122. return -ENOSYS;
  123. break;
  124. default:
  125. return -EINVAL;
  126. }
  127. /* Check privileges */
  128. if (cmd == Q_XGETQUOTA) {
  129. if (((type == XQM_USRQUOTA && current_euid() != id) ||
  130. (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
  131. !capable(CAP_SYS_ADMIN))
  132. return -EPERM;
  133. } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
  134. if (!capable(CAP_SYS_ADMIN))
  135. return -EPERM;
  136. }
  137. return 0;
  138. }
  139. static int check_quotactl_valid(struct super_block *sb, int type, int cmd,
  140. qid_t id)
  141. {
  142. int error;
  143. if (XQM_COMMAND(cmd))
  144. error = xqm_quotactl_valid(sb, type, cmd, id);
  145. else
  146. error = generic_quotactl_valid(sb, type, cmd, id);
  147. if (!error)
  148. error = security_quotactl(cmd, type, id, sb);
  149. return error;
  150. }
  151. #ifdef CONFIG_QUOTA
  152. void sync_quota_sb(struct super_block *sb, int type)
  153. {
  154. int cnt;
  155. if (!sb->s_qcop->quota_sync)
  156. return;
  157. sb->s_qcop->quota_sync(sb, type);
  158. if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE)
  159. return;
  160. /* This is not very clever (and fast) but currently I don't know about
  161. * any other simple way of getting quota data to disk and we must get
  162. * them there for userspace to be visible... */
  163. if (sb->s_op->sync_fs)
  164. sb->s_op->sync_fs(sb, 1);
  165. sync_blockdev(sb->s_bdev);
  166. /*
  167. * Now when everything is written we can discard the pagecache so
  168. * that userspace sees the changes.
  169. */
  170. mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
  171. for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
  172. if (type != -1 && cnt != type)
  173. continue;
  174. if (!sb_has_quota_active(sb, cnt))
  175. continue;
  176. mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex,
  177. I_MUTEX_QUOTA);
  178. truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
  179. mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
  180. }
  181. mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
  182. }
  183. #endif
  184. static void sync_dquots(int type)
  185. {
  186. struct super_block *sb;
  187. int cnt;
  188. spin_lock(&sb_lock);
  189. restart:
  190. list_for_each_entry(sb, &super_blocks, s_list) {
  191. /* This test just improves performance so it needn't be
  192. * reliable... */
  193. for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
  194. if (type != -1 && type != cnt)
  195. continue;
  196. if (!sb_has_quota_active(sb, cnt))
  197. continue;
  198. if (!info_dirty(&sb_dqopt(sb)->info[cnt]) &&
  199. list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list))
  200. continue;
  201. break;
  202. }
  203. if (cnt == MAXQUOTAS)
  204. continue;
  205. sb->s_count++;
  206. spin_unlock(&sb_lock);
  207. down_read(&sb->s_umount);
  208. if (sb->s_root)
  209. sync_quota_sb(sb, type);
  210. up_read(&sb->s_umount);
  211. spin_lock(&sb_lock);
  212. if (__put_super_and_need_restart(sb))
  213. goto restart;
  214. }
  215. spin_unlock(&sb_lock);
  216. }
  217. static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id,
  218. void __user *addr)
  219. {
  220. char *pathname;
  221. int ret;
  222. pathname = getname(addr);
  223. if (IS_ERR(pathname))
  224. return PTR_ERR(pathname);
  225. ret = sb->s_qcop->quota_on(sb, type, id, pathname, 0);
  226. putname(pathname);
  227. return ret;
  228. }
  229. static int quota_getfmt(struct super_block *sb, int type, void __user *addr)
  230. {
  231. __u32 fmt;
  232. down_read(&sb_dqopt(sb)->dqptr_sem);
  233. if (!sb_has_quota_active(sb, type)) {
  234. up_read(&sb_dqopt(sb)->dqptr_sem);
  235. return -ESRCH;
  236. }
  237. fmt = sb_dqopt(sb)->info[type].dqi_format->qf_fmt_id;
  238. up_read(&sb_dqopt(sb)->dqptr_sem);
  239. if (copy_to_user(addr, &fmt, sizeof(fmt)))
  240. return -EFAULT;
  241. return 0;
  242. }
  243. static int quota_getinfo(struct super_block *sb, int type, void __user *addr)
  244. {
  245. struct if_dqinfo info;
  246. int ret;
  247. ret = sb->s_qcop->get_info(sb, type, &info);
  248. if (!ret && copy_to_user(addr, &info, sizeof(info)))
  249. return -EFAULT;
  250. return ret;
  251. }
  252. static int quota_setinfo(struct super_block *sb, int type, void __user *addr)
  253. {
  254. struct if_dqinfo info;
  255. if (copy_from_user(&info, addr, sizeof(info)))
  256. return -EFAULT;
  257. return sb->s_qcop->set_info(sb, type, &info);
  258. }
  259. static int quota_getquota(struct super_block *sb, int type, qid_t id,
  260. void __user *addr)
  261. {
  262. struct if_dqblk idq;
  263. int ret;
  264. ret = sb->s_qcop->get_dqblk(sb, type, id, &idq);
  265. if (ret)
  266. return ret;
  267. if (copy_to_user(addr, &idq, sizeof(idq)))
  268. return -EFAULT;
  269. return 0;
  270. }
  271. static int quota_setquota(struct super_block *sb, int type, qid_t id,
  272. void __user *addr)
  273. {
  274. struct if_dqblk idq;
  275. if (copy_from_user(&idq, addr, sizeof(idq)))
  276. return -EFAULT;
  277. return sb->s_qcop->set_dqblk(sb, type, id, &idq);
  278. }
  279. static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr)
  280. {
  281. __u32 flags;
  282. if (copy_from_user(&flags, addr, sizeof(flags)))
  283. return -EFAULT;
  284. return sb->s_qcop->set_xstate(sb, flags, cmd);
  285. }
  286. static int quota_getxstate(struct super_block *sb, void __user *addr)
  287. {
  288. struct fs_quota_stat fqs;
  289. int ret;
  290. ret = sb->s_qcop->get_xstate(sb, &fqs);
  291. if (!ret && copy_to_user(addr, &fqs, sizeof(fqs)))
  292. return -EFAULT;
  293. return ret;
  294. }
  295. static int quota_setxquota(struct super_block *sb, int type, qid_t id,
  296. void __user *addr)
  297. {
  298. struct fs_disk_quota fdq;
  299. if (copy_from_user(&fdq, addr, sizeof(fdq)))
  300. return -EFAULT;
  301. return sb->s_qcop->set_xquota(sb, type, id, &fdq);
  302. }
  303. static int quota_getxquota(struct super_block *sb, int type, qid_t id,
  304. void __user *addr)
  305. {
  306. struct fs_disk_quota fdq;
  307. int ret;
  308. ret = sb->s_qcop->get_xquota(sb, type, id, &fdq);
  309. if (!ret && copy_to_user(addr, &fdq, sizeof(fdq)))
  310. return -EFAULT;
  311. return ret;
  312. }
  313. /* Copy parameters and call proper function */
  314. static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
  315. void __user *addr)
  316. {
  317. switch (cmd) {
  318. case Q_QUOTAON:
  319. return quota_quotaon(sb, type, cmd, id, addr);
  320. case Q_QUOTAOFF:
  321. return sb->s_qcop->quota_off(sb, type, 0);
  322. case Q_GETFMT:
  323. return quota_getfmt(sb, type, addr);
  324. case Q_GETINFO:
  325. return quota_getinfo(sb, type, addr);
  326. case Q_SETINFO:
  327. return quota_setinfo(sb, type, addr);
  328. case Q_GETQUOTA:
  329. return quota_getquota(sb, type, id, addr);
  330. case Q_SETQUOTA:
  331. return quota_setquota(sb, type, id, addr);
  332. case Q_SYNC:
  333. if (sb)
  334. sync_quota_sb(sb, type);
  335. else
  336. sync_dquots(type);
  337. return 0;
  338. case Q_XQUOTAON:
  339. case Q_XQUOTAOFF:
  340. case Q_XQUOTARM:
  341. return quota_setxstate(sb, cmd, addr);
  342. case Q_XGETQSTAT:
  343. return quota_getxstate(sb, addr);
  344. case Q_XSETQLIM:
  345. return quota_setxquota(sb, type, id, addr);
  346. case Q_XGETQUOTA:
  347. return quota_getxquota(sb, type, id, addr);
  348. case Q_XQUOTASYNC:
  349. return sb->s_qcop->quota_sync(sb, type);
  350. /* We never reach here unless validity check is broken */
  351. default:
  352. BUG();
  353. }
  354. return 0;
  355. }
  356. /*
  357. * look up a superblock on which quota ops will be performed
  358. * - use the name of a block device to find the superblock thereon
  359. */
  360. static struct super_block *quotactl_block(const char __user *special)
  361. {
  362. #ifdef CONFIG_BLOCK
  363. struct block_device *bdev;
  364. struct super_block *sb;
  365. char *tmp = getname(special);
  366. if (IS_ERR(tmp))
  367. return ERR_CAST(tmp);
  368. bdev = lookup_bdev(tmp);
  369. putname(tmp);
  370. if (IS_ERR(bdev))
  371. return ERR_CAST(bdev);
  372. sb = get_super(bdev);
  373. bdput(bdev);
  374. if (!sb)
  375. return ERR_PTR(-ENODEV);
  376. return sb;
  377. #else
  378. return ERR_PTR(-ENODEV);
  379. #endif
  380. }
  381. /*
  382. * This is the system call interface. This communicates with
  383. * the user-level programs. Currently this only supports diskquota
  384. * calls. Maybe we need to add the process quotas etc. in the future,
  385. * but we probably should use rlimits for that.
  386. */
  387. SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
  388. qid_t, id, void __user *, addr)
  389. {
  390. uint cmds, type;
  391. struct super_block *sb = NULL;
  392. int ret;
  393. cmds = cmd >> SUBCMDSHIFT;
  394. type = cmd & SUBCMDMASK;
  395. if (cmds != Q_SYNC || special) {
  396. sb = quotactl_block(special);
  397. if (IS_ERR(sb))
  398. return PTR_ERR(sb);
  399. }
  400. ret = check_quotactl_valid(sb, type, cmds, id);
  401. if (ret >= 0)
  402. ret = do_quotactl(sb, type, cmds, id, addr);
  403. if (sb)
  404. drop_super(sb);
  405. return ret;
  406. }
  407. #if defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)
  408. /*
  409. * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64)
  410. * and is necessary due to alignment problems.
  411. */
  412. struct compat_if_dqblk {
  413. compat_u64 dqb_bhardlimit;
  414. compat_u64 dqb_bsoftlimit;
  415. compat_u64 dqb_curspace;
  416. compat_u64 dqb_ihardlimit;
  417. compat_u64 dqb_isoftlimit;
  418. compat_u64 dqb_curinodes;
  419. compat_u64 dqb_btime;
  420. compat_u64 dqb_itime;
  421. compat_uint_t dqb_valid;
  422. };
  423. /* XFS structures */
  424. struct compat_fs_qfilestat {
  425. compat_u64 dqb_bhardlimit;
  426. compat_u64 qfs_nblks;
  427. compat_uint_t qfs_nextents;
  428. };
  429. struct compat_fs_quota_stat {
  430. __s8 qs_version;
  431. __u16 qs_flags;
  432. __s8 qs_pad;
  433. struct compat_fs_qfilestat qs_uquota;
  434. struct compat_fs_qfilestat qs_gquota;
  435. compat_uint_t qs_incoredqs;
  436. compat_int_t qs_btimelimit;
  437. compat_int_t qs_itimelimit;
  438. compat_int_t qs_rtbtimelimit;
  439. __u16 qs_bwarnlimit;
  440. __u16 qs_iwarnlimit;
  441. };
  442. asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,
  443. qid_t id, void __user *addr)
  444. {
  445. unsigned int cmds;
  446. struct if_dqblk __user *dqblk;
  447. struct compat_if_dqblk __user *compat_dqblk;
  448. struct fs_quota_stat __user *fsqstat;
  449. struct compat_fs_quota_stat __user *compat_fsqstat;
  450. compat_uint_t data;
  451. u16 xdata;
  452. long ret;
  453. cmds = cmd >> SUBCMDSHIFT;
  454. switch (cmds) {
  455. case Q_GETQUOTA:
  456. dqblk = compat_alloc_user_space(sizeof(struct if_dqblk));
  457. compat_dqblk = addr;
  458. ret = sys_quotactl(cmd, special, id, dqblk);
  459. if (ret)
  460. break;
  461. if (copy_in_user(compat_dqblk, dqblk, sizeof(*compat_dqblk)) ||
  462. get_user(data, &dqblk->dqb_valid) ||
  463. put_user(data, &compat_dqblk->dqb_valid))
  464. ret = -EFAULT;
  465. break;
  466. case Q_SETQUOTA:
  467. dqblk = compat_alloc_user_space(sizeof(struct if_dqblk));
  468. compat_dqblk = addr;
  469. ret = -EFAULT;
  470. if (copy_in_user(dqblk, compat_dqblk, sizeof(*compat_dqblk)) ||
  471. get_user(data, &compat_dqblk->dqb_valid) ||
  472. put_user(data, &dqblk->dqb_valid))
  473. break;
  474. ret = sys_quotactl(cmd, special, id, dqblk);
  475. break;
  476. case Q_XGETQSTAT:
  477. fsqstat = compat_alloc_user_space(sizeof(struct fs_quota_stat));
  478. compat_fsqstat = addr;
  479. ret = sys_quotactl(cmd, special, id, fsqstat);
  480. if (ret)
  481. break;
  482. ret = -EFAULT;
  483. /* Copying qs_version, qs_flags, qs_pad */
  484. if (copy_in_user(compat_fsqstat, fsqstat,
  485. offsetof(struct compat_fs_quota_stat, qs_uquota)))
  486. break;
  487. /* Copying qs_uquota */
  488. if (copy_in_user(&compat_fsqstat->qs_uquota,
  489. &fsqstat->qs_uquota,
  490. sizeof(compat_fsqstat->qs_uquota)) ||
  491. get_user(data, &fsqstat->qs_uquota.qfs_nextents) ||
  492. put_user(data, &compat_fsqstat->qs_uquota.qfs_nextents))
  493. break;
  494. /* Copying qs_gquota */
  495. if (copy_in_user(&compat_fsqstat->qs_gquota,
  496. &fsqstat->qs_gquota,
  497. sizeof(compat_fsqstat->qs_gquota)) ||
  498. get_user(data, &fsqstat->qs_gquota.qfs_nextents) ||
  499. put_user(data, &compat_fsqstat->qs_gquota.qfs_nextents))
  500. break;
  501. /* Copying the rest */
  502. if (copy_in_user(&compat_fsqstat->qs_incoredqs,
  503. &fsqstat->qs_incoredqs,
  504. sizeof(struct compat_fs_quota_stat) -
  505. offsetof(struct compat_fs_quota_stat, qs_incoredqs)) ||
  506. get_user(xdata, &fsqstat->qs_iwarnlimit) ||
  507. put_user(xdata, &compat_fsqstat->qs_iwarnlimit))
  508. break;
  509. ret = 0;
  510. break;
  511. default:
  512. ret = sys_quotactl(cmd, special, id, addr);
  513. }
  514. return ret;
  515. }
  516. #endif
  517. #ifdef CONFIG_QUOTA_NETLINK_INTERFACE
  518. /* Netlink family structure for quota */
  519. static struct genl_family quota_genl_family = {
  520. .id = GENL_ID_GENERATE,
  521. .hdrsize = 0,
  522. .name = "VFS_DQUOT",
  523. .version = 1,
  524. .maxattr = QUOTA_NL_A_MAX,
  525. };
  526. /**
  527. * quota_send_warning - Send warning to userspace about exceeded quota
  528. * @type: The quota type: USRQQUOTA, GRPQUOTA,...
  529. * @id: The user or group id of the quota that was exceeded
  530. * @dev: The device on which the fs is mounted (sb->s_dev)
  531. * @warntype: The type of the warning: QUOTA_NL_...
  532. *
  533. * This can be used by filesystems (including those which don't use
  534. * dquot) to send a message to userspace relating to quota limits.
  535. *
  536. */
  537. void quota_send_warning(short type, unsigned int id, dev_t dev,
  538. const char warntype)
  539. {
  540. static atomic_t seq;
  541. struct sk_buff *skb;
  542. void *msg_head;
  543. int ret;
  544. int msg_size = 4 * nla_total_size(sizeof(u32)) +
  545. 2 * nla_total_size(sizeof(u64));
  546. /* We have to allocate using GFP_NOFS as we are called from a
  547. * filesystem performing write and thus further recursion into
  548. * the fs to free some data could cause deadlocks. */
  549. skb = genlmsg_new(msg_size, GFP_NOFS);
  550. if (!skb) {
  551. printk(KERN_ERR
  552. "VFS: Not enough memory to send quota warning.\n");
  553. return;
  554. }
  555. msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
  556. &quota_genl_family, 0, QUOTA_NL_C_WARNING);
  557. if (!msg_head) {
  558. printk(KERN_ERR
  559. "VFS: Cannot store netlink header in quota warning.\n");
  560. goto err_out;
  561. }
  562. ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, type);
  563. if (ret)
  564. goto attr_err_out;
  565. ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, id);
  566. if (ret)
  567. goto attr_err_out;
  568. ret = nla_put_u32(skb, QUOTA_NL_A_WARNING, warntype);
  569. if (ret)
  570. goto attr_err_out;
  571. ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR, MAJOR(dev));
  572. if (ret)
  573. goto attr_err_out;
  574. ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR, MINOR(dev));
  575. if (ret)
  576. goto attr_err_out;
  577. ret = nla_put_u64(skb, QUOTA_NL_A_CAUSED_ID, current_uid());
  578. if (ret)
  579. goto attr_err_out;
  580. genlmsg_end(skb, msg_head);
  581. genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS);
  582. return;
  583. attr_err_out:
  584. printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
  585. err_out:
  586. kfree_skb(skb);
  587. }
  588. EXPORT_SYMBOL(quota_send_warning);
  589. static int __init quota_init(void)
  590. {
  591. if (genl_register_family(&quota_genl_family) != 0)
  592. printk(KERN_ERR
  593. "VFS: Failed to create quota netlink interface.\n");
  594. return 0;
  595. };
  596. module_init(quota_init);
  597. #endif