X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fremove_file.c;h=da1488544ea392825480cf0c041789327b93bf3d;hb=9f5a577a3241597cb5e7ba9f6df33c2e3c440e44;hp=3aaaef8c7f0210f594e5630723b70c9a059ec64c;hpb=f4d40c87d3a18fccb8c0946fc09f1d8f24a2bcf3;p=oweals%2Fbusybox.git diff --git a/libbb/remove_file.c b/libbb/remove_file.c index 3aaaef8c7..da1488544 100644 --- a/libbb/remove_file.c +++ b/libbb/remove_file.c @@ -9,17 +9,19 @@ #include "libbb.h" -int remove_file(const char *path, int flags) +/* Used from NOFORK applets. Must not allocate anything */ + +int FAST_FUNC remove_file(const char *path, int flags) { struct stat path_stat; if (lstat(path, &path_stat) < 0) { if (errno != ENOENT) { - bb_perror_msg("cannot stat '%s'", path); + bb_perror_msg("can't stat '%s'", path); return -1; } if (!(flags & FILEUTILS_FORCE)) { - bb_perror_msg("cannot remove '%s'", path); + bb_perror_msg("can't remove '%s'", path); return -1; } return 0; @@ -61,7 +63,7 @@ int remove_file(const char *path, int flags) } if (closedir(dp) < 0) { - bb_perror_msg("cannot close '%s'", path); + bb_perror_msg("can't close '%s'", path); return -1; } @@ -72,7 +74,7 @@ int remove_file(const char *path, int flags) } if (rmdir(path) < 0) { - bb_perror_msg("cannot remove '%s'", path); + bb_perror_msg("can't remove '%s'", path); return -1; } @@ -80,8 +82,10 @@ int remove_file(const char *path, int flags) } /* !ISDIR */ - if ((!(flags & FILEUTILS_FORCE) && access(path, W_OK) < 0 - && !S_ISLNK(path_stat.st_mode) && isatty(0)) + if ((!(flags & FILEUTILS_FORCE) + && access(path, W_OK) < 0 + && !S_ISLNK(path_stat.st_mode) + && isatty(0)) || (flags & FILEUTILS_INTERACTIVE) ) { fprintf(stderr, "%s: remove '%s'? ", applet_name, path); @@ -90,7 +94,7 @@ int remove_file(const char *path, int flags) } if (unlink(path) < 0) { - bb_perror_msg("cannot remove '%s'", path); + bb_perror_msg("can't remove '%s'", path); return -1; }