- static char new_opts[1024];
- char *s, *old_opts;
-
- s = inet_ntoa(saddr->sin_addr);
- old_opts = *extra_opts;
- if (!old_opts)
- old_opts = "";
- if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
- nfs_error(_("%s: too many mount options\n"),
+ po_remove_all(options, "addr");
+ return nfs_append_generic_address_option(sap, salen, "addr", options);
+}
+
+/*
+ * 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 nfs_append_clientaddr_option(const struct sockaddr *sap,
+ socklen_t salen,
+ struct mount_options *options)
+{
+ struct sockaddr_storage dummy;
+ struct sockaddr *my_addr = (struct sockaddr *)&dummy;
+ socklen_t my_len = sizeof(dummy);
+
+ if (po_contains(options, "clientaddr") == PO_FOUND)
+ return 1;
+
+ nfs_callback_address(sap, salen, my_addr, &my_len);
+
+ return nfs_append_generic_address_option(my_addr, my_len,
+ "clientaddr", options);
+}
+
+/*
+ * Resolve the 'mounthost=' hostname and append a new option using
+ * the resulting address.
+ */
+static int nfs_fix_mounthost_option(const sa_family_t family,
+ struct mount_options *options)
+{
+ struct sockaddr_storage dummy;
+ struct sockaddr *sap = (struct sockaddr *)&dummy;
+ socklen_t salen = sizeof(dummy);
+ char *mounthost;
+
+ mounthost = po_get(options, "mounthost");
+ if (!mounthost)
+ return 1;
+
+ if (!nfs_name_to_address(mounthost, family, sap, &salen)) {
+ nfs_error(_("%s: unable to determine mount server's address"),