Page 1 of 1
Change directories and load a program
Posted: Sat Jan 26, 2013 2:45 pm
by feare56
How would I go about this? I had a test "dir" command but lost some of it due to expirementation. The command was no where near an actual directory command but a test to see if I could jump to the call and print "No working Directories" and do other commands but sadly it just froze my os for now. But how would I actually change to a different directorty? The current directories I have are "source, and obj" and how would I load a simple program?
Re: Change directories and load a program
Posted: Sat Jan 26, 2013 3:07 pm
by Jezze
Loading a program is done by reading the elf information of the binary, copy the relevant sections into memory, set up the relevant page mappings for the program and then jump to the elf entry address.
Changing a directory depends on how you have implemented your virtual filesystem which you probably havent written yet so you should take a look at that first and then everything should be clear to you.
EDIT: hehe I had written problem instead of program.
Re: Change directories and load a program
Posted: Sat Jan 26, 2013 3:11 pm
by Casm
Somewhere in your kernel you would need to maintain a record of what the current directory is. Then you would need a system call, so that whatever other programs might be interested, such as the shell, can find out what it is. Changing directory would mean updating your internal record of what the current directory is (another system call).
Re: Change directories and load a program
Posted: Sat Jan 26, 2013 3:58 pm
by feare56
Thank you! Would that be easier in c or assembly?
Re: Change directories and load a program
Posted: Sun Jan 27, 2013 11:47 am
by Jezze
How the hell would I know. Depends on your preference doesnt it? I'd guess C...
Re: Change directories and load a program
Posted: Sun Jan 27, 2013 11:54 am
by feare56
lol ok