From 7fc7d65e0509127850a7dbfedc1f3fae18b25c86 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 6 Aug 2024 19:05:07 +0200 Subject: [PATCH] New return value 4 of iso_local_get_lfa_flags(): file does not have lfa_flags --- libisofs/aaip-os-linux.c | 12 ++++++++++-- libisofs/fs_local.c | 3 +++ libisofs/libisofs.h | 3 +++ libisofs/messages.c | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libisofs/aaip-os-linux.c b/libisofs/aaip-os-linux.c index 2d0e7f6..6a4e1ae 100644 --- a/libisofs/aaip-os-linux.c +++ b/libisofs/aaip-os-linux.c @@ -452,7 +452,7 @@ try_lfa_flags:; if(!(flag & 64)) { ret= aaip_get_lfa_flags(path, &lfa_flags, &max_bit, &os_errno, 0); - if(ret > 0) { + if(ret == 1 || ret == 2) { ret= aaip_encode_lfa_flags(lfa_flags, lfa_value, &lfa_length, 0); if(ret > 0) { (*names)[*num_attrs]= strdup("isofs.fa"); @@ -520,10 +520,13 @@ ex:; @param lfa_flags Will get filled with the FS_*_FL @param max_bit Will tell the highest bit that is possibly set (-1 = surely no bit is valid) - @param flag Bitfield for control purposes. Submit 0. + @param flag Bitfield for control purposes. + bit0= consider ENOTTY from FS_IOC_GETFLAGS an error + (else return 4 on ENOTTY) @return 1= ok, all local attribute flags are in lfa_flags 2= ok, but some local flags could not be mapped to the FS_*_FL bits + 4= ok, ENOTTY from FS_IOC_GETFLAGS 0= local flag retrieval not enabled at compile time <0 error with system calls */ @@ -552,6 +555,11 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit, ret= ioctl(fd, FS_IOC_GETFLAGS, &ioctl_result); close(fd); if(ret == -1) { + if(errno == ENOTTY && !(flag & 1)) { + /* Usual result with file type or filesystem without Linux attributes */ + *max_bit= 23; + return(4); + } aaip_local_error("ioctl(FS_IOC_GETFLAGS)", path, errno, 0); *os_errno= errno; return(-1); diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 96ed736..2c2cd5a 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -953,6 +953,9 @@ int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag) * 1= ok, lfa_flags is valid * 2= ok, but some local flags could not be mapped to the FS_*_FL bits * 3= ok, symbolic link encountered, flag bit5 not set, lfa_flags set to 0 + * 4= ok, file did not bear attribute flags. E.g. because not S_IFDIR or + * S_IFREG, or because unsuitable filesystem. + * lfa_flags is set to 0 * 0= local flags retrieval not enabled at compile time * <0= error with system calls */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 529ecf6..9bcaa58 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -8062,6 +8062,9 @@ int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names, * 1 = ok, lfa_flags is valid * 2 = ok, but some local flags could not be mapped to the FS_*_FL bits * 3 = ok, symbolic link encountered, flag bit5 not set,lfa_flags set to 0 + * 4 = ok, file did not bear attribute flags. E.g. because not S_IFDIR or + * S_IFREG, or because unsuitable filesystem. + * lfa_flags is set to 0 * <0 = error * * @since 1.5.8 diff --git a/libisofs/messages.c b/libisofs/messages.c index 2582d7e..8798de1 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -393,10 +393,10 @@ const char *iso_error_to_msg(int errcode) return "Error with decoding AAIP info for ACL or xattr"; case ISO_AAIP_NO_GET_LOCAL: case ISO_AAIP_NO_GET_LOCAL_S: - return "Error with reading ACL or xattr from local file"; + return "Error with reading ACL or other attributes from local file"; case ISO_AAIP_NO_SET_LOCAL: case ISO_AAIP_NO_SET_LOCAL_S: - return "Error with attaching ACL or xattr to local file"; + return "Error with attaching ACL or other attributes to local file"; case ISO_AAIP_NON_USER_NAME: return "Unallowed attempt to set an xattr with non-userspace name"; case ISO_EXTF_TOO_OFTEN: