From 32f628bef9a3c3dfed279e68df1ed96c930d88ab Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Thu, 22 Jan 2004 13:40:38 +0000 Subject: [PATCH] * 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 setFile() code into handleFile() git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@688 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/src/chxid.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/util-vserver/src/chxid.c b/util-vserver/src/chxid.c index 32d6683..6af4790 100644 --- a/util-vserver/src/chxid.c +++ b/util-vserver/src/chxid.c @@ -66,46 +66,20 @@ showVersion() exit(0); } -static bool -setFile(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) { - bool res = false; - int fd = open(name, O_RDONLY); - 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, - global_args->ctx, 0, VC_IATTR_XID); + int rc = vc_set_iattr_compat(name, exp_st->st_dev, exp_st->st_ino, + global_args->ctx, 0, VC_IATTR_XID, + &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)) return true; - - return setFile(name, display_name, exp_st); + return true; } void -- 1.8.1.5