Fixes so "make allnoconfig" works again.
[oweals/busybox.git] / util-linux / nfsmount.c
index 0edfdf34a616ffdfbb031006b680702696149fd3..11ca3268ed74df521e6560bf59b0afcc65697c9b 100644 (file)
@@ -24,7 +24,7 @@
  *
  * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
  * - added Native Language Support
- * 
+ *
  * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
  * plus NFSv3 stuff.
  */
@@ -95,7 +95,7 @@ enum nfs_stat {
        NFSERR_BADTYPE = 10007,         /*    v3 */
        NFSERR_JUKEBOX = 10008          /*    v3 */
 };
+
 #define NFS_PROGRAM    100003
 
 
@@ -303,7 +303,7 @@ return &p;
 }
 
 int nfsmount(const char *spec, const char *node, int *flags,
-            char **extra_opts, char **mount_opts, int running_bg)
+            char **mount_opts, int running_bg)
 {
        static char *prev_bg_host;
        char hostdir[1024];
@@ -315,7 +315,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
        char new_opts[1024];
        struct timeval total_timeout;
        enum clnt_stat clnt_stat;
-       static struct nfs_mount_data data;
+       struct nfs_mount_data data;
        char *opt, *opteq;
        int val;
        struct hostent *hp;
@@ -399,7 +399,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
        /* add IP address to mtab options for use when unmounting */
 
        s = inet_ntoa(server_addr.sin_addr);
-       old_opts = *extra_opts;
+       old_opts = *mount_opts;
        if (!old_opts)
                old_opts = "";
        if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
@@ -408,7 +408,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
        }
        sprintf(new_opts, "%s%saddr=%s",
                old_opts, *old_opts ? "," : "", s);
-       *extra_opts = bb_xstrdup(new_opts);
+       *mount_opts = bb_xstrdup(new_opts);
 
        /* Set default options.
         * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
@@ -445,7 +445,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
 
        for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
                if ((opteq = strchr(opt, '='))) {
-                       val = atoi(opteq + 1);  
+                       val = atoi(opteq + 1);
                        *opteq = '\0';
                        if (!strcmp(opt, "rsize"))
                                data.rsize = val;
@@ -515,9 +515,9 @@ int nfsmount(const char *spec, const char *node, int *flags,
                                val = 0;
                                opt += 2;
                        }
-                       if (!strcmp(opt, "bg")) 
+                       if (!strcmp(opt, "bg"))
                                bg = val;
-                       else if (!strcmp(opt, "fg")) 
+                       else if (!strcmp(opt, "fg"))
                                bg = !val;
                        else if (!strcmp(opt, "soft"))
                                soft = val;
@@ -602,10 +602,9 @@ int nfsmount(const char *spec, const char *node, int *flags,
 #endif
 
        data.version = nfs_mount_version;
-       *mount_opts = (char *) &data;
 
        if (*flags & MS_REMOUNT)
-               return 0;
+               goto copy_data_and_return;
 
        /*
         * If the previous mount operation on the same host was
@@ -857,6 +856,9 @@ int nfsmount(const char *spec, const char *node, int *flags,
        auth_destroy(mclient->cl_auth);
        clnt_destroy(mclient);
        close(msock);
+copy_data_and_return:
+       *mount_opts = xrealloc(*mount_opts, sizeof(data));
+       memcpy(*mount_opts, &data, sizeof(data));
        return 0;
 
        /* abort */
@@ -872,7 +874,7 @@ fail:
        if (fsock != -1)
                close(fsock);
        return retval;
-}      
+}
 
 /*
  * We need to translate between nfs status return values and
@@ -976,7 +978,7 @@ xdr_fhandle3 (XDR *xdrs, fhandle3 *objp)
 {
        //register int32_t *buf;
 
-        if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
+        if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3))
                 return FALSE;
        return TRUE;
 }
@@ -988,7 +990,7 @@ xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp)
 
         if (!xdr_fhandle3 (xdrs, &objp->fhandle))
                 return FALSE;
-        if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0,
+        if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (unsigned int *) &objp->auth_flavours.auth_flavours_len, ~0,
                sizeof (int), (xdrproc_t) xdr_int))
                 return FALSE;
        return TRUE;