Conversation
lib/fs/ext2/dir.c
Outdated
| #include "ext2_priv.h" | ||
|
|
||
| #define LOCAL_TRACE 0 | ||
| #define LOCAL_TRACE 1 |
There was a problem hiding this comment.
Not a big deal here, but make sure there's a CL that turns this back off at the end.
| blocknum_t block; | ||
|
|
||
| LTRACEF("inode %p, fileblock %u\n", inode, fileblock); | ||
| if (inode->i_flags & 0x80000) { // inode is stored using extents |
There was a problem hiding this comment.
Same as before, should probably move this into a dump routine that is turned off with LOCAL_TRACE.
lib/fs/ext2/dir.c
Outdated
| } else { | ||
| cookie->cursor = pos; | ||
| } | ||
| strncpy(ent_out->name, ent->name, MIN(ent->name_len, FS_MAX_FILE_LEN)); |
There was a problem hiding this comment.
GCC 11 gives a cryptic warning here:
lib/fs/ext2/dir.c:285:5: error: ‘strncpy’ output may be truncated copying between 0 and 64 bytes from a string of length 254 [-Werror=stringop-truncation]
285 | strncpy(ent_out->name, ent->name, MIN(ent->name_len, FS_MAX_FILE_LEN));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There was a problem hiding this comment.
Suggestion:
size_t tocopy = MIN(ent->name_len, FS_MAX_FILE_LEN - 1);
memcpy(ent_out->name, ent->name, tocopy);
ent_out->name[tocopy + 1] = 0;
| return ERR_NOT_FOUND; | ||
| } | ||
|
|
||
| buf = malloc(EXT2_BLOCK_SIZE(cookie->fs->sb)); |
There was a problem hiding this comment.
preferably find algorithm that does't need to malloc a buffer, but in the short term check for failure to malloc and abort.
lacks the ability to deal with files with more then 4 extents todo: listing the root dir when mounted at / still fails fix block group descriptor handling for ext4
currently lacks the ability to deal with files with more then 4 extents
lacks the ability to deal with filesystems over 2^32 blocks long
only tested on files with 1 extent
based on reading https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout