From ff6777699554b62c1cf43d0a799d63f746bf2d5f Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 15 Mar 2006 15:34:12 +0000 Subject: [PATCH] FS: . loops checked for PID_FREE . exit broken down in exit and cleanup functions; when reboot happens, cleanup is done but not exit (as processes have not actually exited), this keeps drivers working . fixed a few uninitialized and unused variables scripts: . new packaging system --- commands/scripts/packme.sh | 28 +++++++++++----- commands/scripts/setup.sh | 4 +-- servers/fs/cache.c | 2 ++ servers/fs/device.c | 4 +-- servers/fs/dmap.c | 5 +-- servers/fs/filedes.c | 1 + servers/fs/link.c | 6 ++-- servers/fs/lock.c | 1 + servers/fs/main.c | 27 ++------------- servers/fs/misc.c | 67 +++++++++++++++++++++++++------------- servers/fs/pipe.c | 5 +-- tools/chrootmake.sh | 1 + tools/release.sh | 30 +++++++++-------- 13 files changed, 99 insertions(+), 82 deletions(-) diff --git a/commands/scripts/packme.sh b/commands/scripts/packme.sh index e2739da98..08f84711e 100644 --- a/commands/scripts/packme.sh +++ b/commands/scripts/packme.sh @@ -4,6 +4,8 @@ set -e RC=/usr/etc/rc.package CDDIR=PACKAGES +MP=/mnt +CDPACK=${MP}/install/packages if [ -f "$RC" ] then . "$RC" @@ -12,13 +14,23 @@ fi cd / if [ -n "$cddrive" ] -then for package in `isodir "$cddrive" $CDDIR | grep -i '\.tbz'` - do echo -n "Install $package (y/N) ? " - read y - if [ "$y" = y -o "$y" = Y ] - then echo "Extracting $CDDIR/$package .." - isoread "$cddrive" $CDDIR/$package | packit - - fi - done +then pack=${cddrive}p2 + umount $pack >/dev/null 2>&1 || true + if mount $pack $MP + then + cd $CDPACK + for package in `ls *.tar.bz` + do echo $package + grep $package List + echo -n "Install $package (y/N) ? " + read y + if [ "$y" = y -o "$y" = Y ] + then echo "Extracting $CDPACK/$package .." + cat $package | packit - + fi + done + else echo "CD mount failed - skipping CD packages." + fi +else echo "Don't know where the install CD is. fi diff --git a/commands/scripts/setup.sh b/commands/scripts/setup.sh index 6e5b5ebb8..d2f6ed9e3 100755 --- a/commands/scripts/setup.sh +++ b/commands/scripts/setup.sh @@ -555,8 +555,8 @@ mount /dev/$usr /mnt >/dev/null || exit # Mount the intended /usr. (cd /usr || exit 1 if [ "$nobigsource" = 1 ] - then list="`ls | fgrep -v src.`" - else list="`ls`" + then list="`ls | fgrep -v src. | fgrep -v install`" + else list="`ls | fgrep -v install`" fi for d in $list do diff --git a/servers/fs/cache.c b/servers/fs/cache.c index 3b5bcf36a..dfc4b6735 100644 --- a/servers/fs/cache.c +++ b/servers/fs/cache.c @@ -283,6 +283,8 @@ int rw_flag; /* READING or WRITING */ } bp->b_dirt = CLEAN; + + return OK; } /*===========================================================================* diff --git a/servers/fs/device.c b/servers/fs/device.c index c6be9d0a5..72ba958d8 100644 --- a/servers/fs/device.c +++ b/servers/fs/device.c @@ -240,6 +240,7 @@ int flags; /* mode bits and flags */ flags |= O_NOCTTY; } else { for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { + if(rfp->fp_pid == PID_FREE) continue; if (rfp->fp_tty == dev) flags |= O_NOCTTY; } } @@ -358,8 +359,7 @@ message *mess_ptr; /* pointer to message for task */ * pairs. These lead to calls on the following routines via the dmap table. */ - int r, proc_e, dummy_proc; - message local_m; + int r, proc_e; proc_e = mess_ptr->IO_ENDPT; diff --git a/servers/fs/dmap.c b/servers/fs/dmap.c index de82c56ef..8f16a6488 100644 --- a/servers/fs/dmap.c +++ b/servers/fs/dmap.c @@ -173,10 +173,7 @@ PUBLIC void build_dmap() * selection. The boot driver and the controller it handles are set at * the boot monitor. */ - char driver[16]; - char *controller = "c##"; - int nr, major = -1; - int i,s; + int i; struct dmap *dp; /* Build table with device <-> driver mappings. */ diff --git a/servers/fs/filedes.c b/servers/fs/filedes.c index 3d5c13ed2..85e1e2021 100644 --- a/servers/fs/filedes.c +++ b/servers/fs/filedes.c @@ -108,6 +108,7 @@ PUBLIC int inval_filp(struct filp *fp) for(fd = 0; fd < OPEN_MAX; fd++) { if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) { fproc[f].fp_filp[fd] = NIL_FILP; + n++; } } } diff --git a/servers/fs/link.c b/servers/fs/link.c index c43622074..8fef8f8e2 100644 --- a/servers/fs/link.c +++ b/servers/fs/link.c @@ -376,7 +376,6 @@ off_t newsize; /* inode must become this size */ * writing is done. */ zone_t zone_size; - off_t p; int scale, file_type, waspipe; dev_t dev; @@ -566,8 +565,9 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */ if (rip->i_num == ROOT_INODE) return(EBUSY); /* can't remove 'root' */ for (rfp = &fproc[INIT_PROC_NR + 1]; rfp < &fproc[NR_PROCS]; rfp++) - if (rfp->fp_workdir == rip || rfp->fp_rootdir == rip) return(EBUSY); - /* can't remove anybody's working dir */ + if (rfp->fp_pid != PID_FREE && + (rfp->fp_workdir == rip || rfp->fp_rootdir == rip)) + return(EBUSY); /* can't remove anybody's working dir */ /* Actually try to unlink the file; fails if parent is mode 0 etc. */ if ((r = unlink_file(rldirp, rip, dir_name)) != OK) return r; diff --git a/servers/fs/lock.c b/servers/fs/lock.c index f31ff81b8..737f88a9b 100644 --- a/servers/fs/lock.c +++ b/servers/fs/lock.c @@ -177,6 +177,7 @@ PUBLIC void lock_revive() struct fproc *fptr; for (fptr = &fproc[INIT_PROC_NR + 1]; fptr < &fproc[NR_PROCS]; fptr++){ + if(fptr->fp_pid == PID_FREE) continue; task = -fptr->fp_task; if (fptr->fp_suspended == SUSPENDED && task == XLOCK) { revive(fptr->fp_endpoint, 0); diff --git a/servers/fs/main.c b/servers/fs/main.c index 3d34fd35b..d6c4d54a2 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -32,7 +32,6 @@ struct super_block; /* proto.h needs to know this */ #include "super.h" FORWARD _PROTOTYPE( void fs_init, (void) ); -FORWARD _PROTOTYPE( int igetenv, (char *var, int optional) ); FORWARD _PROTOTYPE( void get_work, (void) ); FORWARD _PROTOTYPE( void init_root, (void) ); @@ -45,7 +44,6 @@ PUBLIC int main() * three major activities: getting new work, processing the work, and sending * the reply. This loop never terminates as long as the file system runs. */ - sigset_t sigset; int error; fs_init(); @@ -100,12 +98,11 @@ PRIVATE void get_work() * nonzero, a suspended process must be awakened. */ register struct fproc *rp; - int l = 0; if (reviving != 0) { /* Revive a suspended process. */ for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++) - if (rp->fp_revived == REVIVING) { + if (rp->fp_pid != PID_FREE && rp->fp_revived == REVIVING) { who_p = (int)(rp - fproc); who_e = rp->fp_endpoint; call_nr = rp->fp_fd & BYTE; @@ -203,7 +200,6 @@ PRIVATE void fs_init() * Then, stop and synchronize with the PM. */ do { - int slot; if (OK != (s=receive(PM_PROC_NR, &mess))) panic(__FILE__,"FS couldn't receive from PM", s); if (NONE == mess.PR_ENDPT) break; @@ -253,25 +249,6 @@ PRIVATE void fs_init() } } -/*===========================================================================* - * igetenv * - *===========================================================================*/ -PRIVATE int igetenv(key, optional) -char *key; -int optional; -{ -/* Ask kernel for an integer valued boot environment variable. */ - char value[64]; - int i; - - if ((i = env_get_param(key, value, sizeof(value))) != OK) { - if (!optional) - printf("FS: Warning, couldn't get monitor param: %d\n", i); - return 0; - } - return(atoi(value)); -} - /*===========================================================================* * init_root * *===========================================================================*/ @@ -279,7 +256,7 @@ PRIVATE void init_root() { int bad; register struct super_block *sp; - register struct inode *rip; + register struct inode *rip = NIL_INODE; int s; /* Open the root device. */ diff --git a/servers/fs/misc.c b/servers/fs/misc.c index 3629f62ae..64087c171 100644 --- a/servers/fs/misc.c +++ b/servers/fs/misc.c @@ -31,6 +31,10 @@ #include "param.h" #include "super.h" +FORWARD _PROTOTYPE( int free_proc, (struct fproc *freed, int flags)); + +#define FP_EXITING 1 + /*===========================================================================* * do_getsysinfo * *===========================================================================*/ @@ -260,14 +264,13 @@ PUBLIC int do_reboot() /* Only PM may make this call directly. */ if (who_e != PM_PROC_NR) return(EGENERIC); - /* Sync any unwritten buffers, before exiting processes (drivers). */ - do_sync(); - - /* Do exit processing for all leftover processes and servers. */ - for (i = 0; i < NR_PROCS; i++) { + /* Do exit processing for all leftover processes and servers, + * but don't actually exit them (if they were really gone, PM + * will tell us about it). + */ + for (i = 0; i < NR_PROCS; i++) if((m_in.endpt1 = fproc[i].fp_endpoint) != NONE) - do_exit(); - } + free_proc(&fproc[i], 0); /* The root file system is mounted onto itself, which keeps it from being * unmounted. Pull an inode out of thin air and put the root on it. @@ -286,6 +289,9 @@ PUBLIC int do_reboot() } } + /* Sync any unwritten buffers. */ + do_sync(); + return(OK); } @@ -387,30 +393,22 @@ PUBLIC int do_exec() } /*===========================================================================* - * do_exit * + * free_proc * *===========================================================================*/ -PUBLIC int do_exit() +PRIVATE int free_proc(struct fproc *exiter, int flags) { -/* Perform the file system portion of the exit(status) system call. */ - - int i, exitee_p, exitee_e, task; + int i, task; register struct fproc *rfp; register struct filp *rfilp; register struct inode *rip; dev_t dev; - /* Only PM may do the EXIT call directly. */ - if (who_e != PM_PROC_NR) return(EGENERIC); - - /* Nevertheless, pretend that the call came from the user. */ - exitee_e = m_in.endpt1; - okendpt(exitee_e, &exitee_p); - fp = &fproc[exitee_p]; /* get_filp() needs 'fp' */ + fp = exiter; /* get_filp() needs 'fp' */ if (fp->fp_suspended == SUSPENDED) { task = -fp->fp_task; if (task == XPIPE || task == XPOPEN) susp_count--; - m_in.ENDPT = exitee_e; + m_in.ENDPT = fp->fp_endpoint; (void) do_unpause(); /* this always succeeds for MM */ fp->fp_suspended = NOT_SUSPENDED; } @@ -432,9 +430,15 @@ PUBLIC int do_exit() * (unmapping has to be done after the first step, because the * dmap table is used in the first step.) */ - unsuspend_by_endpt(exitee_e); - dmap_unmap_by_endpt(exitee_e); + unsuspend_by_endpt(fp->fp_endpoint); + /* The rest of these actions is only done when processes actually + * exit. + */ + if(!(flags & FP_EXITING)) + return OK; + + dmap_unmap_by_endpt(fp->fp_endpoint); /* Invalidate endpoint number for error and sanity checks. */ fp->fp_endpoint = NONE; @@ -446,6 +450,7 @@ PUBLIC int do_exit() dev = fp->fp_tty; for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { + if(rfp->fp_pid == PID_FREE) continue; if (rfp->fp_tty == dev) rfp->fp_tty = 0; for (i = 0; i < OPEN_MAX; i++) { @@ -463,6 +468,24 @@ PUBLIC int do_exit() /* Exit done. Mark slot as free. */ fp->fp_pid = PID_FREE; return(OK); + +} + +/*===========================================================================* + * do_exit * + *===========================================================================*/ +PUBLIC int do_exit() +{ + int exitee_p, exitee_e; +/* Perform the file system portion of the exit(status) system call. */ + + /* Only PM may do the EXIT call directly. */ + if (who_e != PM_PROC_NR) return(EGENERIC); + + /* Nevertheless, pretend that the call came from the user. */ + exitee_e = m_in.endpt1; + okendpt(exitee_e, &exitee_p); + return free_proc(&fproc[exitee_p], FP_EXITING); } /*===========================================================================* diff --git a/servers/fs/pipe.c b/servers/fs/pipe.c index e49717d2d..98d5eb2e7 100644 --- a/servers/fs/pipe.c +++ b/servers/fs/pipe.c @@ -216,7 +216,8 @@ PUBLIC void unsuspend_by_endpt(int proc_e) * disappeared with return code EAGAIN. */ for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++, client++) - if(rp->fp_suspended == SUSPENDED && rp->fp_task == -proc_e) { + if(rp->fp_pid != PID_FREE && + rp->fp_suspended == SUSPENDED && rp->fp_task == -proc_e) { revive(rp->fp_endpoint, EAGAIN); } @@ -265,7 +266,7 @@ int count; /* max number of processes to release */ /* Search the proc table. */ for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++) { - if (rp->fp_suspended == SUSPENDED && + if (rp->fp_pid != PID_FREE && rp->fp_suspended == SUSPENDED && rp->fp_revived == NOT_REVIVING && (rp->fp_fd & BYTE) == call_nr && rp->fp_filp[rp->fp_fd>>8]->filp_ino == ip) { diff --git a/tools/chrootmake.sh b/tools/chrootmake.sh index a18ba5e28..5f363f722 100755 --- a/tools/chrootmake.sh +++ b/tools/chrootmake.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin cd /usr/src || exit 1 make etcfiles diff --git a/tools/release.sh b/tools/release.sh index 2bc7e6266..9a6c15534 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -72,6 +72,7 @@ usr=/dev/c0d7p0s2 COPYITEMS="usr/bin bin usr/lib" RELEASEDIR=/usr/r +RELEASEPACKAGE=${RELEASEDIR}/usr/install/packages IMAGE=cdfdimage ROOTIMAGE=rootimage CDFILES=/usr/tmp/cdreleasefiles @@ -121,7 +122,7 @@ fi IMGBZ=${IMG}.bz2 echo "Making $IMGBZ" -USRMB=80 +USRMB=128 USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`" USRSECTS="`expr $USRMB \* 1024 \* 2`" @@ -230,10 +231,24 @@ echo " * Mounting $TMPDISK as $RELEASEDIR/usr" mount $TMPDISK $RELEASEDIR/usr || exit mkdir -p $RELEASEDIR/tmp mkdir -p $RELEASEDIR/usr/tmp +mkdir -p $RELEASEPACKAGE echo " * Transfering $COPYITEMS to $RELEASEDIR" ( cd / && tar cf - $COPYITEMS ) | ( cd $RELEASEDIR && tar xf - ) || exit 1 +if [ -d $PACKAGEDIR ] +then echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE" + cp $PACKAGEDIR/* $RELEASEPACKAGE/ + ( cd $PACKAGEDIR + for p in *.tar.bz + do descr="../`echo $p | sed 's/.tar.bz//'`/.descr" + if [ -f "$descr" ] + then printf "%-27s %s\n" "$p" "`cat $descr`" + fi + done >List + ) +fi + # Make sure compilers and libraries are bin-owned chown -R bin $RELEASEDIR/usr/lib chmod -R u+w $RELEASEDIR/usr/lib @@ -311,19 +326,6 @@ sh mkboot cdfdboot $TMPDISK3 cp $IMAGE $CDFILES/bootflop.img cp release/cd/* $CDFILES -DESTPACKAGES=$CDFILES/PACKAGES -mkdir -p $DESTPACKAGES - -( cd $PACKAGEDIR - for f in *tar* - do - shortname="`echo $f | sed 's/\.tar\..*//' | tr -dc '[a-z][A-z][0-9]' | sed 's/^\(........\).*/\1/' | tr '[a-z]' '[A-Z]'`.TBZ" - cp $f $DESTPACKAGES/$shortname - echo $shortname $f >>$DESTPACKAGES/List - echo " * Copied $f to $shortname" - done -) - h_opt= bootimage=$IMAGE if [ "$HDEMU" -ne 0 ]; then -- 2.44.0