-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial code to support ext4 #303
base: master
Are you sure you want to change the base?
Conversation
lib/fs/ext2/dir.c
Outdated
@@ -12,14 +12,24 @@ | |||
#include <lk/err.h> | |||
#include "ext2_priv.h" | |||
|
|||
#define LOCAL_TRACE 0 | |||
#define LOCAL_TRACE 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal here, but make sure there's a CL that turns this back off at the end.
@@ -128,30 +128,57 @@ static blocknum_t file_block_to_fs_block(ext2_t *ext2, struct ext2_inode *inode, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, should probably move this into a dump routine that is turned off with LOCAL_TRACE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a LE32 as well?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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