nfs-utils/nfs-utils-1.1.0-mount-v4-errors.patch

78 lines
2.0 KiB
Diff

--- nfs-utils-1.1.0/utils/mount/mount.c.orig 2007-07-18 16:26:01.000000000 -0400
+++ nfs-utils-1.1.0/utils/mount/mount.c 2007-07-18 16:37:34.000000000 -0400
@@ -286,17 +286,24 @@ static void parse_opts (const char *opti
}
}
-static void mount_error(char *node)
+static void mount_error(char *mount_point, char *node)
{
switch(errno) {
case ENOTDIR:
- fprintf(stderr, "%s: mount point %s is not a directory\n", progname, node);
+ fprintf(stderr, "%s: mount point %s is not a directory\n",
+ progname, mount_point);
break;
case EBUSY:
- fprintf(stderr, "%s: %s is already mounted or busy\n", progname, node);
+ fprintf(stderr, "%s: %s is already mounted or busy\n", progname,
+ mount_point);
break;
case ENOENT:
- fprintf(stderr, "%s: mount point %s does not exist\n", progname, node);
+ if (node)
+ fprintf(stderr, "%s: %s failed, reason given by server: %s\n",
+ progname, node, strerror(errno));
+ else
+ fprintf(stderr, "%s: mount point %s does not exist\n", progname,
+ mount_point);
break;
default:
fprintf(stderr, "%s: %s\n", progname, strerror(errno));
@@ -352,6 +359,26 @@ static int start_statd()
#endif
return 0;
}
+static int chk_mountpoint(char *mount_point)
+{
+ struct stat sb;
+
+ if (stat(mount_point, &sb) < 0){
+ mount_error(mount_point, NULL);
+ return 1;
+ }
+ if (S_ISDIR(sb.st_mode) == 0){
+ errno = ENOTDIR;
+ mount_error(mount_point, NULL);
+ return 1;
+ }
+ if (access(mount_point, X_OK) < 0) {
+ mount_error(mount_point, NULL);
+ return 1;
+ }
+
+ return 0;
+}
int main(int argc, char *argv[])
{
@@ -509,6 +536,9 @@ int main(int argc, char *argv[])
}
}
+ if (chk_mountpoint(mount_point))
+ exit(1);
+
if (nfs_mount_vers == 4)
mnt_err = nfs4mount(spec, mount_point, &flags, &extra_opts, &mount_opts, 0);
else {
@@ -539,7 +569,7 @@ int main(int argc, char *argv[])
mount_opts);
if (mnt_err) {
- mount_error(mount_point);
+ mount_error(mount_point, spec);
exit(EX_FAIL);
}
}