Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
jnc100
Member
Posts: 775 Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:
Post
by jnc100 » Sun Oct 02, 2016 12:47 pm
ch3ll0v3k wrote: I have also strange extra characters at the end of each "file_name". can"t figure out what can it be.
I see two possibilities:
- You are not reading the length of the name correctly.
- You are reading the length of the name correctly but not null-terminating the actual name after this length.
Regards,
John.
osdever
Member
Posts: 492 Joined: Fri Apr 03, 2015 9:41 am
Contact:
Post
by osdever » Sun Oct 02, 2016 1:39 pm
ch3ll0v3k wrote: I have also strange extra characters at the end of each "file_name". can"t figure out what can it be.
on the second screenshot it is better visible
It must be:
Code: Select all
/.
/ ..
/.Trash-1000
/bin
/.Trash-0
/usr
/src
/boot
/os.iso
/root_dir_12
/root_dir_11
/root_dir_13
/lib
/var
/etc
/dev
/tmp
/run
/root_dir_15
/root_dir_14
At least your Ext2 code works
crunch
Member
Posts: 81 Joined: Wed Aug 31, 2016 9:53 pm
Libera.chat IRC: crunch
Location: San Diego, CA
Post
by crunch » Sun Oct 02, 2016 2:19 pm
ch3ll0v3k wrote: I have also strange extra characters at the end of each "file_name". can"t figure out what can it be.
on the second screenshot it is better visible
It must be:
Code: Select all
/.
/ ..
/.Trash-1000
/bin
/.Trash-0
/usr
/src
/boot
/os.iso
/root_dir_12
/root_dir_11
/root_dir_13
/lib
/var
/etc
/dev
/tmp
/run
/root_dir_15
/root_dir_14
d->name[d->name_len] = '\0';
or you're not incrementing your directory entries by the right amount
ch3ll0v3k
Posts: 10 Joined: Sat Oct 01, 2016 1:26 am
Post
by ch3ll0v3k » Mon Oct 03, 2016 4:59 am
Finally found it:
My structure to store directory info was wrong.
Code: Select all
// this was wrong
typedef struct {
// --------------------------------------------------------------
uint32_t inode; // [DIR] Inode number
uint16_t rec_len; // [DIR] Directory entry length
uint16_t name_len; // [DIR] Name length
int8_t name[ 255 ]; // [DIR] File name
// --------------------------------------------------------------
} __attribute__ ((packed)) ext2_dir_entry_t;
Code: Select all
// and now it is
typedef struct {
// --------------------------------------------------------------
uint32_t inode; // [DIR] Inode number
uint16_t rec_len; // [DIR] Directory entry length
uint8_t name_len; // [DIR] Name length
uint8_t file_type; // [DIR] file type
int8_t name[ 255 ]; // [DIR] File name
// --------------------------------------------------------------
} __attribute__ ((packed)) ext2_dir_entry_t;
thx everyone!