From: Enrico Scholz Date: Fri, 15 Jul 2005 18:06:27 +0000 (+0000) Subject: Changed the barrier-code so that it sets both the 't' ext2-flag and X-Git-Tag: version_0_30_210~130 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1746051be2ef76fea4f58e38beaa0a0a3eb89b1;p=util-vserver.git Changed the barrier-code so that it sets both the 't' ext2-flag and chmod-0 permissions. This is required to work with 1.2.10 patch; formerly the chmod-0 sufficed. [reported by Bjoern Steinbrink, http://savannah.nongnu.org/bugs/?func=detailitem&item_id=13170] git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2151 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/lib/syscall_getiattr-fscompat.hc b/util-vserver/lib/syscall_getiattr-fscompat.hc index c07bae3..e3e216c 100644 --- a/util-vserver/lib/syscall_getiattr-fscompat.hc +++ b/util-vserver/lib/syscall_getiattr-fscompat.hc @@ -41,7 +41,7 @@ vc_get_iattr_fscompat(char const *filename, 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); + fd = open(filename, O_RDONLY|O_NONBLOCK); if (fd==-1) return -1; stat_rc = fstat(fd, &st); @@ -64,8 +64,13 @@ vc_get_iattr_fscompat(char const *filename, } if ( (old_mask&VC_IATTR_BARRIER) && S_ISDIR(st.st_mode)) { + long ext2_flags; + *mask |= VC_IATTR_BARRIER; - if ((st.st_mode&0777) == 0) *flags |= VC_IATTR_BARRIER; + if ((st.st_mode&0777)==0 && + vc_X_get_ext2flags(fd, &ext2_flags)!=-1 && + (ext2_flags & VC_IMMUTABLE_LINK_FL)) + *flags |= VC_IATTR_BARRIER; } if ( (old_mask&(VC_IATTR_WATCH|VC_IATTR_HIDE)) ){ diff --git a/util-vserver/lib/syscall_setiattr-fscompat.hc b/util-vserver/lib/syscall_setiattr-fscompat.hc index 820db95..171e83c 100644 --- a/util-vserver/lib/syscall_setiattr-fscompat.hc +++ b/util-vserver/lib/syscall_setiattr-fscompat.hc @@ -36,7 +36,7 @@ vc_set_iattr_fscompat(char const *filename, struct stat st; int stat_rc; - fd = open(filename, O_RDONLY); + fd = open(filename, O_RDONLY|O_NONBLOCK); if (fd==-1) return -1; stat_rc = fstat(fd, &st); @@ -51,11 +51,16 @@ vc_set_iattr_fscompat(char const *filename, } if ( (mask&VC_IATTR_BARRIER) ) { - mode_t m = ((flags&VC_IATTR_BARRIER) ? 0 : - st.st_mode ? st.st_mode : 0500); - - if (fchmod(fd, m)==-1) - goto err; + if ((flags&VC_IATTR_BARRIER)) { + if (vc_X_set_ext2flags(fd, VC_IMMUTABLE_LINK_FL, 0)==-1 || + fchmod(fd, 0)) + goto err; + } + else { + if (vc_X_set_ext2flags(fd, 0, VC_IMMUTABLE_LINK_FL)==-1 || + fchmod(fd, 0500)) + goto err; + } } if ( (mask&VC_IATTR_XID) &&