mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-11 23:24:57 +02:00
xt_quota2: support for Linux 3.10
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/seq_file.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/uidgid.h>
|
#include <linux/uidgid.h>
|
||||||
@@ -47,22 +48,27 @@ module_param_named(perms, quota_list_perms, uint, S_IRUGO | S_IWUSR);
|
|||||||
module_param_named(uid, quota_list_uid, uint, S_IRUGO | S_IWUSR);
|
module_param_named(uid, quota_list_uid, uint, S_IRUGO | S_IWUSR);
|
||||||
module_param_named(gid, quota_list_gid, uint, S_IRUGO | S_IWUSR);
|
module_param_named(gid, quota_list_gid, uint, S_IRUGO | S_IWUSR);
|
||||||
|
|
||||||
static int quota_proc_read(char *page, char **start, off_t offset,
|
static int quota_proc_show(struct seq_file *m, void *data)
|
||||||
int count, int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct xt_quota_counter *e = data;
|
struct xt_quota_counter *e = m->private;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spin_lock_bh(&e->lock);
|
spin_lock_bh(&e->lock);
|
||||||
ret = snprintf(page, PAGE_SIZE, "%llu\n", e->quota);
|
ret = seq_printf(m, "%llu\n", e->quota);
|
||||||
spin_unlock_bh(&e->lock);
|
spin_unlock_bh(&e->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int quota_proc_write(struct file *file, const char __user *input,
|
static int quota_proc_open(struct inode *inode, struct file *file)
|
||||||
unsigned long size, void *data)
|
|
||||||
{
|
{
|
||||||
struct xt_quota_counter *e = data;
|
return single_open(file, quota_proc_show, PDE_DATA(inode));
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
quota_proc_write(struct file *file, const char __user *input,
|
||||||
|
size_t size, loff_t *loff)
|
||||||
|
{
|
||||||
|
struct xt_quota_counter *e = PDE_DATA(file_inode(file));
|
||||||
char buf[sizeof("18446744073709551616")];
|
char buf[sizeof("18446744073709551616")];
|
||||||
|
|
||||||
if (size > sizeof(buf))
|
if (size > sizeof(buf))
|
||||||
@@ -77,6 +83,14 @@ static int quota_proc_write(struct file *file, const char __user *input,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct file_operations quota_proc_fops = {
|
||||||
|
.open = quota_proc_open,
|
||||||
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.write = quota_proc_write,
|
||||||
|
.release = single_release,
|
||||||
|
};
|
||||||
|
|
||||||
static struct xt_quota_counter *
|
static struct xt_quota_counter *
|
||||||
q2_new_counter(const struct xt_quota_mtinfo2 *q, bool anon)
|
q2_new_counter(const struct xt_quota_mtinfo2 *q, bool anon)
|
||||||
{
|
{
|
||||||
@@ -124,16 +138,14 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
|||||||
if (e == NULL)
|
if (e == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
p = e->procfs_entry = create_proc_entry(e->name, quota_list_perms,
|
p = proc_create_data(e->name, quota_list_perms, proc_xt_quota,
|
||||||
proc_xt_quota);
|
"a_proc_fops, e);
|
||||||
if (p == NULL || IS_ERR(p))
|
if (p == NULL || IS_ERR(p))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
p->data = e;
|
e->procfs_entry = p;
|
||||||
p->read_proc = quota_proc_read;
|
proc_set_user(p, make_kuid(&init_user_ns, quota_list_uid),
|
||||||
p->write_proc = quota_proc_write;
|
make_kgid(&init_user_ns, quota_list_gid));
|
||||||
p->uid = make_kuid(&init_user_ns, quota_list_uid);
|
|
||||||
p->gid = make_kgid(&init_user_ns, quota_list_gid);
|
|
||||||
list_add_tail(&e->list, &counter_list);
|
list_add_tail(&e->list, &counter_list);
|
||||||
spin_unlock_bh(&counter_list_lock);
|
spin_unlock_bh(&counter_list_lock);
|
||||||
return e;
|
return e;
|
||||||
|
Reference in New Issue
Block a user