Source-Changes-HG archive

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

[src/trunk]: src/lib/libquota Some more errno remapping: if the NFS server is...



details:   https://anonhg.NetBSD.org/src/rev/c2042b005f9d
branches:  trunk
changeset: 329827:c2042b005f9d
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jun 11 08:43:01 2014 +0000

description:
Some more errno remapping: if the NFS server is unreachable because we have
no route to it, assume there are no quotas. While this might sound like
an impossible scenario, it actually happens inside rump tests when we have
a virtual shmif network but are querying quotas for / which happens to
be on NFS (but of course outside of the shmif setup).
This fixes tests/fs/nfs/t_rquotad on diskless clients.

diffstat:

 lib/libquota/quota_nfs.c |  22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r c2e87e44a81e -r c2042b005f9d lib/libquota/quota_nfs.c
--- a/lib/libquota/quota_nfs.c  Wed Jun 11 07:05:35 2014 +0000
+++ b/lib/libquota/quota_nfs.c  Wed Jun 11 08:43:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $     */
+/*     $NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $     */
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $");
+__RCSID("$NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h> /* XXX for DEV_BSIZE */
@@ -191,9 +191,21 @@
        free(host);
 
        if (ret != RPC_SUCCESS) {
-               /* if the file server does not support any quotas at all,
-                  return ENOENT */
-               errno = sverrno == ENOTCONN ? ENOENT : sverrno;
+               /*
+                * Remap some error codes for callers convenience:
+                *  - if the file server does not support any quotas at all,
+                *    return ENOENT
+                *  - if the server can not be reached something is very
+                *    wrong - or we are run inside a virtual rump network
+                *    but querying an NFS mount from the host. Make sure
+                *    to fail silently and return ENOENT as well.
+                */
+               if (ret == RPC_SYSTEMERROR
+                   && rpc_createerr.cf_error.re_errno == EHOSTUNREACH)
+                       sverrno = ENOENT;
+               else if (sverrno == ENOTCONN)
+                       sverrno = ENOENT;
+               errno = sverrno;
                return -1;
        }
 



Home | Main Index | Thread Index | Old Index