summaryrefslogtreecommitdiff
path: root/rquota_client.c
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-08-22 21:17:56 +0000
committerjkar8572 <jkar8572>2001-08-22 21:17:56 +0000
commit94a0d407495f21eec4566adca221a07b87583d38 (patch)
tree810fe406f41e8c46dce48fe6f695fc1a51ac849b /rquota_client.c
parent8aaad9540966c73ae67a5065abbbc55391614479 (diff)
downloadlinuxquota-94a0d407495f21eec4566adca221a07b87583d38.tar.gz
Implemented better error handling of RPC calls.
Implemented better host access handling (from nfsutils rquotad).
Diffstat (limited to 'rquota_client.c')
-rw-r--r--rquota_client.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/rquota_client.c b/rquota_client.c
index 553bc10..4b5a582 100644
--- a/rquota_client.c
+++ b/rquota_client.c
@@ -9,7 +9,7 @@
*
* This part does the rpc-communication with the rquotad.
*
- * Version: $Id: rquota_client.c,v 1.4 2001/08/15 20:13:42 jkar8572 Exp $
+ * Version: $Id: rquota_client.c,v 1.5 2001/08/22 21:17:56 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -100,10 +100,28 @@ static inline void cliutil2netdqblk(struct sq_dqblk *n, struct util_dqblk *u)
n->rq_ftimeleft = 0;
}
+/* Write appropriate error message */
+int rquota_err(int stat)
+{
+ switch (stat) {
+ case -1:
+ return -ECONNREFUSED;
+ case 0:
+ return -ENOSYS;
+ case Q_NOQUOTA:
+ case Q_OK:
+ return 0;
+ case Q_EPERM:
+ return -EPERM;
+ default:
+ return -EINVAL;
+ }
+}
+
/*
* Collect the requested quota information from a remote host.
*/
-void rpc_rquota_get(struct dquot *dquot)
+int rpc_rquota_get(struct dquot *dquot)
{
CLIENT *clnt;
getquota_rslt *result;
@@ -131,7 +149,7 @@ void rpc_rquota_get(struct dquot *dquot)
* automounter.
*/
if ((pathname = strchr(fsname_tmp, ':')) == (char *)0 || *(pathname + 1) == '(')
- return;
+ return -ENOENT;
*pathname++ = '\0';
@@ -168,12 +186,10 @@ void rpc_rquota_get(struct dquot *dquot)
*/
auth_destroy(clnt->cl_auth);
clnt_destroy(clnt);
- puts("get2");
}
- else {
+ else
result = NULL;
- }
- printf("result: %p, status: %d\n", result, result?result->status:0);
+
if (result == NULL || !result->status) {
if (dquot->dq_h->qh_type == USRQUOTA) {
/*
@@ -212,14 +228,14 @@ void rpc_rquota_get(struct dquot *dquot)
}
}
}
-
free(fsname_tmp);
+ return rquota_err(result?result->status:-1);
}
/*
* Set the requested quota information on a remote host.
*/
-void rpc_rquota_set(int qcmd, struct dquot *dquot)
+int rpc_rquota_set(int qcmd, struct dquot *dquot)
{
#if defined(RPC_SETQUOTA)
CLIENT *clnt;
@@ -243,7 +259,7 @@ void rpc_rquota_set(int qcmd, struct dquot *dquot)
* automounter.
*/
if ((pathname = strchr(fsname_tmp, ':')) == (char *)0 || *(pathname + 1) == '(')
- return;
+ return -ENOENT;
*pathname++ = '\0';
@@ -324,6 +340,7 @@ void rpc_rquota_set(int qcmd, struct dquot *dquot)
}
}
free(fsname_tmp);
+ return rquota_err(result?result->status:-1);
#endif
}
#endif