Skip to content

Commit aaf7158

Browse files
committed
ext2 debugging
1 parent fb18ef4 commit aaf7158

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

kernel/fs/ext2.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ void ext2_itrunc(struct inode* ip) {
105105
panic("ext2_itrunc not implemented yet");
106106
}
107107

108+
void dump_data(uint8 *ptr, int cnt) {
109+
int j = 0;
110+
while(j <= cnt) {
111+
for(int i = 0; i != 60; i++) {
112+
cprintf("%x ", ptr[j++]);
113+
}
114+
cprintf("\n");
115+
}
116+
}
117+
108118
void ext2_readinode(struct inode *ip) {
109119
struct buf *bp;
110120
struct ext2_inode *ext2i;
@@ -113,14 +123,19 @@ void ext2_readinode(struct inode *ip) {
113123
int index = (ip->inum - 1) % sb.inodes_in_group;
114124
int inodesize = sb.major_ver >= 1 ? sb.inode_size : FS_EXT2_OLD_INODE_SIZE;
115125
int block = (index * inodesize) / blocksize;
126+
cprintf("About to read block %d\n", block);
116127

117-
bp = bread(ip->dev, block);
118-
ext2i = (struct ext2_inode*)bp->data + index;
128+
bp = bread(ip->dev, block + 2);
129+
dump_data(bp->data, 4096);
130+
cprintf("Seeking to inode @ index %d\n", index);
131+
ext2i = (struct ext2_inode*)bp->data + (index * sizeof(struct ext2_inode));
132+
dump_data((uint8 *)ext2i, sizeof(struct ext2_inode));
119133
if (EXT2_TYPE_ISREG(ext2i->type)) {
120134
ip->type = T_FILE;
121135
} else if (EXT2_TYPE_ISDIR(ext2i->type)) {
122136
ip->type = T_DIR;
123137
} else {
138+
cprintf("Uknown type %d\n", ext2i->type);
124139
ip->type = 0; // unknown!
125140
}
126141
ip->nlink = ext2i->hard_link_count;

0 commit comments

Comments
 (0)