X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fsetattr.c;h=4513ac9ce9c038ae3fe2d2a9aa772c8cc49ee73b;hb=a917f24ef7b003dcef54a3db2644cf9cb4bc2db2;hp=0760239ffa692a70bfb9947aae68568271a522e7;hpb=869ef86707f88fe8924fdc30c434a21e128390d9;p=util-vserver.git diff --git a/util-vserver/src/setattr.c b/util-vserver/src/setattr.c index 0760239..4513ac9 100644 --- a/util-vserver/src/setattr.c +++ b/util-vserver/src/setattr.c @@ -38,15 +38,26 @@ CMDLINE_OPTIONS[] = { { "help", no_argument, 0, CMD_HELP }, { "version", no_argument, 0, CMD_VERSION }, { "immu", no_argument, 0, CMD_IMMU }, + { "iunlink", no_argument, 0, CMD_IMMU }, { "admin", no_argument, 0, CMD_ADMIN }, { "watch", no_argument, 0, CMD_WATCH }, { "hide", no_argument, 0, CMD_HIDE }, { "barrier", no_argument, 0, CMD_BARRIER }, + { "~iunlink", no_argument, 0, CMD_UNSET_IMMU }, + { "!iunlink", no_argument, 0, CMD_UNSET_IMMU }, { "~immu", no_argument, 0, CMD_UNSET_IMMU }, + { "!immu", no_argument, 0, CMD_UNSET_IMMU }, { "~admin", no_argument, 0, CMD_UNSET_ADMIN }, + { "!admin", no_argument, 0, CMD_UNSET_ADMIN }, { "~watch", no_argument, 0, CMD_UNSET_WATCH }, + { "!watch", no_argument, 0, CMD_UNSET_WATCH }, { "~hide", no_argument, 0, CMD_UNSET_HIDE }, + { "!hide", no_argument, 0, CMD_UNSET_HIDE }, { "~barrier", no_argument, 0, CMD_UNSET_BARRIER }, + { "!barrier", no_argument, 0, CMD_UNSET_BARRIER }, + { "iunlink-but-not-immutable", no_argument, 0, CMD_IMMUX }, + { "~iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX }, + { "!iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX }, { 0,0,0,0 } }; @@ -58,7 +69,7 @@ showHelp(int fd, char const *cmd, int res) WRITE_MSG(fd, "Usage: "); WRITE_STR(fd, cmd); WRITE_MSG(fd, - " [-Rx] [--[~]immu] [--[~]admin] [--[~]watch] [--[~]hide] [--] +\n\n" + " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable)]* [--] +\n\n" " Options:\n" " -R ... recurse through directories\n" " -x ... do not cross filesystems\n\n" @@ -85,50 +96,22 @@ fixupParams(struct Arguments * args, int argc) exit(1); } - args->do_display_dir = false; + args->do_display_dir = !args->do_recurse; + args->do_display_dot = true; } -static bool -setFlags(char const *name, char const *display_name, - struct stat const *exp_st) +bool +handleFile(char const *name, char const * display_name) { - int fd = open(name, O_RDONLY); - int res = false; - int rc; - - if (fd==-1) { - perror("open()"); - return false; - } - - // this is still needed... the file must be open so that vc_set_iattr() - // operates on a known file/inode - if (!exp_st || - !checkForRace(fd, name, exp_st)) - goto err; - - rc = vc_set_iattr_compat(name, exp_st->st_dev, exp_st->st_ino, - 0, - global_args->set_mask & ~global_args->del_mask, - global_args->set_mask|global_args->del_mask); + int rc = vc_set_iattr(name, + 0, + global_args->set_mask & ~global_args->del_mask, + global_args->set_mask | global_args->del_mask); if (rc==-1) { perror(display_name); - goto err; + return false; } - - res = true; - - err: - close(fd); - return res; -} - -bool -handleFile(char const *name, char const * display_name, - struct stat const *exp_st) -{ - if (!(S_ISREG(exp_st->st_mode) || S_ISDIR(exp_st->st_mode))) return true; - return setFlags(name, display_name, exp_st); + return true; }