boot: print list of block devices on mount fail
This commit is contained in:
parent
f880efe02d
commit
36c6f7b92c
4 changed files with 17 additions and 2 deletions
|
|
@ -54,3 +54,11 @@ inline int block_write(struct block_device *bdev, void *buf, size_t offset, size
|
|||
{
|
||||
return bdev->ops.write(bdev, buf, offset + bdev->lba_start, size);
|
||||
}
|
||||
|
||||
void kerror_print_blkdevs()
|
||||
{
|
||||
kprintf(LOG_ERROR "List of available block devices:\n");
|
||||
for (size_t i = 0; i < block_devices_count; i++) {
|
||||
kprintf(LOG_ERROR " %s\n", block_devices[i]->name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
fs/vfs.c
2
fs/vfs.c
|
|
@ -270,6 +270,7 @@ void vfs_init(const char *rootdev_name)
|
|||
struct block_device *rootdev = block_get_device(rootdev_name);
|
||||
if (!rootdev) {
|
||||
kprintf(LOG_ERROR "Failed to find root device %s\n", rootdev_name);
|
||||
kerror_print_blkdevs();
|
||||
panic();
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +283,7 @@ void vfs_init(const char *rootdev_name)
|
|||
struct fs *fs = ext2_init_fs(rootdev);
|
||||
if (!fs) {
|
||||
kprintf(LOG_ERROR "Failed to mount root device %s\n", rootdev_name);
|
||||
kerror_print_blkdevs();
|
||||
panic();
|
||||
} else {
|
||||
#ifdef KDEBUG
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ struct block_device *block_register(char *name, struct block_device_ops *ops, vo
|
|||
struct block_device *block_get_device(const char *name);
|
||||
int block_read(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
int block_write(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
void kerror_print_blkdevs();
|
||||
|
||||
extern struct block_device *block_devices[];
|
||||
extern size_t block_devices_count;
|
||||
|
|
|
|||
|
|
@ -151,10 +151,14 @@ void kmain()
|
|||
ahci_init();
|
||||
|
||||
char *root_path = kcmdline_get_symbol("root");
|
||||
if (!root_path)
|
||||
if (!root_path) {
|
||||
kprintf(LOG_ERROR "No root= parameter specified\n");
|
||||
else
|
||||
|
||||
kerror_print_blkdevs();
|
||||
panic();
|
||||
} else {
|
||||
vfs_init(root_path);
|
||||
}
|
||||
|
||||
_pic_init();
|
||||
apic_init();
|
||||
|
|
|
|||
Loading…
Reference in a new issue