aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/quota.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-02-16 03:44:54 -0500
committerJan Kara <jack@suse.cz>2010-03-04 18:20:25 -0500
commit799a9d44023c069f46bc5933a930eab0bd37d0df (patch)
tree8c8a752f85ae5801e26e93be977491ea0cbb1fae /fs/quota/quota.c
parenta56fca23f67282467c08e75c40081da2345dfdbf (diff)
quota: split out netlink notification support from quota.c
Instead of adding ifdefs just split it into a new file. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/quota.c')
-rw-r--r--fs/quota/quota.c93
1 files changed, 0 insertions, 93 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index a43bb2c3ceaf..4506c6596347 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -19,8 +19,6 @@
19#include <linux/quotaops.h> 19#include <linux/quotaops.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/writeback.h> 21#include <linux/writeback.h>
22#include <net/netlink.h>
23#include <net/genetlink.h>
24 22
25static int check_quotactl_permission(struct super_block *sb, int type, int cmd, 23static int check_quotactl_permission(struct super_block *sb, int type, int cmd,
26 qid_t id) 24 qid_t id)
@@ -458,94 +456,3 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,
458 return ret; 456 return ret;
459} 457}
460#endif 458#endif
461
462
463#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
464
465/* Netlink family structure for quota */
466static struct genl_family quota_genl_family = {
467 .id = GENL_ID_GENERATE,
468 .hdrsize = 0,
469 .name = "VFS_DQUOT",
470 .version = 1,
471 .maxattr = QUOTA_NL_A_MAX,
472};
473
474/**
475 * quota_send_warning - Send warning to userspace about exceeded quota
476 * @type: The quota type: USRQQUOTA, GRPQUOTA,...
477 * @id: The user or group id of the quota that was exceeded
478 * @dev: The device on which the fs is mounted (sb->s_dev)
479 * @warntype: The type of the warning: QUOTA_NL_...
480 *
481 * This can be used by filesystems (including those which don't use
482 * dquot) to send a message to userspace relating to quota limits.
483 *
484 */
485
486void quota_send_warning(short type, unsigned int id, dev_t dev,
487 const char warntype)
488{
489 static atomic_t seq;
490 struct sk_buff *skb;
491 void *msg_head;
492 int ret;
493 int msg_size = 4 * nla_total_size(sizeof(u32)) +
494 2 * nla_total_size(sizeof(u64));
495
496 /* We have to allocate using GFP_NOFS as we are called from a
497 * filesystem performing write and thus further recursion into
498 * the fs to free some data could cause deadlocks. */
499 skb = genlmsg_new(msg_size, GFP_NOFS);
500 if (!skb) {
501 printk(KERN_ERR
502 "VFS: Not enough memory to send quota warning.\n");
503 return;
504 }
505 msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
506 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
507 if (!msg_head) {
508 printk(KERN_ERR
509 "VFS: Cannot store netlink header in quota warning.\n");
510 goto err_out;
511 }
512 ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, type);
513 if (ret)
514 goto attr_err_out;
515 ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, id);
516 if (ret)
517 goto attr_err_out;
518 ret = nla_put_u32(skb, QUOTA_NL_A_WARNING, warntype);
519 if (ret)
520 goto attr_err_out;
521 ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR, MAJOR(dev));
522 if (ret)
523 goto attr_err_out;
524 ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR, MINOR(dev));
525 if (ret)
526 goto attr_err_out;
527 ret = nla_put_u64(skb, QUOTA_NL_A_CAUSED_ID, current_uid());
528 if (ret)
529 goto attr_err_out;
530 genlmsg_end(skb, msg_head);
531
532 genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS);
533 return;
534attr_err_out:
535 printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
536err_out:
537 kfree_skb(skb);
538}
539EXPORT_SYMBOL(quota_send_warning);
540
541static int __init quota_init(void)
542{
543 if (genl_register_family(&quota_genl_family) != 0)
544 printk(KERN_ERR
545 "VFS: Failed to create quota netlink interface.\n");
546 return 0;
547};
548
549module_init(quota_init);
550#endif
551