. 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
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

View file

@ -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

View file

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

View file

@ -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;

View file

@ -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. */

View file

@ -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++;
}
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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. */

View file

@ -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);
}
/*===========================================================================*

View file

@ -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) {

View file

@ -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

View file

@ -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