Formatting fixes for the book

This commit is contained in:
Ben Gras 2005-08-29 16:47:18 +00:00
parent ed84c34c6b
commit 911ff6a873
25 changed files with 165 additions and 125 deletions

View file

@ -62,9 +62,14 @@ _PROTOTYPE( void check_runqueues, (char *when) );
*/ */
#if (DEBUG_TIME_LOCKS || DEBUG_LOCK_CHECK) #if (DEBUG_TIME_LOCKS || DEBUG_LOCK_CHECK)
# undef lock # undef lock
# define lock(c, v) do { lockcheck; intr_disable(); locktimestart(c, v); } while(0) # define lock(c, v) do { lockcheck; \
intr_disable(); \
locktimestart(c, v); \
} while(0)
# undef unlock # undef unlock
# define unlock(c) do { locktimeend(c); intr_enable(); } while(0) # define unlock(c) do { locktimeend(c); \
intr_enable();\
} while(0)
#endif #endif
#endif /* DEBUG_H */ #endif /* DEBUG_H */

View file

@ -2,7 +2,7 @@
* Together with "mpx.s" it forms the lowest layer of the MINIX kernel. * Together with "mpx.s" it forms the lowest layer of the MINIX kernel.
* There is one entry point from the outside: * There is one entry point from the outside:
* *
* sys_call: a system call, i.e., the kernel is trapped with an INT * sys_call: a system call, i.e., the kernel is trapped with an INT
* *
* As well as several entry points used from the interrupt and task level: * As well as several entry points used from the interrupt and task level:
* *
@ -73,7 +73,8 @@ FORWARD _PROTOTYPE( void pick_proc, (void) );
#if (CHIP == INTEL) #if (CHIP == INTEL)
#define CopyMess(s,sp,sm,dp,dm) \ #define CopyMess(s,sp,sm,dp,dm) \
cp_mess(s, (sp)->p_memmap[D].mem_phys, (vir_bytes)sm, (dp)->p_memmap[D].mem_phys, (vir_bytes)dm) cp_mess(s, (sp)->p_memmap[D].mem_phys, \
(vir_bytes)sm, (dp)->p_memmap[D].mem_phys, (vir_bytes)dm)
#endif /* (CHIP == INTEL) */ #endif /* (CHIP == INTEL) */
#if (CHIP == M68000) #if (CHIP == M68000)
@ -106,7 +107,8 @@ message *m_ptr; /* pointer to message in the caller's space */
* if the caller doesn't do receive(). * if the caller doesn't do receive().
*/ */
if (! (priv(caller_ptr)->s_trap_mask & (1 << function)) || if (! (priv(caller_ptr)->s_trap_mask & (1 << function)) ||
(iskerneln(src_dst) && function != SENDREC && function != RECEIVE)) { (iskerneln(src_dst) && function != SENDREC
&& function != RECEIVE)) {
kprintf("sys_call: trap %d not allowed, caller %d, src_dst %d\n", kprintf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
function, proc_nr(caller_ptr), src_dst); function, proc_nr(caller_ptr), src_dst);
return(ECALLDENIED); /* trap denied by mask or kernel */ return(ECALLDENIED); /* trap denied by mask or kernel */

View file

@ -145,8 +145,10 @@ PUBLIC void prot_init()
* (u32_t *) dtp->base = vir2phys(idt); * (u32_t *) dtp->base = vir2phys(idt);
/* Build segment descriptors for tasks and interrupt handlers. */ /* Build segment descriptors for tasks and interrupt handlers. */
init_codeseg(&gdt[CS_INDEX], kinfo.code_base, kinfo.code_size, INTR_PRIVILEGE); init_codeseg(&gdt[CS_INDEX],
init_dataseg(&gdt[DS_INDEX], kinfo.data_base, kinfo.data_size, INTR_PRIVILEGE); kinfo.code_base, kinfo.code_size, INTR_PRIVILEGE);
init_dataseg(&gdt[DS_INDEX],
kinfo.data_base, kinfo.data_size, INTR_PRIVILEGE);
init_dataseg(&gdt[ES_INDEX], 0L, 0, TASK_PRIVILEGE); init_dataseg(&gdt[ES_INDEX], 0L, 0, TASK_PRIVILEGE);
/* Build scratch descriptors for functions in klib88. */ /* Build scratch descriptors for functions in klib88. */

View file

@ -32,8 +32,8 @@
#define CS_SELECTOR 0x30 /* (CS_INDEX * DESC_SIZE) */ #define CS_SELECTOR 0x30 /* (CS_INDEX * DESC_SIZE) */
#define MON_CS_SELECTOR 0x38 /* (MON_CS_INDEX * DESC_SIZE) */ #define MON_CS_SELECTOR 0x38 /* (MON_CS_INDEX * DESC_SIZE) */
#define TSS_SELECTOR 0x40 /* (TSS_INDEX * DESC_SIZE) */ #define TSS_SELECTOR 0x40 /* (TSS_INDEX * DESC_SIZE) */
#define DS_286_SELECTOR 0x49 /* (DS_286_INDEX*DESC_SIZE + TASK_PRIVILEGE) */ #define DS_286_SELECTOR 0x49 /* (DS_286_INDEX*DESC_SIZE+TASK_PRIVILEGE) */
#define ES_286_SELECTOR 0x51 /* (ES_286_INDEX*DESC_SIZE + TASK_PRIVILEGE) */ #define ES_286_SELECTOR 0x51 /* (ES_286_INDEX*DESC_SIZE+TASK_PRIVILEGE) */
/* Fixed local descriptors. */ /* Fixed local descriptors. */
#define CS_LDT_INDEX 0 /* process CS */ #define CS_LDT_INDEX 0 /* process CS */
@ -113,12 +113,12 @@
#define PAGE_GRAN_SHIFT 12 /* extra shift for page granular limits */ #define PAGE_GRAN_SHIFT 12 /* extra shift for page granular limits */
/* Type-byte bits. */ /* Type-byte bits. */
#define DESC_386_BIT 0x08 /* 386 types are obtained by ORing with this */ #define DESC_386_BIT 0x08 /* 386 types are obtained by ORing with this */
/* LDT's and TASK_GATE's don't need it */ /* LDT's and TASK_GATE's don't need it */
/* Granularity byte. */ /* Granularity byte. */
#define GRANULAR 0x80 /* set for 4K granularilty */ #define GRANULAR 0x80 /* set for 4K granularilty */
#define DEFAULT 0x40 /* set for 32-bit defaults (executable seg) */ #define DEFAULT 0x40 /* set for 32-bit defaults (executable seg) */
#define BIG 0x40 /* set for "BIG" (expand-down seg) */ #define BIG 0x40 /* set for "BIG" (expand-down seg) */
#define AVL 0x10 /* 0 for available */ #define AVL 0x10 /* 0 for available */
#define LIMIT_HIGH 0x0F /* mask for high bits of limit */ #define LIMIT_HIGH 0x0F /* mask for high bits of limit */

View file

@ -402,7 +402,7 @@ vir_bytes bytes; /* # of bytes to copy */
/* Copy bytes from virtual address src_addr to virtual address dst_addr. /* Copy bytes from virtual address src_addr to virtual address dst_addr.
* Virtual addresses can be in ABS, LOCAL_SEG, REMOTE_SEG, or BIOS_SEG. * Virtual addresses can be in ABS, LOCAL_SEG, REMOTE_SEG, or BIOS_SEG.
*/ */
struct vir_addr *vir_addr[2]; /* virtual source and destination address */ struct vir_addr *vir_addr[2]; /* virtual source and destination address */
phys_bytes phys_addr[2]; /* absolute source and destination */ phys_bytes phys_addr[2]; /* absolute source and destination */
int seg_index; int seg_index;
int i; int i;

View file

@ -66,10 +66,10 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
* structure 0 is shared by user processes. * structure 0 is shared by user processes.
*/ */
#define s(n) (1 << s_nr_to_id(n)) #define s(n) (1 << s_nr_to_id(n))
#define SRV_M (~0) #define SRV_M (~0)
#define SYS_M (~0) #define SYS_M (~0)
#define USR_M (s(PM_PROC_NR) | s(FS_PROC_NR) | s(RS_PROC_NR)) #define USR_M (s(PM_PROC_NR) | s(FS_PROC_NR) | s(RS_PROC_NR))
#define DRV_M (USR_M | s(SYSTEM) | s(CLOCK) | s(LOG_PROC_NR) | s(TTY_PROC_NR)) #define DRV_M (USR_M | s(SYSTEM) | s(CLOCK) | s(LOG_PROC_NR) | s(TTY_PROC_NR))
/* Define kernel calls that processes are allowed to make. This is not looking /* Define kernel calls that processes are allowed to make. This is not looking
* very nice, but we need to define the access rights on a per call basis. * very nice, but we need to define the access rights on a per call basis.
@ -89,7 +89,7 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
/* The system image table lists all programs that are part of the boot image. /* The system image table lists all programs that are part of the boot image.
* The order of the entries here MUST agree with the order of the programs * The order of the entries here MUST agree with the order of the programs
* in the boot image and all kernel tasks must come first. * in the boot image and all kernel tasks must come first.
* Each entry provides the process number, flags, quantum size (qs), scheduling * Each entry provides the process number, flags, quantum size (qs), scheduling
* queue, allowed traps, ipc mask, and a name for the process table. The * queue, allowed traps, ipc mask, and a name for the process table. The
* initial program counter and stack size is also provided for kernel tasks. * initial program counter and stack size is also provided for kernel tasks.
*/ */
@ -116,6 +116,7 @@ PUBLIC struct boot_image image[] = {
* causing a compile time error. Note that no space is actually allocated * causing a compile time error. Note that no space is actually allocated
* because 'dummy' is declared extern. * because 'dummy' is declared extern.
*/ */
extern int dummy[(NR_BOOT_PROCS==sizeof(image)/sizeof(struct boot_image))?1:-1]; extern int dummy[(NR_BOOT_PROCS==sizeof(image)/
sizeof(struct boot_image))?1:-1];
extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1]; extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1];

View file

@ -18,12 +18,18 @@ EXTERN struct buf {
/* Data portion of the buffer. */ /* Data portion of the buffer. */
union { union {
char b__data[MAX_BLOCK_SIZE]; /* ordinary user data */ char b__data[MAX_BLOCK_SIZE]; /* ordinary user data */
struct direct b__dir[NR_DIR_ENTRIES(MAX_BLOCK_SIZE)]; /* directory block */ /* directory block */
zone1_t b__v1_ind[V1_INDIRECTS]; /* V1 indirect block */ struct direct b__dir[NR_DIR_ENTRIES(MAX_BLOCK_SIZE)];
zone_t b__v2_ind[V2_INDIRECTS(MAX_BLOCK_SIZE)]; /* V2 indirect block */ /* V1 indirect block */
d1_inode b__v1_ino[V1_INODES_PER_BLOCK]; /* V1 inode block */ zone1_t b__v1_ind[V1_INDIRECTS];
d2_inode b__v2_ino[V2_INODES_PER_BLOCK(MAX_BLOCK_SIZE)]; /* V2 inode block */ /* V2 indirect block */
bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(MAX_BLOCK_SIZE)]; /* bit map block */ zone_t b__v2_ind[V2_INDIRECTS(MAX_BLOCK_SIZE)];
/* V1 inode block */
d1_inode b__v1_ino[V1_INODES_PER_BLOCK];
/* V2 inode block */
d2_inode b__v2_ino[V2_INODES_PER_BLOCK(MAX_BLOCK_SIZE)];
/* bit map block */
bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(MAX_BLOCK_SIZE)];
} b; } b;
/* Header portion of the buffer. */ /* Header portion of the buffer. */
@ -56,8 +62,8 @@ EXTERN struct buf *rear; /* points to most recently used free block */
EXTERN int bufs_in_use; /* # bufs currently in use (not on free list)*/ EXTERN int bufs_in_use; /* # bufs currently in use (not on free list)*/
/* When a block is released, the type of usage is passed to put_block(). */ /* When a block is released, the type of usage is passed to put_block(). */
#define WRITE_IMMED 0100 /* block should be written to disk now */ #define WRITE_IMMED 0100 /* block should be written to disk now */
#define ONE_SHOT 0200 /* set if block not likely to be needed soon */ #define ONE_SHOT 0200 /* set if block not likely to be needed soon */
#define INODE_BLOCK 0 /* inode block */ #define INODE_BLOCK 0 /* inode block */
#define DIRECTORY_BLOCK 1 /* directory block */ #define DIRECTORY_BLOCK 1 /* directory block */

View file

@ -43,10 +43,10 @@
#define DUP_MASK 0100 /* mask to distinguish dup2 from dup */ #define DUP_MASK 0100 /* mask to distinguish dup2 from dup */
#define LOOK_UP 0 /* tells search_dir to lookup string */ #define LOOK_UP 0 /* tells search_dir to lookup string */
#define ENTER 1 /* tells search_dir to make dir entry */ #define ENTER 1 /* tells search_dir to make dir entry */
#define DELETE 2 /* tells search_dir to delete entry */ #define DELETE 2 /* tells search_dir to delete entry */
#define IS_EMPTY 3 /* tells search_dir to ret. OK or ENOTEMPTY */ #define IS_EMPTY 3 /* tells search_dir to ret. OK or ENOTEMPTY */
#define CLEAN 0 /* disk and memory copies identical */ #define CLEAN 0 /* disk and memory copies identical */
#define DIRTY 1 /* disk and memory copies differ */ #define DIRTY 1 /* disk and memory copies differ */
@ -75,8 +75,12 @@
/* Derived sizes pertaining to the V1 file system. */ /* Derived sizes pertaining to the V1 file system. */
#define V1_ZONE_NUM_SIZE usizeof (zone1_t) /* # bytes in V1 zone */ #define V1_ZONE_NUM_SIZE usizeof (zone1_t) /* # bytes in V1 zone */
#define V1_INODE_SIZE usizeof (d1_inode) /* bytes in V1 dsk ino */ #define V1_INODE_SIZE usizeof (d1_inode) /* bytes in V1 dsk ino */
#define V1_INDIRECTS (STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE) /* # zones/indir block */
#define V1_INODES_PER_BLOCK (STATIC_BLOCK_SIZE/V1_INODE_SIZE)/* # V1 dsk inodes/blk */ /* # zones/indir block */
#define V1_INDIRECTS (STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE)
/* # V1 dsk inodes/blk */
#define V1_INODES_PER_BLOCK (STATIC_BLOCK_SIZE/V1_INODE_SIZE)
/* Derived sizes pertaining to the V2 file system. */ /* Derived sizes pertaining to the V2 file system. */
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */ #define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */

View file

