1 // $Id: syscall_getiattr-fscompat.hc 2151 2005-07-15 18:06:27Z ensc $ --*- c -*--
3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "ioctl-getext2flags.hc"
24 #include "ioctl-getfilecontext.hc"
25 #include "ioctl-getxflg.hc"
28 static inline ALWAYSINLINE int
29 vc_get_iattr_fscompat(char const *filename,
30 xid_t * /*@null@*/ xid,
31 uint32_t * /*@null@*/ flags,
41 if (lstat(filename, &st)==-1) return -1;
42 if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) return 0;
44 fd = open(filename, O_RDONLY|O_NONBLOCK);
45 if (fd==-1) return -1;
47 stat_rc = fstat(fd, &st);
48 if (stat_rc==-1) goto err;
50 if ( old_mask&VC_IATTR_XID ) {
51 *xid = vc_X_get_filecontext(fd);
52 if (*xid!=VC_NOCTX) *mask |= VC_IATTR_XID;
55 if ( old_mask&VC_IATTR_IUNLINK ) {
57 int rc = vc_X_get_ext2flags(fd, &tmp);
60 *mask |= VC_IATTR_IUNLINK;
61 if (tmp & (VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL))
62 *flags |= VC_IATTR_IUNLINK;
66 if ( (old_mask&VC_IATTR_BARRIER) && S_ISDIR(st.st_mode)) {
69 *mask |= VC_IATTR_BARRIER;
70 if ((st.st_mode&0777)==0 &&
71 vc_X_get_ext2flags(fd, &ext2_flags)!=-1 &&
72 (ext2_flags & VC_IMMUTABLE_LINK_FL))
73 *flags |= VC_IATTR_BARRIER;
76 if ( (old_mask&(VC_IATTR_WATCH|VC_IATTR_HIDE)) ){
78 int rc = vc_X_get_xflg(fd, &tmp);
80 *mask |= (VC_IATTR_WATCH|VC_IATTR_HIDE);
81 if (tmp&1) *flags |= VC_IATTR_HIDE;
82 if (tmp&2) *flags |= VC_IATTR_WATCH;
90 int old_errno = errno;