From: Daniel Hokka Zakrisson Date: Fri, 11 Jul 2008 15:20:35 +0000 (+0000) Subject: Add support for IATTR_WRITE. X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ca2184598beb16840dffa6680e87e87723f846f;p=util-vserver.git Add support for IATTR_WRITE. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2732 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/lib/vserver.h b/lib/vserver.h index 455e5b8..0d7664f 100644 --- a/lib/vserver.h +++ b/lib/vserver.h @@ -151,7 +151,8 @@ #define VC_IATTR_ADMIN 0x00000001u #define VC_IATTR_WATCH 0x00000002u #define VC_IATTR_HIDE 0x00000004u -#define VC_IATTR_FLAGS 0x00000007u +#define VC_IATTR_WRITE 0x00000008u +#define VC_IATTR_FLAGS 0x0000000fu #define VC_IATTR_BARRIER 0x00010000u #define VC_IATTR_IUNLINK 0x00020000u diff --git a/src/fstool.c b/src/fstool.c index 7cad977..5188393 100644 --- a/src/fstool.c +++ b/src/fstool.c @@ -203,6 +203,7 @@ int main(int argc, char *argv[]) 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_WRITE : args.set_mask |= VC_IATTR_WRITE; 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_IMMUTABLE : args.del_mask |= VC_IATTR_IMMUTABLE; break; @@ -210,6 +211,7 @@ int main(int argc, char *argv[]) case CMD_UNSET_WATCH : args.del_mask |= VC_IATTR_WATCH; break; case CMD_UNSET_HIDE : args.del_mask |= VC_IATTR_HIDE; break; case CMD_UNSET_BARRIER : args.del_mask |= VC_IATTR_BARRIER; break; + case CMD_UNSET_WRITE : args.del_mask |= VC_IATTR_WRITE; break; case 'R' : args.do_recurse = true; break; case 'a' : args.do_display_dot = true; break; case 'd' : args.do_display_dir = true; break; diff --git a/src/fstool.h b/src/fstool.h index 1668baa..dfc4822 100644 --- a/src/fstool.h +++ b/src/fstool.h @@ -33,6 +33,7 @@ #define CMD_HIDE 0x8013 #define CMD_BARRIER 0x8014 #define CMD_IMMUX 0x8015 +#define CMD_WRITE 0x8016 #define CMD_UNSET_IMMU 0x8020 #define CMD_UNSET_ADMIN 0x8021 #define CMD_UNSET_WATCH 0x8022 @@ -40,6 +41,7 @@ #define CMD_UNSET_BARRIER 0x8024 #define CMD_UNSET_IMMUX 0x8025 #define CMD_UNSET_IMMUTABLE 0x8026 +#define CMD_UNSET_WRITE 0x8027 struct stat; diff --git a/src/setattr.c b/src/setattr.c index 1385ccc..60b0468 100644 --- a/src/setattr.c +++ b/src/setattr.c @@ -61,6 +61,9 @@ CMDLINE_OPTIONS[] = { { "immutable", no_argument, 0, CMD_IMMUTABLE }, { "~immutable", no_argument, 0, CMD_UNSET_IMMUTABLE }, { "!immutable", no_argument, 0, CMD_UNSET_IMMUTABLE }, + { "write", no_argument, 0, CMD_WRITE }, + { "~write", no_argument, 0, CMD_UNSET_WRITE }, + { "!write", no_argument, 0, CMD_UNSET_WRITE }, { 0,0,0,0 } }; @@ -72,7 +75,7 @@ showHelp(int fd, char const *cmd, int res) WRITE_MSG(fd, "Usage: "); WRITE_STR(fd, cmd); WRITE_MSG(fd, - " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable)]* [--] +\n\n" + " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable|write)]* [--] +\n\n" " Options:\n" " -R ... recurse through directories\n" " -x ... do not cross filesystems\n\n" diff --git a/src/showattr.c b/src/showattr.c index 7339dab..8e3ff15 100644 --- a/src/showattr.c +++ b/src/showattr.c @@ -107,12 +107,12 @@ handleFile(char const *name, char const *display_name) if (getFlags(name, &flags, &mask)) { // 1 1 0 0 // fedcba9876543210fedcba9876543210 - static char const MARKER[33] = ".......x.....iub.............hwa"; + static char const MARKER[33] = ".......x.....iub............mhwa"; int i; uint32_t used_flags = (VC_IATTR_XID|VC_IATTR_ADMIN| VC_IATTR_WATCH|VC_IATTR_HIDE| VC_IATTR_BARRIER|VC_IATTR_IUNLINK| - VC_IATTR_IMMUTABLE); + VC_IATTR_IMMUTABLE|VC_IATTR_WRITE); for (i=0; i<32; ++i) { if (used_flags & 1) { @@ -127,11 +127,11 @@ handleFile(char const *name, char const *display_name) } } else { - memcpy(buf, "ERR ", 7); + memcpy(buf, "ERR ", 8); res = false; } - Vwrite(1, buf, 8); + Vwrite(1, buf, 9); Vwrite(1, display_name, strlen(display_name)); Vwrite(1, "\n", 1);