lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 30 May 2012 23:07:57 +0800
From:	jeff.liu@...cle.com
To:	containers@...ts.linux-foundation.org
Cc:	cgroups@...r.kernel.org, jack@...e.cz, glommer@...allels.com,
	daniel.lezcano@...e.fr, tytso@....edu, bpm@....com,
	chris.mason@...cle.com, hch@...radead.org,
	christopher.jones@...cle.com, david@...morbit.com,
	tinguely@....com, tm@....ma, linux-ext4@...r.kernel.org,
	linux-fsdevel@...r.kernel.org, Jie Liu <jeff.liu@...cle.com>
Subject: [PATCH 2/3] container quota tool: add quotaio for lxc

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

Signed-off-by: Jie Liu <jeff.liu@...cle.com>
---
 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-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