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);
}
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)) ){
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);
}
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) &&