Small corrections and adjustments to the recent commits

This commit is contained in:
Thomas Schmitt 2024-07-20 13:28:11 +02:00
parent 99700ac94b
commit 843587a7b4
3 changed files with 34 additions and 16 deletions

View File

@ -880,7 +880,7 @@ int aaip_set_lfa_flags(char *path, uint64_t lfa_flags, int max_bit,
*os_errno= 0; *os_errno= 0;
#ifdef Libisofs_with_aaip_lfa_flagS #ifdef Libisofs_with_aaip_lfa_flagS
#ifdef FS_IOC_GETFLAGS #ifdef FS_IOC_SETFLAGS
if(max_bit > (int) sizeof(long) * 8 - 1) { if(max_bit > (int) sizeof(long) * 8 - 1) {
aaip_local_error("ioctl(FS_IOC_SETFLAGS) with too many bits", path, 0, 0); aaip_local_error("ioctl(FS_IOC_SETFLAGS) with too many bits", path, 0, 0);
@ -906,7 +906,7 @@ int aaip_set_lfa_flags(char *path, uint64_t lfa_flags, int max_bit,
} }
ret= 1; ret= 1;
#endif /* FS_IOC_GETFLAGS */ #endif /* FS_IOC_SETFLAGS */
#endif /* Libisofs_with_aaip_lfa_flagS */ #endif /* Libisofs_with_aaip_lfa_flagS */
return(ret); return(ret);

View File

@ -8165,15 +8165,16 @@ int iso_util_decode_lfa_flags(char *flags_text, uint64_t *lfa_flags, int flag);
* *
* @param user_settable * @param user_settable
* The flag bits which are known to be user settable with chattr: * The flag bits which are known to be user settable with chattr:
* sucSdAmtDTCxPF * AcCdDFmPsStTux
* @param su_settable * @param su_settable
* The flag bits which are known to be settable with chattr only by * The flag bits which are known to be settable with chattr only by
* bearers of various superuser powers: * bearers of various superuser powers:
* iaj * aij
* @param non_settable * @param non_settable
* The flags bits which are known to be not settable or not clearable * The flags bits which are known to be not settable or not clearable
* by chattr or only known to lsattr: * by chattr or only known to lsattr:
* ZEIheVN * eEhINVZ
*
* @param unknown * @param unknown
* The flags bits for which no symbolic letter is known. Some of them are * The flags bits for which no symbolic letter is known. Some of them are
* defined in <linux/fs.h> with sparse info, some not even that: * defined in <linux/fs.h> with sparse info, some not even that:

View File

@ -2520,10 +2520,20 @@ static char lfa_flag_letters[] = { 's', 'u', 'c', 'S', 'i', 'a', 'd', 'A',
'-', 'x', '-', '-', 'N', 'P', 'F', '-' }; '-', 'x', '-', '-', 'N', 'P', 'F', '-' };
/* Sequence and coverage as of e2fsprogs 1.47.1, lib/pf.c for lsattr(1) */ /* Sequence and coverage as of e2fsprogs 1.47.1, lib/pf.c for lsattr(1) */
static int lsattr_sequence[] = { 0, 1, 3, 16, 4, 5, 6, 7,
2, 11, 14, 12, 15, 17, 19, 23,
25, 30, 28, 29, 20, 10, -1 };
/* Semi-alphabetic sequence: aAcCdDeE FhiIjNmP sStTuVxZ */
static int semi_alphabetic[] = { 5, 7, 2, 23, 6, 16, 19, 11,
20, 18, 4, 12, 14, 28, 10, 29,
0, 3, 15, 17, 1, 20, 25, 8,
-1 };
/* Unknown bits up to 31 */
static int unknown_flags[] = { 9, 13, 21, 22, 24, 26, 27, 31,
-1 };
static int lsattr_permutation[] = { 0, 1, 3, 16, 4, 5, 6, 7,
2, 11, 14, 12, 15, 17, 19, 23,
25, 30, 28, 29, 20, 10, -1};
static int num_lsattr_bits = 22; static int num_lsattr_bits = 22;
static int max_lsattr_bit = 30; static int max_lsattr_bit = 30;
static int non_lsattr_bits[] = { 8, 9, 13, 18, 21, 22, 24, 26, 27, -1 }; static int non_lsattr_bits[] = { 8, 9, 13, 18, 21, 22, 24, 26, 27, -1 };
@ -2546,20 +2556,27 @@ int iso_util_encode_lfa_flags(uint64_t lfa_flags, char **flags_text, int flag)
if (*flags_text == NULL) if (*flags_text == NULL)
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
for (i = 0; i < 64; i++) { for (i = 0; semi_alphabetic[i] >= 0; i++) {
if (!(lfa_flags & (((uint64_t) 1) << i))) pi = semi_alphabetic[i];
continue; if (lfa_flags & (((uint64_t) 1) << pi))
if (lfa_flag_letters[i] == '-') { (*flags_text)[w++] = lfa_flag_letters[pi];
}
for (i = 0; unknown_flags[i] >= 0; i++) {
pi = unknown_flags[i];
if (lfa_flags & (((uint64_t) 1) << pi))
was_unknown = 1;
}
for (i = 32; i < 64; i++) {
if (lfa_flags & (((uint64_t) 1) << i))
was_unknown = 1; was_unknown = 1;
} else {
(*flags_text)[w++] = lfa_flag_letters[i];
}
} }
(*flags_text)[w] = 0; (*flags_text)[w] = 0;
if (was_unknown) if (was_unknown)
return ISO_LFA_UNKNOWN_BIT; return ISO_LFA_UNKNOWN_BIT;
return ISO_SUCCESS; return ISO_SUCCESS;
lsattr_format:; lsattr_format:;
*flags_text = calloc(num_lsattr_bits + 1, 1); *flags_text = calloc(num_lsattr_bits + 1, 1);
@ -2567,7 +2584,7 @@ lsattr_format:;
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
for (i = 0; i < num_lsattr_bits; i++) { for (i = 0; i < num_lsattr_bits; i++) {
pi = lsattr_permutation[i]; pi = lsattr_sequence[i];
if (pi < 0) if (pi < 0)
break; break;
if (lfa_flags & (((uint64_t) 1) << pi)) { if (lfa_flags & (((uint64_t) 1) << pi)) {