Re: [PATCH palo] remove useless files from directory listing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/29/20 6:54 PM, James Bottomley wrote:
> The directory listing command 'l' currently shows deleted files plus
> other filetypes that couldn't possibly be booted.  Eliminate deleted
> files and make it show only regular/symlink and directory entries.
>
> Signed-off-by: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>

Thanks, applied !

Helge


> ---
>  ipl/ext2.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/ipl/ext2.c b/ipl/ext2.c
> index 86b8259..8a96b9b 100644
> --- a/ipl/ext2.c
> +++ b/ipl/ext2.c
> @@ -728,6 +728,7 @@ static struct ext2_dir_entry_2 *ext2_readdiri(struct ext2_inode *dir_inode,
>  			return NULL;
>  	}
>
> + repeat:
>  #ifdef DEBUG
>  	printf("ext2_readdiri: blkoffset %d diroffset %d len %d\n",
>  		blockoffset, diroffset, dir_inode->i_size);
> @@ -751,6 +752,15 @@ static struct ext2_dir_entry_2 *ext2_readdiri(struct ext2_inode *dir_inode,
>  	dp = (struct ext2_dir_entry_2 *) (blkbuf + blockoffset);
>  	swapde(dp);
>  	blockoffset += dp->rec_len;
> +	/* ext2 deletes a file by zeroing its inode.  We skip deleted
> +	 * files, corrupt entries and entries that aren't a regular
> +	 * file or a symlink */
> +	if (dp->name_len == 0 || dp->inode == 0)
> +		goto repeat;
> +	if (dp->file_type != EXT2_FT_REG_FILE &&
> +	    dp->file_type != EXT2_FT_SYMLINK &&
> +	    dp->file_type != EXT2_FT_DIR)
> +		goto repeat;
>  #ifdef DEBUG
>  	printf("ext2_readdiri: returning %p = %.*s\n", dp, dp->name_len, dp->name);
>  #endif
>





[Index of Archives]     [Linux SoC]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux