2005-04-21 16:53:53 +02:00
|
|
|
/* This file contains the main program of the File System. It consists of
|
|
|
|
* a loop that gets messages requesting work, carries out the work, and sends
|
|
|
|
* replies.
|
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
|
|
|
* main: main program of the File System
|
|
|
|
* reply: send a reply to a process after the requested work is done
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct super_block; /* proto.h needs to know this */
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
2005-07-22 20:28:32 +02:00
|
|
|
#include <stdio.h>
|
2005-07-20 17:27:42 +02:00
|
|
|
#include <signal.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/ioc_memory.h>
|
|
|
|
#include <sys/svrctl.h>
|
2006-03-09 17:00:33 +01:00
|
|
|
#include <sys/select.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/keymap.h>
|
2005-05-13 10:57:08 +02:00
|
|
|
#include <minix/const.h>
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
#include <minix/endpoint.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "buf.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "fproc.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include "param.h"
|
|
|
|
#include "super.h"
|
|
|
|
|
|
|
|
FORWARD _PROTOTYPE( void fs_init, (void) );
|
2005-07-22 20:28:32 +02:00
|
|
|
FORWARD _PROTOTYPE( int igetenv, (char *var, int optional) );
|
2005-04-21 16:53:53 +02:00
|
|
|
FORWARD _PROTOTYPE( void get_work, (void) );
|
2006-03-10 17:10:05 +01:00
|
|
|
FORWARD _PROTOTYPE( void init_root, (void) );
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* main *
|
|
|
|
*===========================================================================*/
|
2005-08-25 14:30:43 +02:00
|
|
|
PUBLIC int main()
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* This is the main program of the file system. The main loop consists of
|
|
|
|
* three major activities: getting new work, processing the work, and sending
|
|
|
|
* the reply. This loop never terminates as long as the file system runs.
|
|
|
|
*/
|
2005-07-20 17:27:42 +02:00
|
|
|
sigset_t sigset;
|
2005-04-21 16:53:53 +02:00
|
|
|
int error;
|
|
|
|
|
|
|
|
fs_init();
|
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* This is the main loop that gets work, processes it, and sends replies. */
|
|
|
|
while (TRUE) {
|
|
|
|
get_work(); /* sets who and call_nr */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
fp = &fproc[who_p]; /* pointer to proc table struct */
|
2005-04-21 16:53:53 +02:00
|
|
|
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
|
|
|
|
|
|
|
|
/* Check for special control messages first. */
|
2006-03-10 17:10:05 +01:00
|
|
|
if (call_nr == PROC_EVENT) {
|
|
|
|
/* Assume FS got signal. Synchronize, but don't exit. */
|
|
|
|
do_sync();
|
2005-07-20 17:27:42 +02:00
|
|
|
} else if (call_nr == SYN_ALARM) {
|
2006-03-10 17:10:05 +01:00
|
|
|
/* Alarm timer expired. Used only for select(). Check it. */
|
2005-07-14 17:16:12 +02:00
|
|
|
fs_expire_timers(m_in.NOTIFY_TIMESTAMP);
|
2005-07-27 15:08:52 +02:00
|
|
|
} else if ((call_nr & NOTIFY_MESSAGE)) {
|
2005-07-29 17:00:49 +02:00
|
|
|
/* Device notifies us of an event. */
|
2005-07-27 15:08:52 +02:00
|
|
|
dev_status(&m_in);
|
2005-06-17 15:41:12 +02:00
|
|
|
} else {
|
|
|
|
/* Call the internal function that does the work. */
|
|
|
|
if (call_nr < 0 || call_nr >= NCALLS) {
|
|
|
|
error = ENOSYS;
|
2006-03-10 17:10:05 +01:00
|
|
|
/* Not supposed to happen. */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("FS, warning illegal %d system call by %d\n", call_nr, who_e);
|
2005-07-27 14:01:11 +02:00
|
|
|
} else if (fp->fp_pid == PID_FREE) {
|
|
|
|
error = ENOSYS;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("FS, bad process, who = %d, call_nr = %d, endpt1 = %d\n",
|
|
|
|
who_e, call_nr, m_in.endpt1);
|
2005-06-17 15:41:12 +02:00
|
|
|
} else {
|
|
|
|
error = (*call_vec[call_nr])();
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-17 15:41:12 +02:00
|
|
|
/* Copy the results back to the user and send reply. */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (error != SUSPEND) { reply(who_e, error); }
|
2005-06-17 15:41:12 +02:00
|
|
|
if (rdahed_inode != NIL_INODE) {
|
|
|
|
read_ahead(); /* do block read ahead */
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
}
|
2005-08-25 14:30:43 +02:00
|
|
|
return(OK); /* shouldn't come here */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* get_work *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void get_work()
|
|
|
|
{
|
|
|
|
/* Normally wait for new input. However, if 'reviving' is
|
|
|
|
* nonzero, a suspended process must be awakened.
|
|
|
|
*/
|
|
|
|
register struct fproc *rp;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int l = 0;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
if (reviving != 0) {
|
|
|
|
/* Revive a suspended process. */
|
|
|
|
for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++)
|
|
|
|
if (rp->fp_revived == REVIVING) {
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
who_p = (int)(rp - fproc);
|
|
|
|
who_e = rp->fp_endpoint;
|
2005-04-21 16:53:53 +02:00
|
|
|
call_nr = rp->fp_fd & BYTE;
|
|
|
|
m_in.fd = (rp->fp_fd >>8) & BYTE;
|
|
|
|
m_in.buffer = rp->fp_buffer;
|
|
|
|
m_in.nbytes = rp->fp_nbytes;
|
|
|
|
rp->fp_suspended = NOT_SUSPENDED; /*no longer hanging*/
|
|
|
|
rp->fp_revived = NOT_REVIVING;
|
|
|
|
reviving--;
|
|
|
|
return;
|
|
|
|
}
|
2005-06-01 16:31:00 +02:00
|
|
|
panic(__FILE__,"get_work couldn't revive anyone", NO_NUM);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
for(;;) {
|
|
|
|
/* Normal case. No one to revive. */
|
|
|
|
if (receive(ANY, &m_in) != OK)
|
|
|
|
panic(__FILE__,"fs receive error", NO_NUM);
|
|
|
|
who_e = m_in.m_source;
|
|
|
|
who_p = _ENDPOINT_P(who_e);
|
|
|
|
if(who_p < -NR_TASKS || who_p >= NR_PROCS)
|
|
|
|
panic(__FILE__,"receive process out of range", who_p);
|
|
|
|
if(who_p >= 0 && fproc[who_p].fp_endpoint == NONE) {
|
2006-03-03 11:25:28 +01:00
|
|
|
printf("FS: ignoring request from %d, endpointless slot %d (%d)\n",
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
m_in.m_source, who_p, m_in.m_type);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(who_p >= 0 && fproc[who_p].fp_endpoint != who_e) {
|
2006-03-10 13:59:46 +01:00
|
|
|
printf("FS: receive endpoint inconsistent (%d, %d, %d).\n",
|
|
|
|
who_e, fproc[who_p].fp_endpoint, who_e);
|
|
|
|
panic(__FILE__, "FS: inconsistent endpoint ", NO_NUM);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
call_nr = m_in.m_type;
|
|
|
|
return;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* buf_pool *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void buf_pool(void)
|
|
|
|
{
|
|
|
|
/* Initialize the buffer pool. */
|
|
|
|
|
|
|
|
register struct buf *bp;
|
|
|
|
|
|
|
|
bufs_in_use = 0;
|
|
|
|
front = &buf[0];
|
|
|
|
rear = &buf[NR_BUFS - 1];
|
|
|
|
|
|
|
|
for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++) {
|
|
|
|
bp->b_blocknr = NO_BLOCK;
|
|
|
|
bp->b_dev = NO_DEV;
|
|
|
|
bp->b_next = bp + 1;
|
|
|
|
bp->b_prev = bp - 1;
|
|
|
|
}
|
|
|
|
buf[0].b_prev = NIL_BUF;
|
|
|
|
buf[NR_BUFS - 1].b_next = NIL_BUF;
|
|
|
|
|
|
|
|
for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++) bp->b_hash = bp->b_next;
|
|
|
|
buf_hash[0] = front;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* reply *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void reply(whom, result)
|
|
|
|
int whom; /* process to reply to */
|
|
|
|
int result; /* result of the call (usually OK or error #) */
|
|
|
|
{
|
2006-03-10 17:10:05 +01:00
|
|
|
/* Send a reply to a user process. If the send fails, just ignore it. */
|
2005-04-21 16:53:53 +02:00
|
|
|
int s;
|
|
|
|
m_out.reply_type = result;
|
|
|
|
s = send(whom, &m_out);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (s != OK) printf("FS: couldn't send reply %d to %d: %d\n",
|
|
|
|
result, whom, s);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_init *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void fs_init()
|
|
|
|
{
|
|
|
|
/* Initialize global variables, tables, etc. */
|
|
|
|
register struct inode *rip;
|
2005-06-02 14:43:21 +02:00
|
|
|
register struct fproc *rfp;
|
2005-04-21 16:53:53 +02:00
|
|
|
message mess;
|
2005-08-25 14:30:43 +02:00
|
|
|
int s;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-02 14:43:21 +02:00
|
|
|
/* Initialize the process table with help of the process manager messages.
|
|
|
|
* Expect one message for each system process with its slot number and pid.
|
|
|
|
* When no more processes follow, the magic process number NONE is sent.
|
|
|
|
* Then, stop and synchronize with the PM.
|
|
|
|
*/
|
|
|
|
do {
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int slot;
|
2005-06-02 14:43:21 +02:00
|
|
|
if (OK != (s=receive(PM_PROC_NR, &mess)))
|
|
|
|
panic(__FILE__,"FS couldn't receive from PM", s);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (NONE == mess.PR_ENDPT) break;
|
2005-06-02 14:43:21 +02:00
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rfp = &fproc[mess.PR_SLOT];
|
2005-06-02 14:43:21 +02:00
|
|
|
rfp->fp_pid = mess.PR_PID;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rfp->fp_endpoint = mess.PR_ENDPT;
|
2005-06-02 14:43:21 +02:00
|
|
|
rfp->fp_realuid = (uid_t) SYS_UID;
|
|
|
|
rfp->fp_effuid = (uid_t) SYS_UID;
|
|
|
|
rfp->fp_realgid = (gid_t) SYS_GID;
|
|
|
|
rfp->fp_effgid = (gid_t) SYS_GID;
|
|
|
|
rfp->fp_umask = ~0;
|
|
|
|
|
|
|
|
} while (TRUE); /* continue until process NONE */
|
|
|
|
mess.m_type = OK; /* tell PM that we succeeded */
|
|
|
|
s=send(PM_PROC_NR, &mess); /* send synchronization message */
|
|
|
|
|
|
|
|
/* All process table entries have been set. Continue with FS initialization.
|
|
|
|
* Certain relations must hold for the file system to work at all. Some
|
2005-05-13 10:57:08 +02:00
|
|
|
* extra block_size requirements are checked at super-block-read-in time.
|
|
|
|
*/
|
2005-06-01 16:31:00 +02:00
|
|
|
if (OPEN_MAX > 127) panic(__FILE__,"OPEN_MAX > 127", NO_NUM);
|
|
|
|
if (NR_BUFS < 6) panic(__FILE__,"NR_BUFS < 6", NO_NUM);
|
|
|
|
if (V1_INODE_SIZE != 32) panic(__FILE__,"V1 inode size != 32", NO_NUM);
|
|
|
|
if (V2_INODE_SIZE != 64) panic(__FILE__,"V2 inode size != 64", NO_NUM);
|
2005-08-29 18:47:18 +02:00
|
|
|
if (OPEN_MAX > 8 * sizeof(long))
|
|
|
|
panic(__FILE__,"Too few bits in fp_cloexec", NO_NUM);
|
2005-05-13 10:57:08 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* The following initializations are needed to let dev_opcl succeed .*/
|
|
|
|
fp = (struct fproc *) NULL;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
who_e = who_p = FS_PROC_NR;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
buf_pool(); /* initialize buffer pool */
|
2005-08-05 20:57:20 +02:00
|
|
|
build_dmap(); /* build device table and map boot driver */
|
2006-03-10 17:10:05 +01:00
|
|
|
init_root(); /* init root device and load super block */
|
2005-07-22 20:28:32 +02:00
|
|
|
init_select(); /* init select() structures */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-02 14:43:21 +02:00
|
|
|
/* The root device can now be accessed; set process directories. */
|
|
|
|
for (rfp=&fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
|
2006-03-09 17:00:33 +01:00
|
|
|
FD_ZERO(&(rfp->fp_filp_inuse));
|
2005-06-02 14:43:21 +02:00
|
|
|
if (rfp->fp_pid != PID_FREE) {
|
|
|
|
rip = get_inode(root_dev, ROOT_INODE);
|
|
|
|
dup_inode(rip);
|
|
|
|
rfp->fp_rootdir = rip;
|
|
|
|
rfp->fp_workdir = rip;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
} else rfp->fp_endpoint = NONE;
|
2005-06-02 14:43:21 +02:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* igetenv *
|
|
|
|
*===========================================================================*/
|
2005-07-22 20:28:32 +02:00
|
|
|
PRIVATE int igetenv(key, optional)
|
2005-04-21 16:53:53 +02:00
|
|
|
char *key;
|
2005-07-22 20:28:32 +02:00
|
|
|
int optional;
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Ask kernel for an integer valued boot environment variable. */
|
|
|
|
char value[64];
|
|
|
|
int i;
|
|
|
|
|
2005-08-05 18:21:32 +02:00
|
|
|
if ((i = env_get_param(key, value, sizeof(value))) != OK) {
|
2005-09-11 18:45:46 +02:00
|
|
|
if (!optional)
|
2005-07-22 20:28:32 +02:00
|
|
|
printf("FS: Warning, couldn't get monitor param: %d\n", i);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
return(atoi(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2006-03-10 17:10:05 +01:00
|
|
|
* init_root *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
2006-03-10 17:10:05 +01:00
|
|
|
PRIVATE void init_root()
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2006-03-10 17:10:05 +01:00
|
|
|
int bad;
|
|
|
|
register struct super_block *sp;
|
|
|
|
register struct inode *rip;
|
2005-08-25 14:30:43 +02:00
|
|
|
int s;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Open the root device. */
|
2006-03-10 17:10:05 +01:00
|
|
|
root_dev = DEV_IMGRD;
|
|
|
|
if ((s=dev_open(root_dev, FS_PROC_NR, R_BIT|W_BIT)) != OK)
|
|
|
|
panic(__FILE__,"Cannot open root device", s);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#if ENABLE_CACHE2
|
|
|
|
/* The RAM disk is a second level block cache while not otherwise used. */
|
|
|
|
init_cache2(ram_size);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize the super_block table. */
|
|
|
|
for (sp = &super_block[0]; sp < &super_block[NR_SUPERS]; sp++)
|
|
|
|
sp->s_dev = NO_DEV;
|
|
|
|
|
|
|
|
/* Read in super_block for the root file system. */
|
|
|
|
sp = &super_block[0];
|
2006-03-10 17:10:05 +01:00
|
|
|
sp->s_dev = root_dev;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Check super_block for consistency. */
|
|
|
|
bad = (read_super(sp) != OK);
|
|
|
|
if (!bad) {
|
2006-03-10 17:10:05 +01:00
|
|
|
rip = get_inode(root_dev, ROOT_INODE); /* inode for root dir */
|
2005-04-21 16:53:53 +02:00
|
|
|
if ( (rip->i_mode & I_TYPE) != I_DIRECTORY || rip->i_nlinks < 3) bad++;
|
|
|
|
}
|
2005-06-01 16:31:00 +02:00
|
|
|
if (bad) panic(__FILE__,"Invalid root file system", NO_NUM);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
sp->s_imount = rip;
|
|
|
|
dup_inode(rip);
|
|
|
|
sp->s_isup = rip;
|
|
|
|
sp->s_rd_only = 0;
|
|
|
|
return;
|
|
|
|
}
|