Various cleanup:

- Got rid of dummy proc[0].  Now proc[0] is init.
 - Added initcode.S to exec /init, so that /init is
   just a regular binary.
 - Moved exec out of sysfile to exec.c
 - Moved code dealing with fs guts (like struct inode)
   from sysfile.c to fs.c.  Code dealing with system call
   arguments stays in sysfile.c
 - Refactored directory routines in fs.c; should be simpler.
 - Changed iget to return *unlocked* inode structure.
   This solves the lookup-then-use race in namei
   without introducing deadlocks.
   It also enabled getting rid of the dummy proc[0].
This commit is contained in:
rsc 2007-08-21 19:22:08 +00:00
parent 2d61a40b20
commit f32f3638f4
12 changed files with 456 additions and 415 deletions

8
defs.h
View file

@ -40,6 +40,7 @@ int memcmp(const void*, const void*, uint);
void* memmove(void*, const void*, uint);
int strncmp(const char*, const char*, uint);
char* safestrcpy(char*, const char*, int);
int strlen(const char*);
// syscall.c
void syscall(void);
@ -135,11 +136,16 @@ int readi(struct inode*, char*, uint, uint);
int writei(struct inode*, char*, uint, uint);
struct inode* mknod(char*, short, short, short);
struct inode* dircreat(struct inode*, char*, int, short, short, short);
int dirlookup(struct inode*, char*, int, uint*, uint*);
struct inode* dirlookup(struct inode*, char*, int, uint*);
int unlink(char*);
void iupdate(struct inode*);
int link(char*, char*);
struct inode* igetroot(void);
int mkdir(char *path);
struct inode* create(char *path);
// exec.c
int exec(char*, char**);
// number of elements in fixed-size array
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))