moved fscompat* files to *iattr-fscompat* and applied the changed iattr interface
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 19 Feb 2004 22:19:50 +0000 (22:19 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 19 Feb 2004 22:19:50 +0000 (22:19 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@951 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/syscall_getiattr-fscompat.hc [moved from util-vserver/lib/fscompat_getiattr-fscompat.hc with 85% similarity]
util-vserver/lib/syscall_setiattr-fscompat.hc [moved from util-vserver/lib/fscompat_setiattr-fscompat.hc with 83% similarity]

 #include "ioctl-getfilecontext.hc"
 #include "ioctl-getxflg.hc"
 
+#include <fcntl.h>
 static inline ALWAYSINLINE int
-vc_get_iattr_compat_fscompat(char const *filename,
-                            dev_t dev, ino_t ino,
-                            xid_t    * /*@null@*/ xid,
-                            uint32_t * /*@null@*/ flags,
-                            uint32_t * mask,
-                            mode_t const *mode)
+vc_get_iattr_fscompat(char const *filename,
+                     xid_t    * /*@null@*/ xid,
+                     uint32_t * /*@null@*/ flags,
+                     uint32_t * mask)
 {
   struct stat          st;
   int                  stat_rc;
@@ -39,9 +38,7 @@ vc_get_iattr_compat_fscompat(char const *filename,
 
   *mask = 0;
 
-  if (mode!=0) st.st_mode = *mode;
-  else if (lstat(filename, &st)==-1) return -1;
-
+  if (lstat(filename, &st)==-1) return -1;
   if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) return 0;
 
   fd = open(filename, O_RDONLY);
@@ -50,11 +47,6 @@ vc_get_iattr_compat_fscompat(char const *filename,
   stat_rc = fstat(fd, &st);
   if (stat_rc==-1) goto err;
 
-  if (st.st_dev!=dev || st.st_ino!=ino) {
-    errno = EINVAL;
-    goto err;
-  }
-    
   if ( old_mask&VC_IATTR_XID ) {
     *xid = vc_X_get_filecontext(fd);
     if (*xid!=VC_NOCTX) *mask |= VC_IATTR_XID;
 #include "ioctl-setxflg.hc"
 #include "ioctl-getxflg.hc"
 
+#include <fcntl.h>
+
 static inline ALWAYSINLINE int
-vc_set_iattr_compat_fscompat(char const *filename,
-                            dev_t dev, ino_t ino, xid_t xid,
-                            uint32_t flags, uint32_t mask,
-                            mode_t const *mode)
+vc_set_iattr_fscompat(char const *filename,
+                     xid_t xid,
+                     uint32_t flags, uint32_t mask)
 {
   int                  fd;
   struct stat          st;
   int                  stat_rc;
 
-  if (mode!=0 && !S_ISREG(*mode) && !S_ISDIR(*mode)) return 0;
-  
   fd = open(filename, O_RDONLY);
   if (fd==-1) return -1;
     
   stat_rc = fstat(fd, &st);
   if (stat_rc==-1) goto err;
 
-  if (st.st_dev!=dev || st.st_ino!=ino) {
-    errno = EINVAL;
-    goto err;
-  }
-
   if ( (mask&VC_IATTR_IUNLINK) ) {
     int const          tmp = VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL;
     if (vc_X_set_ext2flags(fd,
@@ -57,8 +51,10 @@ vc_set_iattr_compat_fscompat(char const *filename,
   }
 
   if ( (mask&VC_IATTR_BARRIER) ) {
-    if (fchmod(fd, (flags&VC_IATTR_BARRIER) ? 0 :
-              (st.st_mode| (mode ? *mode : 0500)))==-1)
+    mode_t     m = ((flags&VC_IATTR_BARRIER) ? 0 :
+                    st.st_mode ? st.st_mode : 0500);
+    
+    if (fchmod(fd, m)==-1)
       goto err;
   }