walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
bbc1dcf
commit 331c2ca949d5b4b4d18d0aca90afb8ae9475bcd6
bbc1dcf
Author: Neil Brown <neilb@suse.de>
bbc1dcf
Date:   Fri Jun 6 14:59:21 2008 -0400
bbc1dcf
bbc1dcf
    Make the text-based mount path check whether statd is running if the "lock"
bbc1dcf
    option is in effect.  This echoes similar logic in the legacy mount path.
bbc1dcf
    
bbc1dcf
    Signed-off-by: Neil Brown <neilb@suse.de>
bbc1dcf
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
bbc1dcf
    Signed-off-by: Steve Dickson <steved@redhat.com>
bbc1dcf
bbc1dcf
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
bbc1dcf
index cdd610e..b2b56be 100644
bbc1dcf
--- a/utils/mount/stropts.c
bbc1dcf
+++ b/utils/mount/stropts.c
bbc1dcf
@@ -219,13 +219,34 @@ static int fix_mounthost_option(struct mount_options *options)
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
+ * Returns zero if the "lock" option is in effect, but statd
bbc1dcf
+ * can't be started.  Otherwise, returns 1.
bbc1dcf
+ */
bbc1dcf
+static int verify_lock_option(struct mount_options *options)
bbc1dcf
+{
bbc1dcf
+	if (po_rightmost(options, "nolock", "lock") == PO_KEY1_RIGHTMOST)
bbc1dcf
+		return 1;
bbc1dcf
+
bbc1dcf
+	if (!start_statd()) {
bbc1dcf
+		nfs_error(_("%s: rpc.statd is not running but is "
bbc1dcf
+			    "required for remote locking."), progname);
bbc1dcf
+		nfs_error(_("%s: Either use '-o nolock' to keep "
bbc1dcf
+			    "locks local, or start statd."), progname);
bbc1dcf
+		return 0;
bbc1dcf
+	}
bbc1dcf
+
bbc1dcf
+	return 1;
bbc1dcf
+}
bbc1dcf
+
bbc1dcf
+/*
bbc1dcf
  * Set up mandatory mount options.
bbc1dcf
  *
bbc1dcf
  * Returns 1 if successful; otherwise zero.
bbc1dcf
  */
bbc1dcf
-static int set_mandatory_options(const char *type,
bbc1dcf
-				 struct sockaddr_in *saddr,
bbc1dcf
-				 struct mount_options *options)
bbc1dcf
+static int validate_options(const char *type,
bbc1dcf
+			    struct sockaddr_in *saddr,
bbc1dcf
+			    struct mount_options *options,
bbc1dcf
+			    int fake)
bbc1dcf
 {
bbc1dcf
 	if (!append_addr_option(saddr, options))
bbc1dcf
 		return 0;
bbc1dcf
@@ -236,6 +257,8 @@ static int set_mandatory_options(const char *type,
bbc1dcf
 	} else {
bbc1dcf
 		if (!fix_mounthost_option(options))
bbc1dcf
 			return 0;
bbc1dcf
+		if (!fake && !verify_lock_option(options))
bbc1dcf
+			return 0;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
 	return 1;
bbc1dcf
@@ -691,7 +714,7 @@ int nfsmount_string(const char *spec, const char *node, const char *type,
bbc1dcf
 		goto fail;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
-	if (!set_mandatory_options(type, &saddr, options))
bbc1dcf
+	if (!validate_options(type, &saddr, options, fake))
bbc1dcf
 		goto out;
bbc1dcf
 
bbc1dcf
 	if (po_rightmost(options, "bg", "fg") == PO_KEY1_RIGHTMOST)