#endif
}
-/*==========================================================================*
- * flushall *
- *==========================================================================*/
+/*===========================================================================*
+ * flushall *
+ *===========================================================================*/
PUBLIC void flushall(dev)
dev_t dev; /* device to flush */
{
bufqsize--;
}
}
- if(rw_flag == WRITING && i == 0) {
+ if (rw_flag == WRITING && i == 0) {
/* We're not making progress, this means we might keep
* looping. Buffers remain dirty if un-written. Buffers are
* lost if invalidate()d or LRU-removed while dirty. This
/* Open device readonly. (This fails if the device
* is also writable, which a CD isn't.)
*/
- if((r = dev_open(dev, FS_PROC_NR, RO_BIT)) != OK) {
+ if ((r = dev_open(dev, FS_PROC_NR, RO_BIT)) != OK) {
continue;
}
- if((r = dev_io(DEV_READ, dev, FS_PROC_NR, pvd,
+ if ((r = dev_io(DEV_READ, dev, FS_PROC_NR, pvd,
16*CD_SECTOR, sizeof(pvd), 0)) != sizeof(pvd)) {
dev_close(dev);
continue;
dev_close(dev);
/* Check PVD ID. */
- if(pvd[0] != 1 || pvd[1] != 'C' || pvd[2] != 'D' ||
+ if (pvd[0] != 1 || pvd[1] != 'C' || pvd[2] != 'D' ||
pvd[3] != '0' || pvd[4] != '0' || pvd[5] != '1' || pvd[6] != 1 ||
strncmp(pvd + 40, "MINIX", 5)) {
continue;
/* 3. Both c0dXp1 and p2 should have a superblock. */
for(minor = minors[i]+2; minor <= minors[i]+3; minor++) {
dev = (AT_MAJOR << MAJOR) | minor;
- if((r = dev_open(dev, FS_PROC_NR, R_BIT)) != OK) {
+ if ((r = dev_open(dev, FS_PROC_NR, R_BIT)) != OK) {
break;
}
probe_super.s_dev = dev;
r = read_super(&probe_super);
dev_close(dev);
- if(r != OK) {
+ if (r != OK) {
break;
}
}
- if(minor > minors[i]+3) {
+ if (minor > minors[i]+3) {
/* Success? Then set dev to p1. */
dev = (AT_MAJOR << MAJOR) | (minors[i]+2);
found = 1;
}
}
- if(!found) return NO_DEV;
+ if (!found) return NO_DEV;
return dev;
}
int d, get_more = 1;
for(d = 0; d < NR_DEVICES; d++)
- if(dmap[d].dmap_driver == m->m_source)
+ if (dmap[d].dmap_driver == m->m_source)
break;
- if(d >= NR_DEVICES)
+ if (d >= NR_DEVICES)
return;
do {
int r;
st.m_type = DEV_STATUS;
- if((r=sendrec(m->m_source, &st)) != OK)
+ if ((r=sendrec(m->m_source, &st)) != OK)
panic(__FILE__,"couldn't sendrec for DEV_STATUS", r);
switch(st.m_type) {
/* Did the process we did the sendrec() for get a result? */
if (mess_ptr->REP_PROC_NR == proc_nr) {
break;
- } else if(mess_ptr->m_type == REVIVE) {
+ } else if (mess_ptr->m_type == REVIVE) {
/* Otherwise it should be a REVIVE. */
revive(mess_ptr->REP_PROC_NR, mess_ptr->REP_STATUS);
} else {
DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /* 6 = /dev/lp */
#if (MACHINE == IBM_PC)
- DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /* 8 = /dev/c1 */
- DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */
- DT(0, no_dev, 0, 0, DMAP_MUTABLE) /*10 = /dev/c2 */
- DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*12 = /dev/c3 */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*13 = /dev/audio */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*14 = /dev/mixer */
- DT(1, gen_opcl, gen_io, LOG_PROC_NR, 0) /*15 = /dev/klog */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*16 = /dev/random */
- DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*17 = /dev/cmos */
+ DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /* 8 = /dev/c1 */
+ DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */
+ DT(0, no_dev, 0, 0, DMAP_MUTABLE) /*10 = /dev/c2 */
+ DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*12 = /dev/c3 */
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*13 = /dev/audio */
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*14 = /dev/mixer */
+ DT(1, gen_opcl, gen_io, LOG_PROC_NR, 0) /*15 = /dev/klog */
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*16 = /dev/random*/
+ DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*17 = /dev/cmos */
#endif /* IBM_PC */
};
int i;
if ((i = env_get_param(key, value, sizeof(value))) != OK) {
- if(!optional)
+ if (!optional)
printf("FS: Warning, couldn't get monitor param: %d\n", i);
return 0;
}
u32_t fsmax, probedev;
/* If we are running from CD, see if we can find it. */
- if(igetenv("cdproberoot", 1) && (probedev=cdprobe()) != NO_DEV) {
+ if (igetenv("cdproberoot", 1) && (probedev=cdprobe()) != NO_DEV) {
char devnum[10];
struct sysgetenv env;
/* RAM block size has to be a multiple of the root image block
* size to make copying easier.
*/
- if(block_size_image % block_size_ram) {
+ if (block_size_image % block_size_ram) {
printf("\nram block size: %d image block size: %d\n",
block_size_ram, block_size_image);
panic(__FILE__, "ram disk block size must be a multiple of "
dev_close(image_dev);
/* Resize the RAM disk root file system. */
- if(dev_io(DEV_READ, root_dev, FS_PROC_NR,
+ if (dev_io(DEV_READ, root_dev, FS_PROC_NR,
sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0) != MIN_BLOCK_SIZE) {
printf("WARNING: ramdisk read for resizing failed\n");
}
dsp = (struct super_block *) sbbuf;
- if(dsp->s_magic == SUPER_V3)
+ if (dsp->s_magic == SUPER_V3)
ramfs_block_size = dsp->s_block_size;
else
ramfs_block_size = STATIC_BLOCK_SIZE;
dsp->s_nzones = conv2(sp->s_native, (u16_t) zones);
dsp->s_zones = conv4(sp->s_native, zones);
- if(dev_io(DEV_WRITE, root_dev, FS_PROC_NR,
+ if (dev_io(DEV_WRITE, root_dev, FS_PROC_NR,
sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0) != MIN_BLOCK_SIZE) {
printf("WARNING: ramdisk write for resizing failed\n");
}
#include "super.h"
/*===========================================================================*
- * do_getsysinfo *
+ * do_getsysinfo *
*===========================================================================*/
PUBLIC int do_getsysinfo()
{
}
/*===========================================================================*
- * do_fsync *
+ * do_fsync *
*===========================================================================*/
PUBLIC int do_fsync()
{
* search_dir *
*===========================================================================*/
PUBLIC int search_dir(ldir_ptr, string, numb, flag)
-register struct inode *ldir_ptr; /* ptr to inode for dir to search */
-char string[NAME_MAX]; /* component to search for */
-ino_t *numb; /* pointer to inode number */
-int flag; /* LOOK_UP, ENTER, DELETE or IS_EMPTY */
+register struct inode *ldir_ptr; /* ptr to inode for dir to search */
+char string[NAME_MAX]; /* component to search for */
+ino_t *numb; /* pointer to inode number */
+int flag; /* LOOK_UP, ENTER, DELETE or IS_EMPTY */
{
/* This function searches the directory whose inode is pointed to by 'ldip':
* if (flag == ENTER) enter 'string' in the directory with inode # '*numb';
/* Since directories don't have holes, 'b' cannot be NO_BLOCK. */
bp = get_block(ldir_ptr->i_dev, b, NORMAL); /* get a dir block */
- if(bp == NO_BLOCK)
+ if (bp == NO_BLOCK)
panic(__FILE__,"get_block returned NO_BLOCK", NO_NUM);
/* Search a directory block. */
if (oflags & O_NONBLOCK) {
r = EAGAIN;
} else {
- if(!notouch)
+ if (!notouch)
suspend(XPIPE); /* block reader */
r = SUSPEND;
}
/* Process is writing to a pipe. */
if (find_filp(rip, R_BIT) == NIL_FILP) {
/* Tell kernel to generate a SIGPIPE signal. */
- if(!notouch)
+ if (!notouch)
sys_kill((int)(fp - fproc), SIGPIPE);
return(EPIPE);
}
if ( (*canwrite = (PIPE_SIZE(rip->i_sp->s_block_size)
- position)) > 0) {
/* Do a partial write. Need to wakeup reader */
- if(!notouch)
+ if (!notouch)
release(rip, READ, susp_count);
return(1);
} else {
return(1);
}
}
- if(!notouch)
+ if (!notouch)
suspend(XPIPE); /* stop writer -- pipe full */
return(SUSPEND);
}
/* Trying to perform the call also includes SELECTing on it with that
* operation.
*/
- if(call_nr == READ || call_nr == WRITE) {
+ if (call_nr == READ || call_nr == WRITE) {
int op;
- if(call_nr == READ)
+ if (call_nr == READ)
op = SEL_RD;
else
op = SEL_WR;
for(f = &filp[0]; f < &filp[NR_FILPS]; f++) {
- if(f->filp_count < 1 || !(f->filp_pipe_select_ops & op) ||
+ if (f->filp_count < 1 || !(f->filp_pipe_select_ops & op) ||
f->filp_ino != ip)
continue;
select_callback(f, op);
rfp->fp_suspended = NOT_SUSPENDED;
if (task == XPOPEN) /* process blocked in open or create */
reply(proc_nr, rfp->fp_fd>>8);
- else if(task == XSELECT) {
+ else if (task == XSELECT) {
reply(proc_nr, returned);
} else {
/* Revive a process suspended on TTY or other device. */
{
int orig_ops, r = 0, err, canwrite;
orig_ops = *ops;
- if((*ops & SEL_RD)) {
- if((err = pipe_check(f->filp_ino, READING, 0,
+ if ((*ops & SEL_RD)) {
+ if ((err = pipe_check(f->filp_ino, READING, 0,
1, f->filp_pos, &canwrite, 1)) != SUSPEND)
r |= SEL_RD;
- if(err < 0 && err != SUSPEND && (*ops & SEL_ERR))
+ if (err < 0 && err != SUSPEND && (*ops & SEL_ERR))
r |= SEL_ERR;
}
- if((*ops & SEL_WR)) {
- if((err = pipe_check(f->filp_ino, WRITING, 0,
+ if ((*ops & SEL_WR)) {
+ if ((err = pipe_check(f->filp_ino, WRITING, 0,
1, f->filp_pos, &canwrite, 1)) != SUSPEND)
r |= SEL_WR;
- if(err < 0 && err != SUSPEND && (*ops & SEL_ERR))
+ if (err < 0 && err != SUSPEND && (*ops & SEL_ERR))
r |= SEL_ERR;
}
*ops = r;
- if(!r && block) {
+ if (!r && block) {
f->filp_pipe_select_ops |= orig_ops;
}
PUBLIC int select_match_pipe(struct filp *f)
{
/* recognize either pipe or named pipe (FIFO) */
- if(f && f->filp_ino && (f->filp_ino->i_mode & I_NAMED_PIPE))
+ if (f && f->filp_ino && (f->filp_ino->i_mode & I_NAMED_PIPE))
return 1;
return 0;
}
_PROTOTYPE( int do_revive, (void) );
_PROTOTYPE( int do_set, (void) );
_PROTOTYPE( int do_sync, (void) );
-_PROTOTYPE( int do_fsync, (void) );
+_PROTOTYPE( int do_fsync, (void) );
_PROTOTYPE( int do_reboot, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_getsysinfo, (void) );
_PROTOTYPE( void release, (struct inode *ip, int call_nr, int count) );
_PROTOTYPE( void revive, (int proc_nr, int bytes) );
_PROTOTYPE( void suspend, (int task) );
-_PROTOTYPE( int select_request_pipe, (struct filp *f, int *ops, int bl) );
+_PROTOTYPE( int select_request_pipe, (struct filp *f, int *ops, int bl) );
_PROTOTYPE( int select_cancel_pipe, (struct filp *f) );
_PROTOTYPE( int select_match_pipe, (struct filp *f) );
_PROTOTYPE( void select_forget, (int fproc) );
_PROTOTYPE( void select_timeout_check, (timer_t *) );
_PROTOTYPE( void init_select, (void) );
-_PROTOTYPE( int select_notified, (int major, int minor, int ops) );
+_PROTOTYPE( int select_notified, (int major, int minor, int ops) );
/* timers.c */
_PROTOTYPE( void fs_set_timer, (timer_t *tp, int delta, tmr_func_t watchdog, int arg));
/* left unfinished rw_chunk()s from previous call! this can't happen.
* it means something has gone wrong we can't repair now.
*/
- if(bufs_in_use < 0) {
+ if (bufs_in_use < 0) {
panic(__FILE__,"start - bufs_in_use negative", bufs_in_use);
}
mode_word = rip->i_mode & I_TYPE;
regular = mode_word == I_REGULAR || mode_word == I_NAMED_PIPE;
- if((char_spec = (mode_word == I_CHAR_SPECIAL ? 1 : 0))) {
- if(rip->i_zone[0] == NO_DEV)
+ if ((char_spec = (mode_word == I_CHAR_SPECIAL ? 1 : 0))) {
+ if (rip->i_zone[0] == NO_DEV)
panic(__FILE__,"read_write tries to read from "
"character device NO_DEV", NO_NUM);
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;
- 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);
block_size = get_block_size(rip->i_zone[0]);
}
- if(!char_spec && !block_spec)
+ if (!char_spec && !block_spec)
block_size = rip->i_sp->s_block_size;
rdwt_err = OK; /* set to EIO if disk error occurs */
}
} else {
if (rip->i_pipe == I_PIPE) {
- if( position >= rip->i_size) {
+ if ( position >= rip->i_size) {
/* Reset pipe pointers. */
rip->i_size = 0; /* no data left */
position = 0; /* reset reader(s) */
fp->fp_cum_io_partial = 0;
return(cum_io);
}
- if(bufs_in_use < 0) {
+ if (bufs_in_use < 0) {
panic(__FILE__,"end - bufs_in_use negative", bufs_in_use);
}
return(r);
}
/* In all cases, bp now points to a valid buffer. */
- if(bp == NIL_BUF) {
+ if (bp == NIL_BUF) {
panic(__FILE__,"bp not valid in rw_chunk, this can't happen", NO_NUM);
}
if (rw_flag == WRITING && chunk != block_size && !block_spec &&
*===========================================================================*/
PRIVATE int select_match_file(struct filp *file)
{
- if(file && file->filp_ino && (file->filp_ino->i_mode & I_REGULAR))
+ if (file && file->filp_ino && (file->filp_ino->i_mode & I_REGULAR))
return 1;
return 0;
}
PRIVATE int select_request_general(struct filp *f, int *ops, int block)
{
int rops = *ops;
- if(block) rops |= SEL_NOTIFY;
+ if (block) rops |= SEL_NOTIFY;
*ops = dev_io(DEV_SELECT, f->filp_ino->i_zone[0], rops, NULL, 0, 0, 0);
- if(*ops < 0)
+ if (*ops < 0)
return SEL_ERR;
return SEL_OK;
}
PRIVATE int select_major_match(int match_major, struct filp *file)
{
int major;
- if(!(file && file->filp_ino &&
+ if (!(file && file->filp_ino &&
(file->filp_ino->i_mode & I_TYPE) == I_CHAR_SPECIAL))
return 0;
major = (file->filp_ino->i_zone[0] >> MAJOR) & BYTE;
- if(major == match_major)
+ if (major == match_major)
return 1;
return 0;
}
PRIVATE void ops2tab(int ops, int fd, struct selectentry *e)
{
- if((ops & SEL_RD) && e->vir_readfds && FD_ISSET(fd, &e->readfds)
+ if ((ops & SEL_RD) && e->vir_readfds && FD_ISSET(fd, &e->readfds)
&& !FD_ISSET(fd, &e->ready_readfds)) {
FD_SET(fd, &e->ready_readfds);
e->nreadyfds++;
}
- if((ops & SEL_WR) && e->vir_writefds && FD_ISSET(fd, &e->writefds)
+ if ((ops & SEL_WR) && e->vir_writefds && FD_ISSET(fd, &e->writefds)
&& !FD_ISSET(fd, &e->ready_writefds)) {
FD_SET(fd, &e->ready_writefds);
e->nreadyfds++;
}
- if((ops & SEL_ERR) && e->vir_errorfds && FD_ISSET(fd, &e->errorfds)
+ if ((ops & SEL_ERR) && e->vir_errorfds && FD_ISSET(fd, &e->errorfds)
&& !FD_ISSET(fd, &e->ready_errorfds)) {
FD_SET(fd, &e->ready_errorfds);
e->nreadyfds++;
PRIVATE void copy_fdsets(struct selectentry *e)
{
- if(e->vir_readfds)
+ if (e->vir_readfds)
sys_vircopy(SELF, D, (vir_bytes) &e->ready_readfds,
e->req_procnr, D, (vir_bytes) e->vir_readfds, sizeof(fd_set));
- if(e->vir_writefds)
+ if (e->vir_writefds)
sys_vircopy(SELF, D, (vir_bytes) &e->ready_writefds,
e->req_procnr, D, (vir_bytes) e->vir_writefds, sizeof(fd_set));
- if(e->vir_errorfds)
+ if (e->vir_errorfds)
sys_vircopy(SELF, D, (vir_bytes) &e->ready_errorfds,
e->req_procnr, D, (vir_bytes) e->vir_errorfds, sizeof(fd_set));
}
/*===========================================================================*
- * do_select *
+ * do_select *
*===========================================================================*/
PUBLIC int do_select(void)
{
struct timeval timeout;
nfds = m_in.SEL_NFDS;
- if(nfds < 0 || nfds > FD_SETSIZE)
+ if (nfds < 0 || nfds > FD_SETSIZE)
return EINVAL;
for(s = 0; s < MAXSELECTS; s++)
- if(!selecttab[s].requestor)
+ if (!selecttab[s].requestor)
break;
- if(s >= MAXSELECTS)
+ if (s >= MAXSELECTS)
return ENOSPC;
selecttab[s].req_procnr = who;
selecttab[s].vir_errorfds = (fd_set *) m_in.SEL_ERRORFDS;
/* copy args */
- if(selecttab[s].vir_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)
return r;
- if(selecttab[s].vir_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)
return r;
- if(selecttab[s].vir_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)
return r;
- if(!m_in.SEL_TIMEOUT)
+ if (!m_in.SEL_TIMEOUT)
is_timeout = nonzero_timeout = 0;
else
- if((r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_TIMEOUT,
+ if ((r=sys_vircopy(who, D, (vir_bytes) m_in.SEL_TIMEOUT,
SELF, D, (vir_bytes) &timeout, sizeof(timeout))) != OK)
return r;
/* No nonsense in the timeval please. */
- if(is_timeout && (timeout.tv_sec < 0 || timeout.tv_usec < 0))
+ if (is_timeout && (timeout.tv_sec < 0 || timeout.tv_usec < 0))
return EINVAL;
/* if is_timeout if 0, we block forever. otherwise, if nonzero_timeout
* is 0, we do a poll (don't block). otherwise, we block up to the
* specified time interval.
*/
- if(is_timeout && (timeout.tv_sec > 0 || timeout.tv_usec > 0))
+ if (is_timeout && (timeout.tv_sec > 0 || timeout.tv_usec > 0))
nonzero_timeout = 1;
- if(nonzero_timeout || !is_timeout)
+ if (nonzero_timeout || !is_timeout)
block = 1;
else
block = 0; /* timeout set as (0,0) - this effects a poll */
int orig_ops, ops, t, type = -1, r;
struct filp *filp;
- if(!(orig_ops = ops = tab2ops(fd, &selecttab[s])))
+ if (!(orig_ops = ops = tab2ops(fd, &selecttab[s])))
continue;
- if(!(filp = selecttab[s].filps[fd] = get_filp(fd))) {
+ if (!(filp = selecttab[s].filps[fd] = get_filp(fd))) {
select_cancel_all(&selecttab[s]);
return EBADF;
}
for(t = 0; t < SEL_FDS; t++) {
- if(fdtypes[t].select_match) {
- if(fdtypes[t].select_match(filp)) {
+ if (fdtypes[t].select_match) {
+ if (fdtypes[t].select_match(filp)) {
#if DEBUG_SELECT
printf("select: fd %d is type %d ", fd, t);
#endif
- if(type != -1)
+ if (type != -1)
printf("select: double match\n");
type = t;
}
- } else if(select_major_match(fdtypes[t].select_major, filp)) {
+ } else if (select_major_match(fdtypes[t].select_major, filp)) {
type = t;
}
}
* If all types are implemented, then this is another
* type of file and we get to do whatever we want.
*/
- if(type == -1)
+ if (type == -1)
{
#if DEBUG_SELECT
printf("do_select: bad type\n");
selecttab[s].type[fd] = type;
- if((selecttab[s].filps[fd]->filp_select_ops & ops) != ops) {
+ if ((selecttab[s].filps[fd]->filp_select_ops & ops) != ops) {
int wantops;
/* Request the select on this fd. */
#if DEBUG_SELECT
#if DEBUG_SELECT
printf("%d\n", selecttab[s].filps[fd]->filp_select_ops);
#endif
- if((r = fdtypes[type].select_request(filp,
+ if ((r = fdtypes[type].select_request(filp,
&wantops, block)) != SEL_OK) {
/* error or bogus return code.. backpaddle */
select_cancel_all(&selecttab[s]);
printf("select: select_request returned error\n");
return EINVAL;
}
- if(wantops) {
- if(wantops & ops) {
+ if (wantops) {
+ if (wantops & ops) {
/* operations that were just requested
* are ready to go right away
*/
#endif
}
- if(selecttab[s].nreadyfds > 0 || !block) {
+ if (selecttab[s].nreadyfds > 0 || !block) {
/* fd's were found that were ready to go right away, and/or
* we were instructed not to block at all. Must return
* immediately.
/* Convert timeval to ticks and set the timer. If it fails, undo
* all, return error.
*/
- if(is_timeout) {
+ if (is_timeout) {
int ticks;
/* Open Group:
* "If the requested timeout interval requires a finer
for(fd = 0; fd < e->nfds; fd++) {
struct filp *fp;
fp = e->filps[fd];
- if(!fp) {
+ if (!fp) {
#if DEBUG_SELECT
printf("[ fd %d/%d NULL ] ", fd, e->nfds);
#endif
continue;
}
- if(fp->filp_selectors < 1) {
+ if (fp->filp_selectors < 1) {
#if DEBUG_SELECT
printf("select: %d selectors?!\n", fp->filp_selectors);
#endif
select_reevaluate(fp);
}
- if(e->expiry > 0) {
+ if (e->expiry > 0) {
#if DEBUG_SELECT
printf("cancelling timer %d\n", e - selecttab);
#endif
{
int s, remain_ops = 0, fd, type = -1;
- if(!fp) {
+ if (!fp) {
printf("fs: select: reevalute NULL fp\n");
return 0;
}
for(s = 0; s < MAXSELECTS; s++) {
- if(!selecttab[s].requestor)
+ if (!selecttab[s].requestor)
continue;
for(fd = 0; fd < selecttab[s].nfds; fd++)
- if(fp == selecttab[s].filps[fd]) {
+ if (fp == selecttab[s].filps[fd]) {
remain_ops |= tab2ops(fd, &selecttab[s]);
type = selecttab[s].type[fd];
}
}
/*===========================================================================*
- * int select_callback *
+ * select_callback *
*===========================================================================*/
PUBLIC int select_callback(struct filp *fp, int ops)
{
type = -1;
for(s = 0; s < MAXSELECTS; s++) {
int wakehim = 0;
- if(!selecttab[s].requestor)
+ if (!selecttab[s].requestor)
continue;
for(fd = 0; fd < selecttab[s].nfds; fd++) {
- if(!selecttab[s].filps[fd])
+ if (!selecttab[s].filps[fd])
continue;
- if(selecttab[s].filps[fd] == fp) {
+ if (selecttab[s].filps[fd] == fp) {
int this_want_ops;
this_want_ops = tab2ops(fd, &selecttab[s]);
want_ops |= this_want_ops;
- if(this_want_ops & ops) {
+ if (this_want_ops & ops) {
/* this select() has been satisfied. */
ops2tab(ops, fd, &selecttab[s]);
wakehim = 1;
type = selecttab[s].type[fd];
}
}
- if(wakehim) {
+ if (wakehim) {
select_cancel_all(&selecttab[s]);
copy_fdsets(&selecttab[s]);
selecttab[s].requestor = NULL;
}
/*===========================================================================*
- * int select_notified *
+ * select_notified *
*===========================================================================*/
PUBLIC int select_notified(int major, int minor, int selected_ops)
{
#endif
for(t = 0; t < SEL_FDS; t++)
- if(!fdtypes[t].select_match && fdtypes[t].select_major == major)
+ if (!fdtypes[t].select_match && fdtypes[t].select_major == major)
break;
- if(t >= SEL_FDS) {
+ if (t >= SEL_FDS) {
#if DEBUG_SELECT
printf("select callback: no fdtype found for device %d\n", major);
#endif
for(s = 0; s < MAXSELECTS; s++) {
int s_minor, ops;
- if(!selecttab[s].requestor)
+ if (!selecttab[s].requestor)
continue;
for(f = 0; f < selecttab[s].nfds; f++) {
- if(!selecttab[s].filps[f] ||
+ if (!selecttab[s].filps[f] ||
!select_major_match(major, selecttab[s].filps[f]))
continue;
ops = tab2ops(f, &selecttab[s]);
s_minor = selecttab[s].filps[f]->filp_ino->i_zone[0] & BYTE;
- if((s_minor == minor) &&
+ if ((s_minor == minor) &&
(selected_ops & ops)) {
select_callback(selecttab[s].filps[f], (selected_ops & ops));
}
}
/*===========================================================================*
- * int select_forget *
+ * select_forget *
*===========================================================================*/
PUBLIC void select_forget(int proc)
{
int s;
for(s = 0; s < MAXSELECTS; s++) {
- if(selecttab[s].requestor &&
+ if (selecttab[s].requestor &&
selecttab[s].req_procnr == proc) {
break;
}
}
- if(s >= MAXSELECTS) {
+ if (s >= MAXSELECTS) {
#if DEBUG_SELECT
printf("select: cancelled select() not found");
#endif
}
/*===========================================================================*
- * int select_timeout_check *
+ * select_timeout_check *
*===========================================================================*/
PUBLIC void select_timeout_check(timer_t *timer)
{
s = tmr_arg(timer)->ta_int;
- if(s < 0 || s >= MAXSELECTS) {
+ if (s < 0 || s >= MAXSELECTS) {
#if DEBUG_SELECT
printf("select: bogus slot arg to watchdog %d\n", s);
#endif
return;
}
- if(!selecttab[s].requestor) {
+ if (!selecttab[s].requestor) {
#if DEBUG_SELECT
printf("select: no requestor in watchdog\n");
#endif
return;
}
- if(selecttab[s].expiry <= 0) {
+ if (selecttab[s].expiry <= 0) {
#if DEBUG_SELECT
printf("select: strange expiry value in watchdog\n", s);
#endif
}
/*===========================================================================*
- * change_into *
+ * change_into *
*===========================================================================*/
PRIVATE int change_into(iip, rip)
struct inode **iip; /* pointer to the inode pointer for the dir */
register struct super_block *sp;
- if(dev == NO_DEV)
+ if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
for (sp = &super_block[0]; sp < &super_block[NR_SUPERS]; sp++)
register struct super_block *sp;
- if(dev == NO_DEV)
+ if (dev == NO_DEV)
panic(__FILE__,"request for block size of NO_DEV", NO_NUM);
for (sp = &super_block[0]; sp < &super_block[NR_SUPERS]; sp++) {
static char sbbuf[MIN_BLOCK_SIZE];
dev = sp->s_dev; /* save device (will be overwritten by copy) */
- if(dev == NO_DEV)
+ if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
r = dev_io(DEV_READ, dev, FS_PROC_NR,
sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0);
- if(r != MIN_BLOCK_SIZE) {
+ if (r != MIN_BLOCK_SIZE) {
return EINVAL;
}
memcpy(sp, sbbuf, sizeof(*sp));
sp->s_ndzones = V1_NR_DZONES;
sp->s_nindirs = V1_INDIRECTS;
} else {
- if(version == V2)
+ if (version == V2)
sp->s_block_size = STATIC_BLOCK_SIZE;
- if(sp->s_block_size < MIN_BLOCK_SIZE)
+ if (sp->s_block_size < MIN_BLOCK_SIZE)
return EINVAL;
sp->s_inodes_per_block = V2_INODES_PER_BLOCK(sp->s_block_size);
sp->s_ndzones = V2_NR_DZONES;
sp->s_nindirs = V2_INDIRECTS(sp->s_block_size);
}
- if(sp->s_block_size < MIN_BLOCK_SIZE) {
+ if (sp->s_block_size < MIN_BLOCK_SIZE) {
return EINVAL;
}
- if(sp->s_block_size > MAX_BLOCK_SIZE) {
+ if (sp->s_block_size > MAX_BLOCK_SIZE) {
printf("Filesystem block size is %d kB; maximum filesystem\n"
"block size is %d kB. This limit can be increased by recompiling.\n",
sp->s_block_size/1024, MAX_BLOCK_SIZE/1024);
return EINVAL;
}
- if((sp->s_block_size % 512) != 0) {
+ if ((sp->s_block_size % 512) != 0) {
return EINVAL;
}
- if(SUPER_SIZE > sp->s_block_size) {
+ if (SUPER_SIZE > sp->s_block_size) {
return EINVAL;
}
- if((sp->s_block_size % V2_INODE_SIZE) != 0 ||
+ if ((sp->s_block_size % V2_INODE_SIZE) != 0 ||
(sp->s_block_size % V1_INODE_SIZE) != 0) {
return EINVAL;
}
int r;
clock_t now, old_head = 0, new_head;
- if((r = getuptime(&now)) != OK)
+ if ((r = getuptime(&now)) != OK)
panic(__FILE__, "FS couldn't get uptime from system task.", NO_NUM);
tmr_arg(tp)->ta_int = arg;
old_head = tmrs_settimer(&fs_timers, tp, now+ticks, watchdog, &new_head);
/* reschedule our synchronous alarm if necessary */
- if(!old_head || old_head > new_head) {
- if(sys_setalarm(new_head, 1) != OK)
+ if (!old_head || old_head > new_head) {
+ if (sys_setalarm(new_head, 1) != OK)
panic(__FILE__, "FS set timer "
"couldn't set synchronous alarm.", NO_NUM);
}
{
clock_t new_head;
tmrs_exptimers(&fs_timers, now, &new_head);
- if(new_head > 0) {
- if(sys_setalarm(new_head, 1) != OK)
+ if (new_head > 0) {
+ if (sys_setalarm(new_head, 1) != OK)
panic(__FILE__, "FS expire timer couldn't set "
"synchronous alarm.", NO_NUM);
}
* altogether if th last time has been cancelled (new_head
* will be 0 then).
*/
- if(old_head < new_head || !new_head) {
- if(sys_setalarm(new_head, 1) != OK)
+ if (old_head < new_head || !new_head) {
+ if (sys_setalarm(new_head, 1) != OK)
panic(__FILE__,
"FS expire timer couldn't set synchronous alarm.",
NO_NUM);
for(c = 0; c < TIMING_CATEGORIES; c++) {
int b;
- if(!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
+ if (!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
continue;
x = printf("%-*s: misses %lu, resets %lu, measurements %lu: ",
TIMING_NAME, timingdata[c].names,
timingdata[c].measurements);
for(b = 0; b < TIMING_POINTS; b++) {
int w;
- if(!timingdata[c].lock_timings[b])
+ if (!timingdata[c].lock_timings[b])
continue;
x += (w = printf(" %5d: %5d", timingdata[c].lock_timings_range[0] +
b*timingdata[c].binsize,
timingdata[c].lock_timings[b]));
- if(x + w >= 80) { printf("\n"); x = 0; }
+ if (x + w >= 80) { printf("\n"); x = 0; }
}
- if(x > 0) printf("\n");
+ if (x > 0) printf("\n");
}
#endif
}
for (r=0;r<NR_SCHED_QUEUES; r++) {
rp = rdy_head[r];
- if(!rp) continue;
+ if (!rp) continue;
printf("%2d: ", r);
while (rp != NIL_PROC) {
printf("%3d ", rp->p_nr);
FORWARD _PROTOTYPE(void reply, (int whom, int result) );
/*===========================================================================*
- * main *
+ * main *
*===========================================================================*/
PUBLIC int main(int argc, char **argv)
{
}
/*===========================================================================*
- * exit_server *
+ * exit_server *
*===========================================================================*/
PRIVATE void exit_server()
{
}
/*===========================================================================*
- * get_work *
+ * get_work *
*===========================================================================*/
PRIVATE void get_work()
{
* patch_ptr *
*===========================================================================*/
PRIVATE void patch_ptr(stack, base)
-char stack[ARG_MAX]; /* pointer to stack image within PM */
+char stack[ARG_MAX]; /* pointer to stack image within PM */
vir_bytes base; /* virtual address of stack base inside user */
{
/* When doing an exec(name, argv, envp) call, the user builds up a stack
a0 = (int) ((char **) stack)[1]; /* argv[0] */
if (a0 < 4 * PTRSIZE || a0 >= old_bytes) return(FALSE);
- a1 = a0; /* a1 will point to the strings to be moved */
+ a1 = a0; /* a1 will point to the strings to be moved */
if (replace) {
/* Move a1 to the end of argv[0][] (argv[1] if nargs > 1). */
do {
FORWARD _PROTOTYPE( void get_work, (void) );
FORWARD _PROTOTYPE( void pm_init, (void) );
-FORWARD _PROTOTYPE( int get_nice_value, (int queue) );
+FORWARD _PROTOTYPE( int get_nice_value, (int queue) );
FORWARD _PROTOTYPE( void get_mem_chunks, (struct memory *mem_chunks) );
FORWARD _PROTOTYPE( void patch_mem_chunks, (struct memory *mem_chunks,
struct mem_map *map_ptr) );
printf(" free %u KB.\n", click_to_round_k(free_clicks));
}
-/*=========================================================================*
- * get_nice_value *
- *=========================================================================*/
+/*===========================================================================*
+ * get_nice_value *
+ *===========================================================================*/
PRIVATE int get_nice_value(queue)
int queue; /* store mem chunks here */
{
#define MAX_16BIT (0xFFF0L << CLICK_SHIFT)
#endif
-/*=========================================================================*
- * get_mem_chunks *
- *=========================================================================*/
+/*===========================================================================*
+ * get_mem_chunks *
+ *===========================================================================*/
PRIVATE void get_mem_chunks(mem_chunks)
struct memory *mem_chunks; /* store mem chunks here */
{
}
}
-/*=========================================================================*
- * patch_mem_chunks *
- *=========================================================================*/
+/*===========================================================================*
+ * patch_mem_chunks *
+ *===========================================================================*/
PRIVATE void patch_mem_chunks(mem_chunks, map_ptr)
struct memory *mem_chunks; /* store mem chunks here */
struct mem_map *map_ptr; /* memory to remove */
#include "param.h"
/*===========================================================================*
- * do_allocmem *
+ * do_allocmem *
*===========================================================================*/
PUBLIC int do_allocmem()
{
}
/*===========================================================================*
- * do_freemem *
+ * do_freemem *
*===========================================================================*/
PUBLIC int do_freemem()
{
}
/*===========================================================================*
- * do_getsysinfo *
+ * do_getsysinfo *
*===========================================================================*/
PUBLIC int do_getsysinfo()
{
}
/*===========================================================================*
- * do_getprocnr *
+ * do_getprocnr *
*===========================================================================*/
PUBLIC int do_getprocnr()
{
return(OK);
}
-/*=====================================================================*
- * do_reboot *
- *=====================================================================*/
+/*===========================================================================*
+ * do_reboot *
+ *===========================================================================*/
#define REBOOT_CODE "delay; boot"
PUBLIC int do_reboot()
{
return(SUSPEND); /* don't reply to killed process */
}
-/*=====================================================================*
- * do_getsetpriority *
- *=====================================================================*/
+/*===========================================================================*
+ * do_getsetpriority *
+ *===========================================================================*/
PUBLIC int do_getsetpriority()
{
int arg_which, arg_who, arg_pri;
/* Code common to GETPRIORITY and SETPRIORITY. */
/* Only support PRIO_PROCESS for now. */
- if(arg_which != PRIO_PROCESS)
+ if (arg_which != PRIO_PROCESS)
return(EINVAL);
- if(arg_who == 0)
+ if (arg_who == 0)
rmp_nr = who;
else
- if((rmp_nr = proc_from_pid(arg_who)) < 0)
+ if ((rmp_nr = proc_from_pid(arg_who)) < 0)
return(ESRCH);
rmp = &mproc[rmp_nr];
- if(mp->mp_effuid != SUPER_USER &&
+ if (mp->mp_effuid != SUPER_USER &&
mp->mp_effuid != rmp->mp_effuid && mp->mp_effuid != rmp->mp_realuid)
return EPERM;
/* If GET, that's it. */
- if(call_nr == GETPRIORITY) {
+ if (call_nr == GETPRIORITY) {
return(rmp->mp_nice - PRIO_MIN);
}
/* Only root is allowed to reduce the nice level. */
- if(rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
+ if (rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
return(EACCES);
/* We're SET, and it's allowed. Do it and tell kernel. */
return sys_nice(rmp_nr, arg_pri);
}
-/*=====================================================================*
- * do_svrctl *
- *=====================================================================*/
+/*===========================================================================*
+ * do_svrctl *
+ *===========================================================================*/
PUBLIC int do_svrctl()
{
int s, req;
sizeof(sysgetenv)) != OK) return(EFAULT);
/* Set a param override? */
- if(req == MMSETPARAM) {
- if(local_params >= MAX_LOCAL_PARAMS) return ENOSPC;
- if(sysgetenv.keylen <= 0
+ if (req == MMSETPARAM) {
+ if (local_params >= MAX_LOCAL_PARAMS) return ENOSPC;
+ if (sysgetenv.keylen <= 0
|| sysgetenv.keylen >=
sizeof(local_param_overrides[local_params].name)
|| sysgetenv.vallen <= 0
*/
search_key[sysgetenv.keylen-1]= '\0';
for(p = 0; p < local_params; p++) {
- if(!strcmp(search_key, local_param_overrides[p].name)) {
+ if (!strcmp(search_key, local_param_overrides[p].name)) {
val_start = local_param_overrides[p].value;
break;
}
}
- if(p >= local_params && (val_start = find_param(search_key)) == NULL)
+ if (p >= local_params && (val_start = find_param(search_key)) == NULL)
return(ESRCH);
val_len = strlen(val_start) + 1;
}
FORWARD _PROTOTYPE( void cause_sigalrm, (struct timer *tp) );
/*===========================================================================*
- * do_sigaction *
+ * do_sigaction *
*===========================================================================*/
PUBLIC int do_sigaction()
{
}
/*===========================================================================*
- * do_sigpending *
+ * do_sigpending *
*===========================================================================*/
PUBLIC int do_sigpending()
{
}
/*===========================================================================*
- * do_sigprocmask *
+ * do_sigprocmask *
*===========================================================================*/
PUBLIC int do_sigprocmask()
{
}
/*===========================================================================*
- * do_sigsuspend *
+ * do_sigsuspend *
*===========================================================================*/
PUBLIC int do_sigsuspend()
{
}
/*===========================================================================*
- * do_sigreturn *
+ * do_sigreturn *
*===========================================================================*/
PUBLIC int do_sigreturn()
{
}
/*===========================================================================*
- * check_pending *
+ * check_pending *
*===========================================================================*/
PUBLIC void check_pending(rmp)
register struct mproc *rmp;
}
/*===========================================================================*
- * do_times *
+ * do_times *
*===========================================================================*/
PUBLIC int do_times()
{
PRIVATE timer_t *pm_timers = NULL;
/*===========================================================================*
- * pm_set_timer *
+ * pm_set_timer *
*===========================================================================*/
PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
int r;
clock_t now, prev_time = 0, next_time;
- if((r = getuptime(&now)) != OK)
+ if ((r = getuptime(&now)) != OK)
panic(__FILE__, "PM couldn't get uptime", NO_NUM);
/* Set timer argument and add timer to the list. */
prev_time = tmrs_settimer(&pm_timers,tp,now+ticks,watchdog,&next_time);
/* Reschedule our synchronous alarm if necessary. */
- if(! prev_time || prev_time > next_time) {
- if(sys_setalarm(next_time, 1) != OK)
+ if (! prev_time || prev_time > next_time) {
+ if (sys_setalarm(next_time, 1) != OK)
panic(__FILE__, "PM set timer couldn't set alarm.", NO_NUM);
}
/* Check for expired timers and possibly reschedule an alarm. */
tmrs_exptimers(&pm_timers, now, &next_time);
- if(next_time > 0) {
- if(sys_setalarm(next_time, 1) != OK)
+ if (next_time > 0) {
+ if (sys_setalarm(next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set alarm.", NO_NUM);
}
}
/*===========================================================================*
- * pm_cancel_timer *
+ * pm_cancel_timer *
*===========================================================================*/
PUBLIC void pm_cancel_timer(timer_t *tp)
{
* the next timer, or cancel the alarm altogether if the last timer has
* been cancelled (next_time will be 0 then).
*/
- if(prev_time < next_time || ! next_time) {
- if(sys_setalarm(next_time, 1) != OK)
+ if (prev_time < next_time || ! next_time) {
+ if (sys_setalarm(next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set alarm.", NO_NUM);
}
}
_taskcall(FS_PROC_NR, what, &m);
}
-/*==========================================================================*
- * find_param *
- *==========================================================================*/
+/*===========================================================================*
+ * find_param *
+ *===========================================================================*/
PUBLIC char *find_param(name)
const char *name;
{
}
/*===========================================================================*
- * get_mem_map *
+ * get_mem_map *
*===========================================================================*/
PUBLIC int get_mem_map(proc_nr, mem_map)
int proc_nr; /* process to get map of */
}
/*===========================================================================*
- * get_stack_ptr *
+ * get_stack_ptr *
*===========================================================================*/
PUBLIC int get_stack_ptr(proc_nr, sp)
int proc_nr; /* process to get sp of */
PRIVATE char arg_buf[MAX_ARGS_LEN+1];
/*===========================================================================*
- * do_start *
+ * do_start *
*===========================================================================*/
PUBLIC int do_start(message *m_ptr)
{
/*===========================================================================*
- * do_stop *
+ * do_stop *
*===========================================================================*/
PUBLIC int do_stop(message *m_ptr)
{
}
/*===========================================================================*
- * do_exit *
+ * do_exit *
*===========================================================================*/
PUBLIC int do_exit(message *m_ptr)
{
FORWARD _PROTOTYPE(void reply, (int whom, int result) );
/*===========================================================================*
- * main *
+ * main *
*===========================================================================*/
PUBLIC int main(void)
{
/*===========================================================================*
- * init_server *
+ * init_server *
*===========================================================================*/
PRIVATE void init_server(void)
{
/*===========================================================================*
- * get_work *
+ * get_work *
*===========================================================================*/
PRIVATE void get_work()
{