Re: [PATCH] gpt: allow spaces in partition list

2024-07-02 Thread Mikhail Kshevetskiy


On 7/2/24 19:51, Simon Glass wrote:
> Hi Mikhail,
>
> On Tue, 2 Jul 2024 at 10:42, Mikhail Kshevetskiy
>  wrote:
>>
>> On 27.06.2024 22:05, Simon Glass wrote:
>>> Hi Mikhail,
>>>
>>> On Thu, 27 Jun 2024 at 12:29, Mikhail Kshevetskiy
>>>  wrote:
 This allows spliting partition list to several lines in environment file

 ex:
 
 gpt_partition_list=
 name=boot1,size=5MiB,start=0x10;
 name=boot2,size=5MiB;
 name=rootfs1,size=70MiB;
 name=rootfs2,size=70MiB;
 name=overlay1,size=20MiB;
 name=overlay2,size=20MiB;
 name=art,size=4MiB;
>>> Is this referring to a .env file, i.e. a text environment file? If so,
>>> I would hope that spaces at the start of a line would be automatically
>>> removed.
>> This is refer to a .env file, so starting space/tabs will be removed,
>> all '\n' will be replaced by spaces. Thus we will get a single line where
>> each partition divided from other with a single space (like below)
>>
>> gpt_partition_list=name=boot1,size=5MiB,start=0x10; 
>> name=boot2,size=5MiB; ...
> Reviewed-by: Simon Glass 
>
> But I wonder if the \t is needed?

no, \t is not mandatory. Spaces can be used instead.

>
 Signed-off-by: Mikhail Kshevetskiy 
 ---
  cmd/gpt.c | 2 ++
  1 file changed, 2 insertions(+)

 diff --git a/cmd/gpt.c b/cmd/gpt.c
 index 7aaf1889a5a..2b29ab98ccc 100644
 --- a/cmd/gpt.c
 +++ b/cmd/gpt.c
 @@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char 
 *key)
 k = strsep(, "=");
 if (!k)
 break;
 +   k += strspn(k, " \t");
 if  (strcmp(k, key) == 0) {
 new = strdup(v);
 break;
 @@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
 k = strsep(, ",");
 if (!k)
 break;
 +   k += strspn(k, " \t");
 if  (strcmp(k, key) == 0) {
 result = true;
 break;
 --
 2.43.0
> Regards,
> Simon


Re: [PATCH] gpt: allow spaces in partition list

2024-07-02 Thread Simon Glass
Hi Mikhail,

On Tue, 2 Jul 2024 at 10:42, Mikhail Kshevetskiy
 wrote:
>
>
> On 27.06.2024 22:05, Simon Glass wrote:
> > Hi Mikhail,
> >
> > On Thu, 27 Jun 2024 at 12:29, Mikhail Kshevetskiy
> >  wrote:
> >> This allows spliting partition list to several lines in environment file
> >>
> >> ex:
> >> 
> >> gpt_partition_list=
> >> name=boot1,size=5MiB,start=0x10;
> >> name=boot2,size=5MiB;
> >> name=rootfs1,size=70MiB;
> >> name=rootfs2,size=70MiB;
> >> name=overlay1,size=20MiB;
> >> name=overlay2,size=20MiB;
> >> name=art,size=4MiB;
> > Is this referring to a .env file, i.e. a text environment file? If so,
> > I would hope that spaces at the start of a line would be automatically
> > removed.
>
> This is refer to a .env file, so starting space/tabs will be removed,
> all '\n' will be replaced by spaces. Thus we will get a single line where
> each partition divided from other with a single space (like below)
>
> gpt_partition_list=name=boot1,size=5MiB,start=0x10; name=boot2,size=5MiB; 
> ...

Reviewed-by: Simon Glass 

But I wonder if the \t is needed?


>
> >> Signed-off-by: Mikhail Kshevetskiy 
> >> ---
> >>  cmd/gpt.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/cmd/gpt.c b/cmd/gpt.c
> >> index 7aaf1889a5a..2b29ab98ccc 100644
> >> --- a/cmd/gpt.c
> >> +++ b/cmd/gpt.c
> >> @@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char 
> >> *key)
> >> k = strsep(, "=");
> >> if (!k)
> >> break;
> >> +   k += strspn(k, " \t");
> >> if  (strcmp(k, key) == 0) {
> >> new = strdup(v);
> >> break;
> >> @@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
> >> k = strsep(, ",");
> >> if (!k)
> >> break;
> >> +   k += strspn(k, " \t");
> >> if  (strcmp(k, key) == 0) {
> >> result = true;
> >> break;
> >> --
> >> 2.43.0
Regards,
Simon


Re: [PATCH] gpt: allow spaces in partition list

2024-07-02 Thread Mikhail Kshevetskiy


On 27.06.2024 22:05, Simon Glass wrote:
> Hi Mikhail,
>
> On Thu, 27 Jun 2024 at 12:29, Mikhail Kshevetskiy
>  wrote:
>> This allows spliting partition list to several lines in environment file
>>
>> ex:
>> 
>> gpt_partition_list=
>> name=boot1,size=5MiB,start=0x10;
>> name=boot2,size=5MiB;
>> name=rootfs1,size=70MiB;
>> name=rootfs2,size=70MiB;
>> name=overlay1,size=20MiB;
>> name=overlay2,size=20MiB;
>> name=art,size=4MiB;
> Is this referring to a .env file, i.e. a text environment file? If so,
> I would hope that spaces at the start of a line would be automatically
> removed.

This is refer to a .env file, so starting space/tabs will be removed,
all '\n' will be replaced by spaces. Thus we will get a single line where
each partition divided from other with a single space (like below)

gpt_partition_list=name=boot1,size=5MiB,start=0x10; name=boot2,size=5MiB; 
...

>> Signed-off-by: Mikhail Kshevetskiy 
>> ---
>>  cmd/gpt.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/cmd/gpt.c b/cmd/gpt.c
>> index 7aaf1889a5a..2b29ab98ccc 100644
>> --- a/cmd/gpt.c
>> +++ b/cmd/gpt.c
>> @@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char 
>> *key)
>> k = strsep(, "=");
>> if (!k)
>> break;
>> +   k += strspn(k, " \t");
>> if  (strcmp(k, key) == 0) {
>> new = strdup(v);
>> break;
>> @@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
>> k = strsep(, ",");
>> if (!k)
>> break;
>> +   k += strspn(k, " \t");
>> if  (strcmp(k, key) == 0) {
>> result = true;
>> break;
>> --
>> 2.43.0
>>
> Regards,
> Simon


Re: [PATCH] gpt: allow spaces in partition list

2024-06-27 Thread Simon Glass
Hi Mikhail,

On Thu, 27 Jun 2024 at 12:29, Mikhail Kshevetskiy
 wrote:
>
> This allows spliting partition list to several lines in environment file
>
> ex:
> 
> gpt_partition_list=
> name=boot1,size=5MiB,start=0x10;
> name=boot2,size=5MiB;
> name=rootfs1,size=70MiB;
> name=rootfs2,size=70MiB;
> name=overlay1,size=20MiB;
> name=overlay2,size=20MiB;
> name=art,size=4MiB;

Is this referring to a .env file, i.e. a text environment file? If so,
I would hope that spaces at the start of a line would be automatically
removed.

>
> Signed-off-by: Mikhail Kshevetskiy 
> ---
>  cmd/gpt.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/cmd/gpt.c b/cmd/gpt.c
> index 7aaf1889a5a..2b29ab98ccc 100644
> --- a/cmd/gpt.c
> +++ b/cmd/gpt.c
> @@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char *key)
> k = strsep(, "=");
> if (!k)
> break;
> +   k += strspn(k, " \t");
> if  (strcmp(k, key) == 0) {
> new = strdup(v);
> break;
> @@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
> k = strsep(, ",");
> if (!k)
> break;
> +   k += strspn(k, " \t");
> if  (strcmp(k, key) == 0) {
> result = true;
> break;
> --
> 2.43.0
>

Regards,
Simon


[PATCH] gpt: allow spaces in partition list

2024-06-27 Thread Mikhail Kshevetskiy
This allows spliting partition list to several lines in environment file

ex:

gpt_partition_list=
name=boot1,size=5MiB,start=0x10;
name=boot2,size=5MiB;
name=rootfs1,size=70MiB;
name=rootfs2,size=70MiB;
name=overlay1,size=20MiB;
name=overlay2,size=20MiB;
name=art,size=4MiB;

Signed-off-by: Mikhail Kshevetskiy 
---
 cmd/gpt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 7aaf1889a5a..2b29ab98ccc 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char *key)
k = strsep(, "=");
if (!k)
break;
+   k += strspn(k, " \t");
if  (strcmp(k, key) == 0) {
new = strdup(v);
break;
@@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
k = strsep(, ",");
if (!k)
break;
+   k += strspn(k, " \t");
if  (strcmp(k, key) == 0) {
result = true;
break;
-- 
2.43.0