ext2: remove ext2_print_root (again)
This commit is contained in:
parent
6aedf88c7e
commit
366c07de45
1 changed files with 0 additions and 76 deletions
76
fs/ext2.c
76
fs/ext2.c
|
|
@ -374,82 +374,6 @@ int ext2_seek_file(struct fs *vfs, struct file *file, size_t offset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDEBUG
|
|
||||||
static void ext2_print_dir(struct ext2fs *fs, struct ext2_inode *inode, int indent)
|
|
||||||
{
|
|
||||||
static const char *types[] = { "UNKNOWN", "FILE", "DIR", "CHARDEV", "BLOCKDEV", "FIFO", "SOCKET", "SYMLINK" };
|
|
||||||
/* print the names of files and directories in the root directory */
|
|
||||||
|
|
||||||
struct ext2_dir_entry *entry = kmalloc(fs->block_size, ALLOC_DMA);
|
|
||||||
void *oentry = entry;
|
|
||||||
if (!entry)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ext2_read_block(fs, entry, inode->block[0]);
|
|
||||||
|
|
||||||
while (entry->inode) {
|
|
||||||
char *name = kmalloc(entry->name_len + 1, ALLOC_KERN);
|
|
||||||
if (!name)
|
|
||||||
break;
|
|
||||||
|
|
||||||
memcpy(name, entry->name, entry->name_len);
|
|
||||||
name[entry->name_len] = '\0';
|
|
||||||
|
|
||||||
kprintf(LOG_DEBUG);
|
|
||||||
for (int i = 0; i < indent; i++)
|
|
||||||
kprintf(" ");
|
|
||||||
kprintf("[%s] %s\n", types[MIN(7, entry->file_type)], name);
|
|
||||||
|
|
||||||
if (entry->file_type == EXT2_DE_DIR) {
|
|
||||||
if (!strcmp(name, ".") || !strcmp(name, ".."))
|
|
||||||
goto next;
|
|
||||||
|
|
||||||
struct ext2_inode *in = kmalloc(sizeof(struct ext2_inode), ALLOC_KERN);
|
|
||||||
if (!in)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ext2_read_inode(fs, in, entry->inode);
|
|
||||||
ext2_print_dir(fs, in, indent + 1);
|
|
||||||
kfree(in);
|
|
||||||
} else if (entry->file_type == EXT2_DE_FILE) {
|
|
||||||
/* print the contents of the file */
|
|
||||||
struct ext2_inode *in = kmalloc(sizeof(struct ext2_inode), ALLOC_KERN);
|
|
||||||
if (!in)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ext2_read_inode(fs, in, entry->inode);
|
|
||||||
|
|
||||||
char *buf = kmalloc(in->size, ALLOC_KERN);
|
|
||||||
|
|
||||||
if (!buf) {
|
|
||||||
kfree(in);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ext2_read_block(fs, buf, in->block[0]);
|
|
||||||
|
|
||||||
kprintf(LOG_DEBUG);
|
|
||||||
for (int i = 0; i < indent + 1; i++)
|
|
||||||
kprintf(" ");
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < in->size; i++) {
|
|
||||||
if (buf[i] == '\n')
|
|
||||||
kprintf("\n");
|
|
||||||
else
|
|
||||||
console_write(buf[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next:
|
|
||||||
|
|
||||||
kfree(name);
|
|
||||||
|
|
||||||
entry = (void *)entry + entry->rec_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
kfree(oentry);
|
|
||||||
}
|
|
||||||
#endif /* KDEBUG */
|
|
||||||
|
|
||||||
struct fs *ext2_init_fs(struct block_device *bdev)
|
struct fs *ext2_init_fs(struct block_device *bdev)
|
||||||
{
|
{
|
||||||
struct ext2fs *extfs = kmalloc(sizeof(*extfs), ALLOC_KERN);
|
struct ext2fs *extfs = kmalloc(sizeof(*extfs), ALLOC_KERN);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue