* [PATCH palo] remove useless files from directory listing
@ 2020-12-29 17:54 James Bottomley
2020-12-29 18:03 ` Helge Deller
0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2020-12-29 17:54 UTC (permalink / raw)
To: Parisc List; +Cc: Helge Deller
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@HansenPartnership.com>
---
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
--
2.30.0.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH palo] remove useless files from directory listing
2020-12-29 17:54 [PATCH palo] remove useless files from directory listing James Bottomley
@ 2020-12-29 18:03 ` Helge Deller
0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2020-12-29 18:03 UTC (permalink / raw)
To: James Bottomley, Parisc List
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@HansenPartnership.com>
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-29 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 17:54 [PATCH palo] remove useless files from directory listing James Bottomley
2020-12-29 18:03 ` Helge Deller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.