1 #include "fs.h" 2 #include "buf.h" 3 #include "inode.h" 4 #include "super.h" 5 6 7 /*===========================================================================* 8 * no_sys * 9 *===========================================================================*/ 10 int no_sys() 11 { 12 /* Somebody has used an illegal system call number */ 13 printf("no_sys: invalid call %d\n", req_nr); 14 return(EINVAL); 15 } 16 17 18 /*===========================================================================* 19 * conv2 * 20 *===========================================================================*/ 21 unsigned conv2(norm, w) 22 int norm; /* TRUE if no swap, FALSE for byte swap */ 23 int w; /* promotion of 16-bit word to be swapped */ 24 { 25 /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */ 26 if (norm) return( (unsigned) w & 0xFFFF); 27 return( ((w&BYTE) << 8) | ( (w>>8) & BYTE)); 28 } 29 30 31 /*===========================================================================* 32 * conv4 * 33 *===========================================================================*/ 34 long conv4(norm, x) 35 int norm; /* TRUE if no swap, FALSE for byte swap */ 36 long x; /* 32-bit long to be byte swapped */ 37 { 38 /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */ 39 unsigned lo, hi; 40 long l; 41 42 if (norm) return(x); /* byte order was already ok */ 43 lo = conv2(FALSE, (int) x & 0xFFFF); /* low-order half, byte swapped */ 44 hi = conv2(FALSE, (int) (x>>16) & 0xFFFF); /* high-order half, swapped */ 45 l = ( (long) lo <<16) | hi; 46 return(l); 47 } 48 49 50 /*===========================================================================* 51 * clock_time * 52 *===========================================================================*/ 53 time_t clock_time() 54 { 55 /* This routine returns the time in seconds since 1.1.1970. MINIX is an 56 * astrophysically naive system that assumes the earth rotates at a constant 57 * rate and that such things as leap seconds do not exist. 58 */ 59 60 register int k; 61 clock_t uptime; 62 clock_t realtime; 63 time_t boottime; 64 65 if ( (k=getuptime(&uptime, &realtime, &boottime)) != OK) 66 panic("clock_time: getuptme2 failed: %d", k); 67 68 return( (time_t) (boottime + (realtime/sys_hz()))); 69 } 70 71 72 /*===========================================================================* 73 * mfs_min * 74 *===========================================================================*/ 75 int min(unsigned int l, unsigned int r) 76 { 77 if(r >= l) return(l); 78 79 return(r); 80 } 81 82 83 /*===========================================================================* 84 * mfs_nul * 85 *===========================================================================*/ 86 void mfs_nul_f(char *file, int line, char *str, unsigned int len, 87 unsigned int maxlen) 88 { 89 if(len < maxlen && str[len-1] != '\0') { 90 printf("MFS %s:%d string (length %d, maxlen %d) not null-terminated\n", 91 file, line, len, maxlen); 92 } 93 } 94 95 #define MYASSERT(c) if(!(c)) { printf("MFS:%s:%d: sanity check: %s failed\n", \ 96 file, line, #c); panic("sanity check " #c " failed: %d", __LINE__); } 97 98