New flag bit2 for iso_local_get_lfa_flags() and iso_local_set_lfa_flags()

This commit is contained in:
Thomas Schmitt 2024-08-25 15:17:15 +02:00
parent c4769f333e
commit 622b5645f0
3 changed files with 25 additions and 9 deletions

View File

@ -526,6 +526,8 @@ ex:;
@param flag Bitfield for control purposes.
bit0= consider ENOTTY from FS_IOC_GETFLAGS an error
(else return 4 on ENOTTY)
bit2= do not issue own error messages with operating
system errors
@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
@ -551,6 +553,7 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit,
#ifdef FS_IOC_GETFLAGS
fd= open(path, O_RDONLY | O_NDELAY);
if(fd == -1) {
if(!(flag & 4))
aaip_local_error("open(2)", path, errno, 0);
*os_errno= errno;
return(-1);
@ -563,6 +566,7 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit,
*max_bit= 23;
return(4);
}
if(!(flag & 4))
aaip_local_error("ioctl(FS_IOC_GETFLAGS)", path, errno, 0);
*os_errno= errno;
return(-1);
@ -878,6 +882,11 @@ ex:;
}
/*
@param flag Bitfield for control purposes.
bit2= do not issue own error messages with operating
system errors
*/
int aaip_set_lfa_flags(char *path, uint64_t lfa_flags, int max_bit,
int *os_errno, int flag)
{
@ -900,6 +909,7 @@ int aaip_set_lfa_flags(char *path, uint64_t lfa_flags, int max_bit,
fd= open(path, O_RDONLY | O_NDELAY);
if(fd == -1) {
if(!(flag & 4))
aaip_local_error("open(2)", path, errno, 0);
*os_errno= errno;
return(-1);
@ -911,6 +921,7 @@ int aaip_set_lfa_flags(char *path, uint64_t lfa_flags, int max_bit,
ret= ioctl(fd, FS_IOC_SETFLAGS, &ioctl_arg);
close(fd);
if(ret == -1) {
if(!(flag & 4))
aaip_local_error("ioctl(FS_IOC_SETFLAGS)", path, errno, 0);
*os_errno= errno;
return(-1);

View File

@ -948,6 +948,7 @@ int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag)
/*
* @param flag
* Bitfield for control purposes
* bit2= do not issue own error messages with operating system errors
* bit5= in case of symbolic link: inquire link target
* @return
* 1= ok, lfa_flags is valid
@ -978,7 +979,8 @@ int iso_local_get_lfa_flags(char *disk_path, uint64_t *lfa_flags, int *max_bit,
}
if ((stbuf.st_mode & S_IFMT) == S_IFLNK && !(flag & 32))
return 3;
ret = aaip_get_lfa_flags(disk_path, lfa_flags, max_bit, os_errno, 0);
ret = aaip_get_lfa_flags(disk_path, lfa_flags, max_bit, os_errno,
flag & 4);
if(ret == 0)
return ISO_LFA_NOT_ENABLED;
if(ret < 0)
@ -991,6 +993,7 @@ int iso_local_get_lfa_flags(char *disk_path, uint64_t *lfa_flags, int *max_bit,
* @param flag Bitfield for control purposes
* bit0= do not try to change known superuser flags
* bit1= change only known chattr settable flags
* bit2= do not issue own error messages with operating system errors
* bit5= in case of symbolic link: inquire link target
* @return
* 1 = ok, all lfa_flags bits were written
@ -1023,7 +1026,7 @@ int iso_local_set_lfa_flags(char *disk_path, uint64_t lfa_flags, int max_bit,
eff_flags = lfa_flags;
} else {
ret = aaip_get_lfa_flags(disk_path, &eff_flags, &old_max_bit, os_errno,
0);
flag & 4);
if (ret == 0)
return ISO_LFA_NOT_ENABLED;
if (ret < 0)
@ -1031,7 +1034,7 @@ int iso_local_set_lfa_flags(char *disk_path, uint64_t lfa_flags, int max_bit,
eff_flags &= ~change_mask;
eff_flags |= (lfa_flags & change_mask);
}
ret= aaip_set_lfa_flags(disk_path, eff_flags, max_bit, os_errno, 0);
ret= aaip_set_lfa_flags(disk_path, eff_flags, max_bit, os_errno, flag & 4);
if(ret == 0)
return ISO_LFA_NOT_ENABLED;
if(ret < 0)

View File

@ -8057,6 +8057,7 @@ int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names,
* Else it will be filled with 0.
* @param flag
* Bitfield for control purposes
* bit2= do not issue own error messages with system call errors
* bit5= in case of symbolic link: inquire link target
* @return
* 1 = ok, lfa_flags is valid
@ -8101,6 +8102,7 @@ int iso_local_get_lfa_flags(char *disk_path, uint64_t *lfa_flags, int *max_bit,
* Bitfield for control purposes
* bit0= do not try to change known chattr superuser flags: iaj
* bit1= change only known chattr settable flags: sucSiadAmjtDTCxPF
* bit2= do not issue own error messages with system call errors
* bit5= in case of symbolic link: operate on link target
* @return
* 1 = ok, all lfa_flags bits were written