]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/stropts.c
mount.nfs: Remove get_my_ipv4addr() from append_addr_opt()
[nfs-utils.git] / utils / mount / stropts.c
index c11420069d97e363d456eb2c998c8e0054cfd03d..cc13325750aa1eb22e542c6c7911a8333e770838 100644 (file)
@@ -37,6 +37,7 @@
 #include "nls.h"
 #include "nfs_mount.h"
 #include "mount_constants.h"
 #include "nls.h"
 #include "nfs_mount.h"
 #include "mount_constants.h"
+#include "stropts.h"
 #include "error.h"
 #include "network.h"
 
 #include "error.h"
 #include "network.h"
 
@@ -129,7 +130,7 @@ static int get_my_ipv4addr(char *ip_addr, int len)
 
 /*
  * Walk through our mount options string, and indicate the presence
 
 /*
  * Walk through our mount options string, and indicate the presence
- * of 'bg', 'retry=', and 'clientaddr='.
+ * of 'bg', 'retry=', 'addr=', and 'clientaddr='.
  */
 static void extract_interesting_options(char *opts)
 {
  */
 static void extract_interesting_options(char *opts)
 {
@@ -160,13 +161,14 @@ static void extract_interesting_options(char *opts)
 }
 
 /*
 }
 
 /*
- * Append the "addr=" option to the options string.
+ * Append the 'addr=' option to the options string.
  *
  *
- * We always add our own addr= to the end of the options string.
+ * Returns 1 if 'addr=' option created successfully;
+ * otherwise zero.
  */
 static int append_addr_opt(const char *spec, char **extra_opts)
 {
  */
 static int append_addr_opt(const char *spec, char **extra_opts)
 {
-       static char hostdir[1024], new_opts[1024], ip_addr[255];
+       static char hostdir[1024], new_opts[1024];
        char *hostname, *dirname, *s, *old_opts;
        struct sockaddr_in addr;
 
        char *hostname, *dirname, *s, *old_opts;
        struct sockaddr_in addr;
 
@@ -184,8 +186,6 @@ static int append_addr_opt(const char *spec, char **extra_opts)
 
        if (!fill_ipv4_sockaddr(hostname, &addr))
                return 0;
 
        if (!fill_ipv4_sockaddr(hostname, &addr))
                return 0;
-       if (!get_my_ipv4addr(ip_addr, sizeof(ip_addr)))
-               return 0;
 
        /* add IP address to mtab options for use when unmounting */
        s = inet_ntoa(addr.sin_addr);
 
        /* add IP address to mtab options for use when unmounting */
        s = inet_ntoa(addr.sin_addr);
@@ -205,9 +205,9 @@ static int append_addr_opt(const char *spec, char **extra_opts)
 }
 
 /*
 }
 
 /*
- * Append the "clientaddr=" option to the options string.
+ * Append the 'clientaddr=' option to the options string.
  *
  *
- * Returns 1 if clientaddr option created successfully;
+ * Returns 1 if 'clientaddr=' option created successfully;
  * otherwise zero.
  */
 static int append_clientaddr_opt(const char *spec, char **extra_opts)
  * otherwise zero.
  */
 static int append_clientaddr_opt(const char *spec, char **extra_opts)
@@ -254,17 +254,18 @@ int nfsmount_s(const char *spec, const char *node, int flags,
 {
        int retval = EX_FAIL;
 
 {
        int retval = EX_FAIL;
 
-       if (verbose)
-               printf(_("%s: using C string mount system call interface\n"),
-                       progname);
-
        extract_interesting_options(*extra_opts);
 
        extract_interesting_options(*extra_opts);
 
-       if (!addr_opt && !append_addr_opt(spec, extra_opts))
+       if (!bg && addr_opt) {
+               nfs_error(_("%s: Illegal option: 'addr='"), progname);
+               goto fail;
+       }
+
+       if (!append_addr_opt(spec, extra_opts))
                goto fail;
 
        if (verbose)
                goto fail;
 
        if (verbose)
-               printf(_("%s: option string is '%s'\n"),
+               printf(_("%s: text-based options: '%s'\n"),
                        progname, *extra_opts);
 
        if (!fake) {
                        progname, *extra_opts);
 
        if (!fake) {
@@ -290,30 +291,36 @@ fail:
  * @extra_opts:        pointer to C string containing fs-specific mount options
  *             (possibly also a return argument)
  * @fake:      flag indicating whether to carry out the whole operation
  * @extra_opts:        pointer to C string containing fs-specific mount options
  *             (possibly also a return argument)
  * @fake:      flag indicating whether to carry out the whole operation
- * @bg:                one if this is a backgrounded mount attempt
+ * @child:     one if this is a backgrounded mount
  *
  * XXX: need to handle bg, fg, and retry options.
  *
  */
 int nfs4mount_s(const char *spec, const char *node, int flags,
  *
  * XXX: need to handle bg, fg, and retry options.
  *
  */
 int nfs4mount_s(const char *spec, const char *node, int flags,
-               char **extra_opts, int fake)
+               char **extra_opts, int fake, int child)
 {
        int retval = EX_FAIL;
 
 {
        int retval = EX_FAIL;
 
-       if (verbose)
-               printf(_("%s: using C string mount system call interface\n"),
-                       progname);
-
        extract_interesting_options(*extra_opts);
 
        extract_interesting_options(*extra_opts);
 
-       if (!addr_opt && !append_addr_opt(spec, extra_opts))
+       if (addr_opt) {
+               nfs_error(_("%s: Illegal option: 'addr='"), progname);
+               goto fail;
+       }
+
+       if (ca_opt) {
+               nfs_error(_("%s: Illegal option: 'clientaddr='"), progname);
+               goto fail;
+       }
+
+       if (!append_addr_opt(spec, extra_opts))
                goto fail;
 
                goto fail;
 
-       if (!ca_opt && !append_clientaddr_opt(spec, extra_opts))
+       if (!append_clientaddr_opt(spec, extra_opts))
                goto fail;
 
        if (verbose)
                goto fail;
 
        if (verbose)
-               printf(_("%s: option string is '%s'\n"),
+               printf(_("%s: text-based options: '%s'\n"),
                        progname, *extra_opts);
 
        if (!fake) {
                        progname, *extra_opts);
 
        if (!fake) {