. 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
This commit is contained in:
Ben Gras 2006-03-15 15:34:12 +00:00
parent 7879c008ae
commit ff67776995
13 changed files with 99 additions and 82 deletions

View file

@ -4,6 +4,8 @@ set -e
RC=/usr/etc/rc.package RC=/usr/etc/rc.package
CDDIR=PACKAGES CDDIR=PACKAGES
MP=/mnt
CDPACK=${MP}/install/packages
if [ -f "$RC" ] if [ -f "$RC" ]
then . "$RC" then . "$RC"
@ -12,13 +14,23 @@ fi
cd / cd /
if [ -n "$cddrive" ] if [ -n "$cddrive" ]
then for package in `isodir "$cddrive" $CDDIR | grep -i '\.tbz'` then pack=${cddrive}p2
do echo -n "Install $package (y/N) ? " 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 read y
if [ "$y" = y -o "$y" = Y ] if [ "$y" = y -o "$y" = Y ]
then echo "Extracting $CDDIR/$package .." then echo "Extracting $CDPACK/$package .."
isoread "$cddrive" $CDDIR/$package | packit - cat $package | packit -
fi fi
done done
else echo "CD mount failed - skipping CD packages."
fi
else echo "Don't know where the install CD is.
fi fi

View file

@ -555,8 +555,8 @@ mount /dev/$usr /mnt >/dev/null || exit # Mount the intended /usr.
(cd /usr || exit 1 (cd /usr || exit 1
if [ "$nobigsource" = 1 ] if [ "$nobigsource" = 1 ]
then list="`ls | fgrep -v src.`" then list="`ls | fgrep -v src. | fgrep -v install`"
else list="`ls`" else list="`ls | fgrep -v install`"
fi fi
for d in $list for d in $list
do do

View file

@ -283,6 +283,8 @@ int rw_flag; /* READING or WRITING */
} }
bp->b_dirt = CLEAN; bp->b_dirt = CLEAN;
return OK;
} }
/*===========================================================================* /*===========================================================================*

View file

@ -240,6 +240,7 @@ int flags; /* mode bits and flags */
flags |= O_NOCTTY; flags |= O_NOCTTY;
} else { } else {
for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
if(rfp->fp_pid == PID_FREE) continue;
if (rfp->fp_tty == dev) flags |= O_NOCTTY; 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. * pairs. These lead to calls on the following routines via the dmap table.
*/ */
int r, proc_e, dummy_proc; int r, proc_e;
message local_m;
proc_e = mess_ptr->IO_ENDPT; proc_e = mess_ptr->IO_ENDPT;

View file

@ -173,10 +173,7 @@ PUBLIC void build_dmap()
* selection. The boot driver and the controller it handles are set at * selection. The boot driver and the controller it handles are set at
* the boot monitor. * the boot monitor.
*/ */
char driver[16]; int i;
char *controller = "c##";
int nr, major = -1;
int i,s;
struct dmap *dp; struct dmap *dp;
/* Build table with device <-> driver mappings. */ /* Build table with device <-> driver mappings. */

View file

@ -108,6 +108,7 @@ PUBLIC int inval_filp(struct filp *fp)
for(fd = 0; fd < OPEN_MAX; fd++) { for(fd = 0; fd < OPEN_MAX; fd++) {
if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) { if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) {
fproc[f].fp_filp[fd] = NIL_FILP; fproc[f].fp_filp[fd] = NIL_FILP;
n++;
} }
} }
} }

View file

