[klibc] nfsmount: better debugging info and error messages
In particular, the error message we get when the kernel doesn't
have the appropriate NFS support was very confusing.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/usr/kinit/kinit.c b/usr/kinit/kinit.c
index ecc514f..bd7c60e 100644
--- a/usr/kinit/kinit.c
+++ b/usr/kinit/kinit.c
@@ -18,27 +18,21 @@
int mnt_sysfs;
#ifdef INI_DEBUG
-static void dump_args(int argc, char *argv[])
+void dump_args(int argc, char *argv[])
{
int i;
printf(" argc == %d\n", argc);
for (i = 0; i < argc; i++) {
- printf(" argv[%d]: '%s'\n", i, argv[i]);
+ printf(" argv[%d]: \"%s\"\n", i, argv[i]);
}
if (argv[argc] != NULL) {
- printf(" argv[%d]: '%s' (SHOULD BE NULL)\n",
+ printf(" argv[%d]: \"%s\" (SHOULD BE NULL)\n",
argc, argv[argc]);
}
}
-#else
-static inline void dump_args(int argc, char *argv[])
-{
- (void)argc;
- (void)argv;
-}
#endif
diff --git a/usr/kinit/kinit.h b/usr/kinit/kinit.h
index bf20a63..23d974b 100644
--- a/usr/kinit/kinit.h
+++ b/usr/kinit/kinit.h
@@ -60,4 +60,14 @@
#define DEBUG(x) do { } while (0)
#endif
+#ifdef INI_DEBUG
+void dump_args(int argc, char *argv[]);
+#else
+static inline void dump_args(int argc, char *argv[])
+{
+ (void)argc;
+ (void)argv;
+}
+#endif
+
#endif /* KINIT_H */
diff --git a/usr/kinit/nfsmount/mount.c b/usr/kinit/nfsmount/mount.c
index 1c6d3f3..066f6cd 100644
--- a/usr/kinit/nfsmount/mount.c
+++ b/usr/kinit/nfsmount/mount.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "nfsmount.h"
#include "sunrpc.h"
@@ -265,7 +266,7 @@
goto bail;
}
- dump_params(server, path, data);
+ dump_params(server, rem_path, data);
if (data->flags & NFS_MOUNT_TCP) {
clnt = tcp_client(server, mount_port, CLI_RESVPORT);
@@ -318,7 +319,13 @@
ret = mount(pathname, path, "nfs", mountflags, data);
if (ret == -1) {
- perror("mount");
+ if (errno == ENODEV) {
+ fprintf(stderr, "mount: the kernel lacks NFS v%d "
+ "support\n",
+ (data->flags & NFS_MOUNT_VER3) ? 3 : 2);
+ } else {
+ perror("mount");
+ }
goto bail;
}
diff --git a/usr/kinit/nfsroot.c b/usr/kinit/nfsroot.c
index 1965987..12ffce5 100644
--- a/usr/kinit/nfsroot.c
+++ b/usr/kinit/nfsroot.c
@@ -88,20 +88,21 @@
}
snprintf(root, len, "%s:%s", inet_ntoa(addr), path);
-
- nfs_argv[a++] = sub_client(client, root, len);
} else {
strcpy(root, path);
- nfs_argv[a++] = sub_client(client, root, len);
}
+
+ nfs_argv[a++] = sub_client(client, root, len);
- DEBUG(("NFS-Root: mounting %s on %s with options '%s'\n",
- argv[a - 1], mtpt, opts ? opts : "none"));
+ DEBUG(("NFS-Root: mounting %s on %s with options \"%s\"\n",
+ nfs_argv[a-1], mtpt, opts ? opts : ""));
nfs_argv[a++] = mtpt;
nfs_argv[a] = NULL;
assert(a <= NFS_ARGC);
+ dump_args(a, nfs_argv);
+
if ((ret = nfsmount_main(a, nfs_argv)) != 0) {
ret = -1;
goto done;