@ -3,7 +3,8 @@
* them from the disk. * them from the disk.
* *
* The entry points into this file are * The entry points into this file are
* get_inode: search inode table for a given inode; if not there, read it * get_inode: search inode table for a given inode; if not there,
* read it
* put_inode: indicate that an inode is no longer needed in memory * put_inode: indicate that an inode is no longer needed in memory
* alloc_inode: allocate a new, unused inode * alloc_inode: allocate a new, unused inode
* wipe_inode: erase some fields of a newly allocated inode * wipe_inode: erase some fields of a newly allocated inode
@ -241,7 +242,8 @@ int rw_flag; /* READING or WRITING */
b = (block_t) (rip->i_num - 1)/sp->s_inodes_per_block + offset; b = (block_t) (rip->i_num - 1)/sp->s_inodes_per_block + offset;
bp = get_block(rip->i_dev, b, NORMAL); bp = get_block(rip->i_dev, b, NORMAL);
dip = bp->b_v1_ino + (rip->i_num - 1) % V1_INODES_PER_BLOCK; dip = bp->b_v1_ino + (rip->i_num - 1) % V1_INODES_PER_BLOCK;
dip2 = bp->b_v2_ino + (rip->i_num - 1) % V2_INODES_PER_BLOCK(sp->s_block_size); dip2 = bp->b_v2_ino + (rip->i_num - 1) %
V2_INODES_PER_BLOCK(sp->s_block_size);
/* Do the read or write. */ /* Do the read or write. */
if (rw_flag == WRITING) { if (rw_flag == WRITING) {

View file

@ -17,7 +17,7 @@ EXTERN struct inode {
time_t i_atime; /* time of last access (V2 only) */ time_t i_atime; /* time of last access (V2 only) */
time_t i_mtime; /* when was file data last changed */ time_t i_mtime; /* when was file data last changed */
time_t i_ctime; /* when was inode itself changed (V2 only)*/ time_t i_ctime; /* when was inode itself changed (V2 only)*/
zone_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */ zone_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */
/* The following items are not present on the disk. */ /* The following items are not present on the disk. */
dev_t i_dev; /* which device is the inode on */ dev_t i_dev; /* which device is the inode on */

View file

@ -78,8 +78,8 @@ PUBLIC int main()
printf("FS, warning illegal %d system call by %d\n", call_nr, who); printf("FS, warning illegal %d system call by %d\n", call_nr, who);
} else if (fp->fp_pid == PID_FREE) { } else if (fp->fp_pid == PID_FREE) {
error = ENOSYS; error = ENOSYS;
printf("FS, bad process, who = %d, call_nr = %d, slot1 = %d\n", who, call_nr, m_in.slot1); printf("FS, bad process, who = %d, call_nr = %d, slot1 = %d\n",
who, call_nr, m_in.slot1);
} else { } else {
error = (*call_vec[call_nr])(); error = (*call_vec[call_nr])();
} }
@ -212,7 +212,8 @@ PRIVATE void fs_init()
if (NR_BUFS < 6) panic(__FILE__,"NR_BUFS < 6", 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 (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); if (V2_INODE_SIZE != 64) panic(__FILE__,"V2 inode size != 64", NO_NUM);
if (OPEN_MAX > 8 * sizeof(long)) panic(__FILE__,"Too few bits in fp_cloexec", NO_NUM); if (OPEN_MAX > 8 * sizeof(long))
panic(__FILE__,"Too few bits in fp_cloexec", NO_NUM);
/* The following initializations are needed to let dev_opcl succeed .*/ /* The following initializations are needed to let dev_opcl succeed .*/
fp = (struct fproc *) NULL; fp = (struct fproc *) NULL;
@ -373,7 +374,8 @@ PRIVATE void load_ram(void)
if(block_size_image % block_size_ram) { if(block_size_image % block_size_ram) {
printf("\nram block size: %d image block size: %d\n", printf("\nram block size: %d image block size: %d\n",
block_size_ram, block_size_image); block_size_ram, block_size_image);
panic(__FILE__, "ram disk block size must be a multiple of the image disk block size", NO_NUM); panic(__FILE__, "ram disk block size must be a multiple of "
"the image disk block size", NO_NUM);
} }
/* Loading blocks from image device. */ /* Loading blocks from image device. */

View file

@ -317,7 +317,8 @@ PUBLIC int do_mkdir()
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
ldirp = last_dir(user_path, string); /* pointer to new dir's parent */ ldirp = last_dir(user_path, string); /* pointer to new dir's parent */
if (ldirp == NIL_INODE) return(err_code); if (ldirp == NIL_INODE) return(err_code);
if (ldirp->i_nlinks >= (ldirp->i_sp->s_version == V1 ? CHAR_MAX : SHRT_MAX)) { if (ldirp->i_nlinks >= (ldirp->i_sp->s_version == V1 ?
CHAR_MAX : SHRT_MAX)) {
put_inode(ldirp); /* return parent */ put_inode(ldirp); /* return parent */
return(EMLINK); return(EMLINK);
} }

View file

@ -290,7 +290,9 @@ int flag; /* LOOK_UP, ENTER, DELETE or IS_EMPTY */
panic(__FILE__,"get_block returned NO_BLOCK", NO_NUM); panic(__FILE__,"get_block returned NO_BLOCK", NO_NUM);
/* Search a directory block. */ /* Search a directory block. */
for (dp = &bp->b_dir[0]; dp < &bp->b_dir[NR_DIR_ENTRIES(ldir_ptr->i_sp->s_block_size)]; dp++) { for (dp = &bp->b_dir[0];
dp < &bp->b_dir[NR_DIR_ENTRIES(ldir_ptr->i_sp->s_block_size)];
dp++) {
if (++new_slots > old_slots) { /* not found, but room left */ if (++new_slots > old_slots) { /* not found, but room left */
if (flag == ENTER) e_hit = TRUE; if (flag == ENTER) e_hit = TRUE;
break; break;

View file

@ -8,7 +8,8 @@
* do_pipe: perform the PIPE system call * do_pipe: perform the PIPE system call
* pipe_check: check to see that a read or write on a pipe is feasible now * pipe_check: check to see that a read or write on a pipe is feasible now
* suspend: suspend a process that cannot do a requested read or write * suspend: suspend a process that cannot do a requested read or write
* release: check to see if a suspended process can be released and do it * release: check to see if a suspended process can be released and do
* it
* revive: mark a suspended process as able to run again * revive: mark a suspended process as able to run again
* do_unpause: a signal has been sent to a process; see if it suspended * do_unpause: a signal has been sent to a process; see if it suspended
*/ */
@ -128,10 +129,13 @@ int notouch; /* check only */
} }
if (position + bytes > PIPE_SIZE(rip->i_sp->s_block_size)) { if (position + bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {
if ((oflags & O_NONBLOCK) && bytes < PIPE_SIZE(rip->i_sp->s_block_size)) if ((oflags & O_NONBLOCK)
&& bytes < PIPE_SIZE(rip->i_sp->s_block_size))
return(EAGAIN); return(EAGAIN);
else if ((oflags & O_NONBLOCK) && bytes > PIPE_SIZE(rip->i_sp->s_block_size)) { else if ((oflags & O_NONBLOCK)
if ( (*canwrite = (PIPE_SIZE(rip->i_sp->s_block_size) - position)) > 0) { && bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {
if ( (*canwrite = (PIPE_SIZE(rip->i_sp->s_block_size)
- position)) > 0) {
/* Do a partial write. Need to wakeup reader */ /* Do a partial write. Need to wakeup reader */
if(!notouch) if(!notouch)
release(rip, READ, susp_count); release(rip, READ, susp_count);
@ -141,7 +145,8 @@ int notouch; /* check only */
} }
} }
if (bytes > PIPE_SIZE(rip->i_sp->s_block_size)) { if (bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {
if ((*canwrite = PIPE_SIZE(rip->i_sp->s_block_size) - position) > 0) { if ((*canwrite = PIPE_SIZE(rip->i_sp->s_block_size)
- position) > 0) {
/* Do a partial write. Need to wakeup reader /* Do a partial write. Need to wakeup reader
* since we'll suspend ourself in read_write() * since we'll suspend ourself in read_write()
*/ */
@ -250,7 +255,8 @@ int returned; /* if hanging on task, how many bytes read */
register struct fproc *rfp; register struct fproc *rfp;
register int task; register int task;
if (proc_nr < 0 || proc_nr >= NR_PROCS) panic(__FILE__,"revive err", proc_nr); if (proc_nr < 0 || proc_nr >= NR_PROCS)
panic(__FILE__,"revive err", proc_nr);
rfp = &fproc[proc_nr]; rfp = &fproc[proc_nr];
if (rfp->fp_suspended == NOT_SUSPENDED || rfp->fp_revived == REVIVING)return; if (rfp->fp_suspended == NOT_SUSPENDED || rfp->fp_revived == REVIVING)return;
@ -295,7 +301,8 @@ PUBLIC int do_unpause()
if (who > PM_PROC_NR) return(EPERM); if (who > PM_PROC_NR) return(EPERM);
proc_nr = m_in.pro; proc_nr = m_in.pro;
if (proc_nr < 0 || proc_nr >= NR_PROCS) panic(__FILE__,"unpause err 1", proc_nr); if (proc_nr < 0 || proc_nr >= NR_PROCS)
panic(__FILE__,"unpause err 1", proc_nr);
rfp = &fproc[proc_nr]; rfp = &fproc[proc_nr];
if (rfp->fp_suspended == NOT_SUSPENDED) return(OK); if (rfp->fp_suspended == NOT_SUSPENDED) return(OK);
task = -rfp->fp_task; task = -rfp->fp_task;

View file

@ -22,8 +22,8 @@
#include "super.h" #include "super.h"
FORWARD _PROTOTYPE( int rw_chunk, (struct inode *rip, off_t position, FORWARD _PROTOTYPE( int rw_chunk, (struct inode *rip, off_t position,
unsigned off, int chunk, unsigned left, int rw_flag, unsigned off, int chunk, unsigned left, int rw_flag,
char *buff, int seg, int usr, int block_size, int *completed) ); char *buff, int seg, int usr, int block_size, int *completed));
/*===========================================================================* /*===========================================================================*
* do_read * * do_read *
@ -76,7 +76,8 @@ int rw_flag; /* READING or WRITING */
if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) { if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) {
return(f->filp_mode == FILP_CLOSED ? EIO : EBADF); return(f->filp_mode == FILP_CLOSED ? EIO : EBADF);
} }
if (m_in.nbytes == 0) return(0); /* so char special files need not check for 0*/ if (m_in.nbytes == 0)
return(0); /* so char special files need not check for 0*/
/* check if user process has the memory it needs. /* check if user process has the memory it needs.
* if not, copying will fail later. * if not, copying will fail later.
@ -101,13 +102,15 @@ int rw_flag; /* READING or WRITING */
if((char_spec = (mode_word == I_CHAR_SPECIAL ? 1 : 0))) { if((char_spec = (mode_word == I_CHAR_SPECIAL ? 1 : 0))) {
if(rip->i_zone[0] == NO_DEV) if(rip->i_zone[0] == NO_DEV)
panic(__FILE__,"read_write tries to read from character device NO_DEV", NO_NUM); panic(__FILE__,"read_write tries to read from "
"character device NO_DEV", NO_NUM);
block_size = get_block_size(rip->i_zone[0]); block_size = get_block_size(rip->i_zone[0]);
} }
if((block_spec = (mode_word == I_BLOCK_SPECIAL ? 1 : 0))) { if((block_spec = (mode_word == I_BLOCK_SPECIAL ? 1 : 0))) {
f_size = ULONG_MAX; f_size = ULONG_MAX;
if(rip->i_zone[0] == NO_DEV) if(rip->i_zone[0] == NO_DEV)
panic(__FILE__,"read_write tries to read from block device NO_DEV", NO_NUM); panic(__FILE__,"read_write tries to read from "
" block device NO_DEV", NO_NUM);
block_size = get_block_size(rip->i_zone[0]); block_size = get_block_size(rip->i_zone[0]);
} }
@ -246,7 +249,8 @@ int rw_flag; /* READING or WRITING */
/*===========================================================================* /*===========================================================================*
* rw_chunk * * rw_chunk *
*===========================================================================*/ *===========================================================================*/
PRIVATE int rw_chunk(rip, position, off, chunk, left, rw_flag, buff, seg, usr, block_size, completed) PRIVATE int rw_chunk(rip, position, off, chunk, left, rw_flag, buff,
seg, usr, block_size, completed)
register struct inode *rip; /* pointer to inode for file to be rd/wr */ register struct inode *rip; /* pointer to inode for file to be rd/wr */
off_t position; /* position within file to read or write */ off_t position; /* position within file to read or write */
unsigned off; /* off within the current block */ unsigned off; /* off within the current block */

View file

@ -9,13 +9,6 @@
* 6 june 2005 Created (Ben Gras) * 6 june 2005 Created (Ben Gras)
*/ */
/* TODO: check if close (pipe?) / exit works;
* some printf()s are serious errors;
* check combinations of cases listen in open group select
* spec (various NULLs and behaviours);
* make select cancel disappearing fp's
*/
#define DEBUG_SELECT 0 #define DEBUG_SELECT 0
#include "fs.h" #include "fs.h"
@ -53,11 +46,14 @@ PRIVATE struct selectentry {
FORWARD _PROTOTYPE(int select_reevaluate, (struct filp *fp)); FORWARD _PROTOTYPE(int select_reevaluate, (struct filp *fp));
FORWARD _PROTOTYPE(int select_request_file, (struct filp *f, int *ops, int block)); FORWARD _PROTOTYPE(int select_request_file,
(struct filp *f, int *ops, int block));
FORWARD _PROTOTYPE(int select_match_file, (struct filp *f)); FORWARD _PROTOTYPE(int select_match_file, (struct filp *f));
FORWARD _PROTOTYPE(int select_request_general, (struct filp *f, int *ops, int block)); FORWARD _PROTOTYPE(int select_request_general,
FORWARD _PROTOTYPE(int select_major_match, (int match_major, struct filp *file)); (struct filp *f, int *ops, int block));
FORWARD _PROTOTYPE(int select_major_match,
(int match_major, struct filp *file));
FORWARD _PROTOTYPE(void select_cancel_all, (struct selectentry *e)); FORWARD _PROTOTYPE(void select_cancel_all, (struct selectentry *e));
FORWARD _PROTOTYPE(void select_wakeup, (struct selectentry *e)); FORWARD _PROTOTYPE(void select_wakeup, (struct selectentry *e));
@ -218,15 +214,18 @@ PUBLIC int do_select(void)
selecttab[s].vir_errorfds = (fd_set *) m_in.SEL_ERRORFDS; selecttab[s].vir_errorfds = (fd_set *) m_in.SEL_ERRORFDS;
/* copy args */ /* copy args */
if(selecttab[s].vir_readfds && (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_READFDS, if(selecttab[s].vir_readfds
&& (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_READFDS,
SELF, D, (vir_bytes) &selecttab[s].readfds, sizeof(fd_set))) != OK) SELF, D, (vir_bytes) &selecttab[s].readfds, sizeof(fd_set))) != OK)
return r; return r;
if(selecttab[s].vir_writefds && (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_WRITEFDS, if(selecttab[s].vir_writefds
&& (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_WRITEFDS,
SELF, D, (vir_bytes) &selecttab[s].writefds, sizeof(fd_set))) != OK) SELF, D, (vir_bytes) &selecttab[s].writefds, sizeof(fd_set))) != OK)
return r; return r;
if(selecttab[s].vir_errorfds && (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_ERRORFDS, if(selecttab[s].vir_errorfds
&& (r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_ERRORFDS,
SELF, D, (vir_bytes) &selecttab[s].errorfds, sizeof(fd_set))) != OK) SELF, D, (vir_bytes) &selecttab[s].errorfds, sizeof(fd_set))) != OK)
return r; return r;

View file

@ -187,7 +187,10 @@ char *user_addr; /* user space address where stat buf goes */
/* Fill in the statbuf struct. */ /* Fill in the statbuf struct. */
mo = rip->i_mode & I_TYPE; mo = rip->i_mode & I_TYPE;
s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL); /* true iff special */
/* true iff special */
s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL);
statbuf.st_dev = rip->i_dev; statbuf.st_dev = rip->i_dev;
statbuf.st_ino = rip->i_num; statbuf.st_ino = rip->i_num;
statbuf.st_mode = rip->i_mode; statbuf.st_mode = rip->i_mode;

View file

@ -1,4 +1,5 @@
/* This file manages the super block table and the related data structures, * namely, the bit maps that keep track of which zones and which inodes are /* This file manages the super block table and the related data structures,
* namely, the bit maps that keep track of which zones and which inodes are
* allocated and which are free. When a new inode or zone is needed, the * allocated and which are free. When a new inode or zone is needed, the
* appropriate bit map is searched for a free entry. * appropriate bit map is searched for a free entry.
* *
@ -118,7 +119,9 @@ bit_t bit_returned; /* number of bit to insert into the map */
start_block = START_BLOCK + sp->s_imap_blocks; start_block = START_BLOCK + sp->s_imap_blocks;
} }
block = bit_returned / FS_BITS_PER_BLOCK(sp->s_block_size); block = bit_returned / FS_BITS_PER_BLOCK(sp->s_block_size);
word = (bit_returned % FS_BITS_PER_BLOCK(sp->s_block_size)) / FS_BITCHUNK_BITS; word = (bit_returned % FS_BITS_PER_BLOCK(sp->s_block_size))
/ FS_BITCHUNK_BITS;
bit = bit_returned % FS_BITCHUNK_BITS; bit = bit_returned % FS_BITCHUNK_BITS;
mask = 1 << bit; mask = 1 << bit;
@ -315,7 +318,8 @@ register struct super_block *sp; /* pointer to a superblock */
|| sp->s_ninodes < 1 || sp->s_zones < 1 || sp->s_ninodes < 1 || sp->s_zones < 1
|| (unsigned) sp->s_log_zone_size > 4) { || (unsigned) sp->s_log_zone_size > 4) {
printf("not enough imap or zone map blocks, \n"); printf("not enough imap or zone map blocks, \n");
printf("or not enough inodes, or not enough zones, or zone size too large\n"); printf("or not enough inodes, or not enough zones, "
"or zone size too large\n");
return(EINVAL); return(EINVAL);
} }
sp->s_dev = dev; /* restore device number */ sp->s_dev = dev; /* restore device number */

View file

@ -3,8 +3,6 @@
#include "fs.h" #include "fs.h"
#define VERBOSE 0
#include <timers.h> #include <timers.h>
#include <minix/syslib.h> #include <minix/syslib.h>
#include <minix/com.h> #include <minix/com.h>
@ -26,11 +24,8 @@ PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
/* reschedule our synchronous alarm if necessary */ /* reschedule our synchronous alarm if necessary */
if(!old_head || old_head > new_head) { if(!old_head || old_head > new_head) {
if(sys_setalarm(new_head, 1) != OK) if(sys_setalarm(new_head, 1) != OK)
panic(__FILE__, "FS set timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__, "FS set timer "
#if VERBOSE "couldn't set synchronous alarm.", NO_NUM);
else
printf("timers: after setting, set synalarm to %d -> %d\n", old_head, new_head);
#endif
} }
return; return;
@ -42,15 +37,9 @@ PUBLIC void fs_expire_timers(clock_t now)
tmrs_exptimers(&fs_timers, now, &new_head); tmrs_exptimers(&fs_timers, now, &new_head);
if(new_head > 0) { if(new_head > 0) {
if(sys_setalarm(new_head, 1) != OK) if(sys_setalarm(new_head, 1) != OK)
panic(__FILE__, "FS expire timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__, "FS expire timer couldn't set "
#if VERBOSE "synchronous alarm.", NO_NUM);
else
printf("timers: after expiry, set synalarm to %d\n", new_head);
#endif
} }
#if VERBOSE
else printf("after expiry, no new timer set\n");
#endif
} }
PUBLIC void fs_init_timer(timer_t *tp) PUBLIC void fs_init_timer(timer_t *tp)
@ -70,9 +59,8 @@ PUBLIC void fs_cancel_timer(timer_t *tp)
*/ */
if(old_head < new_head || !new_head) { if(old_head < new_head || !new_head) {
if(sys_setalarm(new_head, 1) != OK) if(sys_setalarm(new_head, 1) != OK)
panic(__FILE__, "FS expire timer couldn't set synchronous alarm.", NO_NUM); panic(__FILE__,
#if VERBOSE "FS expire timer couldn't set synchronous alarm.",
printf("timers: after cancelling, set synalarm to %d -> %d\n", old_head, new_head); NO_NUM);
#endif
} }
} }

