rfp = &fproc[m_in.slot1];
rfp->fp_sesldr = TRUE;
rfp->fp_tty = 0;
+ return(OK);
}
/*===========================================================================*
/*===========================================================================*
* main *
*===========================================================================*/
-PUBLIC void main()
+PUBLIC int main()
{
/* This is the main program of the file system. The main loop consists of
* three major activities: getting new work, processing the work, and sending
}
}
}
+ return(OK); /* shouldn't come here */
}
/*===========================================================================*
/* Initialize global variables, tables, etc. */
register struct inode *rip;
register struct fproc *rfp;
- int key, s, i;
message mess;
+ int s;
/* Initialize the process table with help of the process manager messages.
* Expect one message for each system process with its slot number and pid.
struct super_block *sp, *dsp;
block_t b;
Dev_t image_dev;
- int s,r;
static char sbbuf[MIN_BLOCK_SIZE];
int block_size_image, block_size_ram, ramfs_block_size;
+ int s;
/* Get some boot environment variables. */
root_dev = igetenv("rootdev", 0);
*/
env.key = "cdproberoot";
env.keylen = strlen(env.key);
- sprintf(devnum, "%d", probedev);
+ sprintf(devnum, "%d", (int) probedev);
env.val = devnum;
env.vallen = strlen(devnum);
svrctl(MMSETPARAM, &env);
/* Commit changes to RAM so dev_io will see it. */
do_sync();
- printf("\rRAM disk of %u KB loaded onto /dev/ram.", ram_size_kb);
+ printf("\rRAM disk of %u KB loaded onto /dev/ram.", (unsigned) ram_size_kb);
if (root_dev == DEV_RAM) printf(" Using RAM disk as root FS.");
printf(" \n");
/* A server in user space calls in to manage a device. */
struct fssignon device;
int r, major;
- struct dmap *dp;
if (fp->fp_effuid != SU_UID) return(EPERM);
put_inode(rip); /* bad path in user space */
return(NIL_INODE);
}
- if (*new_name == '\0')
+ if (*new_name == '\0') {
if ( (rip->i_mode & I_TYPE) == I_DIRECTORY) {
return(rip); /* normal exit */
} else {
err_code = ENOTDIR;
return(NIL_INODE);
}
+ }
/* There is more path. Keep parsing. */
new_ip = advance(rip, string);
* if 'string' is dot1 or dot2, no access permissions are checked.
*/
- register struct direct *dp;
- register struct buf *bp;
+ register struct direct *dp = NULL;
+ register struct buf *bp = NULL;
int i, r, e_hit, t, match;
mode_t bits;
off_t pos;
_PROTOTYPE( void lock_revive, (void) );
/* main.c */
-_PROTOTYPE( void main, (void) );
+_PROTOTYPE( int main, (void) );
_PROTOTYPE( void reply, (int whom, int result) );
/* misc.c */
#include "param.h"
#include "super.h"
-#define VVIRCOPY 0
-
-#if VVIRCOPY
-#define NOVVIRCOPY 0
-#else
-#define NOVVIRCOPY 1
-#endif
-
FORWARD _PROTOTYPE( int rw_chunk, (struct inode *rip, off_t position,
unsigned off, int chunk, unsigned left, int rw_flag,
char *buff, int seg, int usr, int block_size, int *completed) );
-FORWARD _PROTOTYPE( int rw_chunk_finish, (int *) );
-
/*===========================================================================*
* do_read *
*===========================================================================*/
return(read_write(READING));
}
-/* The following data is shared between rw_chunk() and rw_chunk_finish().
- * It saves up the copying operations that have to be done between user
- * space and the file system. After every (set of) rw_chunk()s,
- * rw_chunk_finish() has to be called immediately (before the FS call returns)
- * so the actual data copying is done.
- *
- * The point of this is to save on the number of copy system calls.
- */
-#define COPY_QUEUE_LEN CPVEC_NR
-PRIVATE struct copy_queue_entry {
- struct buf *bp; /* buf to put_block after copying */
- int user_seg, user_proc; /* user space data */
- phys_bytes user_offset, fs_offset;
- int blocktype;
- int chunk;
- int op;
-} copy_queue[COPY_QUEUE_LEN];
-PRIVATE int copy_queue_used = 0;
-
/*===========================================================================*
* read_write *
*===========================================================================*/
/* left unfinished rw_chunk()s from previous call! this can't happen.
* it means something has gone wrong we can't repair now.
*/
- if(copy_queue_used != 0) {
- panic(__FILE__,"start - copy queue size nonzero", copy_queue_used);
- }
if(bufs_in_use < 0) {
panic(__FILE__,"start - bufs_in_use negative", bufs_in_use);
}
/* Pipes are a little different. Check. */
if (rip->i_pipe == I_PIPE) {
- struct filp *other_end;
r = pipe_check(rip, rw_flag, oflags,
m_in.nbytes, position, &partial_cnt, 0);
if (r <= 0) return(r);
}
}
-#if VVIRCOPY
- /* do copying to/from user space */
- r2 = rw_chunk_finish(&completed);
-#endif
-
/* On write, update file size and access time. */
if (rw_flag == WRITING) {
if (regular || mode_word == I_DIRECTORY) {
fp->fp_cum_io_partial = 0;
return(cum_io);
}
- if(copy_queue_used != 0) {
- panic(__FILE__,"end - copy queue size nonzero", copy_queue_used);
- }
if(bufs_in_use < 0) {
panic(__FILE__,"end - bufs_in_use negative", bufs_in_use);
}
int n, block_spec;
block_t b;
dev_t dev;
- int entry;
*completed = 0;
zero_block(bp);
}
-#if NOVVIRCOPY
if (rw_flag == READING) {
/* Copy a chunk from the block buffer to user space. */
r = sys_vircopy(FS_PROC_NR, D, (phys_bytes) (bp->b_data+off),
}
n = (off + chunk == block_size ? FULL_DATA_BLOCK : PARTIAL_DATA_BLOCK);
put_block(bp, n);
-#else
- /* have to copy a buffer now. remember to do it. */
- if(copy_queue_used < 0 || copy_queue_used > COPY_QUEUE_LEN) {
- panic(__FILE__,"copy_queue_used illegal size", copy_queue_used);
- }
-
- if(copy_queue_used == COPY_QUEUE_LEN) {
- r = rw_chunk_finish(completed);
- if(copy_queue_used != 0) {
- panic(__FILE__,"copy_queue_used nonzero", copy_queue_used);
- }
- }
-
- entry = copy_queue_used++;
-
- if(entry < 0 || entry >= COPY_QUEUE_LEN) {
- panic(__FILE__,"entry illegal slot", entry);
- }
-
- copy_queue[entry].bp = bp;
- copy_queue[entry].op = rw_flag;
- copy_queue[entry].user_seg = seg;
- copy_queue[entry].user_proc = usr;
- copy_queue[entry].fs_offset = (phys_bytes) bp->b_data+off;
- copy_queue[entry].user_offset = (phys_bytes) buff;
- copy_queue[entry].chunk = chunk;
- copy_queue[entry].blocktype = (off + chunk == block_size ? FULL_DATA_BLOCK : PARTIAL_DATA_BLOCK);
-
- if(rw_flag == WRITING) {
- bp->b_dirt = DIRTY;
- }
-#endif
return(r);
}
-/*===========================================================================*
- * rw_chunk_finish *
- *===========================================================================*/
-PRIVATE int rw_chunk_finish(int *completed)
-{
- int i, total = 0, r;
- static struct vir_cp_req vir_cp_req[CPVEC_NR];
- message m;
-
- *completed = 0;
- if(copy_queue_used < 1) {
- return OK;
- }
-
- for(i = 0; i < copy_queue_used; i++) {
- struct vir_addr *fs, *user;
-
- if(copy_queue[i].op == READING) {
- fs = &vir_cp_req[i].src;
- user = &vir_cp_req[i].dst;
- } else {
- fs = &vir_cp_req[i].dst;
- user = &vir_cp_req[i].src;
- }
-
- vir_cp_req[i].count = copy_queue[i].chunk;
- fs->proc_nr = FS_PROC_NR;
- fs->segment = D;
- fs->offset = copy_queue[i].fs_offset;
- user->proc_nr = copy_queue[i].user_proc;
- user->segment = copy_queue[i].user_seg;
- user->offset = copy_queue[i].user_offset;
- total += copy_queue[i].chunk;
- }
-
- m.m_type = SYS_VIRVCOPY;
- m.VCP_VEC_SIZE = i;
- m.VCP_VEC_ADDR = (char *) vir_cp_req;
-
- if((r=sendrec(SYSTASK, &m)) < 0) {
- panic(__FILE__,"rw_chunk_finish: virvcopy sendrec failed", r);
- }
-
- for(i = 0; i < copy_queue_used; i++) {
- put_block(copy_queue[i].bp, copy_queue[i].blocktype);
- }
-
- *completed = total;
-
- copy_queue_used = 0;
-
- /* return VIRVCOPY return code */
- return m.m_type;
-}
/*===========================================================================*
* read_map *
* some printf()s are serious errors;
* check combinations of cases listen in open group select
* spec (various NULLs and behaviours);
- * pty support in tty
* make select cancel disappearing fp's
*/
FORWARD _PROTOTYPE(int select_major_match, (int match_major, struct filp *file));
FORWARD _PROTOTYPE(void select_cancel_all, (struct selectentry *e));
-FORWARD _PROTOTYPE(int select_wakeup, (struct selectentry *e));
+FORWARD _PROTOTYPE(void select_wakeup, (struct selectentry *e));
/* The Open Group:
* "The pselect() and select() functions shall support
return 0;
}
-/*===========================================================================*
- * select_request_tty *
- *===========================================================================*/
-PRIVATE int select_request_tty(struct filp *f, int *ops, int block)
-{
- int r, rops;
- rops = *ops;
- if(block) rops |= SEL_NOTIFY;
- *ops = dev_io(DEV_SELECT, f->filp_ino->i_zone[0], rops, NULL, 0, 0, 0);
- if(*ops < 0)
- return SEL_ERR;
- return SEL_OK;
-}
-
/*===========================================================================*
* select_request_general *
*===========================================================================*/
PRIVATE int select_request_general(struct filp *f, int *ops, int block)
{
- int r, rops;
- rops = *ops;
+ int rops = *ops;
if(block) rops |= SEL_NOTIFY;
*ops = dev_io(DEV_SELECT, f->filp_ino->i_zone[0], rops, NULL, 0, 0, 0);
if(*ops < 0)
return;
}
-PRIVATE int select_wakeup(struct selectentry *e)
+PRIVATE void select_wakeup(struct selectentry *e)
{
/* Open Group:
* "Upon successful completion, the pselect() and select()
* set in the bit masks."
*/
revive(e->req_procnr, e->nreadyfds);
- return;
}
PRIVATE int select_reevaluate(struct filp *fp)
{
- int r;
int s, remain_ops = 0, fd, type = -1;
- int want_ops;
if(!fp) {
printf("fs: select: reevalute NULL fp\n");
*===========================================================================*/
PUBLIC int select_callback(struct filp *fp, int ops)
{
- int s, f, fd, want_ops, remain_ops, type;
+ int s, fd, want_ops, type;
/* We are being notified that file pointer fp is available for
* operations 'ops'. We must re-register the select for
*===========================================================================*/
PUBLIC void select_timeout_check(timer_t *timer)
{
- int s, r;
- clock_t now;
+ int s;
s = tmr_arg(timer)->ta_int;
block_t start_block; /* first bit block */
bit_t map_bits; /* how many bits are there in the bit map? */
unsigned bit_blocks; /* how many blocks are there in the bit map? */
- unsigned block, word, bcount, wcount;
+ unsigned block, word, bcount;
struct buf *bp;
bitchunk_t *wptr, *wlim, k;
bit_t i, b;
/* Read a superblock. */
dev_t dev;
int magic;
- int version, native, sb_block, r;
- off_t sb_bytes_offset, sb_io_offset;
+ int version, native, r;
static char sbbuf[MIN_BLOCK_SIZE];
dev = sp->s_dev; /* save device (will be overwritten by copy) */
* inconsistency is detected, e.g., a programming error or illegal value of a
* defined constant.
*/
- int i;
-
if (panicking) return; /* do not panic during a sync */
panicking = TRUE; /* prevent another panic during the sync */
register struct buf *bp; /* pointer to buffer to zero */
{
/* Zero a block. */
- struct super_block *sb;
- int block_size;
memset(bp->b_data, 0, MAX_BLOCK_SIZE);
bp->b_dirt = DIRTY;
}