summaryrefslogtreecommitdiff
path: root/quotaio_rpc.c
diff options
context:
space:
mode:
authorYang Lin <lin.a.yang@intel.com>2012-05-30 19:43:21 +0800
committerYang Lin <lin.a.yang@intel.com>2012-05-30 19:43:21 +0800
commit8c82de96cd23e4823a2d29eb2de2295c0866b0c9 (patch)
tree4c255e87442eb17f710f1674e13303ff56be0c7a /quotaio_rpc.c
downloadquota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.tar.gz
quota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.tar.bz2
quota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.zip
Initial commit to Gerrittizen/20120530.11.0_branch1.0
Diffstat (limited to 'quotaio_rpc.c')
-rw-r--r--quotaio_rpc.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/quotaio_rpc.c b/quotaio_rpc.c
new file mode 100644
index 0000000..14fe410
--- /dev/null
+++ b/quotaio_rpc.c
@@ -0,0 +1,71 @@
+/*
+ * quotaio_rpc.c - quota IO operations for RPC (just wrappers for RPC calls)
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "common.h"
+#include "quotaio.h"
+#include "dqblk_rpc.h"
+#include "rquota_client.h"
+#include "pot.h"
+
+static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id);
+static int rpc_commit_dquot(struct dquot *dquot, int flags);
+
+struct quotafile_ops quotafile_ops_rpc = {
+read_dquot: rpc_read_dquot,
+commit_dquot: rpc_commit_dquot
+};
+
+/*
+ * Read a dqblk struct from RPC server - just wrapper function.
+ */
+static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id)
+{
+#ifdef RPC
+ struct dquot *dquot = get_empty_dquot();
+ int ret;
+
+ dquot->dq_id = id;
+ dquot->dq_h = h;
+ if ((ret = rpc_rquota_get(dquot)) < 0) {
+ errno = -ret;
+ free(dquot);
+ return NULL;
+ }
+ return dquot;
+#else
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
+/*
+ * Write a dqblk struct to RPC server - just wrapper function.
+ */
+static int rpc_commit_dquot(struct dquot *dquot, int flags)
+{
+#ifdef RPC
+ int ret;
+
+ if (QIO_RO(dquot->dq_h)) {
+ errstr(_("Trying to write quota to readonly quotafile on %s\n"), dquot->dq_h->qh_quotadev);
+ errno = EPERM;
+ return -1;
+ }
+ if ((ret = rpc_rquota_set(QCMD(Q_RPC_SETQUOTA, dquot->dq_h->qh_type), dquot)) < 0) {
+ errno = -ret;
+ return -1;
+ }
+ return 0;
+#else
+ errno = ENOTSUP;
+ return -1;
+#endif
+}