vc_set_iattr_compat_fscompat(): fixed usage of the mode argument
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 18 Feb 2004 04:50:12 +0000 (04:50 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 18 Feb 2004 04:50:12 +0000 (04:50 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@944 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/fscompat_setiattr-fscompat.hc

index 7772074..a8e6f68 100644 (file)
@@ -35,8 +35,7 @@ vc_set_iattr_compat_fscompat(char const *filename,
   struct stat          st;
   int                  stat_rc;
 
-  if (mode!=0) st.st_mode = *mode;
-  if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) return 0;
+  if (mode!=0 && !S_ISREG(*mode) && !S_ISDIR(*mode)) return 0;
   
   fd = open(filename, O_RDONLY);
   if (fd==-1) return -1;
@@ -58,7 +57,8 @@ vc_set_iattr_compat_fscompat(char const *filename,
   }
 
   if ( (mask&VC_IATTR_BARRIER) ) {
-    if (fchmod(fd, (flags&VC_IATTR_BARRIER) ? 0 : (st.st_mode|0500))==-1)
+    if (fchmod(fd, (flags&VC_IATTR_BARRIER) ? 0 :
+              (st.st_mode| (mode ? *mode : 0500)))==-1)
       goto err;
   }