aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2005-07-18 22:40:59 +0000
committerEric Andersen <andersen@codepoet.org>2005-07-18 22:40:59 +0000
commit90161c92139c03fdcc060e472a764af604d25858 (patch)
tree8806a3c0e001f4a11e9a2f9bf4ce6fe7530d1ff1
parent7b71d740b9186633b9a4b1d05247376485e2b805 (diff)
downloadbusybox-w32-90161c92139c03fdcc060e472a764af604d25858.tar.gz
busybox-w32-90161c92139c03fdcc060e472a764af604d25858.tar.bz2
busybox-w32-90161c92139c03fdcc060e472a764af604d25858.zip
Fixup makedevs to handle regular files, and also fix
it to properly update file permissions as specified.
-rw-r--r--miscutils/makedevs.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index b6473e7e5..8a407299a 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -178,7 +178,30 @@ extern int makedevs_main(int argc, char **argv)
178 ret = EXIT_FAILURE; 178 ret = EXIT_FAILURE;
179 goto loop; 179 goto loop;
180 } 180 }
181 } else { 181 if ((mode != -1) && (chmod(full_name, mode) < 0)){
182 bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
183 ret = EXIT_FAILURE;
184 goto loop;
185 }
186 } else if (type == 'f') {
187 struct stat st;
188 if ((stat(full_name, &st) < 0 || !S_ISREG(st.st_mode))) {
189 bb_perror_msg("line %d: regular file '%s' does not exist", linenum, full_name);
190 ret = EXIT_FAILURE;
191 goto loop;
192 }
193 if (chown(full_name, uid, gid) == -1) {
194 bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
195 ret = EXIT_FAILURE;
196 goto loop;
197 }
198 if ((mode != -1) && (chmod(full_name, mode) < 0)){
199 bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
200 ret = EXIT_FAILURE;
201 goto loop;
202 }
203 } else
204 {
182 dev_t rdev; 205 dev_t rdev;
183 206
184 if (type == 'p') { 207 if (type == 'p') {
@@ -211,6 +234,10 @@ extern int makedevs_main(int argc, char **argv)
211 bb_perror_msg("line %d: chown failed for %s", linenum, full_name_inc); 234 bb_perror_msg("line %d: chown failed for %s", linenum, full_name_inc);
212 ret = EXIT_FAILURE; 235 ret = EXIT_FAILURE;
213 } 236 }
237 if ((mode != -1) && (chmod(full_name_inc, mode) < 0)){
238 bb_perror_msg("line %d: chmod failed for %s", linenum, full_name_inc);
239 ret = EXIT_FAILURE;
240 }
214 } 241 }
215 free(full_name_inc); 242 free(full_name_inc);
216 } else { 243 } else {
@@ -223,6 +250,10 @@ extern int makedevs_main(int argc, char **argv)
223 bb_perror_msg("line %d: chown failed for %s", linenum, full_name); 250 bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
224 ret = EXIT_FAILURE; 251 ret = EXIT_FAILURE;
225 } 252 }
253 if ((mode != -1) && (chmod(full_name, mode) < 0)){
254 bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
255 ret = EXIT_FAILURE;
256 }
226 } 257 }
227 } 258 }
228loop: 259loop: