X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Ffstool.c;h=e686f8c7d5f4f15e074c8b6ee416ca9bedde7f9b;hb=5b39edfee423f5f3cbe8fa223dcfdc9e8d66e286;hp=9b750a5f784f76d36a5e3a44f8e4983a301f0766;hpb=869ef86707f88fe8924fdc30c434a21e128390d9;p=util-vserver.git diff --git a/util-vserver/src/fstool.c b/util-vserver/src/fstool.c index 9b750a5..e686f8c 100644 --- a/util-vserver/src/fstool.c +++ b/util-vserver/src/fstool.c @@ -22,43 +22,26 @@ #include "fstool.h" #include "util.h" -#include "wrappers.h" -#include "wrappers-dirent.h" #include #include #include #include +#include +#include +#include +#include +#define ENSC_WRAPPERS_DIRENT 1 +#define ENSC_WRAPPERS_FCNTL 1 +#define ENSC_WRAPPERS_UNISTD 1 +#include struct Arguments const * global_args = 0; int wrapper_exit_code = 1; -bool -checkForRace(int fd, char const * name, struct stat const *exp_st) -{ - struct stat st; - - if (fstat(fd, &st)==-1) { - perror("fstat()"); - return false; - } - - if (st.st_dev != exp_st->st_dev || - st.st_ino != exp_st->st_ino || - st.st_mode != exp_st->st_mode) { - close(fd); - WRITE_MSG(2, "race while visiting '"); - WRITE_STR(2, name); - WRITE_MSG(2, "'\n"); - exit(2); - } - - return true; -} - inline static bool isSpecialDir(char const *d) { @@ -90,7 +73,7 @@ iterateFilesystem(char const *path) // show current directory entry first if (lstat(".", &cur_st)==-1) perror("lstat()"); - else err += handleFile(".", path, &cur_st) ? 0 : 1; + else err += handleFile(".", path) ? 0 : 1; // strip trailing '/' while (path_len>0 && path[path_len-1]=='/') --path_len; @@ -116,7 +99,7 @@ iterateFilesystem(char const *path) { CONCAT_PATHS(path, path_len, ent->d_name); - err += handleFile(ent->d_name, new_path, &st) ? 0 : 1; + err += handleFile(ent->d_name, new_path) ? 0 : 1; } } @@ -173,11 +156,16 @@ processFile(char const *path) } if (S_ISDIR(st.st_mode) && !global_args->do_display_dir) { + int cur_dir = Eopen(".", O_RDONLY, 0); + uint64_t ret; Echdir(path); - return iterateFilesystem(path); + ret = iterateFilesystem(path); + Efchdir(cur_dir); + Eclose(cur_dir); + return ret; } else - return handleFile(path, path, &st); + return handleFile(path, path) ? 0 : 1; } int main(int argc, char *argv[]) @@ -189,8 +177,6 @@ int main(int argc, char *argv[]) .do_display_dot = false, .do_display_dir = false, .do_mapping = true, - .immutable = false, - .immulink = false, .ctx = VC_NOCTX, .is_legacy = false, .do_set = false, @@ -209,12 +195,14 @@ int main(int argc, char *argv[]) switch (c) { case CMD_HELP : showHelp(1, argv[0], 0); case CMD_VERSION : showVersion(); - case CMD_IMMU : args.set_mask |= VC_IATTR_IUNLINK; break; + case CMD_IMMU : args.set_mask |= VC_IATTR_IMMUTABLE; /*@fallthrough@*/ + case CMD_IMMUX : args.set_mask |= VC_IATTR_IUNLINK; break; case CMD_ADMIN : args.set_mask |= VC_IATTR_ADMIN; break; case CMD_WATCH : args.set_mask |= VC_IATTR_WATCH; break; case CMD_HIDE : args.set_mask |= VC_IATTR_HIDE; break; case CMD_BARRIER : args.set_mask |= VC_IATTR_BARRIER; break; - case CMD_UNSET_IMMU : args.del_mask |= VC_IATTR_IUNLINK; break; + case CMD_UNSET_IMMU : args.del_mask |= VC_IATTR_IMMUTABLE; /*@fallthrough@*/ + case CMD_UNSET_IMMUX : args.del_mask |= VC_IATTR_IUNLINK; break; case CMD_UNSET_ADMIN : args.del_mask |= VC_IATTR_ADMIN; break; case CMD_UNSET_WATCH : args.del_mask |= VC_IATTR_WATCH; break; case CMD_UNSET_HIDE : args.del_mask |= VC_IATTR_HIDE; break;