X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Ferror.c;h=1b64bd7fb1c9d4267ff88646b5836f4335b4bac4;hp=480c944c88020b0cd14821b636c3c81b2489fb1a;hb=05f93b531d59df6e976d9b40c97b51546524040a;hpb=6e54f6179cb9e9d5706901a06744b8f4667c24e7 diff --git a/utils/mount/error.c b/utils/mount/error.c index 480c944..1b64bd7 100644 --- a/utils/mount/error.c +++ b/utils/mount/error.c @@ -23,7 +23,10 @@ * + Proper support for internationalization */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -32,8 +35,6 @@ #include #include #include -#include -#include #include "xcommon.h" #include "nls.h" @@ -69,9 +70,15 @@ static int rpc_strerror(int spos) pos = snprintf(tmp, (erreob - tmp), _("System Error: %s"), strerror(cf_errno)); - else - pos = snprintf(tmp, (erreob - tmp), - _("RPC Error:%s"), estr); + else { + if (cf_errno) + pos = snprintf(tmp, (erreob - tmp), + _("RPC Error:%s; errno = %s"), + estr, strerror(cf_errno)); + else + pos = snprintf(tmp, (erreob - tmp), + _("RPC Error:%s"), estr); + } } return pos; } @@ -185,7 +192,7 @@ void sys_mount_errors(char *server, int error, int will_retry, int bg) fprintf(stderr, "%s\n", errbuf); } -/* +/** * mount_error - report a foreground mount error * @spec: C string containing the device name being mounted * @mount_point: C string containing the pathname of the local mounted on dir @@ -195,12 +202,24 @@ void sys_mount_errors(char *server, int error, int will_retry, int bg) void mount_error(const char *spec, const char *mount_point, int error) { switch(error) { + case EACCES: + nfs_error(_("%s: access denied by server while mounting %s"), + progname, spec); + break; + case EINVAL: + nfs_error(_("%s: an incorrect mount option was specified"), progname); + break; + case EOPNOTSUPP: + nfs_error(_("%s: requested NFS version or transport" + " protocol is not supported"), + progname); + break; case ENOTDIR: nfs_error(_("%s: mount point %s is not a directory"), progname, mount_point); break; case EBUSY: - nfs_error(_("%s: %s is already mounted or busy"), + nfs_error(_("%s: %s is busy or already mounted"), progname, mount_point); break; case ENOENT: @@ -212,6 +231,18 @@ void mount_error(const char *spec, const char *mount_point, int error) nfs_error(_("%s: mount point %s does not exist"), progname, mount_point); break; + case ESPIPE: + rpc_mount_errors((char *)spec, 0, 0); + break; + case EIO: + nfs_error(_("%s: mount system call failed"), progname); + break; + case EFAULT: + nfs_error(_("%s: encountered unexpected error condition."), + progname); + nfs_error(_("%s: please report the error to" PACKAGE_BUGREPORT), + progname); + break; default: nfs_error(_("%s: %s"), progname, strerror(error)); @@ -275,6 +306,8 @@ void umount_error(int err, const char *dev) #define EDQUOT ENOSPC #endif +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + static struct { enum nfsstat stat; int errnum; @@ -304,19 +337,17 @@ static struct { #endif /* Throw in some NFSv3 values for even more fun (HP returns these) */ { 71, EREMOTE }, - - { -1, EIO } }; -char *nfs_strerror(int stat) +char *nfs_strerror(unsigned int stat) { - int i; + unsigned int i; static char buf[256]; - for (i = 0; nfs_errtbl[i].stat != -1; i++) { + for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) { if (nfs_errtbl[i].stat == stat) return strerror(nfs_errtbl[i].errnum); } - sprintf(buf, _("unknown nfs status return value: %d"), stat); + sprintf(buf, _("unknown nfs status return value: %u"), stat); return buf; }