]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/stropts.c
mount.nfs: Don't do anything fancy if this is a remount
[nfs-utils.git] / utils / mount / stropts.c
index c5c4ba157f9ec9d4ff0f5d7e7f644a1b9c226b63..50a1a2a06626a72ba2c09fe656df3331e66a85b1 100644 (file)
@@ -966,6 +966,26 @@ static int nfsmount_bg(struct nfsmount_info *mi)
                return nfsmount_child(mi);
 }
 
+/*
+ * Usually all that is needed for an NFS remount is to change
+ * generic mount options like "sync" or "ro".  These generic
+ * options are controlled by mi->flags, not by text-based
+ * options, and no contact with the server is needed.
+ *
+ * Take care with the /etc/mtab entry for this mount; just
+ * calling update_mtab() will change an "-t nfs -o vers=4"
+ * mount to an "-t nfs -o remount" mount, and that will
+ * confuse umount.nfs.
+ *
+ * Returns a valid mount command exit code.
+ */
+static int nfs_remount(struct nfsmount_info *mi)
+{
+       if (nfs_sys_mount(mi, mi->options))
+               return EX_SUCCESS;
+       return EX_FAIL;
+}
+
 /*
  * Process mount options and try a mount system call.
  *
@@ -982,6 +1002,12 @@ static int nfsmount_start(struct nfsmount_info *mi)
        if (!nfs_validate_options(mi))
                return EX_FAIL;
 
+       /*
+        * Avoid retry and negotiation logic when remounting
+        */
+       if (mi->flags & MS_REMOUNT)
+               return nfs_remount(mi);
+
        if (po_rightmost(mi->options, nfs_background_opttbl) == 0)
                return nfsmount_bg(mi);
        else
@@ -998,6 +1024,8 @@ static int nfsmount_start(struct nfsmount_info *mi)
  *             (input and output argument)
  * @fake: flag indicating whether to carry out the whole operation
  * @child: one if this is a mount daemon (bg)
+ *
+ * Returns a valid mount command exit code.
  */
 int nfsmount_string(const char *spec, const char *node, const char *type,
                    int flags, char **extra_opts, int fake, int child)