[PATCH 2/3] container quota tool: add quotaio for lxc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add quotaio_lxc.c[.h] to isolate container quotactl operations.

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
 quotaio_lxc.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 quotaio_lxc.h |    4 +++
 2 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100644 quotaio_lxc.c
 create mode 100644 quotaio_lxc.h

diff --git a/quotaio_lxc.c b/quotaio_lxc.c
new file mode 100644
index 0000000..b3a8144
--- /dev/null
+++ b/quotaio_lxc.c
@@ -0,0 +1,78 @@
+#include "config.h"
+
+#include <errno.h>
+#include <string.h>
+#include <pwd.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "pot.h"
+#include "common.h"
+#include "quotaio.h"
+#include "quotaio_generic.h"
+#include "quota.h"
+#include "quotasys.h"
+#include "dqblk_lxc.h"
+
+int lxc_init_io(struct quota_handle *h);
+int lxc_write_info(struct quota_handle *h);
+struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id);
+int lxc_commit_dquot(struct dquot *dquot, int flags);
+int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct
+dquot *dquot, char *dqname));
+
+struct quotafile_ops quotafile_ops_lxc = {
+init_io:	lxc_init_io,
+write_info:	lxc_write_info,
+read_dquot:	lxc_read_dquot,
+commit_dquot:	lxc_commit_dquot,
+scan_dquots:	lxc_scan_dquots
+};
+
+/*
+ *	Initialize container quota information
+ */
+int lxc_init_io(struct quota_handle *h)
+{
+	/*
+	 * FIXME: at first, before turning LXC quota on,
+	 * call vfs_get_info() will failed as ENOSCH, so
+	 * just return 0 is ok.
+	 * Should we consider to call vfs_get_info(h) here?
+	 */
+	return 0;
+}
+
+/*
+ *	Write information (grace times)
+ */
+int lxc_write_info(struct quota_handle *h)
+{
+	return vfs_set_info(h, IIF_BGRACE | IIF_IGRACE);
+}
+
+struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id)
+{
+	struct dquot *dquot = get_empty_dquot();
+
+	dquot->dq_id = id;
+	dquot->dq_h = h;
+	memset(&dquot->dq_dqb, 0, sizeof(struct util_dqblk));
+	if (vfs_get_dquot(dquot) < 0) {
+		free(dquot);
+		return NULL;
+	}
+	return dquot;
+}
+
+int lxc_commit_dquot(struct dquot *dquot, int flags)
+{
+	return vfs_set_dquot(dquot, flags);
+}
+
+int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct
+dquot *dquot, char *dqname))
+{
+	return generic_scan_dquots(h, process_dquot, vfs_get_dquot);
+}
diff --git a/quotaio_lxc.h b/quotaio_lxc.h
new file mode 100644
index 0000000..2ae2899
--- /dev/null
+++ b/quotaio_lxc.h
@@ -0,0 +1,4 @@
+#ifndef GUARD_QUOTAIO_GENERIC_H
+#define GUARD_QUOTAIO_GENERIC_H
+
+#endif
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux