Finding the kenrel (ext*)

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Finding the kenrel (ext*)

Post by PavelChekov »

Hi all.

i'm sure this is a very basic question, but I've been working on my bootloader, and I wondered if there's a way to locate which inode belongs to the kernel binary (in the ext family), other than just going through all the inodes and checking if they're the kernel. I've done some searching, and the closest I can find is a reserved inode for the bootloader, but that's not what I'm after.

Thanks!
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
nullplan
Member
Member
Posts: 1760
Joined: Wed Aug 30, 2017 8:24 am

Re: Finding the kenrel (ext*)

Post by nullplan »

If you have a path name, you can just look it up. I-Node 2 is the root directory, so open it, then iterate through the directory, find the first path name, open its i-node, find the second one, etc. until you have iterated through the entire path. That's actually how most people find a file in a file system.
Carpe diem!
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Re: Finding the kenrel (ext*)

Post by PavelChekov »

nullplan wrote:If you have a path name, you can just look it up. I-Node 2 is the root directory, so open it, then iterate through the directory, find the first path name, open its i-node, find the second one, etc. until you have iterated through the entire path. That's actually how most people find a file in a file system.
That's what I figured. I was afraid I might have been missing some sort of lookup table by filename or something. Thanks.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
nullplan
Member
Member
Posts: 1760
Joined: Wed Aug 30, 2017 8:24 am

Re: Finding the kenrel (ext*)

Post by nullplan »

Apparently, there is some sort of look-up table on large directories, but it is only optional, only on large directories, and only tells you which filesystem block contains the directory entry you are looking for. Way overkill for a bootloader. So I'd just stick to reading the directories normally.
Carpe diem!
Post Reply