From 7b363fd3c904c2530844150d00b99f7b32d97f05 Mon Sep 17 00:00:00 2001
From: Rob Landley <rob@landley.net>
Date: Tue, 20 Dec 2005 17:18:01 +0000
Subject: [PATCH] Some minor cleanups/bugfixes split off from the big remount
 work:   Shorten GPL boilerplate.   Enabling FEATURE_CLEAN_UP broke things in
 two places.   Move the NFS with uClibc check to nfsmount.c

---
 util-linux/mount.c    | 35 ++++++++---------------------------
 util-linux/nfsmount.c |  6 ++++++
 2 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/util-linux/mount.c b/util-linux/mount.c
index cc6b73eb0..4b8e81ca1 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -6,20 +6,7 @@
  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  * Copyright (C) 2005 by Rob Landley <rob@landley.net>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include <limits.h>
@@ -35,12 +22,6 @@
 #include <sys/ioctl.h>  // for CONFIG_FEATURE_MOUNT_LOOP
 #include "busybox.h"
 
-/* This is just a warning of a common mistake.  Possibly this should be a
- * uclibc faq entry rather than in busybox... */
-#if ENABLE_FEATURE_MOUNT_NFS && defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
-#error "You need to build uClibc with UCLIBC_HAS_RPC for busybox mount with NFS support to compile."
-#endif
-
 // These two aren't always defined in old headers
 #ifndef MS_BIND
 #define MS_BIND		4096
@@ -182,7 +163,7 @@ extern int mount_main(int argc, char **argv)
 		while (getmntent_r(mountTable,&m,path,sizeof(path))) {
 			blockDevice = m.mnt_fsname;
 
-			// Clean up display a little bit regarding root devie
+			// Clean up display a little bit regarding root device
 			if(!strcmp(blockDevice, "rootfs")) continue;
 			if(!strcmp(blockDevice, "/dev/root"))
 				blockDevice = find_block_device("/");
@@ -260,7 +241,7 @@ extern int mount_main(int argc, char **argv)
 			free(blockDevice);
 			blockDevice=strdup(m.mnt_fsname);
 			free(directory);
-			directory=strdup(m.mnt_type);
+			directory=strdup(m.mnt_dir);
 		} else {
 			blockDevice=m.mnt_fsname;
 			directory=m.mnt_dir;
@@ -387,16 +368,16 @@ mount_it_now:
 				bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
 		}
 		// We couldn't free this earlier becase fsType could be in buf.
-		if(ENABLE_FEATURE_CLEAN_UP) {
-			free(buf);
-			free(blockDevice);
-			free(directory);
-		}
+		if(ENABLE_FEATURE_CLEAN_UP) free(buf);
 		if(!all) break;
 	}
 
 	if(file) endmntent(file);
 	if(rc) bb_perror_msg("Mounting %s on %s failed", blockDevice, directory);
+	if(ENABLE_FEATURE_CLEAN_UP) {
+		free(blockDevice);
+		free(directory);
+	}
 
 	return rc;
 }
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c
index 842fa0351..75f341a92 100644
--- a/util-linux/nfsmount.c
+++ b/util-linux/nfsmount.c
@@ -52,6 +52,12 @@
 #include <rpc/pmap_clnt.h>
 #include "nfsmount.h"
 
+/* This is just a warning of a common mistake.  Possibly this should be a
+ *  * uclibc faq entry rather than in busybox... */
+#if ENABLE_FEATURE_MOUNT_NFS && defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
+#error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
+#endif
+
 
 /*
  * NFS stats. The good thing with these values is that NFSv3 errors are