FS cleanup with gcc.
This commit is contained in:
parent
46c8884e36
commit
207f4731dc
10 changed files with 19 additions and 171 deletions
|
@ -246,6 +246,7 @@ PUBLIC int do_setsid()
|
|||
rfp = &fproc[m_in.slot1];
|
||||
rfp->fp_sesldr = TRUE;
|
||||
rfp->fp_tty = 0;
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
|
@ -38,7 +38,7 @@ FORWARD _PROTOTYPE( void load_super, (Dev_t super_dev) );
|
|||
/*===========================================================================*
|
||||
* 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
|
||||
|
@ -91,6 +91,7 @@ PUBLIC void main()
|
|||
}
|
||||
}
|
||||
}
|
||||
return(OK); /* shouldn't come here */
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -178,8 +179,8 @@ PRIVATE void fs_init()
|
|||
/* 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.
|
||||
|
@ -269,9 +270,9 @@ PRIVATE void load_ram(void)
|
|||
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);
|
||||
|
@ -299,7 +300,7 @@ PRIVATE void load_ram(void)
|
|||
*/
|
||||
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);
|
||||
|
@ -395,7 +396,7 @@ PRIVATE void load_ram(void)
|
|||
/* 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");
|
||||
|
||||
|
|
|
@ -425,7 +425,6 @@ PUBLIC int do_svrctl()
|
|||
/* 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);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ char string[NAME_MAX]; /* the final component is returned here */
|
|||
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 {
|
||||
|
@ -95,6 +95,7 @@ char string[NAME_MAX]; /* the final component is returned here */
|
|||
err_code = ENOTDIR;
|
||||
return(NIL_INODE);
|
||||
}
|
||||
}
|
||||
|
||||
/* There is more path. Keep parsing. */
|
||||
new_ip = advance(rip, string);
|
||||
|
@ -247,8 +248,8 @@ int flag; /* LOOK_UP, ENTER, DELETE or IS_EMPTY */
|
|||
* 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;
|
||||
|
|
|
@ -77,7 +77,7 @@ _PROTOTYPE( int lock_op, (struct filp *f, int req) );
|
|||
_PROTOTYPE( void lock_revive, (void) );
|
||||
|
||||
/* main.c */
|
||||
_PROTOTYPE( void main, (void) );
|
||||
_PROTOTYPE( int main, (void) );
|
||||
_PROTOTYPE( void reply, (int whom, int result) );
|
||||
|
||||
/* misc.c */
|
||||
|
|
|
@ -21,20 +21,10 @@
|
|||
#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 *
|
||||
*===========================================================================*/
|
||||
|
@ -43,25 +33,6 @@ PUBLIC 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 *
|
||||
*===========================================================================*/
|
||||
|
@ -85,9 +56,6 @@ int rw_flag; /* READING or WRITING */
|
|||
/* 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);
|
||||
}
|
||||
|
@ -176,7 +144,6 @@ int rw_flag; /* READING or WRITING */
|
|||
|
||||
/* 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);
|
||||
|
@ -220,11 +187,6 @@ int rw_flag; /* READING or WRITING */
|
|||
}
|
||||
}
|
||||
|
||||
#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) {
|
||||
|
@ -275,9 +237,6 @@ int rw_flag; /* READING or WRITING */
|
|||
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);
|
||||
}
|
||||
|
@ -307,7 +266,6 @@ int *completed; /* number of bytes copied */
|
|||
int n, block_spec;
|
||||
block_t b;
|
||||
dev_t dev;
|
||||
int entry;
|
||||
|
||||
*completed = 0;
|
||||
|
||||
|
@ -351,7 +309,6 @@ int *completed; /* number of bytes copied */
|
|||
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),
|
||||
|
@ -366,96 +323,10 @@ int *completed; /* number of bytes copied */
|
|||
}
|
||||
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 *
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* 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
|
||||
*/
|
||||
|
||||
|
@ -61,7 +60,7 @@ FORWARD _PROTOTYPE(int select_request_general, (struct filp *f, int *ops, int bl
|
|||
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
|
||||
|
@ -110,27 +109,12 @@ PRIVATE int select_match_file(struct filp *file)
|
|||
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)
|
||||
|
@ -460,7 +444,7 @@ PRIVATE void select_cancel_all(struct selectentry *e)
|
|||
return;
|
||||
}
|
||||
|
||||
PRIVATE int select_wakeup(struct selectentry *e)
|
||||
PRIVATE void select_wakeup(struct selectentry *e)
|
||||
{
|
||||
/* Open Group:
|
||||
* "Upon successful completion, the pselect() and select()
|
||||
|
@ -468,14 +452,11 @@ PRIVATE int select_wakeup(struct selectentry *e)
|
|||
* 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");
|
||||
|
@ -509,7 +490,7 @@ PRIVATE int select_reevaluate(struct filp *fp)
|
|||
*===========================================================================*/
|
||||
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
|
||||
|
@ -641,8 +622,7 @@ PUBLIC void select_forget(int proc)
|
|||
*===========================================================================*/
|
||||
PUBLIC void select_timeout_check(timer_t *timer)
|
||||
{
|
||||
int s, r;
|
||||
clock_t now;
|
||||
int s;
|
||||
|
||||
s = tmr_arg(timer)->ta_int;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ bit_t origin; /* number of bit to start searching at */
|
|||
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;
|
||||
|
@ -210,8 +210,7 @@ register struct super_block *sp; /* pointer to a superblock */
|
|||
/* 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) */
|
||||
|
|
|
@ -99,8 +99,6 @@ int num; /* number to go with it */
|
|||
* 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 */
|
||||
|
||||
|
|
|
@ -240,8 +240,6 @@ PUBLIC void zero_block(bp)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue