[uClibc-cvs] svn commit: trunk/buildroot/target/makedevs

andersen at uclibc.org andersen at uclibc.org
Mon Jul 18 20:06:50 UTC 2005


Author: andersen
Date: 2005-07-18 14:06:49 -0600 (Mon, 18 Jul 2005)
New Revision: 10850

Log:
Fixup standalong makedevs to handle regular files, and also fix
it to properly update file permissions as specified.


Modified:
   trunk/buildroot/target/makedevs/makedevs.c


Changeset:
Modified: trunk/buildroot/target/makedevs/makedevs.c
===================================================================
--- trunk/buildroot/target/makedevs/makedevs.c	2005-07-18 10:32:59 UTC (rev 10849)
+++ trunk/buildroot/target/makedevs/makedevs.c	2005-07-18 20:06:49 UTC (rev 10850)
@@ -443,7 +443,30 @@
 				ret = EXIT_FAILURE;
 				goto loop;
 			}
-		} else {
+			if ((mode != -1) && (chmod(full_name, mode) < 0)){
+				bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
+		} else if (type == 'f') {
+			struct stat st;
+			if ((stat(full_name, &st) < 0 || !S_ISREG(st.st_mode))) {
+				bb_perror_msg("line %d: regular file '%s' does not exist", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
+			if (chown(full_name, uid, gid) == -1) {
+				bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
+			if ((mode != -1) && (chmod(full_name, mode) < 0)){
+				bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
+		} else
+		{
 			dev_t rdev;
 
 			if (type == 'p') {
@@ -476,6 +499,10 @@
 						bb_perror_msg("line %d: chown failed for %s", linenum, full_name_inc);
 						ret = EXIT_FAILURE;
 					}
+					if ((mode != -1) && (chmod(full_name_inc, mode) < 0)){
+						bb_perror_msg("line %d: chmod failed for %s", linenum, full_name_inc);
+						ret = EXIT_FAILURE;
+					}
 				}
 				free(full_name_inc);
 			} else {
@@ -488,6 +515,10 @@
 					bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
 					ret = EXIT_FAILURE;
 				}
+				if ((mode != -1) && (chmod(full_name, mode) < 0)){
+					bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+					ret = EXIT_FAILURE;
+				}
 			}
 		}
 loop:




More information about the uClibc-cvs mailing list