+ po_remove_all(options, "addr");
+
+ snprintf(new_option, sizeof(new_option) - 1,
+ "addr=%s", inet_ntoa(saddr->sin_addr));
+
+ if (po_append(options, new_option) == PO_SUCCEEDED)
+ return 1;
+ return 0;
+}
+
+/*
+ * Called to discover our address and append an appropriate 'clientaddr='
+ * option to the options string.
+ *
+ * Returns 1 if 'clientaddr=' option created successfully or if
+ * 'clientaddr=' option is already present; otherwise zero.
+ */
+static int append_clientaddr_option(struct sockaddr_in *saddr,
+ struct mount_options *options)
+{
+ struct sockaddr_in my_addr;
+ char new_option[32];
+
+ if (po_contains(options, "clientaddr") == PO_SUCCEEDED)
+ return 1;
+
+ if (!get_client_address(saddr, &my_addr))
+ return 0;
+
+ snprintf(new_option, sizeof(new_option) - 1,
+ "clientaddr=%s", inet_ntoa(my_addr.sin_addr));
+
+ if (po_append(options, new_option) == PO_SUCCEEDED)
+ return 1;
+ return 0;
+}
+
+/*
+ * Resolve the 'mounthost=' hostname and append a new option using
+ * the resulting IPv4 address.
+ */
+static int fix_mounthost_option(struct mount_options *options)
+{
+ struct sockaddr_in maddr;
+ char *mounthost, new_option[32];
+
+ mounthost = po_get(options, "mounthost");
+ if (!mounthost)
+ return 1;
+
+ if (!fill_ipv4_sockaddr(mounthost, &maddr))
+ return 0;
+
+ snprintf(new_option, sizeof(new_option) - 1,
+ "mountaddr=%s", inet_ntoa(maddr.sin_addr));
+
+ if (po_append(options, new_option) == PO_SUCCEEDED)
+ return 1;
+ return 0;
+}
+
+/*
+ * Returns zero if the "lock" option is in effect, but statd
+ * can't be started. Otherwise, returns 1.
+ */
+static int verify_lock_option(struct mount_options *options)
+{
+ if (po_rightmost(options, "nolock", "lock") == PO_KEY1_RIGHTMOST)
+ return 1;
+
+ if (!start_statd()) {
+ nfs_error(_("%s: rpc.statd is not running but is "
+ "required for remote locking."), progname);
+ nfs_error(_("%s: Either use '-o nolock' to keep "
+ "locks local, or start statd."), progname);