diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-12-29 09:54:56 -0800 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2020-12-29 19:00:01 +0100 |
commit | 812b3b3231869f4dee194491dd3da0e166538953 (patch) | |
tree | a3b4b5740e19222fa195e9bb64701b0febe2f32f | |
parent | 63ccb72619bf0decd9fc2dd32701c9b1517a7653 (diff) | |
download | palo-812b3b3231869f4dee194491dd3da0e166538953.tar.gz |
Remove useless files from directory listing
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>
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r-- | ipl/ext2.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 |