[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-btrfs
Subject:    Re: [PATCH] btrfs: sysfs: display ACL support
From:       Anand Jain <anand.jain () oracle ! com>
Date:       2023-06-29 22:31:07
Message-ID: 101cdf7f-771f-4f07-df49-2a2d2ad4bd80 () oracle ! com
[Download RAW message or body]



On 30/06/2023 00:41, David Sterba wrote:
> On Tue, Jun 20, 2023 at 04:55:09PM +0800, Anand Jain wrote:
>> ACL support is dependent on the compile-time configuration option
>> CONFIG_BTRFS_FS_POSIX_ACL. Prior to mounting a btrfs filesystem, it is not
>> possible to determine whether ACL support has been compiled in. To address
>> this, add a sysfs interface, /sys/fs/btrfs/features/acl, and check for ACL
>> support in the system's btrfs.
>>
>>    To determine ACL support:
>>
>>    Return 0 indicates ACL is not supported:
>>      $ cat /sys/fs/btrfs/features/acl
>>      0
>>
>>    Return 1 indicates ACL is supported:
>>      $ cat /sys/fs/btrfs/features/acl
>>      1
>>
>> IMO, this is a better approach, so that we also know if kernel is older.
>>
>>    On an older kernel
>>      $ ls /sys/fs/btrfs/features/acl
>>      ls: cannot access '/sys/fs/btrfs/features/acl': No such file or directory
>>
>>      mount a btrfs filesystem
>>      $ cat /proc/self/mounts | grep btrfs | grep -q noacl
>>      $ echo $?
>>      0
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> 
> Added to misc-next, thanks.
> 
>> ---
>>   fs/btrfs/sysfs.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
>> index 25294e624851..25b311bb47ac 100644
>> --- a/fs/btrfs/sysfs.c
>> +++ b/fs/btrfs/sysfs.c
>> @@ -414,6 +414,21 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
>>   BTRFS_ATTR(static_feature, supported_sectorsizes,
>>   	   supported_sectorsizes_show);
>>   
>> +static ssize_t acl_show(struct kobject *kobj, struct kobj_attribute *a,
>> +			char *buf)
>> +{
>> +	ssize_t ret = 0;
> 
> The simple callback can return directly sysfs_emit_at without the return
> variable. Updated.
> 

Changes in mics-next look good and much cooler.


>> +
>> +#ifdef CONFIG_BTRFS_FS_POSIX_ACL
>> +	ret += sysfs_emit_at(buf, ret, "%d\n", 1);
>> +#else
>> +	ret += sysfs_emit_at(buf, ret, "%d\n", 0);
>> +#endif
>> +
>> +	return ret;
>> +}
>> +BTRFS_ATTR(static_feature, acl, acl_show);
>> +
>>   /*
>>    * Features which only depend on kernel version.
>>    *
>> @@ -426,6 +441,7 @@ static struct attribute *btrfs_supported_static_feature_attrs[] = {
>>   	BTRFS_ATTR_PTR(static_feature, send_stream_version),
>>   	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
>>   	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
>> +	BTRFS_ATTR_PTR(static_feature, acl),
> 
> Please keep the features sorted alphabetically, moved to the beginning
> of the list.

  Ah. Got it.

Thanks Anand

>>   	NULL
>>   };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic