diff mbox series

ubiswap: avoid checking if the archive provide a file for this script

Message ID 1562946840-3808-1-git-send-email-philippe.reynes@softathome.com
State Changes Requested
Headers show
Series ubiswap: avoid checking if the archive provide a file for this script | expand

Commit Message

Philippe REYNES July 12, 2019, 3:54 p.m. UTC
Swupdate check that all script has a file in the archive.
But the script ubiswap is special and don't request a file.
So we remove this check for script ubiswap.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 core/swupdate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic July 12, 2019, 4:44 p.m. UTC | #1
Hi Philippe,

On 12/07/19 17:54, Philippe Reynes wrote:
> Swupdate check that all script has a file in the archive.
> But the script ubiswap is special and don't request a file.
> So we remove this check for script ubiswap.
> 
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
>  core/swupdate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/core/swupdate.c b/core/swupdate.c
> index 216d837..b9f7676 100644
> --- a/core/swupdate.c
> +++ b/core/swupdate.c
> @@ -175,7 +175,7 @@ static int check_provided(struct imglist *list)
>  
>  	for (p = list->lh_first; p != NULL;
>  		p = p->next.le_next) {
> -		if (!p->provided) {
> +		if (!p->provided && strcmp(p->type,"ubiswap")) {
>  			ERROR("Requested file not found in image: %s", \
>  				p->fname);
>  			ret = -1;
> 

This is the second occurrencies of the check - the other one is in he
parser. I am just noting that this does not scale very well. If
additional handler will be added that does not require an image, we have
always to patch as above and add additonal strcmp() to the statement.

What about to add a flag to the handler type ? Something like
NO_DATA_HANDLER, and by registering :

        register_handler("ubivol", install_ubivol_image,
                                 IMAGE_HANDLER, NULL);
         register_handler("ubipartition", adjust_volume,
                                 PARTITION_HANDLER, NULL);
         register_handler("ubiswap", swap_volume,
                                 SCRIPT_HANDLER | NO_DATA_HANDLER, NULL);

Abover we can have :

		if (!p->provided && !(p->type & NO_DATA_HANDLER)

and teh same in core/parser.c:

  74                 if ( !(p->type & NO_DATA_HANDLER)

Anyway, I understand that this is a fix and I could also merge as it is
- but it is not a long term solution.

Regards,
Stefano
Philippe REYNES July 12, 2019, 5:19 p.m. UTC | #2
Hi Stefano,

> Hi Philippe,
> 
> On 12/07/19 17:54, Philippe Reynes wrote:
>> Swupdate check that all script has a file in the archive.
>> But the script ubiswap is special and don't request a file.
>> So we remove this check for script ubiswap.
>> 
>> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
>> ---
>> core/swupdate.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/core/swupdate.c b/core/swupdate.c
>> index 216d837..b9f7676 100644
>> --- a/core/swupdate.c
>> +++ b/core/swupdate.c
>> @@ -175,7 +175,7 @@ static int check_provided(struct imglist *list)
>> 
>> for (p = list->lh_first; p != NULL;
>> p = p->next.le_next) {
>> - if (!p->provided) {
>> + if (!p->provided && strcmp(p->type,"ubiswap")) {
>> ERROR("Requested file not found in image: %s", \
>> p->fname);
>> ret = -1;
>> 
> 
> This is the second occurrencies of the check - the other one is in he
> parser. I am just noting that this does not scale very well. If
> additional handler will be added that does not require an image, we have
> always to patch as above and add additonal strcmp() to the statement.
> 
> What about to add a flag to the handler type ? Something like
> NO_DATA_HANDLER, and by registering :
> 
> register_handler("ubivol", install_ubivol_image,
> IMAGE_HANDLER, NULL);
> register_handler("ubipartition", adjust_volume,
> PARTITION_HANDLER, NULL);
> register_handler("ubiswap", swap_volume,
> SCRIPT_HANDLER | NO_DATA_HANDLER, NULL);
> 
> Abover we can have :
> 
> if (!p->provided && !(p->type & NO_DATA_HANDLER)
> 
> and teh same in core/parser.c:
> 
> 74 if ( !(p->type & NO_DATA_HANDLER)
> 
> Anyway, I understand that this is a fix and I could also merge as it is
> - but it is not a long term solution.

I think it's a better (and far more scalable) solution than using strcmp
for each exception. We may also use it with ubipartition. 

I propose NO_FILE_HANDLER as flasg name.

If you agree, I may implement it next week.

> Regards,
> Stefano
> 

Regards,
Philippe
diff mbox series

Patch

diff --git a/core/swupdate.c b/core/swupdate.c
index 216d837..b9f7676 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -175,7 +175,7 @@  static int check_provided(struct imglist *list)
 
 	for (p = list->lh_first; p != NULL;
 		p = p->next.le_next) {
-		if (!p->provided) {
+		if (!p->provided && strcmp(p->type,"ubiswap")) {
 			ERROR("Requested file not found in image: %s", \
 				p->fname);
 			ret = -1;