@ -376,7 +376,6 @@ off_t newsize; /* inode must become this size */
* writing is done. * writing is done.
*/ */
zone_t zone_size; zone_t zone_size;
off_t p;
int scale, file_type, waspipe; int scale, file_type, waspipe;
dev_t dev; 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' */ if (rip->i_num == ROOT_INODE) return(EBUSY); /* can't remove 'root' */
for (rfp = &fproc[INIT_PROC_NR + 1]; rfp < &fproc[NR_PROCS]; rfp++) for (rfp = &fproc[INIT_PROC_NR + 1]; rfp < &fproc[NR_PROCS]; rfp++)
if (rfp->fp_workdir == rip || rfp->fp_rootdir == rip) return(EBUSY); if (rfp->fp_pid != PID_FREE &&
/* can't remove anybody's working dir */ (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. */ /* Actually try to unlink the file; fails if parent is mode 0 etc. */
if ((r = unlink_file(rldirp, rip, dir_name)) != OK) return r; if ((r = unlink_file(rldirp, rip, dir_name)) != OK) return r;

View file

@ -177,6 +177,7 @@ PUBLIC void lock_revive()
struct fproc *fptr; struct fproc *fptr;
for (fptr = &fproc[INIT_PROC_NR + 1]; fptr < &fproc[NR_PROCS]; fptr++){ for (fptr = &fproc[INIT_PROC_NR + 1]; fptr < &fproc[NR_PROCS]; fptr++){
if(fptr->fp_pid == PID_FREE) continue;
task = -fptr->fp_task; task = -fptr->fp_task;
if (fptr->fp_suspended == SUSPENDED && task == XLOCK) { if (fptr->fp_suspended == SUSPENDED && task == XLOCK) {
revive(fptr->fp_endpoint, 0); revive(fptr->fp_endpoint, 0);

View file

@ -32,7 +32,6 @@ struct super_block; /* proto.h needs to know this */
#include "super.h" #include "super.h"
FORWARD _PROTOTYPE( void fs_init, (void) ); FORWARD _PROTOTYPE( void fs_init, (void) );
FORWARD _PROTOTYPE( int igetenv, (char *var, int optional) );
FORWARD _PROTOTYPE( void get_work, (void) ); FORWARD _PROTOTYPE( void get_work, (void) );
FORWARD _PROTOTYPE( void init_root, (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 * three major activities: getting new work, processing the work, and sending
* the reply. This loop never terminates as long as the file system runs. * the reply. This loop never terminates as long as the file system runs.
*/ */
sigset_t sigset;
int error; int error;
fs_init(); fs_init();
@ -100,12 +98,11 @@ PRIVATE void get_work()
* nonzero, a suspended process must be awakened. * nonzero, a suspended process must be awakened.
*/ */
register struct fproc *rp; register struct fproc *rp;
int l = 0;
if (reviving != 0) { if (reviving != 0) {
/* Revive a suspended process. */ /* Revive a suspended process. */
for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++) 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_p = (int)(rp - fproc);
who_e = rp->fp_endpoint; who_e = rp->fp_endpoint;
call_nr = rp->fp_fd & BYTE; call_nr = rp->fp_fd & BYTE;
@ -203,7 +200,6 @@ PRIVATE void fs_init()
* Then, stop and synchronize with the PM. * Then, stop and synchronize with the PM.
*/ */
do { do {
int slot;
if (OK != (s=receive(PM_PROC_NR, &mess))) if (OK != (s=receive(PM_PROC_NR, &mess)))
panic(__FILE__,"FS couldn't receive from PM", s); panic(__FILE__,"FS couldn't receive from PM", s);
if (NONE == mess.PR_ENDPT) break; 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 * * init_root *
*===========================================================================*/ *===========================================================================*/
@ -279,7 +256,7 @@ PRIVATE void init_root()
{ {
int bad; int bad;
register struct super_block *sp; register struct super_block *sp;
register struct inode *rip; register struct inode *rip = NIL_INODE;
int s; int s;
/* Open the root device. */ /* Open the root device. */

View file

@ -31,6 +31,10 @@
#include "param.h" #include "param.h"
#include "super.h" #include "super.h"
FORWARD _PROTOTYPE( int free_proc, (struct fproc *freed, int flags));
#define FP_EXITING 1
/*===========================================================================* /*===========================================================================*
* do_getsysinfo * * do_getsysinfo *
*===========================================================================*/ *===========================================================================*/
@ -260,14 +264,13 @@ PUBLIC int do_reboot()
/* Only PM may make this call directly. */ /* Only PM may make this call directly. */
if (who_e != PM_PROC_NR) return(EGENERIC); if (who_e != PM_PROC_NR) return(EGENERIC);
/* Sync any unwritten buffers, before exiting processes (drivers). */ /* Do exit processing for all leftover processes and servers,
do_sync(); * but don't actually exit them (if they were really gone, PM
* will tell us about it).
/* Do exit processing for all leftover processes and servers. */ */
for (i = 0; i < NR_PROCS; i++) { for (i = 0; i < NR_PROCS; i++)
if((m_in.endpt1 = fproc[i].fp_endpoint) != NONE) 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 /* 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. * 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); 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, task;
int i, exitee_p, exitee_e, task;
register struct fproc *rfp; register struct fproc *rfp;
register struct filp *rfilp; register struct filp *rfilp;
register struct inode *rip; register struct inode *rip;
dev_t dev; dev_t dev;
/* Only PM may do the EXIT call directly. */ fp = exiter; /* get_filp() needs 'fp' */
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' */
if (fp->fp_suspended == SUSPENDED) { if (fp->fp_suspended == SUSPENDED) {
task = -fp->fp_task; task = -fp->fp_task;
if (task == XPIPE || task == XPOPEN) susp_count--; 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 */ (void) do_unpause(); /* this always succeeds for MM */
fp->fp_suspended = NOT_SUSPENDED; fp->fp_suspended = NOT_SUSPENDED;
} }
@ -432,9 +430,15 @@ PUBLIC int do_exit()
* (unmapping has to be done after the first step, because the * (unmapping has to be done after the first step, because the
* dmap table is used in the first step.) * dmap table is used in the first step.)
*/ */
unsuspend_by_endpt(exitee_e); unsuspend_by_endpt(fp->fp_endpoint);
dmap_unmap_by_endpt(exitee_e);
/* 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. */ /* Invalidate endpoint number for error and sanity checks. */
fp->fp_endpoint = NONE; fp->fp_endpoint = NONE;
@ -446,6 +450,7 @@ PUBLIC int do_exit()
dev = fp->fp_tty; dev = fp->fp_tty;
for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { 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; if (rfp->fp_tty == dev) rfp->fp_tty = 0;
for (i = 0; i < OPEN_MAX; i++) { for (i = 0; i < OPEN_MAX; i++) {
@ -463,6 +468,24 @@ PUBLIC int do_exit()
/* Exit done. Mark slot as free. */ /* Exit done. Mark slot as free. */
fp->fp_pid = PID_FREE; fp->fp_pid = PID_FREE;
return(OK); 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);
} }
/*===========================================================================* /*===========================================================================*

View file

@ -216,7 +216,8 @@ PUBLIC void unsuspend_by_endpt(int proc_e)
* disappeared with return code EAGAIN. * disappeared with return code EAGAIN.
*/ */
for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++, client++) 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); revive(rp->fp_endpoint, EAGAIN);
} }
@ -265,7 +266,7 @@ int count; /* max number of processes to release */
/* Search the proc table. */ /* Search the proc table. */
for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++) { 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_revived == NOT_REVIVING &&
(rp->fp_fd & BYTE) == call_nr && (rp->fp_fd & BYTE) == call_nr &&
rp->fp_filp[rp->fp_fd>>8]->filp_ino == ip) { rp->fp_filp[rp->fp_fd>>8]->filp_ino == ip) {

View file

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
set -e
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
cd /usr/src || exit 1 cd /usr/src || exit 1
make etcfiles make etcfiles

View file

@ -72,6 +72,7 @@ usr=/dev/c0d7p0s2
COPYITEMS="usr/bin bin usr/lib" COPYITEMS="usr/bin bin usr/lib"
RELEASEDIR=/usr/r RELEASEDIR=/usr/r
RELEASEPACKAGE=${RELEASEDIR}/usr/install/packages
IMAGE=cdfdimage IMAGE=cdfdimage
ROOTIMAGE=rootimage ROOTIMAGE=rootimage
CDFILES=/usr/tmp/cdreleasefiles CDFILES=/usr/tmp/cdreleasefiles
@ -121,7 +122,7 @@ fi
IMGBZ=${IMG}.bz2 IMGBZ=${IMG}.bz2
echo "Making $IMGBZ" echo "Making $IMGBZ"
USRMB=80 USRMB=128
USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`" USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`"
USRSECTS="`expr $USRMB \* 1024 \* 2`" USRSECTS="`expr $USRMB \* 1024 \* 2`"
@ -230,10 +231,24 @@ echo " * Mounting $TMPDISK as $RELEASEDIR/usr"
mount $TMPDISK $RELEASEDIR/usr || exit mount $TMPDISK $RELEASEDIR/usr || exit
mkdir -p $RELEASEDIR/tmp mkdir -p $RELEASEDIR/tmp
mkdir -p $RELEASEDIR/usr/tmp mkdir -p $RELEASEDIR/usr/tmp
mkdir -p $RELEASEPACKAGE
echo " * Transfering $COPYITEMS to $RELEASEDIR" echo " * Transfering $COPYITEMS to $RELEASEDIR"
( cd / && tar cf - $COPYITEMS ) | ( cd $RELEASEDIR && tar xf - ) || exit 1 ( 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 # Make sure compilers and libraries are bin-owned
chown -R bin $RELEASEDIR/usr/lib chown -R bin $RELEASEDIR/usr/lib
chmod -R u+w $RELEASEDIR/usr/lib chmod -R u+w $RELEASEDIR/usr/lib
@ -311,19 +326,6 @@ sh mkboot cdfdboot $TMPDISK3
cp $IMAGE $CDFILES/bootflop.img cp $IMAGE $CDFILES/bootflop.img
cp release/cd/* $CDFILES 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= h_opt=
bootimage=$IMAGE bootimage=$IMAGE
if [ "$HDEMU" -ne 0 ]; then if [ "$HDEMU" -ne 0 ]; then