public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] squashfs: Fix sqfsls errors when root is a ldir
@ 2021-12-15  1:53 Campbell Suter
  2021-12-15 11:20 ` Miquel Raynal
  2022-01-28 23:36 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Campbell Suter @ 2021-12-15  1:53 UTC (permalink / raw)
  To: u-boot; +Cc: Joao Marcos Costa, Miquel Raynal, Thomas Petazzoni

Previously, if root had more than 256 files or otherwise needed to be an
ldir, sqfsls would emit the error 'Inode not found.' which was caused by
code in sqfs_search_dir assuming it was a regular directory inode.

Signed-off-by: Campbell Suter <campbell@snapit.group>
---

  fs/squashfs/sqfs.c | 16 +++++++++++++---
  1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index e2d91c654c..4d7bf76fa3 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -482,13 +482,20 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
  
  	/* Initialize squashfs_dir_stream members */
  	dirs->table += SQFS_DIR_HEADER_SIZE;
-	dirs->size = get_unaligned_le16(&dir->file_size) - SQFS_DIR_HEADER_SIZE;
+	if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
+		dirs->size = get_unaligned_le16(&dir->file_size);
+	else
+		dirs->size = get_unaligned_le32(&ldir->file_size);
+	dirs->size -= SQFS_DIR_HEADER_SIZE;
  	dirs->entry_count = dirs->dir_header->count + 1;
  
  	/* No path given -> root directory */
  	if (!strcmp(token_list[0], "/")) {
  		dirs->table = &dirs->dir_table[offset];
-		memcpy(&dirs->i_dir, dir, sizeof(*dir));
+		if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
+			memcpy(&dirs->i_dir, dir, sizeof(*dir));
+		else
+			memcpy(&dirs->i_ldir, ldir, sizeof(*ldir));
  		return 0;
  	}
  
@@ -608,7 +615,10 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
  		}
  
  		dirs->table += SQFS_DIR_HEADER_SIZE;
-		dirs->size = get_unaligned_le16(&dir->file_size);
+		if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
+			dirs->size = get_unaligned_le16(&dir->file_size);
+		else
+			dirs->size = get_unaligned_le32(&ldir->file_size);
  		dirs->entry_count = dirs->dir_header->count + 1;
  		dirs->size -= SQFS_DIR_HEADER_SIZE;
  		free(dirs->entry);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] squashfs: Fix sqfsls errors when root is a ldir
  2021-12-15  1:53 [PATCH] squashfs: Fix sqfsls errors when root is a ldir Campbell Suter
@ 2021-12-15 11:20 ` Miquel Raynal
  2022-01-28 23:36 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2021-12-15 11:20 UTC (permalink / raw)
  To: Campbell Suter; +Cc: u-boot, Joao Marcos Costa, Thomas Petazzoni

Hi Campbell,

campbell@snapit.group wrote on Wed, 15 Dec 2021 14:53:43 +1300:

> Previously, if root had more than 256 files or otherwise needed to be an
> ldir, sqfsls would emit the error 'Inode not found.' which was caused by
> code in sqfs_search_dir assuming it was a regular directory inode.
> 

It would be good to group your commits into series, generated
automatically with git-format-patch.

Also when you send different version of patches, you need to generate
them with a different version in the subject prefix with the option:
-v <version>

Otherwise for this commit:
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> Signed-off-by: Campbell Suter <campbell@snapit.group>
> ---
> 
>   fs/squashfs/sqfs.c | 16 +++++++++++++---
>   1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
> index e2d91c654c..4d7bf76fa3 100644
> --- a/fs/squashfs/sqfs.c
> +++ b/fs/squashfs/sqfs.c
> @@ -482,13 +482,20 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
>     	/* Initialize squashfs_dir_stream members */
>   	dirs->table += SQFS_DIR_HEADER_SIZE;
> -	dirs->size = get_unaligned_le16(&dir->file_size) - SQFS_DIR_HEADER_SIZE;
> +	if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
> +		dirs->size = get_unaligned_le16(&dir->file_size);
> +	else
> +		dirs->size = get_unaligned_le32(&ldir->file_size);
> +	dirs->size -= SQFS_DIR_HEADER_SIZE;
>   	dirs->entry_count = dirs->dir_header->count + 1;
>     	/* No path given -> root directory */
>   	if (!strcmp(token_list[0], "/")) {
>   		dirs->table = &dirs->dir_table[offset];
> -		memcpy(&dirs->i_dir, dir, sizeof(*dir));
> +		if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
> +			memcpy(&dirs->i_dir, dir, sizeof(*dir));
> +		else
> +			memcpy(&dirs->i_ldir, ldir, sizeof(*ldir));
>   		return 0;
>   	}
>   @@ -608,7 +615,10 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
>   		}
>     		dirs->table += SQFS_DIR_HEADER_SIZE;
> -		dirs->size = get_unaligned_le16(&dir->file_size);
> +		if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
> +			dirs->size = get_unaligned_le16(&dir->file_size);
> +		else
> +			dirs->size = get_unaligned_le32(&ldir->file_size);
>   		dirs->entry_count = dirs->dir_header->count + 1;
>   		dirs->size -= SQFS_DIR_HEADER_SIZE;
>   		free(dirs->entry);


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] squashfs: Fix sqfsls errors when root is a ldir
  2021-12-15  1:53 [PATCH] squashfs: Fix sqfsls errors when root is a ldir Campbell Suter
  2021-12-15 11:20 ` Miquel Raynal
@ 2022-01-28 23:36 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2022-01-28 23:36 UTC (permalink / raw)
  To: Campbell Suter; +Cc: u-boot, Joao Marcos Costa, Miquel Raynal, Thomas Petazzoni

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

On Wed, Dec 15, 2021 at 02:53:43PM +1300, Campbell Suter wrote:

> Previously, if root had more than 256 files or otherwise needed to be an
> ldir, sqfsls would emit the error 'Inode not found.' which was caused by
> code in sqfs_search_dir assuming it was a regular directory inode.
> 
> Signed-off-by: Campbell Suter <campbell@snapit.group>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

This causes one of the tests to fail as it likely needs to be updated
now.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-28 23:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15  1:53 [PATCH] squashfs: Fix sqfsls errors when root is a ldir Campbell Suter
2021-12-15 11:20 ` Miquel Raynal
2022-01-28 23:36 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox