Hello,
Sorry for my late reply...
On Sat, May 06, 2017 at 11:39:56AM -0400, Theodore Ts'o wrote:
> Sorry, no. Just to be clear, is what you want is to be able to
> convert flag value to a string (instead of printing it to stdio FILE
> handle)? Or to go the other way --- e.g., given a charafter flag such
> as 's', convert it to EXT2_SECRM_FL?
>
> I don't want to expose the array as a public interface, since that
> ties my hands as to the implementation. I'm willing to expose new
> function interfaces, though. But there you need to be a lot more
> explicit what you want, and of course, patches will make it much more
> likely that the request will be satisified. :-)
That makes sense.
I would need the following functions:
unsigned long get_flag(char)
- return flag for given character
- return 0 for invalid characters
- example: get_flag('s') returns EXT2_SECRM_FL
char get_char(unsigned long flag)
- return character for given flag
- return '?' for invalid flags
- example: get_flag(EXT2_SECRM_FL) returns 's'
unsigned long get_readonly_flags()
- return all read only flags (so I can provide an option to ignore
changes of read only flags)
AIDE has an option to ignore changes of given flags and marks then with
a colon in the report (e.g. `----:a--------e-------` for ignored
immutable flag); hence I cannot use the print_flags library function.
To iterate over the available flags the following function would help:
unsigned long get_available_flags()
* return all available flags
Unfortunately the bit order of the available flags does not match the
order returned by print_flags (sucSiadAmEIjtDTeVCxNPF vs
suSDiadAcEjItTeCxFNPVm). A function that returns the flag for a given
output position could solve that:
unsigned long output_get_flag(int)
- return flag for character position
- return 0 for positions > num_flags
- example: output_get_flag(4) returns EXT2_IMMUTABLE_FL
Best regards
Hannes