int sys_lremovexattr (const char *path, const char *uname) { const char *name = prefix(uname); #if defined(HAVE_LREMOVEXATTR) return lremovexattr(path, name); #elif defined(HAVE_REMOVEXATTR) && defined(XATTR_ADD_OPT) int options = XATTR_NOFOLLOW; return removexattr(path, name, options); #elif defined(HAVE_LREMOVEEA) return lremoveea(path, name); #elif defined(HAVE_EXTATTR_DELETE_LINK) return extattr_delete_link(path, EXTATTR_NAMESPACE_USER, uname); #elif defined(HAVE_ATTR_REMOVE) int flags = ATTR_DONTFOLLOW; char *attrname = strchr(name,'.') + 1; if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT; return attr_remove(path, attrname, flags); #elif defined(HAVE_ATTROPEN) int ret = -1; int attrdirfd = solaris_attropen(path, ".", O_RDONLY|AT_SYMLINK_NOFOLLOW, 0); if (attrdirfd >= 0) { ret = solaris_unlinkat(attrdirfd, name); close(attrdirfd); } return ret; #else errno = ENOSYS; return -1; #endif }
static int VerifyXFSInodeSize(char *part, char *fstype) { afs_xfs_attr_t junk; int length = SIZEOF_XFS_ATTR_T; int fd = 0; int code = -1; struct fsxattr fsx; if (strcmp("xfs", fstype)) return 0; if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT) == 0) { if (((fd = open(part, O_RDONLY, 0)) != -1) && (fcntl(fd, F_FSGETXATTRA, &fsx) == 0)) { if (fsx.fsx_nextents) { Log("Partition %s: XFS inodes too small, exiting.\n", part); Log("Run xfs_size_check utility and remake partitions.\n"); } else code = 0; } if (fd > 0) close(fd); (void)attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT); } return code; }
static int VerifyXFSInodeSize(char *part) { afs_xfs_attr_t junk; int length = SIZEOF_XFS_ATTR_T; int fd; int code = VERIFY_ERROR; struct fsxattr fsx; if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT) < 0) { if (errno == EPERM) { printf("Must be root to run %s\n", prog); exit(1); } return VERIFY_ERROR; } if ((fd = open(part, O_RDONLY, 0)) < 0) goto done; if (fcntl(fd, F_FSGETXATTRA, &fsx) < 0) goto done; if (fsx.fsx_nextents == 0) code = VERIFY_OK; else code = VERIFY_FIX; done: if (fd >= 0) close(fd); (void)attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT); return code; }
int sys_fremovexattr (int filedes, const char *path, const char *uname) { const char *name = prefix(uname); #if defined(HAVE_REMOVEXATTR) #ifndef XATTR_ADD_OPT return removexattr(path, name); #else int options = 0; return removexattr(path, name, options); #endif #elif defined(HAVE_REMOVEEA) return removeea(path, name); #elif defined(HAVE_EXTATTR_DELETE_FILE) return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, uname); #elif defined(HAVE_ATTR_REMOVE) int flags = 0; char *attrname = strchr(name,'.') + 1; if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT; return attr_remove(path, attrname, flags); #elif defined(SOLARIS) int ret = -1; int attrdirfd = solaris_attropenat(filedes, path, ".", O_RDONLY, 0); if (attrdirfd >= 0) { ret = solaris_unlinkat(attrdirfd, name); close(attrdirfd); } return ret; #else errno = ENOSYS; return -1; #endif }
int sys_lremovexattr (const char *path, const char *name) { #if defined(HAVE_LREMOVEXATTR) return lremovexattr(path, name); #elif defined(HAVE_ATTR_REMOVE) int flags = ATTR_DONTFOLLOW; char *attrname = strchr(name,'.') +1; if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT; return attr_remove(path, attrname, flags); #else errno = ENOSYS; return -1; #endif }
int rep_removexattr (const char *path, const char *name) { #if defined(HAVE_REMOVEXATTR) #ifndef XATTR_ADDITIONAL_OPTIONS return removexattr(path, name); #else /* So that we do not recursivly call this function */ #undef removexattr int options = 0; return removexattr(path, name, options); #endif #elif defined(HAVE_REMOVEEA) return removeea(path, name); #elif defined(HAVE_EXTATTR_DELETE_FILE) char *s; int attrnamespace = (strncmp(name, "system", 6) == 0) ? EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER; const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1; return extattr_delete_file(path, attrnamespace, attrname); #elif defined(HAVE_ATTR_REMOVE) int flags = 0; char *attrname = strchr(name,'.') + 1; if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT; return attr_remove(path, attrname, flags); #elif defined(HAVE_ATTROPEN) int ret = -1; int attrdirfd = solaris_attropen(path, ".", O_RDONLY, 0); if (attrdirfd >= 0) { ret = solaris_unlinkat(attrdirfd, name); close(attrdirfd); } return ret; #else errno = ENOSYS; return -1; #endif }