[PATCH fstools] partname: add "fstools_use_partlabel" option to find part from label

INAGAKI Hiroshi musashino.open at gmail.com
Sat Mar 12 06:00:06 PST 2022


Hi Daniel,

Thank you for your review.

On 2022/03/12 19:57, Daniel Golle wrote:
> On Sat, Mar 12, 2022 at 01:05:17PM +0900, INAGAKI Hiroshi wrote:
>> This patch adds "fstools_use_partlabel" option to partname driver.
>>
>> The Linux Kernel supports "root=PARTLABEL=<label>" syntax, but fstools
>> doesn't and fail to parse the path to the root device.
>> To use this syntax, add the option and find from all block devices.
>>
>> Note:
>> This change is required for I-O DATA HDL-A/HDL2-A. On they, kernel and
>> rootfs are stored in the storage device connected to SATA, port1 or
>> port2 and the path to the partition will be assigned dynamically. So
>> "root=PARTLABEL=<label>" syntax is required instead of "/dev/sdXN".
>>
>> Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
>> ---
>>   libfstools/partname.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/libfstools/partname.c b/libfstools/partname.c
>> index f59c52e..7e57311 100644
>> --- a/libfstools/partname.c
>> +++ b/libfstools/partname.c
>> @@ -121,6 +121,7 @@ static struct volume *partname_volume_find(char *name)
>>   	char *rootdev = NULL, *devname, *tmp;
>>   	int j;
>>   	bool found = false;
>> +	bool use_label = false;
>>   	glob_t gl;
>>   
>>   	if (get_var_from_file("/proc/cmdline", "fstools_ignore_partname", rootparam, sizeof(rootparam))) {
>> @@ -128,12 +129,17 @@ static struct volume *partname_volume_find(char *name)
>>   			return NULL;
>>   	}
>>   
>> -	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam))) {
>> +	if (get_var_from_file("/proc/cmdline", "fstools_use_partlabel", rootparam, sizeof(rootparam)))
>> +		if (!strcmp("1", rootparam))
>> +			use_label = true;
>> +
>> +	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) &&
>> +	    !use_label) {
> Wouldn't it be easier to use strncmp() to match the PARTLABEL= prefix
> in string stored at rootparam? In that case you won't have to introduce
> a new 'fstools_use_partlabel' parameter and achieve the same result.
>

Ah indeed, you are right.

I'll update the patch and re-send.

>>   		rootdev = rootdevname(rootparam);
>>   		/* find partition on same device as rootfs */
>>   		snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev);
>>   	} else {
>> -		/* no 'root=' kernel cmdline parameter, find on any block device */
>> +		/* no 'root=' kernel cmdline parameter or use_label=true, find on any block device */
>>   		snprintf(ueventgstr, sizeof(ueventgstr), "%s/*/uevent", block_dir_name);
>>   	}
>>   
>> -- 
>> 2.34.1.windows.1
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Thanks,
Hiroshi




More information about the openwrt-devel mailing list