Add support for IATTR_WRITE.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 11 Jul 2008 15:20:35 +0000 (15:20 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 11 Jul 2008 15:20:35 +0000 (15:20 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2732 94cd875c-1c1d-0410-91d2-eb244daf1a30

lib/vserver.h
src/fstool.c
src/fstool.h
src/setattr.c
src/showattr.c

index 455e5b8..0d7664f 100644 (file)
 #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
index 7cad977..5188393 100644 (file)
@@ -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;
index 1668baa..dfc4822 100644 (file)
@@ -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;
index 1385ccc..60b0468 100644 (file)
@@ -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)]* [--] <file>+\n\n"
+           " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable|write)]* [--] <file>+\n\n"
            " Options:\n"
            "   -R  ...  recurse through directories\n"
            "   -x  ...  do not cross filesystems\n\n"
index 7339dab..8e3ff15 100644 (file)
@@ -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);