Change directories and load a program

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Change directories and load a program

Post 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?
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: Change directories and load a program

Post 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.
Last edited by Jezze on Sun Jan 27, 2013 11:48 am, edited 1 time in total.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: Change directories and load a program

Post 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).
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Re: Change directories and load a program

Post by feare56 »

Thank you! Would that be easier in c or assembly?
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: Change directories and load a program

Post by Jezze »

How the hell would I know. Depends on your preference doesnt it? I'd guess C...
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Re: Change directories and load a program

Post by feare56 »

lol ok
Post Reply