5 #include <minix/callnr.h>
10 #include <minix/vfsif.h>
13 /*===========================================================================*
15 *===========================================================================*/
18 /* Somebody has used an illegal system call number */
19 printf("no_sys: invalid call %d\n", req_nr
);
24 /*===========================================================================*
26 *===========================================================================*/
27 PUBLIC
unsigned conv2(norm
, w
)
28 int norm
; /* TRUE if no swap, FALSE for byte swap */
29 int w
; /* promotion of 16-bit word to be swapped */
31 /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
32 if (norm
) return( (unsigned) w
& 0xFFFF);
33 return( ((w
&BYTE
) << 8) | ( (w
>>8) & BYTE
));
37 /*===========================================================================*
39 *===========================================================================*/
40 PUBLIC
long conv4(norm
, x
)
41 int norm
; /* TRUE if no swap, FALSE for byte swap */
42 long x
; /* 32-bit long to be byte swapped */
44 /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
48 if (norm
) return(x
); /* byte order was already ok */
49 lo
= conv2(FALSE
, (int) x
& 0xFFFF); /* low-order half, byte swapped */
50 hi
= conv2(FALSE
, (int) (x
>>16) & 0xFFFF); /* high-order half, swapped */
51 l
= ( (long) lo
<<16) | hi
;
56 /*===========================================================================*
58 *===========================================================================*/
59 PUBLIC
time_t clock_time()
61 /* This routine returns the time in seconds since 1.1.1970. MINIX is an
62 * astrophysically naive system that assumes the earth rotates at a constant
63 * rate and that such things as leap seconds do not exist.
70 if ( (k
=getuptime2(&uptime
,&boottime
)) != OK
)
71 panic(__FILE__
,"clock_time: getuptme2 failed", k
);
73 if ( (k
=getuptime(&uptime
)) != OK
)
74 panic(__FILE__
,"clock_time err", k
);
77 return( (time_t) (boottime
+ (uptime
/sys_hz())));
81 /*===========================================================================*
83 *===========================================================================*/
84 PUBLIC
int mfs_min_f(char *file
, int line
, int v1
, int v2
)
86 if(v1
< 0 || v2
< 0) {
87 printf("mfs:%s:%d: strange string lengths: %d, %d\n",
89 panic(file
, "strange string lengths", NO_NUM
);
91 if(v2
>= v1
) return v1
;
97 /*===========================================================================*
99 *===========================================================================*/
100 PUBLIC
void mfs_nul_f(char *file
, int line
, char *str
, int len
, int maxlen
)
103 printf("mfs:%s:%d: %d-length string?!\n", file
, line
, len
);
104 panic(file
, "strange string length", NO_NUM
);
106 if(len
< maxlen
&& str
[len
-1] != '\0') {
107 printf("mfs:%s:%d: string (length %d, maxlen %d) "
108 "not null-terminated\n",
109 file
, line
, len
, maxlen
);
113 #define MYASSERT(c) if(!(c)) { printf("MFS:%s:%d: sanity check: %s failed\n", \
114 file, line, #c); panic("MFS", "sanity check " #c " failed", __LINE__); }
117 /*===========================================================================*
119 *===========================================================================*/
120 PUBLIC
void sanitycheck(char *file
, int line
)
122 MYASSERT(SELF_E
> 0);
123 if(superblock
.s_dev
!= NO_DEV
) {
124 MYASSERT(superblock
.s_dev
== fs_dev
);
125 MYASSERT(superblock
.s_block_size
== fs_block_size
);
127 MYASSERT(_MIN_BLOCK_SIZE
== fs_block_size
);