From: Enrico Scholz Date: Thu, 22 Jan 2004 13:41:20 +0000 (+0000) Subject: * removed the race-check; this is done by vc_set_iattr_compat() already X-Git-Tag: VERSION_0_10~841 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e98c668cfc56e080cb083eee269ed2fbbc3ffa9f;p=util-vserver.git * removed the race-check; this is done by vc_set_iattr_compat() already * provide st_mode at vc_set_iattr_compat() call * do not stop on non-regular files; vc_set_iattr_compat() handles this already * moved setFlags() code into handleFile() * added 'iunlink' option git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@689 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/setattr.c b/util-vserver/src/setattr.c index 0760239..db2aef0 100644 --- a/util-vserver/src/setattr.c +++ b/util-vserver/src/setattr.c @@ -38,10 +38,12 @@ 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 }, { "~immu", no_argument, 0, CMD_UNSET_IMMU }, { "~admin", no_argument, 0, CMD_UNSET_ADMIN }, { "~watch", no_argument, 0, CMD_UNSET_WATCH }, @@ -58,7 +60,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] [--] +\n\n" " Options:\n" " -R ... recurse through directories\n" " -x ... do not cross filesystems\n\n" @@ -88,47 +90,20 @@ fixupParams(struct Arguments * args, int argc) args->do_display_dir = false; } -static bool -setFlags(char const *name, char const *display_name, - struct stat const *exp_st) +bool +handleFile(char const *name, char const * display_name, + struct stat const *exp_st) { - 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_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, + &exp_st->st_mode); 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; }