2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#include "fs.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/com.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/callnr.h>
|
2007-10-23 16:17:51 +02:00
|
|
|
#include <stdlib.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "buf.h"
|
|
|
|
#include "inode.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "super.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
static int panicking;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* no_sys *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int no_sys()
|
|
|
|
{
|
|
|
|
/* Somebody has used an illegal system call number */
|
2007-08-07 14:38:35 +02:00
|
|
|
printf("no_sys: invalid call %d\n", req_nr);
|
2005-04-21 16:53:53 +02:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* panic *
|
|
|
|
*===========================================================================*/
|
2005-06-01 16:31:00 +02:00
|
|
|
PUBLIC void panic(who, mess, num)
|
|
|
|
char *who; /* who caused the panic */
|
|
|
|
char *mess; /* panic message string */
|
|
|
|
int num; /* number to go with it */
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Something awful has happened. Panics are caused when an internal
|
|
|
|
* inconsistency is detected, e.g., a programming error or illegal value of a
|
|
|
|
* defined constant.
|
|
|
|
*/
|
2007-10-23 16:17:51 +02:00
|
|
|
if (!panicking) { /* do not panic during a sync */
|
|
|
|
panicking = TRUE; /* prevent another panic during the sync */
|
|
|
|
|
|
|
|
printf("MFS panic (%s): %s ", who, mess);
|
|
|
|
if (num != NO_NUM) printf("%d",num);
|
|
|
|
printf("\n");
|
|
|
|
(void) fs_sync(); /* flush everything to the disk */
|
|
|
|
} else printf("MFS re-panic\n");
|
|
|
|
exit(1);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* conv2 *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC unsigned conv2(norm, w)
|
|
|
|
int norm; /* TRUE if no swap, FALSE for byte swap */
|
|
|
|
int w; /* promotion of 16-bit word to be swapped */
|
|
|
|
{
|
|
|
|
/* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
|
|
|
|
if (norm) return( (unsigned) w & 0xFFFF);
|
|
|
|
return( ((w&BYTE) << 8) | ( (w>>8) & BYTE));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* conv4 *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC long conv4(norm, x)
|
|
|
|
int norm; /* TRUE if no swap, FALSE for byte swap */
|
|
|
|
long x; /* 32-bit long to be byte swapped */
|
|
|
|
{
|
|
|
|
/* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
|
|
|
|
unsigned lo, hi;
|
|
|
|
long l;
|
|
|
|
|
|
|
|
if (norm) return(x); /* byte order was already ok */
|
|
|
|
lo = conv2(FALSE, (int) x & 0xFFFF); /* low-order half, byte swapped */
|
|
|
|
hi = conv2(FALSE, (int) (x>>16) & 0xFFFF); /* high-order half, swapped */
|
|
|
|
l = ( (long) lo <<16) | hi;
|
|
|
|
return(l);
|
|
|
|
}
|
2005-05-13 10:57:08 +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
|
|
|
/*===========================================================================*
|
2006-10-25 15:40:36 +02:00
|
|
|
* clock_time *
|
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
|
|
|
*===========================================================================*/
|
2006-10-25 15:40:36 +02:00
|
|
|
PUBLIC time_t clock_time()
|
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
|
|
|
{
|
2006-10-25 15:40:36 +02:00
|
|
|
/* This routine returns the time in seconds since 1.1.1970. MINIX is an
|
|
|
|
* astrophysically naive system that assumes the earth rotates at a constant
|
|
|
|
* rate and that such things as leap seconds do not exist.
|
|
|
|
*/
|
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
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
register int k;
|
|
|
|
clock_t uptime;
|
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
|
|
|
|
2007-08-07 14:38:35 +02:00
|
|
|
if (use_getuptime2)
|
|
|
|
{
|
|
|
|
if ( (k=getuptime2(&uptime,&boottime)) != OK)
|
|
|
|
panic(__FILE__,"clock_time: getuptme2 failed", k);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( (k=getuptime(&uptime)) != OK)
|
|
|
|
panic(__FILE__,"clock_time err", k);
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
return( (time_t) (boottime + (uptime/HZ)));
|
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
|
|
|
}
|
|
|
|
|
2007-01-16 15:50:10 +01:00
|
|
|
int mfs_min_f(char *file, int line, int v1, int v2)
|
|
|
|
{
|
2007-01-22 16:25:41 +01:00
|
|
|
if(v1 < 0 || v2 < 0) {
|
|
|
|
printf("mfs:%s:%d: strange string lengths: %d, %d\n",
|
|
|
|
file, line, v1, v2);
|
|
|
|
panic(file, "strange string lengths", NO_NUM);
|
|
|
|
}
|
2007-01-16 15:50:10 +01:00
|
|
|
if(v2 >= v1) return v1;
|
2007-04-13 16:00:31 +02:00
|
|
|
#if 0
|
2007-01-16 15:50:10 +01:00
|
|
|
printf("mfs:%s:%d: truncated %d to %d\n",
|
|
|
|
file, line, v1, v2);
|
2007-04-13 16:00:31 +02:00
|
|
|
#endif
|
2007-01-16 15:50:10 +01:00
|
|
|
return v2;
|
|
|
|
}
|
2007-01-22 16:25:41 +01:00
|
|
|
|
|
|
|
void mfs_nul_f(char *file, int line, char *str, int len, int maxlen)
|
|
|
|
{
|
|
|
|
if(len < 1) {
|
|
|
|
printf("mfs:%s:%d: %d-length string?!\n", file, line, len);
|
|
|
|
panic(file, "strange string length", NO_NUM);
|
|
|
|
}
|
|
|
|
if(len < maxlen && str[len-1] != '\0') {
|
|
|
|
printf("mfs:%s:%d: string (length %d, maxlen %d) "
|
|
|
|
"not null-terminated\n",
|
|
|
|
file, line, len, maxlen);
|
|
|
|
}
|
|
|
|
}
|