View file

@ -48,7 +48,8 @@ zone_t new_zone; /* zone # to be inserted */
rip->i_dirt = DIRTY; /* inode will be changed */ rip->i_dirt = DIRTY; /* inode will be changed */
bp = NIL_BUF; bp = NIL_BUF;
scale = rip->i_sp->s_log_zone_size; /* for zone-block conversion */ scale = rip->i_sp->s_log_zone_size; /* for zone-block conversion */
zone = (position/rip->i_sp->s_block_size) >> scale; /* relative zone # to insert */ /* relative zone # to insert */
zone = (position/rip->i_sp->s_block_size) >> scale;
zones = rip->i_ndzones; /* # direct zones in the inode */ zones = rip->i_ndzones; /* # direct zones in the inode */
nr_indirects = rip->i_nindirs;/* # indirect zones per indirect block */ nr_indirects = rip->i_nindirs;/* # indirect zones per indirect block */

View file

@ -1,5 +1,3 @@
/* $FreeBSD: src/sys/crypto/sha2/sha2.c,v 1.2.2.2 2002/03/05 08:36:47 ume Exp $ */
/* $KAME: sha2.c,v 1.8 2001/11/08 01:07:52 itojun Exp $ */
/* /*
* sha2.c * sha2.c
@ -74,8 +72,8 @@
* *
* Please make sure that your system defines SHA2_BYTE_ORDER. If your * Please make sure that your system defines SHA2_BYTE_ORDER. If your
* architecture is little-endian, make sure it also defines * architecture is little-endian, make sure it also defines
* SHA2_LITTLE_ENDIAN and that the two (SHA2_BYTE_ORDER and SHA2_LITTLE_ENDIAN) are * SHA2_LITTLE_ENDIAN and that the two (SHA2_BYTE_ORDER and
* equivilent. * SHA2_LITTLE_ENDIAN) are equivilent.
* *
* If your system does not define the above, then you can do so by * If your system does not define the above, then you can do so by
* hand like this: * hand like this:

View file

@ -145,8 +145,10 @@ phys_clicks clicks; /* number of clicks to free */
* del_slot * * del_slot *
*===========================================================================*/ *===========================================================================*/
PRIVATE void del_slot(prev_ptr, hp) PRIVATE void del_slot(prev_ptr, hp)
register struct hole *prev_ptr; /* pointer to hole entry just ahead of 'hp' */ /* pointer to hole entry just ahead of 'hp' */
register struct hole *hp; /* pointer to hole entry to be removed */ register struct hole *prev_ptr;
/* pointer to hole entry to be removed */
register struct hole *hp;
{ {
/* Remove an entry from the hole list. This procedure is called when a /* Remove an entry from the hole list. This procedure is called when a
* request to allocate memory removes a hole in its entirety, thus reducing * request to allocate memory removes a hole in its entirety, thus reducing

View file

@ -39,8 +39,8 @@ FORWARD _PROTOTYPE( int read_header, (int fd, int *ft, vir_bytes *text_bytes,
phys_bytes *tot_bytes, long *sym_bytes, vir_clicks sc, phys_bytes *tot_bytes, long *sym_bytes, vir_clicks sc,
vir_bytes *pc) ); vir_bytes *pc) );
#define ESCRIPT (-2000) /* Returned by read_header for a #! script. */ #define ESCRIPT (-2000) /* Returned by read_header for a #! script. */
#define PTRSIZE sizeof(char *) /* Size of pointers in argv[] and envp[]. */ #define PTRSIZE sizeof(char *) /* Size of pointers in argv[] and envp[]. */
/*===========================================================================* /*===========================================================================*
* do_exec * * do_exec *
@ -82,8 +82,8 @@ PUBLIC int do_exec()
dst = (vir_bytes) mbuf; dst = (vir_bytes) mbuf;
r = sys_datacopy(who, (vir_bytes) src, r = sys_datacopy(who, (vir_bytes) src,
PM_PROC_NR, (vir_bytes) dst, (phys_bytes)stk_bytes); PM_PROC_NR, (vir_bytes) dst, (phys_bytes)stk_bytes);
/* can't fetch stack (e.g. bad virtual addr) */
if (r != OK) return(EACCES); /* can't fetch stack (e.g. bad virtual addr) */ if (r != OK) return(EACCES);
r = 0; /* r = 0 (first attempt), or 1 (interpreted script) */ r = 0; /* r = 0 (first attempt), or 1 (interpreted script) */
name = name_buf; /* name of file to exec. */ name = name_buf; /* name of file to exec. */
@ -287,7 +287,8 @@ vir_bytes *pc; /* program entry point (initial PC) */
/*===========================================================================* /*===========================================================================*
* new_mem * * new_mem *
*===========================================================================*/ *===========================================================================*/
PRIVATE int new_mem(sh_mp, text_bytes, data_bytes,bss_bytes,stk_bytes,tot_bytes) PRIVATE int new_mem(sh_mp, text_bytes, data_bytes,
bss_bytes,stk_bytes,tot_bytes)
struct mproc *sh_mp; /* text can be shared with this process */ struct mproc *sh_mp; /* text can be shared with this process */
vir_bytes text_bytes; /* text segment size in bytes */ vir_bytes text_bytes; /* text segment size in bytes */
vir_bytes data_bytes; /* size of initialized data in bytes */ vir_bytes data_bytes; /* size of initialized data in bytes */
@ -337,7 +338,7 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */
} }
/* Free the data and stack segments. */ /* Free the data and stack segments. */
free_mem(rmp->mp_seg[D].mem_phys, free_mem(rmp->mp_seg[D].mem_phys,
rmp->mp_seg[S].mem_vir + rmp->mp_seg[S].mem_len - rmp->mp_seg[D].mem_vir); rmp->mp_seg[S].mem_vir + rmp->mp_seg[S].mem_len - rmp->mp_seg[D].mem_vir);
/* We have now passed the point of no return. The old core image has been /* We have now passed the point of no return. The old core image has been
* forever lost, memory for a new core image has been allocated. Set up * forever lost, memory for a new core image has been allocated. Set up
@ -361,7 +362,8 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */
#if (CHIP == M68000) #if (CHIP == M68000)
rmp->mp_seg[T].mem_vir = 0; rmp->mp_seg[T].mem_vir = 0;
rmp->mp_seg[D].mem_vir = rmp->mp_seg[T].mem_len; rmp->mp_seg[D].mem_vir = rmp->mp_seg[T].mem_len;
rmp->mp_seg[S].mem_vir = rmp->mp_seg[D].mem_vir + rmp->mp_seg[D].mem_len + gap_clicks; rmp->mp_seg[S].mem_vir = rmp->mp_seg[D].mem_vir
+ rmp->mp_seg[D].mem_len + gap_clicks;
#endif #endif
sys_newmap(who, rmp->mp_seg); /* report new map to the kernel */ sys_newmap(who, rmp->mp_seg); /* report new map to the kernel */

View file

@ -161,7 +161,8 @@ int exit_status; /* the process' exit status (for parent) */
} }
/* Free the data and stack segments. */ /* Free the data and stack segments. */
free_mem(rmp->mp_seg[D].mem_phys, free_mem(rmp->mp_seg[D].mem_phys,
rmp->mp_seg[S].mem_vir + rmp->mp_seg[S].mem_len - rmp->mp_seg[D].mem_vir); rmp->mp_seg[S].mem_vir
+ rmp->mp_seg[S].mem_len - rmp->mp_seg[D].mem_vir);
/* The process slot can only be freed if the parent has done a WAIT. */ /* The process slot can only be freed if the parent has done a WAIT. */
rmp->mp_exitstatus = (char) exit_status; rmp->mp_exitstatus = (char) exit_status;

View file

@ -250,25 +250,29 @@ PUBLIC int do_svrctl()
/* Set a param override? */ /* Set a param override? */
if(req == MMSETPARAM) { if(req == MMSETPARAM) {
if(local_params >= MAX_LOCAL_PARAMS) return ENOSPC; if(local_params >= MAX_LOCAL_PARAMS) return ENOSPC;
if(sysgetenv.keylen <= 0 || sysgetenv.keylen >= sizeof(local_param_overrides[local_params].name) if(sysgetenv.keylen <= 0
|| sysgetenv.vallen <= 0 || sysgetenv.vallen >= sizeof(local_param_overrides[local_params].value)) || sysgetenv.keylen >=
return EINVAL; sizeof(local_param_overrides[local_params].name)
|| sysgetenv.vallen <= 0
|| sysgetenv.vallen >=
sizeof(local_param_overrides[local_params].value))
return EINVAL;
if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.key, if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.key,
SELF, (vir_bytes) local_param_overrides[local_params].name, SELF, (vir_bytes) local_param_overrides[local_params].name,
sysgetenv.keylen)) != OK) sysgetenv.keylen)) != OK)
return s; return s;
if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.val, if ((s = sys_datacopy(who, (vir_bytes) sysgetenv.val,
SELF, (vir_bytes) local_param_overrides[local_params].value, SELF, (vir_bytes) local_param_overrides[local_params].value,
sysgetenv.keylen)) != OK) sysgetenv.keylen)) != OK)
return s; return s;
local_param_overrides[local_params].name[sysgetenv.keylen] = '\0'; local_param_overrides[local_params].name[sysgetenv.keylen] = '\0';
local_param_overrides[local_params].value[sysgetenv.vallen] = '\0'; local_param_overrides[local_params].value[sysgetenv.vallen] = '\0';
local_params++; local_params++;
return OK; return OK;
} }
if (sysgetenv.keylen == 0) { /* copy all parameters */ if (sysgetenv.keylen == 0) { /* copy all parameters */