6 #include <minix/callnr.h>
12 #include <minix/vfsif.h>
16 /*===========================================================================*
18 *===========================================================================*/
21 /* Somebody has used an illegal system call number */
25 /*===========================================================================*
27 *===========================================================================*/
28 PUBLIC
void panic(who
, mess
, num
)
29 char *who
; /* who caused the panic */
30 char *mess
; /* panic message string */
31 int num
; /* number to go with it */
33 /* Something awful has happened. Panics are caused when an internal
34 * inconsistency is detected, e.g., a programming error or illegal value of a
37 if (panicking
) return; /* do not panic during a sync */
38 panicking
= TRUE
; /* prevent another panic during the sync */
40 printf("FS panic (%s): %s ", who
, mess
);
41 if (num
!= NO_NUM
) printf("%d",num
);
42 (void) fs_sync(); /* flush everything to the disk */
46 /*===========================================================================*
48 *===========================================================================*/
49 PUBLIC
unsigned conv2(norm
, w
)
50 int norm
; /* TRUE if no swap, FALSE for byte swap */
51 int w
; /* promotion of 16-bit word to be swapped */
53 /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
54 if (norm
) return( (unsigned) w
& 0xFFFF);
55 return( ((w
&BYTE
) << 8) | ( (w
>>8) & BYTE
));
58 /*===========================================================================*
60 *===========================================================================*/
61 PUBLIC
long conv4(norm
, x
)
62 int norm
; /* TRUE if no swap, FALSE for byte swap */
63 long x
; /* 32-bit long to be byte swapped */
65 /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
69 if (norm
) return(x
); /* byte order was already ok */
70 lo
= conv2(FALSE
, (int) x
& 0xFFFF); /* low-order half, byte swapped */
71 hi
= conv2(FALSE
, (int) (x
>>16) & 0xFFFF); /* high-order half, swapped */
72 l
= ( (long) lo
<<16) | hi
;
76 /*===========================================================================*
78 *===========================================================================*/
79 PUBLIC
time_t clock_time()
81 /* This routine returns the time in seconds since 1.1.1970. MINIX is an
82 * astrophysically naive system that assumes the earth rotates at a constant
83 * rate and that such things as leap seconds do not exist.
89 if ( (k
=getuptime(&uptime
)) != OK
) panic(__FILE__
,"clock_time err", k
);
90 return( (time_t) (boottime
+ (uptime
/HZ
)));
93 int mfs_min_f(char *file
, int line
, int v1
, int v2
)
95 if(v1
< 0 || v2
< 0) {
96 printf("mfs:%s:%d: strange string lengths: %d, %d\n",
98 panic(file
, "strange string lengths", NO_NUM
);
100 if(v2
>= v1
) return v1
;
101 printf("mfs:%s:%d: truncated %d to %d\n",
106 void mfs_nul_f(char *file
, int line
, char *str
, int len
, int maxlen
)
109 printf("mfs:%s:%d: %d-length string?!\n", file
, line
, len
);
110 panic(file
, "strange string length", NO_NUM
);
112 if(len
< maxlen
&& str
[len
-1] != '\0') {
113 printf("mfs:%s:%d: string (length %d, maxlen %d) "
114 "not null-terminated\n",
115 file
, line
, len
, maxlen
);