diff options
author | Eric Andersen <andersen@codepoet.org> | 2005-07-18 20:06:49 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2005-07-18 20:06:49 +0000 |
commit | 7b8aeaeb28d113d4dafb20339376b2b5daa15e5f (patch) | |
tree | 1c7aec261f75180831ff4eb97f3e090f7651128f | |
parent | c56927879fa6638d643d83f4440a6db71bb727ff (diff) |
Fixup standalong makedevs to handle regular files, and also fix
it to properly update file permissions as specified.
-rw-r--r-- | target/makedevs/makedevs.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/target/makedevs/makedevs.c b/target/makedevs/makedevs.c index 0f166dfd2..08378e288 100644 --- a/target/makedevs/makedevs.c +++ b/target/makedevs/makedevs.c @@ -443,7 +443,30 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) 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: |