svn commit: trunk/busybox/util-linux

vda at busybox.net vda at busybox.net
Sun Sep 17 15:00:58 UTC 2006


Author: vda
Date: 2006-09-17 08:00:58 -0700 (Sun, 17 Sep 2006)
New Revision: 16131

Log:
mount: style fixes


Modified:
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2006-09-17 14:45:09 UTC (rev 16130)
+++ trunk/busybox/util-linux/mount.c	2006-09-17 15:00:58 UTC (rev 16131)
@@ -101,7 +101,7 @@
 /* Append mount options to string */
 static void append_mount_options(char **oldopts, char *newopts)
 {
-	if(*oldopts && **oldopts) {
+	if (*oldopts && **oldopts) {
 		char *temp = xasprintf("%s,%s",*oldopts,newopts);
 		free(*oldopts);
 		*oldopts = temp;
@@ -128,7 +128,7 @@
 		for (i = 0; i < (sizeof(mount_options) / sizeof(*mount_options)); i++) {
 			if (!strcasecmp(mount_options[i].name, options)) {
 				long fl = mount_options[i].flags;
-				if(fl < 0) flags &= fl;
+				if (fl < 0) flags &= fl;
 				else flags |= fl;
 				break;
 			}
@@ -147,7 +147,7 @@
 		}
 
 		// Advance to next option, or finish
-		if(comma) {
+		if (comma) {
 			*comma = ',';
 			options = ++comma;
 		} else break;
@@ -166,17 +166,18 @@
 	int i;
 	FILE *f;
 
-	for(i = 0; filesystems[i]; i++) {
-		if(!(f = fopen(filesystems[i], "r"))) continue;
+	for (i = 0; filesystems[i]; i++) {
+		f = fopen(filesystems[i], "r");
+		if (!f) continue;
 
-		for(fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f));
+		for (fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f));
 			free(buf))
 		{
-			if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
+			if (!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
 
-			while(isspace(*fs)) fs++;
-			if(*fs=='#' || *fs=='*') continue;
-			if(!*fs) continue;
+			while (isspace(*fs)) fs++;
+			if (*fs=='#' || *fs=='*') continue;
+			if (!*fs) continue;
 
 			llist_add_to_end(&list,xstrdup(fs));
 		}
@@ -206,18 +207,19 @@
 #endif
 
 // Perform actual mount of specific filesystem at specific location.
+// NB: mp->xxx fields may be trashed on exit
 static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
 {
 	int rc;
 
-	if (fakeIt) { return 0; }
+	if (fakeIt) return 0;
 
 	// Mount, with fallback to read-only if necessary.
 
-	for(;;) {
+	for (;;) {
 		rc = mount(mp->mnt_fsname, mp->mnt_dir, mp->mnt_type,
 				vfsflags, filteropts);
-		if(!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS))
+		if (!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS))
 			break;
 		bb_error_msg("%s is write-protected, mounting read-only",
 				mp->mnt_fsname);
@@ -440,7 +442,6 @@
 #endif
 };
 
-
 /*
  * We want to be able to compile mount on old kernels in such a way
  * that the binary will work well on more recent kernels.
@@ -1283,7 +1284,7 @@
 
 	// Might this be an CIFS filesystem?
 
-	if(ENABLE_FEATURE_MOUNT_CIFS &&
+	if (ENABLE_FEATURE_MOUNT_CIFS &&
 		(!mp->mnt_type || !strcmp(mp->mnt_type,"cifs")) &&
 		(mp->mnt_fsname[0]==mp->mnt_fsname[1] && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\')))
 	{
@@ -1345,7 +1346,7 @@
 		if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
 			loopFile = bb_simplify_path(mp->mnt_fsname);
 			mp->mnt_fsname = 0;
-			switch(set_loop(&(mp->mnt_fsname), loopFile, 0)) {
+			switch (set_loop(&(mp->mnt_fsname), loopFile, 0)) {
 				case 0:
 				case 1:
 					break;
@@ -1385,7 +1386,8 @@
 		for (fl = fslist; fl; fl = fl->link) {
 			mp->mnt_type = fl->data;
 
-			if (!(rc = mount_it_now(mp,vfsflags, filteropts))) break;
+			rc = mount_it_now(mp,vfsflags, filteropts);
+			if (!rc) break;
 
 			mp->mnt_type = 0;
 		}
@@ -1474,7 +1476,7 @@
 		if (!all) {
 			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
 
-			if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
+			if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
 
 			while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1,
 								sizeof(bb_common_bufsiz1)))
@@ -1521,14 +1523,15 @@
 		fstabname = bb_path_mtab_file;
 	else fstabname="/etc/fstab";
 
-	if (!(fstab=setmntent(fstabname,"r")))
+	fstab = setmntent(fstabname,"r");
+	if (!fstab)
 		bb_perror_msg_and_die("cannot read %s",fstabname);
 
 	// Loop through entries until we find what we're looking for.
 
 	memset(mtpair,0,sizeof(mtpair));
 	for (;;) {
-		struct mntent *mtnext = mtpair + (mtcur==mtpair ? 1 : 0);
+		struct mntent *mtnext = (mtcur==mtpair ? mtpair+1 : mtpair);
 
 		// Get next fstab entry
 
@@ -1565,7 +1568,7 @@
 
 			// Is this what we're looking for?
 
-			if(strcmp(argv[optind],mtcur->mnt_fsname) &&
+			if (strcmp(argv[optind],mtcur->mnt_fsname) &&
 			   strcmp(storage_path,mtcur->mnt_fsname) &&
 			   strcmp(argv[optind],mtcur->mnt_dir) &&
 			   strcmp(storage_path,mtcur->mnt_dir)) continue;




More information about the busybox-cvs mailing list