Kernel sources reformated with 4 space indent, no tabs.
Unused file include/trace.h deleted.
This commit is contained in:
@@ -863,7 +863,6 @@ file /include/sys/syslog.h
|
||||
file /include/sys/systm.h
|
||||
file /include/sys/time.h
|
||||
file /include/sys/times.h
|
||||
file /include/sys/trace.h
|
||||
file /include/sys/ttychars.h
|
||||
file /include/sys/ttydev.h
|
||||
file /include/sys/tty.h
|
||||
|
||||
@@ -36,5 +36,5 @@ clean: FRC
|
||||
rm -f ${OBJS}
|
||||
|
||||
install: _make_01
|
||||
cp ${OBJS} ${DESTDIR}${MDIR}
|
||||
# cp ${OBJS} ${DESTDIR}${MDIR}
|
||||
FRC:
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)adc.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
* @(#)adc.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
*/
|
||||
|
||||
#ifndef _ADC_H
|
||||
#ifndef _ADC_H
|
||||
#define _ADC_H
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* doubly linked for easy removal.
|
||||
*
|
||||
* There are currently two queues for buffers:
|
||||
* one for buffers containing ``useful'' information (the cache)
|
||||
* one for buffers containing ``non-useful'' information
|
||||
* (and empty buffers, pushed onto the front)
|
||||
* one for buffers containing ``useful'' information (the cache)
|
||||
* one for buffers containing ``non-useful'' information
|
||||
* (and empty buffers, pushed onto the front)
|
||||
* These queues contain the buffers which are available for
|
||||
* reallocation, are kept in lru order. When not on one of these queues,
|
||||
* the buffers are ``checked out'' to drivers which use the available list
|
||||
@@ -30,26 +30,26 @@
|
||||
*/
|
||||
struct bufhd
|
||||
{
|
||||
int b_flags; /* see defines below */
|
||||
struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */
|
||||
int b_flags; /* see defines below */
|
||||
struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */
|
||||
};
|
||||
|
||||
struct buf
|
||||
{
|
||||
int b_flags; /* see defines below */
|
||||
struct buf *b_forw, *b_back; /* hash chain (2 way street) */
|
||||
struct buf *av_forw, *av_back; /* position on free list if not BUSY */
|
||||
#define b_actf av_forw /* alternate names for driver queue */
|
||||
#define b_actl av_back /* head - isn't history wonderful */
|
||||
u_int b_bcount; /* transfer count */
|
||||
#define b_active b_bcount /* driver queue head: drive active */
|
||||
int b_error; /* returned after I/O */
|
||||
dev_t b_dev; /* major+minor device name */
|
||||
caddr_t b_addr; /* core address */
|
||||
daddr_t b_blkno; /* block # on device */
|
||||
u_int b_resid; /* words not transferred after error */
|
||||
#define b_cylin b_resid /* disksort */
|
||||
#define b_errcnt b_resid /* while i/o in progress: # retries */
|
||||
int b_flags; /* see defines below */
|
||||
struct buf *b_forw, *b_back; /* hash chain (2 way street) */
|
||||
struct buf *av_forw, *av_back; /* position on free list if not BUSY */
|
||||
#define b_actf av_forw /* alternate names for driver queue */
|
||||
#define b_actl av_back /* head - isn't history wonderful */
|
||||
u_int b_bcount; /* transfer count */
|
||||
#define b_active b_bcount /* driver queue head: drive active */
|
||||
int b_error; /* returned after I/O */
|
||||
dev_t b_dev; /* major+minor device name */
|
||||
caddr_t b_addr; /* core address */
|
||||
daddr_t b_blkno; /* block # on device */
|
||||
u_int b_resid; /* words not transferred after error */
|
||||
#define b_cylin b_resid /* disksort */
|
||||
#define b_errcnt b_resid /* while i/o in progress: # retries */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -57,30 +57,30 @@ struct buf
|
||||
* code to drop in, you have to have BQ_AGE and BQ_LRU *after* the first
|
||||
* queue, and it only costs 6 bytes of data space.
|
||||
*/
|
||||
#define BQUEUES 3 /* number of free buffer queues */
|
||||
#define BQUEUES 3 /* number of free buffer queues */
|
||||
|
||||
#define BQ_LOCKED 0 /* super-blocks &c */
|
||||
#define BQ_LRU 1 /* lru, useful buffers */
|
||||
#define BQ_AGE 2 /* rubbish */
|
||||
#define BQ_EMPTY 3 /* buffer headers with no memory */
|
||||
#define BQ_LOCKED 0 /* super-blocks &c */
|
||||
#define BQ_LRU 1 /* lru, useful buffers */
|
||||
#define BQ_AGE 2 /* rubbish */
|
||||
#define BQ_EMPTY 3 /* buffer headers with no memory */
|
||||
|
||||
/* Flags to low-level allocation routines. */
|
||||
#define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */
|
||||
#define B_SYNC 0x02 /* Do all allocations synchronously. */
|
||||
#define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */
|
||||
#define B_SYNC 0x02 /* Do all allocations synchronously. */
|
||||
|
||||
#define bawrite(bp) { (bp)->b_flags |= B_ASYNC; bwrite(bp); }
|
||||
#define bfree(bp) (bp)->b_bcount = 0
|
||||
#define bawrite(bp) { (bp)->b_flags |= B_ASYNC; bwrite(bp); }
|
||||
#define bfree(bp) (bp)->b_bcount = 0
|
||||
|
||||
#ifdef KERNEL
|
||||
struct inode;
|
||||
|
||||
#define BUFHSZ 16 /* must be power of 2 */
|
||||
#define BUFHASH(dev,bn) ((struct buf*) &bufhash [((dev) + bn) & (BUFHSZ - 1)])
|
||||
#define BUFHSZ 16 /* must be power of 2 */
|
||||
#define BUFHASH(dev,bn) ((struct buf*) &bufhash [((dev) + bn) & (BUFHSZ - 1)])
|
||||
|
||||
extern struct buf buf[]; /* the buffer pool itself */
|
||||
extern char bufdata[]; /* core data */
|
||||
extern struct bufhd bufhash[]; /* heads of hash lists */
|
||||
extern struct buf bfreelist[]; /* heads of available lists */
|
||||
extern struct buf buf[]; /* the buffer pool itself */
|
||||
extern char bufdata[]; /* core data */
|
||||
extern struct bufhd bufhash[]; /* heads of hash lists */
|
||||
extern struct buf bfreelist[]; /* heads of available lists */
|
||||
|
||||
/*
|
||||
* Assign a buffer for the given block. If the appropriate
|
||||
@@ -163,65 +163,65 @@ int geterror (struct buf *bp);
|
||||
/*
|
||||
* These flags are kept in b_flags.
|
||||
*/
|
||||
#define B_WRITE 0x00000 /* non-read pseudo-flag */
|
||||
#define B_READ 0x00001 /* read when I/O occurs */
|
||||
#define B_DONE 0x00002 /* transaction finished */
|
||||
#define B_ERROR 0x00004 /* transaction aborted */
|
||||
#define B_BUSY 0x00008 /* not on av_forw/back list */
|
||||
#define B_PHYS 0x00010 /* physical IO */
|
||||
#define B_MAP 0x00020 /* alloc UNIBUS */
|
||||
#define B_WANTED 0x00040 /* issue wakeup when BUSY goes off */
|
||||
#define B_AGE 0x00080 /* delayed write for correct aging */
|
||||
#define B_ASYNC 0x00100 /* don't wait for I/O completion */
|
||||
#define B_DELWRI 0x00200 /* write at exit of avail list */
|
||||
#define B_TAPE 0x00400 /* this is a magtape (no bdwrite) */
|
||||
#define B_INVAL 0x00800 /* does not contain valid info */
|
||||
#define B_BAD 0x01000 /* bad block revectoring in progress */
|
||||
#define B_LOCKED 0x02000 /* locked in core (not reusable) */
|
||||
#define B_UBAREMAP 0x04000 /* addr UNIBUS virtual, not physical */
|
||||
#define B_RAMREMAP 0x08000 /* remapped into ramdisk */
|
||||
#define B_WRITE 0x00000 /* non-read pseudo-flag */
|
||||
#define B_READ 0x00001 /* read when I/O occurs */
|
||||
#define B_DONE 0x00002 /* transaction finished */
|
||||
#define B_ERROR 0x00004 /* transaction aborted */
|
||||
#define B_BUSY 0x00008 /* not on av_forw/back list */
|
||||
#define B_PHYS 0x00010 /* physical IO */
|
||||
#define B_MAP 0x00020 /* alloc UNIBUS */
|
||||
#define B_WANTED 0x00040 /* issue wakeup when BUSY goes off */
|
||||
#define B_AGE 0x00080 /* delayed write for correct aging */
|
||||
#define B_ASYNC 0x00100 /* don't wait for I/O completion */
|
||||
#define B_DELWRI 0x00200 /* write at exit of avail list */
|
||||
#define B_TAPE 0x00400 /* this is a magtape (no bdwrite) */
|
||||
#define B_INVAL 0x00800 /* does not contain valid info */
|
||||
#define B_BAD 0x01000 /* bad block revectoring in progress */
|
||||
#define B_LOCKED 0x02000 /* locked in core (not reusable) */
|
||||
#define B_UBAREMAP 0x04000 /* addr UNIBUS virtual, not physical */
|
||||
#define B_RAMREMAP 0x08000 /* remapped into ramdisk */
|
||||
|
||||
/*
|
||||
* Insq/Remq for the buffer hash lists.
|
||||
*/
|
||||
#define bremhash(bp) { \
|
||||
(bp)->b_back->b_forw = (bp)->b_forw; \
|
||||
(bp)->b_forw->b_back = (bp)->b_back; \
|
||||
#define bremhash(bp) { \
|
||||
(bp)->b_back->b_forw = (bp)->b_forw; \
|
||||
(bp)->b_forw->b_back = (bp)->b_back; \
|
||||
}
|
||||
#define binshash(bp, dp) { \
|
||||
(bp)->b_forw = (dp)->b_forw; \
|
||||
(bp)->b_back = (dp); \
|
||||
(dp)->b_forw->b_back = (bp); \
|
||||
(dp)->b_forw = (bp); \
|
||||
#define binshash(bp, dp) { \
|
||||
(bp)->b_forw = (dp)->b_forw; \
|
||||
(bp)->b_back = (dp); \
|
||||
(dp)->b_forw->b_back = (bp); \
|
||||
(dp)->b_forw = (bp); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Insq/Remq for the buffer free lists.
|
||||
*/
|
||||
#define bremfree(bp) { \
|
||||
(bp)->av_back->av_forw = (bp)->av_forw; \
|
||||
(bp)->av_forw->av_back = (bp)->av_back; \
|
||||
#define bremfree(bp) { \
|
||||
(bp)->av_back->av_forw = (bp)->av_forw; \
|
||||
(bp)->av_forw->av_back = (bp)->av_back; \
|
||||
}
|
||||
#define binsheadfree(bp, dp) { \
|
||||
(dp)->av_forw->av_back = (bp); \
|
||||
(bp)->av_forw = (dp)->av_forw; \
|
||||
(dp)->av_forw = (bp); \
|
||||
(bp)->av_back = (dp); \
|
||||
#define binsheadfree(bp, dp) { \
|
||||
(dp)->av_forw->av_back = (bp); \
|
||||
(bp)->av_forw = (dp)->av_forw; \
|
||||
(dp)->av_forw = (bp); \
|
||||
(bp)->av_back = (dp); \
|
||||
}
|
||||
#define binstailfree(bp, dp) { \
|
||||
(dp)->av_back->av_forw = (bp); \
|
||||
(bp)->av_back = (dp)->av_back; \
|
||||
(dp)->av_back = (bp); \
|
||||
(bp)->av_forw = (dp); \
|
||||
#define binstailfree(bp, dp) { \
|
||||
(dp)->av_back->av_forw = (bp); \
|
||||
(bp)->av_back = (dp)->av_back; \
|
||||
(dp)->av_back = (bp); \
|
||||
(bp)->av_forw = (dp); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Take a buffer off the free list it's on and
|
||||
* mark it as being use (B_BUSY) by a device.
|
||||
*/
|
||||
#define notavail(bp) { \
|
||||
register int x = splbio(); \
|
||||
bremfree(bp); \
|
||||
(bp)->b_flags |= B_BUSY; \
|
||||
splx(x); \
|
||||
#define notavail(bp) { \
|
||||
register int x = splbio(); \
|
||||
bremfree(bp); \
|
||||
(bp)->b_flags |= B_BUSY; \
|
||||
splx(x); \
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
* forced to use a long, you might as well start doing the real-time
|
||||
* timer as a timeout like 4.3BSD.
|
||||
*/
|
||||
struct callout {
|
||||
int c_time; /* incremental time */
|
||||
caddr_t c_arg; /* argument to routine */
|
||||
void (*c_func) (caddr_t); /* routine */
|
||||
struct callout *c_next;
|
||||
struct callout {
|
||||
int c_time; /* incremental time */
|
||||
caddr_t c_arg; /* argument to routine */
|
||||
void (*c_func) (caddr_t); /* routine */
|
||||
struct callout *c_next;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct callout *callfree, callout[], calltodo;
|
||||
extern struct callout *callfree, callout[], calltodo;
|
||||
#endif
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
struct cblock {
|
||||
struct cblock *c_next;
|
||||
char c_info [CBSIZE];
|
||||
struct cblock *c_next;
|
||||
char c_info [CBSIZE];
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct cblock cfree[];
|
||||
struct cblock *cfreelist;
|
||||
int cfreecount;
|
||||
struct cblock *cfreelist;
|
||||
int cfreecount;
|
||||
#endif
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef _DIR_
|
||||
#define _DIR_
|
||||
#ifndef _DIR_
|
||||
#define _DIR_
|
||||
|
||||
#ifndef MAXNAMLEN
|
||||
#define MAXNAMLEN 63
|
||||
#define MAXNAMLEN 63
|
||||
#endif
|
||||
|
||||
#define DIRBLKSIZ 1024
|
||||
#define DIRBLKSIZ 1024
|
||||
|
||||
/*
|
||||
* inode numbers are ino_t rather than u_long now. before, when v7direct
|
||||
@@ -19,11 +19,11 @@
|
||||
* like a good idea to change the "real direct structure". SMS
|
||||
*/
|
||||
|
||||
struct direct {
|
||||
ino_t d_ino; /* inode number of entry */
|
||||
u_short d_reclen; /* length of this record */
|
||||
u_short d_namlen; /* length of string in d_name */
|
||||
char d_name[MAXNAMLEN+1]; /* name must be no longer than this */
|
||||
struct direct {
|
||||
ino_t d_ino; /* inode number of entry */
|
||||
u_short d_reclen; /* length of this record */
|
||||
u_short d_namlen; /* length of string in d_name */
|
||||
char d_name[MAXNAMLEN+1]; /* name must be no longer than this */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -60,27 +60,27 @@ struct direct {
|
||||
* Definitions for library routines operating on directories.
|
||||
*/
|
||||
typedef struct _dirdesc {
|
||||
int dd_fd;
|
||||
long dd_loc;
|
||||
long dd_size;
|
||||
char dd_buf[DIRBLKSIZ];
|
||||
struct direct dd_cur;
|
||||
int dd_fd;
|
||||
long dd_loc;
|
||||
long dd_size;
|
||||
char dd_buf[DIRBLKSIZ];
|
||||
struct direct dd_cur;
|
||||
} DIR;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
|
||||
extern DIR *opendir (const char *);
|
||||
extern struct direct *readdir (DIR *);
|
||||
extern long telldir (DIR *);
|
||||
extern void seekdir (DIR *, long);
|
||||
extern void closedir (DIR *);
|
||||
extern DIR *opendir (const char *);
|
||||
extern struct direct *readdir (DIR *);
|
||||
extern long telldir (DIR *);
|
||||
extern void seekdir (DIR *, long);
|
||||
extern void closedir (DIR *);
|
||||
|
||||
#define rewinddir(dirp) seekdir ((dirp), (long)0)
|
||||
#define dirfd(dirp) ((dirp)->dd_fd)
|
||||
#define rewinddir(dirp) seekdir ((dirp), (long)0)
|
||||
#define dirfd(dirp) ((dirp)->dd_fd)
|
||||
|
||||
#endif /* !KERNEL */
|
||||
|
||||
@@ -89,17 +89,17 @@ extern void closedir (DIR *);
|
||||
* Should use struct direct's, but the name field
|
||||
* is MAXNAMLEN - 1, and this just won't do.
|
||||
*/
|
||||
#define dotdot_ino dtdt_ino
|
||||
#define dotdot_reclen dtdt_rec
|
||||
#define dotdot_name dtdt_name
|
||||
#define dotdot_ino dtdt_ino
|
||||
#define dotdot_reclen dtdt_rec
|
||||
#define dotdot_name dtdt_name
|
||||
struct dirtemplate {
|
||||
ino_t dot_ino;
|
||||
u_short dot_reclen;
|
||||
u_short dot_namlen;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
ino_t dotdot_ino;
|
||||
u_short dotdot_reclen;
|
||||
u_short dotdot_namlen;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
ino_t dot_ino;
|
||||
u_short dot_reclen;
|
||||
u_short dot_namlen;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
ino_t dotdot_ino;
|
||||
u_short dotdot_reclen;
|
||||
u_short dotdot_namlen;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
#endif /* _DIR_ */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
@@ -8,8 +8,8 @@
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratory.
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratory.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -21,8 +21,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -39,8 +39,8 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _SYS_DISK_H_
|
||||
#define _SYS_DISK_H_
|
||||
#ifndef _SYS_DISK_H_
|
||||
#define _SYS_DISK_H_
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
/*
|
||||
@@ -51,7 +51,7 @@
|
||||
*
|
||||
* Note: the 2.11BSD version is very different. The 4.4 version served
|
||||
* as the inspiration. I needed something similar but for slightly
|
||||
* different purposes.
|
||||
* different purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -76,38 +76,33 @@
|
||||
*/
|
||||
|
||||
struct dkdevice {
|
||||
int dk_bopenmask; /* block devices open */
|
||||
int dk_copenmask; /* character devices open */
|
||||
int dk_openmask; /* composite (bopen|copen) */
|
||||
int dk_flags; /* label state see below */
|
||||
size_t dk_label; /* sector containing label */
|
||||
struct partition dk_parts[MAXPARTITIONS]; /* inkernel portion */
|
||||
int dk_bopenmask; /* block devices open */
|
||||
int dk_copenmask; /* character devices open */
|
||||
int dk_openmask; /* composite (bopen|copen) */
|
||||
int dk_flags; /* label state - see below */
|
||||
size_t dk_label; /* sector containing label */
|
||||
struct partition dk_parts[MAXPARTITIONS]; /* inkernel portion */
|
||||
};
|
||||
|
||||
#define DKF_OPENING 0x0001 /* drive is being opened */
|
||||
#define DKF_CLOSING 0x0002 /* drive is being closed */
|
||||
#define DKF_WANTED 0x0004 /* drive is being waited for */
|
||||
#define DKF_ALIVE 0x0008 /* drive is alive */
|
||||
#define DKF_ONLINE 0x0010 /* drive is online */
|
||||
#define DKF_WLABEL 0x0020 /* label area is being written */
|
||||
#define DKF_SEEK 0x0040 /* drive is seeking */
|
||||
#define DKF_SWAIT 0x0080 /* waiting for seek to complete */
|
||||
#define DKF_OPENING 0x0001 /* drive is being opened */
|
||||
#define DKF_CLOSING 0x0002 /* drive is being closed */
|
||||
#define DKF_WANTED 0x0004 /* drive is being waited for */
|
||||
#define DKF_ALIVE 0x0008 /* drive is alive */
|
||||
#define DKF_ONLINE 0x0010 /* drive is online */
|
||||
#define DKF_WLABEL 0x0020 /* label area is being written */
|
||||
#define DKF_SEEK 0x0040 /* drive is seeking */
|
||||
#define DKF_SWAIT 0x0080 /* waiting for seek to complete */
|
||||
|
||||
/* encoding of disk minor numbers, should be elsewhere... but better
|
||||
* here than in ufs_disksubr.c
|
||||
*
|
||||
* Note: the controller number in bits 6 and 7 of the minor device are NOT
|
||||
* removed. It is the responsibility of the driver to extract or mask
|
||||
* these bits.
|
||||
* removed. It is the responsibility of the driver to extract or mask
|
||||
* these bits.
|
||||
*/
|
||||
|
||||
#define dkunit(dev) (minor(dev) >> 3)
|
||||
#define dkpart(dev) (minor(dev) & 07)
|
||||
#define dkminor(unit, part) (((unit) << 3) | (part))
|
||||
#define dkunit(dev) (minor(dev) >> 3)
|
||||
#define dkpart(dev) (minor(dev) & 07)
|
||||
#define dkminor(unit, part) (((unit) << 3) | (part))
|
||||
|
||||
#ifdef KERNEL
|
||||
//char *readdisklabel();
|
||||
//int setdisklabel();
|
||||
//int writedisklabel();
|
||||
#endif
|
||||
#endif /* _SYS_DISK_H_ */
|
||||
|
||||
@@ -7,25 +7,25 @@
|
||||
/*
|
||||
* Instrumentation
|
||||
*/
|
||||
#define CPUSTATES 4
|
||||
#define CPUSTATES 4
|
||||
|
||||
#define CP_USER 0
|
||||
#define CP_NICE 1
|
||||
#define CP_SYS 2
|
||||
#define CP_IDLE 3
|
||||
#define CP_USER 0
|
||||
#define CP_NICE 1
|
||||
#define CP_SYS 2
|
||||
#define CP_IDLE 3
|
||||
|
||||
#define DK_NDRIVE 4
|
||||
#define DK_NDRIVE 4
|
||||
|
||||
#if defined(KERNEL) && defined(UCB_METER)
|
||||
long cp_time[CPUSTATES]; /* number of ticks spent in each cpu state */
|
||||
int dk_ndrive; /* number of drives being monitored */
|
||||
int dk_busy; /* bit array of drive busy flags */
|
||||
long dk_xfer[DK_NDRIVE]; /* number of transfers */
|
||||
long dk_bytes[DK_NDRIVE]; /* number of bytes transfered */
|
||||
char *dk_name[DK_NDRIVE]; /* names of monitored drives */
|
||||
int dk_unit[DK_NDRIVE]; /* unit numbers of monitored drives */
|
||||
int dk_n; /* number of dk numbers assigned so far */
|
||||
long cp_time[CPUSTATES]; /* number of ticks spent in each cpu state */
|
||||
int dk_ndrive; /* number of drives being monitored */
|
||||
int dk_busy; /* bit array of drive busy flags */
|
||||
long dk_xfer[DK_NDRIVE]; /* number of transfers */
|
||||
long dk_bytes[DK_NDRIVE]; /* number of bytes transfered */
|
||||
char *dk_name[DK_NDRIVE]; /* names of monitored drives */
|
||||
int dk_unit[DK_NDRIVE]; /* unit numbers of monitored drives */
|
||||
int dk_n; /* number of dk numbers assigned so far */
|
||||
|
||||
long tk_nin; /* number of tty characters input */
|
||||
long tk_nout; /* number of tty characters output */
|
||||
long tk_nin; /* number of tty characters input */
|
||||
long tk_nout; /* number of tty characters output */
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)dkbad.h 1.1 (2.10BSD Berkeley) 12/1/86
|
||||
* @(#)dkbad.h 1.1 (2.10BSD Berkeley) 12/1/86
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -39,19 +39,19 @@
|
||||
* there are exceptions to this rule. Note, this value is also present
|
||||
* in the bad144 program.
|
||||
*/
|
||||
#define MAXBAD 32 /* Maximum bad sectors supported */
|
||||
#define MAXBAD 32 /* Maximum bad sectors supported */
|
||||
|
||||
struct dkbad {
|
||||
long bt_csn; /* cartridge serial number */
|
||||
u_short bt_mbz; /* unused; should be 0 */
|
||||
u_short bt_flag; /* -1 => alignment cartridge */
|
||||
struct bt_bad {
|
||||
u_short bt_cyl; /* cylinder number of bad sector */
|
||||
u_short bt_trksec; /* track and sector number */
|
||||
} bt_bad[MAXBAD];
|
||||
long bt_csn; /* cartridge serial number */
|
||||
u_short bt_mbz; /* unused; should be 0 */
|
||||
u_short bt_flag; /* -1 => alignment cartridge */
|
||||
struct bt_bad {
|
||||
u_short bt_cyl; /* cylinder number of bad sector */
|
||||
u_short bt_trksec; /* track and sector number */
|
||||
} bt_bad[MAXBAD];
|
||||
};
|
||||
|
||||
#define ECC 0
|
||||
#define SSE 1
|
||||
#define BSE 2
|
||||
#define CONT 3
|
||||
#define ECC 0
|
||||
#define SSE 1
|
||||
#define BSE 2
|
||||
#define CONT 3
|
||||
|
||||
@@ -3,119 +3,119 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)errno.h 7.1.3 (2.11BSD) 1999/9/6
|
||||
* @(#)errno.h 7.1.3 (2.11BSD) 1999/9/6
|
||||
*/
|
||||
|
||||
#ifndef KERNEL
|
||||
extern int errno; /* global error number */
|
||||
#ifndef KERNEL
|
||||
extern int errno; /* global error number */
|
||||
#endif
|
||||
|
||||
#define EPERM 1 /* Not owner */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No children */
|
||||
#define EAGAIN 11 /* No more processes */
|
||||
#define ENOMEM 12 /* Not enough core */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Mount device busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory*/
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EPERM 1 /* Not owner */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No children */
|
||||
#define EAGAIN 11 /* No more processes */
|
||||
#define ENOMEM 12 /* Not enough core */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Mount device busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory*/
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
|
||||
/* math software */
|
||||
#define EDOM 33 /* Argument too large */
|
||||
#define ERANGE 34 /* Result too large */
|
||||
#define EDOM 33 /* Argument too large */
|
||||
#define ERANGE 34 /* Result too large */
|
||||
|
||||
/* non-blocking and interrupt i/o */
|
||||
#define EWOULDBLOCK 35 /* Operation would block */
|
||||
#define EDEADLK EWOULDBLOCK /* ditto */
|
||||
#define EINPROGRESS 36 /* Operation now in progress */
|
||||
#define EALREADY 37 /* Operation already in progress */
|
||||
#define EWOULDBLOCK 35 /* Operation would block */
|
||||
#define EDEADLK EWOULDBLOCK /* ditto */
|
||||
#define EINPROGRESS 36 /* Operation now in progress */
|
||||
#define EALREADY 37 /* Operation already in progress */
|
||||
|
||||
/* ipc/network software */
|
||||
|
||||
/* argument errors */
|
||||
#define ENOTSOCK 38 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 39 /* Destination address required */
|
||||
#define EMSGSIZE 40 /* Message too long */
|
||||
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 42 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 43 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 45 /* Operation not supported on socket */
|
||||
#define EPFNOSUPPORT 46 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
|
||||
#define EADDRINUSE 48 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
|
||||
/* argument errors */
|
||||
#define ENOTSOCK 38 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 39 /* Destination address required */
|
||||
#define EMSGSIZE 40 /* Message too long */
|
||||
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 42 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 43 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 45 /* Operation not supported on socket */
|
||||
#define EPFNOSUPPORT 46 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
|
||||
#define EADDRINUSE 48 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
|
||||
|
||||
/* operational errors */
|
||||
#define ENETDOWN 50 /* Network is down */
|
||||
#define ENETUNREACH 51 /* Network is unreachable */
|
||||
#define ENETRESET 52 /* Network dropped connection on reset */
|
||||
#define ECONNABORTED 53 /* Software caused connection abort */
|
||||
#define ECONNRESET 54 /* Connection reset by peer */
|
||||
#define ENOBUFS 55 /* No buffer space available */
|
||||
#define EISCONN 56 /* Socket is already connected */
|
||||
#define ENOTCONN 57 /* Socket is not connected */
|
||||
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
|
||||
#define ETOOMANYREFS 59 /* Too many references: can't splice */
|
||||
#define ETIMEDOUT 60 /* Connection timed out */
|
||||
#define ECONNREFUSED 61 /* Connection refused */
|
||||
/* operational errors */
|
||||
#define ENETDOWN 50 /* Network is down */
|
||||
#define ENETUNREACH 51 /* Network is unreachable */
|
||||
#define ENETRESET 52 /* Network dropped connection on reset */
|
||||
#define ECONNABORTED 53 /* Software caused connection abort */
|
||||
#define ECONNRESET 54 /* Connection reset by peer */
|
||||
#define ENOBUFS 55 /* No buffer space available */
|
||||
#define EISCONN 56 /* Socket is already connected */
|
||||
#define ENOTCONN 57 /* Socket is not connected */
|
||||
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
|
||||
#define ETOOMANYREFS 59 /* Too many references: can't splice */
|
||||
#define ETIMEDOUT 60 /* Connection timed out */
|
||||
#define ECONNREFUSED 61 /* Connection refused */
|
||||
|
||||
/* */
|
||||
#define ELOOP 62 /* Too many levels of symbolic links */
|
||||
#define ENAMETOOLONG 63 /* File name too long */
|
||||
/* */
|
||||
#define ELOOP 62 /* Too many levels of symbolic links */
|
||||
#define ENAMETOOLONG 63 /* File name too long */
|
||||
|
||||
/* should be rearranged */
|
||||
#define EHOSTDOWN 64 /* Host is down */
|
||||
#define EHOSTUNREACH 65 /* No route to host */
|
||||
#define ENOTEMPTY 66 /* Directory not empty */
|
||||
#define EHOSTDOWN 64 /* Host is down */
|
||||
#define EHOSTUNREACH 65 /* No route to host */
|
||||
#define ENOTEMPTY 66 /* Directory not empty */
|
||||
|
||||
/* quotas & mush */
|
||||
#define EPROCLIM 67 /* Too many processes */
|
||||
#define EUSERS 68 /* Too many users */
|
||||
#define EDQUOT 69 /* Disc quota exceeded */
|
||||
#define EPROCLIM 67 /* Too many processes */
|
||||
#define EUSERS 68 /* Too many users */
|
||||
#define EDQUOT 69 /* Disc quota exceeded */
|
||||
|
||||
/* Network File System */
|
||||
#define ESTALE 70 /* Stale NFS file handle */
|
||||
#define EREMOTE 71 /* Too many levels of remote in path */
|
||||
#define EBADRPC 72 /* RPC struct is bad */
|
||||
#define ERPCMISMATCH 73 /* RPC version wrong */
|
||||
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
|
||||
#define EPROGMISMATCH 75 /* Program version wrong */
|
||||
#define EPROCUNAVAIL 76 /* Bad procedure for program */
|
||||
#define ESTALE 70 /* Stale NFS file handle */
|
||||
#define EREMOTE 71 /* Too many levels of remote in path */
|
||||
#define EBADRPC 72 /* RPC struct is bad */
|
||||
#define ERPCMISMATCH 73 /* RPC version wrong */
|
||||
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
|
||||
#define EPROGMISMATCH 75 /* Program version wrong */
|
||||
#define EPROCUNAVAIL 76 /* Bad procedure for program */
|
||||
|
||||
#define ENOLCK 77 /* No locks available */
|
||||
#define ENOSYS 78 /* Function not implemented */
|
||||
#define ENOLCK 77 /* No locks available */
|
||||
#define ENOSYS 78 /* Function not implemented */
|
||||
|
||||
#define EFTYPE 79 /* Inappropriate file type or format */
|
||||
#define EAUTH 80 /* Authentication error */
|
||||
#define ENEEDAUTH 81 /* Need authenticator */
|
||||
#define ELAST 81 /* Must be equal largest errno */
|
||||
#define EFTYPE 79 /* Inappropriate file type or format */
|
||||
#define EAUTH 80 /* Authentication error */
|
||||
#define ENEEDAUTH 81 /* Need authenticator */
|
||||
#define ELAST 81 /* Must be equal largest errno */
|
||||
|
||||
#ifdef KERNEL
|
||||
#ifdef KERNEL
|
||||
/* pseudo-errors returned inside kernel to modify return back to user mode */
|
||||
#define ERESTART -1 /* restart syscall */
|
||||
#define EJUSTRETURN -2 /* don't modify regs, just return */
|
||||
#define ERESTART -1 /* restart syscall */
|
||||
#define EJUSTRETURN -2 /* don't modify regs, just return */
|
||||
#endif
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#ifdef KERNEL
|
||||
|
||||
#ifdef EXEC_SCRIPT
|
||||
#define SHSIZE 64
|
||||
#define SHPATHLEN 64
|
||||
#define SHSIZE 64
|
||||
#define SHPATHLEN 64
|
||||
#endif
|
||||
#ifdef EXEC_ELF
|
||||
#define STRLEN 32
|
||||
#define STRLEN 32
|
||||
#endif
|
||||
#ifdef EXEC_AOUT
|
||||
#include "exec_aout.h"
|
||||
@@ -22,70 +22,70 @@
|
||||
#include "exec_elf.h"
|
||||
#endif
|
||||
|
||||
#define NO_ADDR ((caddr_t)(~0U)) /* Indicates addr. not yet filled in */
|
||||
#define NO_ADDR ((caddr_t)(~0U)) /* Indicates addr. not yet filled in */
|
||||
|
||||
struct memsect {
|
||||
caddr_t vaddr;
|
||||
unsigned len;
|
||||
caddr_t vaddr;
|
||||
unsigned len;
|
||||
};
|
||||
|
||||
struct exec_params {
|
||||
char *userfname; /* The arguments to the exec() call */
|
||||
char **userargp;
|
||||
char **userenvp;
|
||||
union {
|
||||
char *userfname; /* The arguments to the exec() call */
|
||||
char **userargp;
|
||||
char **userenvp;
|
||||
union {
|
||||
#ifdef EXEC_SCRIPT
|
||||
char sh[SHSIZE];
|
||||
char sh[SHSIZE];
|
||||
#endif
|
||||
#ifdef EXEC_AOUT
|
||||
struct exec aout;
|
||||
struct exec aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF
|
||||
struct elf_ehdr elf;
|
||||
struct elf_ehdr elf;
|
||||
#endif
|
||||
} hdr; /* head of file to exec */
|
||||
int hdr_len; /* number of bytes valid in image_header */
|
||||
char **argp, **envp;
|
||||
u_short argc, envc; /* count of argument and environment strings */
|
||||
u_short argbc, envbc; /* total number of chars in argc and envc string pool */
|
||||
union {
|
||||
} hdr; /* head of file to exec */
|
||||
int hdr_len; /* number of bytes valid in image_header */
|
||||
char **argp, **envp;
|
||||
u_short argc, envc; /* count of argument and environment strings */
|
||||
u_short argbc, envbc; /* total number of chars in argc and envc string pool */
|
||||
union {
|
||||
#ifdef EXEC_SCRIPT
|
||||
struct {
|
||||
char interpname[20]; /* real name of the script interpreter */
|
||||
char interparg[SHPATHLEN]; /* interpreter arg */
|
||||
char interpreted; /* flag - this executable is interpreted */
|
||||
} sh;
|
||||
struct {
|
||||
char interpname[20]; /* real name of the script interpreter */
|
||||
char interparg[SHPATHLEN]; /* interpreter arg */
|
||||
char interpreted; /* flag - this executable is interpreted */
|
||||
} sh;
|
||||
#endif
|
||||
#ifdef EXEC_ELF
|
||||
struct {
|
||||
struct buf *stbp; /* String table buffer pointer */
|
||||
int stbpos; /* String table pos in buffer */
|
||||
int stsize; /* String table size */
|
||||
int stoffset; /* String table file pos */
|
||||
char str[STRLEN];
|
||||
} elf;
|
||||
struct {
|
||||
struct buf *stbp; /* String table buffer pointer */
|
||||
int stbpos; /* String table pos in buffer */
|
||||
int stsize; /* String table size */
|
||||
int stoffset; /* String table file pos */
|
||||
char str[STRLEN];
|
||||
} elf;
|
||||
#endif
|
||||
#ifdef EXEC_AOUT
|
||||
struct {
|
||||
} aout;
|
||||
struct {
|
||||
} aout;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
gid_t gid;
|
||||
uid_t uid;
|
||||
#define MAXALLOCBUF 6
|
||||
struct {
|
||||
struct buf *bp; /* Memory allocator buffer */
|
||||
u_short fill; /* Memory allocator "free" pointer */
|
||||
} alloc[MAXALLOCBUF];
|
||||
u_long ep_taddr, ep_tsize, ep_daddr, ep_dsize;
|
||||
struct inode *ip; /* executable file ip */
|
||||
struct memsect text, data, bss, heap, stack;
|
||||
gid_t gid;
|
||||
uid_t uid;
|
||||
#define MAXALLOCBUF 6
|
||||
struct {
|
||||
struct buf *bp; /* Memory allocator buffer */
|
||||
u_short fill; /* Memory allocator "free" pointer */
|
||||
} alloc[MAXALLOCBUF];
|
||||
u_long ep_taddr, ep_tsize, ep_daddr, ep_dsize;
|
||||
struct inode *ip; /* executable file ip */
|
||||
struct memsect text, data, bss, heap, stack;
|
||||
};
|
||||
|
||||
struct execsw {
|
||||
int (*es_check)(struct exec_params *epp);
|
||||
const char* es_name;
|
||||
int (*es_check)(struct exec_params *epp);
|
||||
const char* es_name;
|
||||
};
|
||||
extern const struct execsw execsw[];
|
||||
extern int nexecs, exec_maxhdrsz;
|
||||
|
||||
@@ -4,99 +4,98 @@
|
||||
/*
|
||||
* Header prepended to each a.out file.
|
||||
*/
|
||||
struct exec {
|
||||
unsigned a_midmag; /* magic number */
|
||||
unsigned a_text; /* size of text segment */
|
||||
unsigned a_data; /* size of initialized data */
|
||||
unsigned a_bss; /* size of uninitialized data */
|
||||
unsigned a_reltext; /* size of text relocation info */
|
||||
unsigned a_reldata; /* size of data relocation info */
|
||||
unsigned a_syms; /* size of symbol table */
|
||||
unsigned a_entry; /* entry point */
|
||||
struct exec {
|
||||
unsigned a_midmag; /* magic number */
|
||||
unsigned a_text; /* size of text segment */
|
||||
unsigned a_data; /* size of initialized data */
|
||||
unsigned a_bss; /* size of uninitialized data */
|
||||
unsigned a_reltext; /* size of text relocation info */
|
||||
unsigned a_reldata; /* size of data relocation info */
|
||||
unsigned a_syms; /* size of symbol table */
|
||||
unsigned a_entry; /* entry point */
|
||||
};
|
||||
|
||||
#define a_magic a_midmag & 0xffff
|
||||
#define a_magic a_midmag & 0xffff
|
||||
|
||||
/* a_magic (a_midmag & 0x0000ffff) */
|
||||
#define RMAGIC 0406 /* relocatable object file */
|
||||
#define OMAGIC 0407 /* old impure format */
|
||||
#define NMAGIC 0410 /* read-only text */
|
||||
#define RMAGIC 0406 /* relocatable object file */
|
||||
#define OMAGIC 0407 /* old impure format */
|
||||
#define NMAGIC 0410 /* read-only text */
|
||||
|
||||
/*
|
||||
* a_mid ((a_midmag & 0x03ff0000) >> 16)
|
||||
*/
|
||||
#define MID_ZERO 0 /* unknown - implementation dependent */
|
||||
#define MID_SUN010 1 /* sun 68010/68020 binary */
|
||||
#define MID_SUN020 2 /* sun 68020-only binary */
|
||||
#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */
|
||||
#define MID_HP200 200 /* hp200 (68010) BSD binary */
|
||||
#define MID_I386 134 /* i386 BSD binary */
|
||||
#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */
|
||||
#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */
|
||||
#define MID_NS32532 137 /* ns32532 */
|
||||
#define MID_SPARC 138 /* sparc */
|
||||
#define MID_PMAX 139 /* pmax */
|
||||
#define MID_VAX1K 140 /* vax 1K page size binaries */
|
||||
#define MID_ALPHA 141 /* Alpha BSD binary */
|
||||
#define MID_MIPS 142 /* big-endian MIPS */
|
||||
#define MID_ARM6 143 /* ARM6 */
|
||||
#define MID_SH3 145 /* SH3 */
|
||||
#define MID_POWERPC 149 /* big-endian PowerPC */
|
||||
#define MID_VAX 150 /* vax */
|
||||
#define MID_SPARC64 151 /* LP64 sparc */
|
||||
#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
||||
#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
||||
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
||||
#define MID_ZERO 0 /* unknown - implementation dependent */
|
||||
#define MID_SUN010 1 /* sun 68010/68020 binary */
|
||||
#define MID_SUN020 2 /* sun 68020-only binary */
|
||||
#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */
|
||||
#define MID_HP200 200 /* hp200 (68010) BSD binary */
|
||||
#define MID_I386 134 /* i386 BSD binary */
|
||||
#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */
|
||||
#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */
|
||||
#define MID_NS32532 137 /* ns32532 */
|
||||
#define MID_SPARC 138 /* sparc */
|
||||
#define MID_PMAX 139 /* pmax */
|
||||
#define MID_VAX1K 140 /* vax 1K page size binaries */
|
||||
#define MID_ALPHA 141 /* Alpha BSD binary */
|
||||
#define MID_MIPS 142 /* big-endian MIPS */
|
||||
#define MID_ARM6 143 /* ARM6 */
|
||||
#define MID_SH3 145 /* SH3 */
|
||||
#define MID_POWERPC 149 /* big-endian PowerPC */
|
||||
#define MID_VAX 150 /* vax */
|
||||
#define MID_SPARC64 151 /* LP64 sparc */
|
||||
#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
||||
#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
||||
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
||||
|
||||
/*
|
||||
* a_flags ((a_midmag & 0xfc000000 ) << 26)
|
||||
*/
|
||||
#define EX_PIC 0x10
|
||||
#define EX_DYNAMIC 0x20
|
||||
#define EX_DPMASK 0x30
|
||||
#define EX_PIC 0x10
|
||||
#define EX_DYNAMIC 0x20
|
||||
#define EX_DPMASK 0x30
|
||||
/*
|
||||
* Interpretation of the (a_flags & EX_DPMASK) bits:
|
||||
*
|
||||
* 00 traditional executable or object file
|
||||
* 01 object file contains PIC code (set by `as -k')
|
||||
* 10 dynamic executable
|
||||
* 11 position independent executable image
|
||||
* (eg. a shared library)
|
||||
* 00 traditional executable or object file
|
||||
* 01 object file contains PIC code (set by `as -k')
|
||||
* 10 dynamic executable
|
||||
* 11 position independent executable image
|
||||
* (eg. a shared library)
|
||||
*/
|
||||
|
||||
/*
|
||||
* The a.out structure's a_midmag field is a network-byteorder encoding
|
||||
* of this int
|
||||
* FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
|
||||
* FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
|
||||
* Where `F' is 6 bits of flag like EX_DYNAMIC,
|
||||
* `m' is 10 bits of machine-id like MID_I386, and
|
||||
* `M' is 16 bits worth of magic number, ie. ZMAGIC.
|
||||
* The macros below will set/get the needed fields.
|
||||
*/
|
||||
#define N_GETMAGIC(ex) (((ex).a_midmag)&0x0000ffff)
|
||||
#define N_GETMID(ex) ((((ex).a_midmag)&0x03ff0000) >> 16)
|
||||
#define N_GETFLAG(ex) ((((ex).a_midmag)&0xfc000000 ) << 26)
|
||||
#define N_GETMAGIC(ex) (((ex).a_midmag)&0x0000ffff)
|
||||
#define N_GETMID(ex) ((((ex).a_midmag)&0x03ff0000) >> 16)
|
||||
#define N_GETFLAG(ex) ((((ex).a_midmag)&0xfc000000 ) << 26)
|
||||
|
||||
/* Valid magic number check. */
|
||||
#define N_BADMAG(x) (N_GETMAGIC(x) != RMAGIC && \
|
||||
N_GETMAGIC(x) != OMAGIC && \
|
||||
N_GETMAGIC(x) != NMAGIC)
|
||||
#define N_BADMAG(x) (N_GETMAGIC(x) != RMAGIC && \
|
||||
N_GETMAGIC(x) != OMAGIC && \
|
||||
N_GETMAGIC(x) != NMAGIC)
|
||||
|
||||
/* Text segment offset. */
|
||||
#define N_TXTOFF(x) sizeof(struct exec)
|
||||
#define N_TXTOFF(x) sizeof(struct exec)
|
||||
|
||||
/* Data segment offset. */
|
||||
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
||||
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
||||
|
||||
/* Text relocation table offset. */
|
||||
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
||||
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
||||
|
||||
/* Data relocation table offset. */
|
||||
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext)
|
||||
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext)
|
||||
|
||||
/* Symbol table offset. */
|
||||
#define N_SYMOFF(x) (N_GETMAGIC(x) == RMAGIC ? \
|
||||
N_DRELOFF(x) + (x).a_reldata : \
|
||||
N_DATOFF(x) + (x).a_data)
|
||||
|
||||
#define N_SYMOFF(x) (N_GETMAGIC(x) == RMAGIC ? \
|
||||
N_DRELOFF(x) + (x).a_reldata : \
|
||||
N_DATOFF(x) + (x).a_data)
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_elf.h,v 1.37.4.1 2000/07/26 23:57:06 mycroft Exp $ */
|
||||
/* $NetBSD: exec_elf.h,v 1.37.4.1 2000/07/26 23:57:06 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@@ -17,8 +17,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#ifndef _SYS_EXEC_ELF_H_
|
||||
#define _SYS_EXEC_ELF_H_
|
||||
#define _SYS_EXEC_ELF_H_
|
||||
|
||||
#ifndef _SYS_TYPES_H_
|
||||
#include <machine/types.h>
|
||||
@@ -46,434 +46,430 @@
|
||||
/*
|
||||
* ELF Header
|
||||
*/
|
||||
#define ELF_NIDENT 16
|
||||
#define ELF_NIDENT 16
|
||||
|
||||
struct elf_ehdr {
|
||||
unsigned char e_ident[ELF_NIDENT]; /* Id bytes */
|
||||
unsigned short e_type; /* file type */
|
||||
unsigned short e_machine; /* machine type */
|
||||
unsigned int e_version; /* version number */
|
||||
unsigned int e_entry; /* entry point */
|
||||
unsigned int e_phoff; /* Program header table offset */
|
||||
unsigned int e_shoff; /* Section header table offset */
|
||||
unsigned int e_flags; /* Processor flags (currently unused, should be 0) */
|
||||
unsigned short e_ehsize; /* sizeof elf_ehdr */
|
||||
unsigned short e_phentsize; /* Program header entry size */
|
||||
unsigned short e_phnum; /* Number of program headers */
|
||||
unsigned short e_shentsize; /* Section header entry size */
|
||||
unsigned short e_shnum; /* Number of section headers */
|
||||
unsigned short e_shstrndx; /* String table index */
|
||||
unsigned char e_ident[ELF_NIDENT]; /* Id bytes */
|
||||
unsigned short e_type; /* file type */
|
||||
unsigned short e_machine; /* machine type */
|
||||
unsigned int e_version; /* version number */
|
||||
unsigned int e_entry; /* entry point */
|
||||
unsigned int e_phoff; /* Program header table offset */
|
||||
unsigned int e_shoff; /* Section header table offset */
|
||||
unsigned int e_flags; /* Processor flags (currently unused, should be 0) */
|
||||
unsigned short e_ehsize; /* sizeof elf_ehdr */
|
||||
unsigned short e_phentsize; /* Program header entry size */
|
||||
unsigned short e_phnum; /* Number of program headers */
|
||||
unsigned short e_shentsize; /* Section header entry size */
|
||||
unsigned short e_shnum; /* Number of section headers */
|
||||
unsigned short e_shstrndx; /* String table index */
|
||||
};
|
||||
|
||||
/* e_ident offsets */
|
||||
#define EI_MAG0 0 /* first byte of magic number */
|
||||
#define ELFMAG0 0x7f
|
||||
#define EI_MAG1 1 /* second byte of magic number */
|
||||
#define ELFMAG1 'E'
|
||||
#define EI_MAG2 2 /* third byte of magic number */
|
||||
#define ELFMAG2 'L'
|
||||
#define EI_MAG3 3 /* fourth byte of magic number */
|
||||
#define ELFMAG3 'F'
|
||||
#define EI_MAG0 0 /* first byte of magic number */
|
||||
#define ELFMAG0 0x7f
|
||||
#define EI_MAG1 1 /* second byte of magic number */
|
||||
#define ELFMAG1 'E'
|
||||
#define EI_MAG2 2 /* third byte of magic number */
|
||||
#define ELFMAG2 'L'
|
||||
#define EI_MAG3 3 /* fourth byte of magic number */
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define EI_CLASS 4 /* 5:th byte: File class */
|
||||
#define ELFCLASSNONE 0 /* Invalid class */
|
||||
#define ELFCLASS32 1 /* 32-bit objects */
|
||||
#define ELFCLASS64 2 /* 64-bit objects */
|
||||
#define ELFCLASSNUM 3
|
||||
#define EI_CLASS 4 /* 5:th byte: File class */
|
||||
#define ELFCLASSNONE 0 /* Invalid class */
|
||||
#define ELFCLASS32 1 /* 32-bit objects */
|
||||
#define ELFCLASS64 2 /* 64-bit objects */
|
||||
#define ELFCLASSNUM 3
|
||||
|
||||
#define EI_DATA 5 /* 6:th byte: Data encoding */
|
||||
#define ELFDATANONE 0 /* Unknown data format */
|
||||
#define ELFDATA2LSB 1 /* two's complement, little-endian */
|
||||
#define ELFDATA2MSB 2 /* two's complement, big-endian */
|
||||
#define EI_DATA 5 /* 6:th byte: Data encoding */
|
||||
#define ELFDATANONE 0 /* Unknown data format */
|
||||
#define ELFDATA2LSB 1 /* two's complement, little-endian */
|
||||
#define ELFDATA2MSB 2 /* two's complement, big-endian */
|
||||
|
||||
#define EI_VERSION 6 /* Version number of the ELF specification */
|
||||
#define EV_NONE 0 /* Invalid version */
|
||||
#define EV_CURRENT 1 /* Current version */
|
||||
#define EV_NUM 2
|
||||
#define EI_VERSION 6 /* Version number of the ELF specification */
|
||||
#define EV_NONE 0 /* Invalid version */
|
||||
#define EV_CURRENT 1 /* Current version */
|
||||
#define EV_NUM 2
|
||||
|
||||
#define EI_OSABI 7 /* Operating system/ABI identification */
|
||||
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
|
||||
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
|
||||
#define ELFOSABI_NETBSD /* NetBSD ABI */
|
||||
#define ELFOSABI_LINUX /* Linux ABI */
|
||||
#define ELFOSABI_SOLARIS /* Solaris ABI */
|
||||
#define ELFOSABI_FREEBSD /* FreeBSD ABI */
|
||||
#define ELFOSABI_ARM /* ARM architecture ABI */
|
||||
#define ELFOSABI_STANDALONE 255 /* Stand-alone (embedded) application */
|
||||
#define EI_OSABI 7 /* Operating system/ABI identification */
|
||||
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
|
||||
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
|
||||
#define ELFOSABI_NETBSD /* NetBSD ABI */
|
||||
#define ELFOSABI_LINUX /* Linux ABI */
|
||||
#define ELFOSABI_SOLARIS /* Solaris ABI */
|
||||
#define ELFOSABI_FREEBSD /* FreeBSD ABI */
|
||||
#define ELFOSABI_ARM /* ARM architecture ABI */
|
||||
#define ELFOSABI_STANDALONE 255 /* Stand-alone (embedded) application */
|
||||
|
||||
#define EI_ABIVERSION 8 /* ABI version */
|
||||
#define EI_ABIVERSION 8 /* ABI version */
|
||||
|
||||
#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
|
||||
#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
|
||||
|
||||
#define ELFMAG "\177ELF"
|
||||
#define SELFMAG 4
|
||||
#define ELFMAG "\177ELF"
|
||||
#define SELFMAG 4
|
||||
|
||||
/* e_type */
|
||||
#define ET_NONE 0 /* Unknown file type */
|
||||
#define ET_REL 1 /* A Relocatable file */
|
||||
#define ET_EXEC 2 /* An Executable file */
|
||||
#define ET_DYN 3 /* A Shared object file */
|
||||
#define ET_CORE 4 /* A Core file */
|
||||
#define ET_NUM 5
|
||||
#define ET_NONE 0 /* Unknown file type */
|
||||
#define ET_REL 1 /* A Relocatable file */
|
||||
#define ET_EXEC 2 /* An Executable file */
|
||||
#define ET_DYN 3 /* A Shared object file */
|
||||
#define ET_CORE 4 /* A Core file */
|
||||
#define ET_NUM 5
|
||||
|
||||
#define ET_LOOS 0xfe00 /* Operating system specific range */
|
||||
#define ET_HIOS 0xfeff
|
||||
#define ET_LOPROC 0xff00 /* Processor-specific range */
|
||||
#define ET_HIPROC 0xffff
|
||||
#define ET_LOOS 0xfe00 /* Operating system specific range */
|
||||
#define ET_HIOS 0xfeff
|
||||
#define ET_LOPROC 0xff00 /* Processor-specific range */
|
||||
#define ET_HIPROC 0xffff
|
||||
|
||||
/* e_machine */
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SPARC */
|
||||
#define EM_386 3 /* Intel 80386 */
|
||||
#define EM_68K 4 /* Motorola 68000 */
|
||||
#define EM_88K 5 /* Motorola 88000 */
|
||||
#define EM_486 6 /* Intel 80486 */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS I Architecture */
|
||||
#define EM_S370 9 /* Amdahl UTS on System/370 */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
|
||||
#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
|
||||
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
|
||||
#define EM_NCUBE 16 /* NCube XXX reserved */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_V800 36 /* NEC V800 */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* Advanced RISC Machines ARM */
|
||||
#define EM_ALPHA 41 /* DIGITAL Alpha */
|
||||
#define EM_SH 42 /* Hitachi Super-H */
|
||||
#define EM_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define EM_TRICORE 44 /* Siemens Tricore */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel Merced Processor */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola Coldfire */
|
||||
#define EM_68HC12 53 /* Motorola MC68HC12 */
|
||||
#define EM_VAX 75 /* DIGITAL VAX */
|
||||
#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
|
||||
#define EM_NUM 36903
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SPARC */
|
||||
#define EM_386 3 /* Intel 80386 */
|
||||
#define EM_68K 4 /* Motorola 68000 */
|
||||
#define EM_88K 5 /* Motorola 88000 */
|
||||
#define EM_486 6 /* Intel 80486 */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS I Architecture */
|
||||
#define EM_S370 9 /* Amdahl UTS on System/370 */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
|
||||
#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
|
||||
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
|
||||
#define EM_NCUBE 16 /* NCube XXX reserved */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_V800 36 /* NEC V800 */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* Advanced RISC Machines ARM */
|
||||
#define EM_ALPHA 41 /* DIGITAL Alpha */
|
||||
#define EM_SH 42 /* Hitachi Super-H */
|
||||
#define EM_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define EM_TRICORE 44 /* Siemens Tricore */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel Merced Processor */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola Coldfire */
|
||||
#define EM_68HC12 53 /* Motorola MC68HC12 */
|
||||
#define EM_VAX 75 /* DIGITAL VAX */
|
||||
#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
|
||||
#define EM_NUM 36903
|
||||
|
||||
/*
|
||||
* ELF Program Header
|
||||
*/
|
||||
struct elf_phdr {
|
||||
unsigned int p_type; /* entry type */
|
||||
unsigned int p_offset; /* file offset */
|
||||
unsigned int p_vaddr; /* virtual address */
|
||||
unsigned int p_paddr; /* physical address (reserved, 0) */
|
||||
unsigned int p_filesz; /* file size of segment (may be 0) */
|
||||
unsigned int p_memsz; /* memory size of segment (may be 0) */
|
||||
unsigned int p_flags; /* flags */
|
||||
unsigned int p_align; /* memory & file alignment */
|
||||
unsigned int p_type; /* entry type */
|
||||
unsigned int p_offset; /* file offset */
|
||||
unsigned int p_vaddr; /* virtual address */
|
||||
unsigned int p_paddr; /* physical address (reserved, 0) */
|
||||
unsigned int p_filesz; /* file size of segment (may be 0) */
|
||||
unsigned int p_memsz; /* memory size of segment (may be 0) */
|
||||
unsigned int p_flags; /* flags */
|
||||
unsigned int p_align; /* memory & file alignment */
|
||||
};
|
||||
|
||||
/* p_type */
|
||||
#define PT_NULL 0 /* Program header table entry unused */
|
||||
#define PT_LOAD 1 /* Loadable program segment */
|
||||
#define PT_DYNAMIC 2 /* Dynamic linking information */
|
||||
#define PT_INTERP 3 /* Program interpreter */
|
||||
#define PT_NOTE 4 /* Auxiliary information */
|
||||
#define PT_SHLIB 5 /* Reserved, unspecified semantics */
|
||||
#define PT_PHDR 6 /* Entry for header table itself */
|
||||
#define PT_NUM 7
|
||||
#define PT_LOPROC 0x70000000 /* Start of processor-specific semantics */
|
||||
#define PT_HIPROC 0x7fffffff /* end of processor-specific semantics */
|
||||
#define PT_GNU_STACK /* GNU stack extension */
|
||||
#define PT_NULL 0 /* Program header table entry unused */
|
||||
#define PT_LOAD 1 /* Loadable program segment */
|
||||
#define PT_DYNAMIC 2 /* Dynamic linking information */
|
||||
#define PT_INTERP 3 /* Program interpreter */
|
||||
#define PT_NOTE 4 /* Auxiliary information */
|
||||
#define PT_SHLIB 5 /* Reserved, unspecified semantics */
|
||||
#define PT_PHDR 6 /* Entry for header table itself */
|
||||
#define PT_NUM 7
|
||||
#define PT_LOPROC 0x70000000 /* Start of processor-specific semantics */
|
||||
#define PT_HIPROC 0x7fffffff /* end of processor-specific semantics */
|
||||
#define PT_GNU_STACK /* GNU stack extension */
|
||||
|
||||
/* p_flags */
|
||||
#define PF_R 0x4 /* Segment is readable */
|
||||
#define PF_W 0x2 /* Segment is writable */
|
||||
#define PF_X 0x1 /* Segment is executable */
|
||||
#define PF_R 0x4 /* Segment is readable */
|
||||
#define PF_W 0x2 /* Segment is writable */
|
||||
#define PF_X 0x1 /* Segment is executable */
|
||||
/* A text segment commonly have PF_X|PF_R, a data segment PF_X|PF_W and PF_R */
|
||||
|
||||
#define PF_MASKOS 0x0ff00000 /* Opersting system specific values */
|
||||
#define PF_MASKPROC 0xf0000000 /* Processor-specific values */
|
||||
#define PF_MASKOS 0x0ff00000 /* Opersting system specific values */
|
||||
#define PF_MASKPROC 0xf0000000 /* Processor-specific values */
|
||||
|
||||
|
||||
#define PT_MIPS_REGINFO 0x70000000
|
||||
#define PT_MIPS_REGINFO 0x70000000
|
||||
|
||||
/*
|
||||
* Section Headers
|
||||
*/
|
||||
struct elf_shdr {
|
||||
unsigned int sh_name; /* section name (.shstrtab index) */
|
||||
unsigned int sh_type; /* section type */
|
||||
unsigned int sh_flags; /* section flags */
|
||||
unsigned int sh_addr; /* virtual address */
|
||||
unsigned int sh_offset; /* file offset */
|
||||
unsigned int sh_size; /* section size */
|
||||
unsigned int sh_link; /* link to another */
|
||||
unsigned int sh_info; /* misc info */
|
||||
unsigned int sh_addralign; /* memory alignment */
|
||||
unsigned int sh_entsize; /* table entry size */
|
||||
unsigned int sh_name; /* section name (.shstrtab index) */
|
||||
unsigned int sh_type; /* section type */
|
||||
unsigned int sh_flags; /* section flags */
|
||||
unsigned int sh_addr; /* virtual address */
|
||||
unsigned int sh_offset; /* file offset */
|
||||
unsigned int sh_size; /* section size */
|
||||
unsigned int sh_link; /* link to another */
|
||||
unsigned int sh_info; /* misc info */
|
||||
unsigned int sh_addralign; /* memory alignment */
|
||||
unsigned int sh_entsize; /* table entry size */
|
||||
};
|
||||
|
||||
/* sh_type */
|
||||
#define SHT_NULL 0 /* inactive */
|
||||
#define SHT_PROGBITS 1 /* program defined contents */
|
||||
#define SHT_SYMTAB 2 /* holds symbol table */
|
||||
#define SHT_STRTAB 3 /* holds string table */
|
||||
#define SHT_RELA 4 /* holds relocation info with explicit addends */
|
||||
#define SHT_HASH 5 /* holds symbol hash table */
|
||||
#define SHT_DYNAMIC 6 /* holds dynamic linking information */
|
||||
#define SHT_NOTE 7 /* holds information marking */
|
||||
#define SHT_NOBITS 8 /* holds a section that does not occupy space */
|
||||
#define SHT_REL 9 /* holds relocation info without explicit addends */
|
||||
#define SHT_SHLIB 10 /* reserved with unspecified semantics */
|
||||
#define SHT_DYNSYM 11 /* holds a minimal set of dynamic linking symbols */
|
||||
#define SHT_NUM 12
|
||||
#define SHT_NULL 0 /* inactive */
|
||||
#define SHT_PROGBITS 1 /* program defined contents */
|
||||
#define SHT_SYMTAB 2 /* holds symbol table */
|
||||
#define SHT_STRTAB 3 /* holds string table */
|
||||
#define SHT_RELA 4 /* holds relocation info with explicit addends */
|
||||
#define SHT_HASH 5 /* holds symbol hash table */
|
||||
#define SHT_DYNAMIC 6 /* holds dynamic linking information */
|
||||
#define SHT_NOTE 7 /* holds information marking */
|
||||
#define SHT_NOBITS 8 /* holds a section that does not occupy space */
|
||||
#define SHT_REL 9 /* holds relocation info without explicit addends */
|
||||
#define SHT_SHLIB 10 /* reserved with unspecified semantics */
|
||||
#define SHT_DYNSYM 11 /* holds a minimal set of dynamic linking symbols */
|
||||
#define SHT_NUM 12
|
||||
|
||||
#define SHT_LOOS 0x60000000 /* Operating system specific range */
|
||||
#define SHT_HIOS 0x6fffffff
|
||||
#define SHT_LOPROC 0x70000000 /* Processor-specific range */
|
||||
#define SHT_HIPROC 0x7fffffff
|
||||
#define SHT_LOUSER 0x80000000 /* Application-specific range */
|
||||
#define SHT_HIUSER 0xffffffff
|
||||
#define SHT_LOOS 0x60000000 /* Operating system specific range */
|
||||
#define SHT_HIOS 0x6fffffff
|
||||
#define SHT_LOPROC 0x70000000 /* Processor-specific range */
|
||||
#define SHT_HIPROC 0x7fffffff
|
||||
#define SHT_LOUSER 0x80000000 /* Application-specific range */
|
||||
#define SHT_HIUSER 0xffffffff
|
||||
|
||||
/* sh_flags */
|
||||
#define SHF_WRITE 0x1 /* Section contains writable data */
|
||||
#define SHF_ALLOC 0x2 /* Section occupies memory */
|
||||
#define SHF_EXECINSTR 0x4 /* Section contains executable insns */
|
||||
#define SHF_WRITE 0x1 /* Section contains writable data */
|
||||
#define SHF_ALLOC 0x2 /* Section occupies memory */
|
||||
#define SHF_EXECINSTR 0x4 /* Section contains executable insns */
|
||||
|
||||
#define SHF_MASKOS 0x0f000000 /* Operating system specific values */
|
||||
#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */
|
||||
#define SHF_MASKOS 0x0f000000 /* Operating system specific values */
|
||||
#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */
|
||||
|
||||
/*
|
||||
* Symbol Table
|
||||
*/
|
||||
struct elf_sym {
|
||||
unsigned int st_name; /* Symbol name (.symtab index) */
|
||||
unsigned int st_value; /* value of symbol */
|
||||
unsigned int st_size; /* size of symbol */
|
||||
unsigned char st_info; /* type / binding attrs */
|
||||
unsigned char st_other; /* unused */
|
||||
unsigned short st_shndx; /* section index of symbol */
|
||||
unsigned int st_name; /* Symbol name (.symtab index) */
|
||||
unsigned int st_value; /* value of symbol */
|
||||
unsigned int st_size; /* size of symbol */
|
||||
unsigned char st_info; /* type / binding attrs */
|
||||
unsigned char st_other; /* unused */
|
||||
unsigned short st_shndx; /* section index of symbol */
|
||||
};
|
||||
|
||||
/* Symbol Table index of the undefined symbol */
|
||||
#define ELF_SYM_UNDEFINED 0
|
||||
#define ELF_SYM_UNDEFINED 0
|
||||
|
||||
/* st_info: Symbol Bindings */
|
||||
#define STB_LOCAL 0 /* local symbol */
|
||||
#define STB_GLOBAL 1 /* global symbol */
|
||||
#define STB_WEAK 2 /* weakly defined global symbol */
|
||||
#define STB_NUM 3
|
||||
#define STB_LOCAL 0 /* local symbol */
|
||||
#define STB_GLOBAL 1 /* global symbol */
|
||||
#define STB_WEAK 2 /* weakly defined global symbol */
|
||||
#define STB_NUM 3
|
||||
|
||||
#define STB_LOOS 10 /* Operating system specific range */
|
||||
#define STB_HIOS 12
|
||||
#define STB_LOPROC 13 /* Processor-specific range */
|
||||
#define STB_HIPROC 15
|
||||
#define STB_LOOS 10 /* Operating system specific range */
|
||||
#define STB_HIOS 12
|
||||
#define STB_LOPROC 13 /* Processor-specific range */
|
||||
#define STB_HIPROC 15
|
||||
|
||||
/* st_info: Symbol Types */
|
||||
#define STT_NOTYPE 0 /* Type not specified */
|
||||
#define STT_OBJECT 1 /* Associated with a data object */
|
||||
#define STT_FUNC 2 /* Associated with a function */
|
||||
#define STT_SECTION 3 /* Associated with a section */
|
||||
#define STT_FILE 4 /* Associated with a file name */
|
||||
#define STT_NUM 5
|
||||
#define STT_NOTYPE 0 /* Type not specified */
|
||||
#define STT_OBJECT 1 /* Associated with a data object */
|
||||
#define STT_FUNC 2 /* Associated with a function */
|
||||
#define STT_SECTION 3 /* Associated with a section */
|
||||
#define STT_FILE 4 /* Associated with a file name */
|
||||
#define STT_NUM 5
|
||||
|
||||
#define STT_LOOS 10 /* Operating system specific range */
|
||||
#define STT_HIOS 12
|
||||
#define STT_LOPROC 13 /* Processor-specific range */
|
||||
#define STT_HIPROC 15
|
||||
#define STT_LOOS 10 /* Operating system specific range */
|
||||
#define STT_HIOS 12
|
||||
#define STT_LOPROC 13 /* Processor-specific range */
|
||||
#define STT_HIPROC 15
|
||||
|
||||
/* st_info utility macros */
|
||||
#define ELF_ST_BIND(info) ((unsigned int)(info) >> 4)
|
||||
#define ELF_ST_TYPE(info) ((unsigned int)(info) & 0xf)
|
||||
#define ELF_ST_INFO(bind,type) ((unsigned char)(((bind) << 4) | ((type) & 0xf)))
|
||||
#define ELF_ST_BIND(info) ((unsigned int)(info) >> 4)
|
||||
#define ELF_ST_TYPE(info) ((unsigned int)(info) & 0xf)
|
||||
#define ELF_ST_INFO(bind,type) ((unsigned char)(((bind) << 4) | ((type) & 0xf)))
|
||||
|
||||
/*
|
||||
* Special section indexes
|
||||
*/
|
||||
#define SHN_UNDEF 0 /* Undefined section */
|
||||
#define SHN_UNDEF 0 /* Undefined section */
|
||||
|
||||
#define SHN_LORESERVE 0xff00 /* Start of Reserved range */
|
||||
#define SHN_ABS 0xfff1 /* Absolute symbols */
|
||||
#define SHN_COMMON 0xfff2 /* Common symbols */
|
||||
#define SHN_HIRESERVE 0xffff
|
||||
#define SHN_LORESERVE 0xff00 /* Start of Reserved range */
|
||||
#define SHN_ABS 0xfff1 /* Absolute symbols */
|
||||
#define SHN_COMMON 0xfff2 /* Common symbols */
|
||||
#define SHN_HIRESERVE 0xffff
|
||||
|
||||
#define SHN_LOPROC 0xff00 /* Start of Processor-specific range */
|
||||
#define SHN_HIPROC 0xff1f
|
||||
#define SHN_LOOS 0xff20 /* Operating system specific range */
|
||||
#define SHN_HIOS 0xff3f
|
||||
#define SHN_LOPROC 0xff00 /* Start of Processor-specific range */
|
||||
#define SHN_HIPROC 0xff1f
|
||||
#define SHN_LOOS 0xff20 /* Operating system specific range */
|
||||
#define SHN_HIOS 0xff3f
|
||||
|
||||
#define SHN_MIPS_ACOMMON 0xff00
|
||||
#define SHN_MIPS_TEXT 0xff01
|
||||
#define SHN_MIPS_DATA 0xff02
|
||||
#define SHN_MIPS_SCOMMON 0xff03
|
||||
#define SHN_MIPS_ACOMMON 0xff00
|
||||
#define SHN_MIPS_TEXT 0xff01
|
||||
#define SHN_MIPS_DATA 0xff02
|
||||
#define SHN_MIPS_SCOMMON 0xff03
|
||||
|
||||
/*
|
||||
* Relocation Entries
|
||||
*/
|
||||
struct elf_rel {
|
||||
unsigned int r_offset; /* where to do it */
|
||||
unsigned int r_info; /* index & type of relocation */
|
||||
unsigned int r_offset; /* where to do it */
|
||||
unsigned int r_info; /* index & type of relocation */
|
||||
};
|
||||
|
||||
struct elf_rela {
|
||||
unsigned int r_offset; /* where to do it */
|
||||
unsigned int r_info; /* index & type of relocation */
|
||||
int r_addend; /* adjustment value */
|
||||
unsigned int r_offset; /* where to do it */
|
||||
unsigned int r_info; /* index & type of relocation */
|
||||
int r_addend; /* adjustment value */
|
||||
};
|
||||
|
||||
/* r_info utility macros */
|
||||
#define ELF_R_SYM(info) ((info) >> 8)
|
||||
#define ELF_R_TYPE(info) ((info) & 0xff)
|
||||
#define ELF_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
|
||||
#define ELF_R_SYM(info) ((info) >> 8)
|
||||
#define ELF_R_TYPE(info) ((info) & 0xff)
|
||||
#define ELF_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
|
||||
|
||||
/*
|
||||
* Dynamic Section structure array
|
||||
*/
|
||||
struct elf_dyn {
|
||||
unsigned int d_tag; /* entry tag value */
|
||||
union {
|
||||
unsigned int d_ptr;
|
||||
unsigned int d_val;
|
||||
} d_un;
|
||||
unsigned int d_tag; /* entry tag value */
|
||||
union {
|
||||
unsigned int d_ptr;
|
||||
unsigned int d_val;
|
||||
} d_un;
|
||||
};
|
||||
|
||||
/* d_tag */
|
||||
#define DT_NULL 0 /* Marks end of dynamic array */
|
||||
#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */
|
||||
#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */
|
||||
#define DT_PLTGOT 3 /* Address of PLT and/or GOT */
|
||||
#define DT_HASH 4 /* Address of symbol hash table */
|
||||
#define DT_STRTAB 5 /* Address of string table */
|
||||
#define DT_SYMTAB 6 /* Address of symbol table */
|
||||
#define DT_RELA 7 /* Address of Rela relocation table */
|
||||
#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */
|
||||
#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */
|
||||
#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */
|
||||
#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */
|
||||
#define DT_INIT 12 /* Address of initialization function */
|
||||
#define DT_FINI 13 /* Address of termination function */
|
||||
#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */
|
||||
#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */
|
||||
#define DT_SYMBOLIC 16 /* Start symbol search within local object */
|
||||
#define DT_REL 17 /* Address of Rel relocation table */
|
||||
#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */
|
||||
#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */
|
||||
#define DT_PLTREL 20 /* Type of PLT relocation entries */
|
||||
#define DT_DEBUG 21 /* Used for debugging; unspecified */
|
||||
#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */
|
||||
#define DT_JMPREL 23 /* Address of relocations associated with PLT */
|
||||
#define DT_BIND_NOW 24 /* Process all relocations at load-time */
|
||||
#define DT_INIT_ARRAY 25 /* Address of initialization function array */
|
||||
#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */
|
||||
#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */
|
||||
#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/
|
||||
#define DT_NUM 29
|
||||
#define DT_NULL 0 /* Marks end of dynamic array */
|
||||
#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */
|
||||
#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */
|
||||
#define DT_PLTGOT 3 /* Address of PLT and/or GOT */
|
||||
#define DT_HASH 4 /* Address of symbol hash table */
|
||||
#define DT_STRTAB 5 /* Address of string table */
|
||||
#define DT_SYMTAB 6 /* Address of symbol table */
|
||||
#define DT_RELA 7 /* Address of Rela relocation table */
|
||||
#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */
|
||||
#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */
|
||||
#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */
|
||||
#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */
|
||||
#define DT_INIT 12 /* Address of initialization function */
|
||||
#define DT_FINI 13 /* Address of termination function */
|
||||
#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */
|
||||
#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */
|
||||
#define DT_SYMBOLIC 16 /* Start symbol search within local object */
|
||||
#define DT_REL 17 /* Address of Rel relocation table */
|
||||
#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */
|
||||
#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */
|
||||
#define DT_PLTREL 20 /* Type of PLT relocation entries */
|
||||
#define DT_DEBUG 21 /* Used for debugging; unspecified */
|
||||
#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */
|
||||
#define DT_JMPREL 23 /* Address of relocations associated with PLT */
|
||||
#define DT_BIND_NOW 24 /* Process all relocations at load-time */
|
||||
#define DT_INIT_ARRAY 25 /* Address of initialization function array */
|
||||
#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */
|
||||
#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */
|
||||
#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/
|
||||
#define DT_NUM 29
|
||||
|
||||
#define DT_LOOS 0x60000000 /* Operating system specific range */
|
||||
#define DT_HIOS 0x6fffffff
|
||||
#define DT_LOPROC 0x70000000 /* Processor-specific range */
|
||||
#define DT_HIPROC 0x7fffffff
|
||||
#define DT_LOOS 0x60000000 /* Operating system specific range */
|
||||
#define DT_HIOS 0x6fffffff
|
||||
#define DT_LOPROC 0x70000000 /* Processor-specific range */
|
||||
#define DT_HIPROC 0x7fffffff
|
||||
|
||||
/*
|
||||
* Auxiliary Vectors
|
||||
*/
|
||||
struct elf_auxinfo {
|
||||
unsigned int a_type; /* 32-bit id */
|
||||
unsigned int a_v; /* 32-bit id */
|
||||
unsigned int a_type; /* 32-bit id */
|
||||
unsigned int a_v; /* 32-bit id */
|
||||
};
|
||||
|
||||
/* a_type */
|
||||
#define AT_NULL 0 /* Marks end of array */
|
||||
#define AT_IGNORE 1 /* No meaning, a_un is undefined */
|
||||
#define AT_EXECFD 2 /* Open file descriptor of object file */
|
||||
#define AT_PHDR 3 /* &phdr[0] */
|
||||
#define AT_PHENT 4 /* sizeof(phdr[0]) */
|
||||
#define AT_PHNUM 5 /* # phdr entries */
|
||||
#define AT_PAGESZ 6 /* PAGESIZE */
|
||||
#define AT_BASE 7 /* Interpreter base addr */
|
||||
#define AT_FLAGS 8 /* Processor flags */
|
||||
#define AT_ENTRY 9 /* Entry address of executable */
|
||||
#define AT_DCACHEBSIZE 10 /* Data cache block size */
|
||||
#define AT_ICACHEBSIZE 11 /* Instruction cache block size */
|
||||
#define AT_UCACHEBSIZE 12 /* Unified cache block size */
|
||||
#define AT_NULL 0 /* Marks end of array */
|
||||
#define AT_IGNORE 1 /* No meaning, a_un is undefined */
|
||||
#define AT_EXECFD 2 /* Open file descriptor of object file */
|
||||
#define AT_PHDR 3 /* &phdr[0] */
|
||||
#define AT_PHENT 4 /* sizeof(phdr[0]) */
|
||||
#define AT_PHNUM 5 /* # phdr entries */
|
||||
#define AT_PAGESZ 6 /* PAGESIZE */
|
||||
#define AT_BASE 7 /* Interpreter base addr */
|
||||
#define AT_FLAGS 8 /* Processor flags */
|
||||
#define AT_ENTRY 9 /* Entry address of executable */
|
||||
#define AT_DCACHEBSIZE 10 /* Data cache block size */
|
||||
#define AT_ICACHEBSIZE 11 /* Instruction cache block size */
|
||||
#define AT_UCACHEBSIZE 12 /* Unified cache block size */
|
||||
|
||||
/* Vendor specific */
|
||||
#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */
|
||||
/* Vendor specific */
|
||||
#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */
|
||||
|
||||
#define AT_SUN_UID 2000 /* euid */
|
||||
#define AT_SUN_RUID 2001 /* ruid */
|
||||
#define AT_SUN_GID 2002 /* egid */
|
||||
#define AT_SUN_RGID 2003 /* rgid */
|
||||
#define AT_SUN_UID 2000 /* euid */
|
||||
#define AT_SUN_RUID 2001 /* ruid */
|
||||
#define AT_SUN_GID 2002 /* egid */
|
||||
#define AT_SUN_RGID 2003 /* rgid */
|
||||
|
||||
/* Solaris kernel specific */
|
||||
#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */
|
||||
#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */
|
||||
#define AT_SUN_LDNAME 2006 /* dynamic linker's name */
|
||||
#define AT_SUN_LPGSIZE 2007 /* large pagesize */
|
||||
/* Solaris kernel specific */
|
||||
#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */
|
||||
#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */
|
||||
#define AT_SUN_LDNAME 2006 /* dynamic linker's name */
|
||||
#define AT_SUN_LPGSIZE 2007 /* large pagesize */
|
||||
|
||||
/* Other information */
|
||||
#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */
|
||||
#define AT_SUN_HWCAP 2009 /* process hardware capabilities */
|
||||
#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */
|
||||
#define AT_SUN_CPU 2011 /* cpu name */
|
||||
/* ibcs2 emulation band aid */
|
||||
#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */
|
||||
#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
|
||||
/* Executable's fully resolved name */
|
||||
#define AT_SUN_EXECNAME 2014
|
||||
/* Other information */
|
||||
#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */
|
||||
#define AT_SUN_HWCAP 2009 /* process hardware capabilities */
|
||||
#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */
|
||||
#define AT_SUN_CPU 2011 /* cpu name */
|
||||
/* ibcs2 emulation band aid */
|
||||
#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */
|
||||
#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
|
||||
/* Executable's fully resolved name */
|
||||
#define AT_SUN_EXECNAME 2014
|
||||
|
||||
/*
|
||||
* Note Headers
|
||||
*/
|
||||
struct elf_nhdr {
|
||||
|
||||
unsigned int n_namesz;
|
||||
unsigned int n_descsz;
|
||||
unsigned int n_type;
|
||||
unsigned int n_namesz;
|
||||
unsigned int n_descsz;
|
||||
unsigned int n_type;
|
||||
};
|
||||
|
||||
#define ELF_NOTE_TYPE_OSVERSION 1
|
||||
#define ELF_NOTE_TYPE_OSVERSION 1
|
||||
|
||||
/* NetBSD-specific note type: Emulation name. desc is emul name string. */
|
||||
#define ELF_NOTE_NETBSD_TYPE_EMULNAME 2
|
||||
#define ELF_NOTE_NETBSD_TYPE_EMULNAME 2
|
||||
|
||||
/* NetBSD-specific note name and description sizes */
|
||||
#define ELF_NOTE_NETBSD_NAMESZ 7
|
||||
#define ELF_NOTE_NETBSD_DESCSZ 4
|
||||
#define ELF_NOTE_NETBSD_NAMESZ 7
|
||||
#define ELF_NOTE_NETBSD_DESCSZ 4
|
||||
/* NetBSD-specific note name */
|
||||
#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0"
|
||||
#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0"
|
||||
|
||||
/* GNU-specific note name and description sizes */
|
||||
#define ELF_NOTE_GNU_NAMESZ 4
|
||||
#define ELF_NOTE_GNU_DESCSZ 4
|
||||
#define ELF_NOTE_GNU_NAMESZ 4
|
||||
#define ELF_NOTE_GNU_DESCSZ 4
|
||||
/* GNU-specific note name */
|
||||
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||
|
||||
/* GNU-specific OS/version value stuff */
|
||||
#define ELF_NOTE_GNU_OSMASK (unsigned int)0xff000000
|
||||
#define ELF_NOTE_GNU_OSLINUX (unsigned int)0x01000000
|
||||
#define ELF_NOTE_GNU_OSMACH (unsigned int)0x00000000
|
||||
|
||||
//#define CONCAT(x,y) __CONCAT(x,y)
|
||||
|
||||
#define ELF_NOTE_GNU_OSMASK (unsigned int)0xff000000
|
||||
#define ELF_NOTE_GNU_OSLINUX (unsigned int)0x01000000
|
||||
#define ELF_NOTE_GNU_OSMACH (unsigned int)0x00000000
|
||||
|
||||
#include <machine/elf_machdep.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */
|
||||
#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */
|
||||
|
||||
struct elf_args {
|
||||
unsigned int arg_entry; /* program entry point */
|
||||
unsigned int arg_interp; /* Interpreter load address */
|
||||
unsigned int arg_phaddr; /* program header address */
|
||||
unsigned int arg_phentsize; /* Size of program header */
|
||||
unsigned int arg_phnum; /* Number of program headers */
|
||||
unsigned int arg_entry; /* program entry point */
|
||||
unsigned int arg_interp; /* Interpreter load address */
|
||||
unsigned int arg_phaddr; /* program header address */
|
||||
unsigned int arg_phentsize; /* Size of program header */
|
||||
unsigned int arg_phnum; /* Number of program headers */
|
||||
};
|
||||
|
||||
#ifndef _LKM
|
||||
@@ -481,15 +477,15 @@ struct elf_args {
|
||||
#endif
|
||||
|
||||
#ifdef EXEC_ELF
|
||||
int exec_elf_makecmds __P((struct proc *, struct exec_package *));
|
||||
int elf_read_from __P((struct proc *, struct vnode *, u_long,
|
||||
caddr_t, int));
|
||||
void *elf_copyargs __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
int exec_elf_makecmds __P((struct proc *, struct exec_package *));
|
||||
int elf_read_from __P((struct proc *, struct vnode *, u_long,
|
||||
caddr_t, int));
|
||||
void *elf_copyargs __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
#endif
|
||||
|
||||
/* common */
|
||||
int exec_elf_setup_stack __P((struct proc *, struct exec_package *));
|
||||
int exec_elf_setup_stack __P((struct proc *, struct exec_package *));
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 1983, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
@@ -17,8 +17,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)fcntl.h 8.3.1 (2.11BSD GTE) 11/25/94
|
||||
* @(#)fcntl.h 8.3.1 (2.11BSD GTE) 11/25/94
|
||||
*
|
||||
* Copied from 4.4-Lite and modified for 2.11BSD. The modifications consisted
|
||||
* of removing: function prototypes (I don't like them, the compiler does not
|
||||
@@ -46,7 +46,7 @@
|
||||
*/
|
||||
|
||||
#ifndef _FCNTL_H_
|
||||
#define _FCNTL_H_
|
||||
#define _FCNTL_H_
|
||||
|
||||
/*
|
||||
* This file includes the definitions for open and fcntl
|
||||
@@ -66,10 +66,10 @@
|
||||
* Open/fcntl flags begin with O_; kernel-internal flags begin with F.
|
||||
*/
|
||||
/* open-only flags */
|
||||
#define O_RDONLY 0x0000 /* open for reading only */
|
||||
#define O_WRONLY 0x0001 /* open for writing only */
|
||||
#define O_RDWR 0x0002 /* open for reading and writing */
|
||||
#define O_ACCMODE 0x0003 /* mask for above modes */
|
||||
#define O_RDONLY 0x0000 /* open for reading only */
|
||||
#define O_WRONLY 0x0001 /* open for writing only */
|
||||
#define O_RDWR 0x0002 /* open for reading and writing */
|
||||
#define O_ACCMODE 0x0003 /* mask for above modes */
|
||||
|
||||
/*
|
||||
* Kernel encoding of open mode; separate read and write bits that are
|
||||
@@ -79,35 +79,35 @@
|
||||
* FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH,
|
||||
* which was documented to use FREAD/FWRITE, continues to work.
|
||||
*/
|
||||
#define FREAD 0x0001
|
||||
#define FWRITE 0x0002
|
||||
#define O_NONBLOCK 0x0004 /* no delay */
|
||||
#define O_APPEND 0x0008 /* set append mode */
|
||||
#define O_SHLOCK 0x0010 /* open with shared file lock */
|
||||
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
||||
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
||||
#define O_FSYNC 0x0080 /* synchronous writes */
|
||||
#define O_CREAT 0x0200 /* create if nonexistant */
|
||||
#define O_TRUNC 0x0400 /* truncate to zero length */
|
||||
#define O_EXCL 0x0800 /* error if already exists */
|
||||
#define FREAD 0x0001
|
||||
#define FWRITE 0x0002
|
||||
#define O_NONBLOCK 0x0004 /* no delay */
|
||||
#define O_APPEND 0x0008 /* set append mode */
|
||||
#define O_SHLOCK 0x0010 /* open with shared file lock */
|
||||
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
||||
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
||||
#define O_FSYNC 0x0080 /* synchronous writes */
|
||||
#define O_CREAT 0x0200 /* create if nonexistant */
|
||||
#define O_TRUNC 0x0400 /* truncate to zero length */
|
||||
#define O_EXCL 0x0800 /* error if already exists */
|
||||
#ifdef KERNEL
|
||||
#define FMARK 0x1000 /* mark during gc() */
|
||||
#define FDEFER 0x2000 /* defer for next gc pass */
|
||||
#define FMARK 0x1000 /* mark during gc() */
|
||||
#define FDEFER 0x2000 /* defer for next gc pass */
|
||||
#endif
|
||||
|
||||
/* defined by POSIX 1003.1; not 2.11BSD default, so bit is required */
|
||||
/* Not currently implemented but it may be placed on the TODO list shortly */
|
||||
#define O_NOCTTY 0x4000 /* don't assign controlling terminal */
|
||||
#define O_NOCTTY 0x4000 /* don't assign controlling terminal */
|
||||
|
||||
#ifdef KERNEL
|
||||
/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
|
||||
#define FFLAGS(oflags) ((oflags) + 1)
|
||||
#define OFLAGS(fflags) ((fflags) - 1)
|
||||
#define FFLAGS(oflags) ((oflags) + 1)
|
||||
#define OFLAGS(fflags) ((fflags) - 1)
|
||||
|
||||
/* bits to save after open */
|
||||
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
|
||||
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
|
||||
/* bits settable by fcntl(F_SETFL, ...) */
|
||||
#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
|
||||
#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -115,35 +115,35 @@
|
||||
* and by fcntl. We retain the F* names for the kernel f_flags field
|
||||
* and for backward compatibility for fcntl.
|
||||
*/
|
||||
#define FAPPEND O_APPEND /* kernel/compat */
|
||||
#define FASYNC O_ASYNC /* kernel/compat */
|
||||
#define FFSYNC O_FSYNC /* kernel */
|
||||
#define FEXLOCK O_EXLOCK /* kernel */
|
||||
#define FSHLOCK O_SHLOCK /* kernel */
|
||||
#define FNONBLOCK O_NONBLOCK /* kernel */
|
||||
#define FNDELAY O_NONBLOCK /* compat */
|
||||
#define O_NDELAY O_NONBLOCK /* compat */
|
||||
#define FAPPEND O_APPEND /* kernel/compat */
|
||||
#define FASYNC O_ASYNC /* kernel/compat */
|
||||
#define FFSYNC O_FSYNC /* kernel */
|
||||
#define FEXLOCK O_EXLOCK /* kernel */
|
||||
#define FSHLOCK O_SHLOCK /* kernel */
|
||||
#define FNONBLOCK O_NONBLOCK /* kernel */
|
||||
#define FNDELAY O_NONBLOCK /* compat */
|
||||
#define O_NDELAY O_NONBLOCK /* compat */
|
||||
|
||||
/*
|
||||
* Constants used for fcntl(2)
|
||||
*/
|
||||
|
||||
/* command values */
|
||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
||||
#define F_GETFD 1 /* get file descriptor flags */
|
||||
#define F_SETFD 2 /* set file descriptor flags */
|
||||
#define F_GETFL 3 /* get file status flags */
|
||||
#define F_SETFL 4 /* set file status flags */
|
||||
#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
||||
#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
||||
#define F_GETFD 1 /* get file descriptor flags */
|
||||
#define F_SETFD 2 /* set file descriptor flags */
|
||||
#define F_GETFL 3 /* get file status flags */
|
||||
#define F_SETFL 4 /* set file status flags */
|
||||
#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
||||
#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
||||
|
||||
/* file descriptor flags (F_GETFD, F_SETFD) */
|
||||
#define FD_CLOEXEC 1 /* close-on-exec flag */
|
||||
#define FD_CLOEXEC 1 /* close-on-exec flag */
|
||||
|
||||
/* lock operations for flock(2) */
|
||||
#define LOCK_SH 0x01 /* shared file lock */
|
||||
#define LOCK_EX 0x02 /* exclusive file lock */
|
||||
#define LOCK_NB 0x04 /* don't block when locking */
|
||||
#define LOCK_UN 0x08 /* unlock file */
|
||||
#define LOCK_SH 0x01 /* shared file lock */
|
||||
#define LOCK_EX 0x02 /* exclusive file lock */
|
||||
#define LOCK_NB 0x04 /* don't block when locking */
|
||||
#define LOCK_UN 0x08 /* unlock file */
|
||||
|
||||
#endif /* !_FCNTL_H_ */
|
||||
|
||||
@@ -5,37 +5,37 @@
|
||||
*/
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#ifndef _SYS_FILE_H_
|
||||
#define _SYS_FILE_H_
|
||||
#ifndef _SYS_FILE_H_
|
||||
#define _SYS_FILE_H_
|
||||
|
||||
/*
|
||||
* Descriptor table entry.
|
||||
* One for each kernel object.
|
||||
*/
|
||||
struct file {
|
||||
int f_flag; /* see below */
|
||||
int f_type; /* descriptor type */
|
||||
u_int f_count; /* reference count */
|
||||
int f_msgcount; /* references from message queue */
|
||||
union {
|
||||
caddr_t f_Data;
|
||||
struct socket *f_Socket;
|
||||
} f_un;
|
||||
off_t f_offset;
|
||||
struct file {
|
||||
int f_flag; /* see below */
|
||||
int f_type; /* descriptor type */
|
||||
u_int f_count; /* reference count */
|
||||
int f_msgcount; /* references from message queue */
|
||||
union {
|
||||
caddr_t f_Data;
|
||||
struct socket *f_Socket;
|
||||
} f_un;
|
||||
off_t f_offset;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
struct uio;
|
||||
|
||||
struct fileops {
|
||||
int (*fo_rw) (struct file *fp, struct uio *uio);
|
||||
int (*fo_ioctl) (struct file *fp, u_int com, char *data);
|
||||
int (*fo_select) (struct file *fp, int flag);
|
||||
int (*fo_close) (struct file *fp);
|
||||
struct fileops {
|
||||
int (*fo_rw) (struct file *fp, struct uio *uio);
|
||||
int (*fo_ioctl) (struct file *fp, u_int com, char *data);
|
||||
int (*fo_select) (struct file *fp, int flag);
|
||||
int (*fo_close) (struct file *fp);
|
||||
};
|
||||
|
||||
#define f_data f_un.f_Data
|
||||
#define f_socket f_un.f_Socket
|
||||
#define f_data f_un.f_Data
|
||||
#define f_socket f_un.f_Socket
|
||||
|
||||
extern struct file file[];
|
||||
extern const struct fileops *const Fops[];
|
||||
@@ -94,27 +94,27 @@ int flock(int fd, int operation);
|
||||
/*
|
||||
* Access call.
|
||||
*/
|
||||
#define F_OK 0 /* does file exist */
|
||||
#define X_OK 1 /* is it executable by caller */
|
||||
#define W_OK 2 /* writable by caller */
|
||||
#define R_OK 4 /* readable by caller */
|
||||
#define F_OK 0 /* does file exist */
|
||||
#define X_OK 1 /* is it executable by caller */
|
||||
#define W_OK 2 /* writable by caller */
|
||||
#define R_OK 4 /* readable by caller */
|
||||
|
||||
/*
|
||||
* Lseek call.
|
||||
*/
|
||||
#define L_SET 0 /* absolute offset */
|
||||
#define L_INCR 1 /* relative to current offset */
|
||||
#define L_XTND 2 /* relative to end of file */
|
||||
#define L_SET 0 /* absolute offset */
|
||||
#define L_INCR 1 /* relative to current offset */
|
||||
#define L_XTND 2 /* relative to end of file */
|
||||
|
||||
#ifdef KERNEL
|
||||
#define GETF(fp, fd) { \
|
||||
if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
|
||||
u.u_error = EBADF; \
|
||||
return; \
|
||||
} \
|
||||
#define GETF(fp, fd) { \
|
||||
if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
|
||||
u.u_error = EBADF; \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define DTYPE_INODE 1 /* file */
|
||||
#define DTYPE_SOCKET 2 /* communications endpoint */
|
||||
#define DTYPE_PIPE 3 /* I don't want to hear it, okay? */
|
||||
#define DTYPE_INODE 1 /* file */
|
||||
#define DTYPE_SOCKET 2 /* communications endpoint */
|
||||
#define DTYPE_PIPE 3 /* I don't want to hear it, okay? */
|
||||
#endif
|
||||
#endif /* _SYS_FILE_H_ */
|
||||
#endif /* _SYS_FILE_H_ */
|
||||
|
||||
@@ -7,7 +7,7 @@ static const unsigned char vga[] = {
|
||||
1, // bpp
|
||||
|
||||
// 32 $20 'space'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -26,7 +26,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 33 $21 'exclam'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -45,7 +45,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 34 $22 'quotedbl'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b01100110,
|
||||
@@ -64,7 +64,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 35 $23 'numbersign'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -83,7 +83,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 36 $24 'dollar'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00011000,
|
||||
0b00011000,
|
||||
@@ -102,7 +102,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 37 $25 'percent'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -121,7 +121,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 38 $26 'ampersand'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -140,7 +140,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 39 $27 'quotesingle'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00001100,
|
||||
@@ -159,7 +159,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 40 $28 'parenleft'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -178,7 +178,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 41 $29 'parenright'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -197,7 +197,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 42 $2a 'asterisk'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -216,7 +216,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 43 $2b 'plus'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -235,7 +235,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 44 $2c 'comma'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -254,7 +254,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 45 $2d 'hyphen'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -273,7 +273,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 46 $2e 'period'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -292,7 +292,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 47 $2f 'slash'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -311,7 +311,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 48 $30 'zero'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -330,7 +330,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 49 $31 'one'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -349,7 +349,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 50 $32 'two'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -368,7 +368,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 51 $33 'three'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -387,7 +387,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 52 $34 'four'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -406,7 +406,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 53 $35 'five'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -425,7 +425,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 54 $36 'six'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -444,7 +444,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 55 $37 'seven'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -463,7 +463,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 56 $38 'eight'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -482,7 +482,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 57 $39 'nine'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -501,7 +501,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 58 $3a 'colon'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -520,7 +520,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 59 $3b 'semicolon'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -539,7 +539,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 60 $3c 'less'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -558,7 +558,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 61 $3d 'equal'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -577,7 +577,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 62 $3e 'greater'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -596,7 +596,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 63 $3f 'question'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -615,7 +615,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 64 $40 'at'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -634,7 +634,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 65 $41 'A'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -653,7 +653,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 66 $42 'B'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -672,7 +672,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 67 $43 'C'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -691,7 +691,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 68 $44 'D'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -710,7 +710,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 69 $45 'E'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -729,7 +729,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 70 $46 'F'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -748,7 +748,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 71 $47 'G'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -767,7 +767,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 72 $48 'H'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -786,7 +786,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 73 $49 'I'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -805,7 +805,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 74 $4a 'J'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -824,7 +824,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 75 $4b 'K'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -843,7 +843,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 76 $4c 'L'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -862,7 +862,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 77 $4d 'M'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -881,7 +881,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 78 $4e 'N'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -900,7 +900,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 79 $4f 'O'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -919,7 +919,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 80 $50 'P'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -938,7 +938,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 81 $51 'Q'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -957,7 +957,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 82 $52 'R'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -976,7 +976,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 83 $53 'S'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -995,7 +995,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 84 $54 'T'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1014,7 +1014,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 85 $55 'U'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1033,7 +1033,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 86 $56 'V'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1052,7 +1052,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 87 $57 'W'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1071,7 +1071,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 88 $58 '1'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1090,7 +1090,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 89 $59 'Y'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1109,7 +1109,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 90 $5a 'Z'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1128,7 +1128,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 91 $5b 'bracketleft'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1147,7 +1147,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 92 $5c 'backslash'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1166,7 +1166,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 93 $5d 'bracketright'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1185,7 +1185,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 94 $5e 'asciicircum'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00001000,
|
||||
0b00011100,
|
||||
@@ -1204,7 +1204,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 95 $5f 'underscore'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1223,7 +1223,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 96 $60 'grave'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00001100,
|
||||
0b00001100,
|
||||
@@ -1242,7 +1242,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 97 $61 'a'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1261,7 +1261,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 98 $62 'b'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1280,7 +1280,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 99 $63 'c'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1299,7 +1299,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 100 $64 'd'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1318,7 +1318,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 101 $65 'e'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1337,7 +1337,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 102 $66 'f'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1356,7 +1356,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 103 $67 'g'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1375,7 +1375,7 @@ static const unsigned char vga[] = {
|
||||
0b00011110,
|
||||
0b00000000,
|
||||
// 104 $68 'h'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1394,7 +1394,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 105 $69 'i'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1413,7 +1413,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 106 $6a 'j'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1432,7 +1432,7 @@ static const unsigned char vga[] = {
|
||||
0b00111100,
|
||||
0b00000000,
|
||||
// 107 $6b 'k'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1451,7 +1451,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 108 $6c 'l'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1470,7 +1470,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 109 $6d 'm'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1489,7 +1489,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 110 $6e 'n'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1508,7 +1508,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 111 $6f 'o'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1527,7 +1527,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 112 $70 'p'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1546,7 +1546,7 @@ static const unsigned char vga[] = {
|
||||
0b00001111,
|
||||
0b00000000,
|
||||
// 113 $71 'q'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1565,7 +1565,7 @@ static const unsigned char vga[] = {
|
||||
0b01111000,
|
||||
0b00000000,
|
||||
// 114 $72 'r'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1584,7 +1584,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 115 $73 's'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1603,7 +1603,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 116 $74 't'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1622,7 +1622,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 117 $75 'u'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1641,7 +1641,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 118 $76 'v'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1660,7 +1660,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 119 $77 'w'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1679,7 +1679,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 120 $78 'x'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1698,7 +1698,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 121 $79 'y'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1717,7 +1717,7 @@ static const unsigned char vga[] = {
|
||||
0b00011111,
|
||||
0b00000000,
|
||||
// 122 $7a 'z'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1736,7 +1736,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 123 $7b 'braceleft'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1755,7 +1755,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 124 $7c 'bar'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1774,7 +1774,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 125 $7d 'braceright'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1793,7 +1793,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 126 $7e 'asciitilde'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
@@ -1812,7 +1812,7 @@ static const unsigned char vga[] = {
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
// 127 $7f 'char127'
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
// width 8, bbx 0, bby -4, bbw 8, bbh 16
|
||||
8,
|
||||
0b00000000,
|
||||
0b00000000,
|
||||
|
||||
102
sys/include/fs.h
102
sys/include/fs.h
@@ -3,8 +3,8 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef _SYS_FS_H_
|
||||
#define _SYS_FS_H_
|
||||
#ifndef _SYS_FS_H_
|
||||
#define _SYS_FS_H_
|
||||
|
||||
/*
|
||||
* The root inode is the root of the file system.
|
||||
@@ -16,104 +16,104 @@
|
||||
* The lost+found directory is given the next available
|
||||
* inode when it is created by ``mkfs''.
|
||||
*/
|
||||
#define SBSIZE DEV_BSIZE
|
||||
#define SUPERB ((daddr_t)0) /* block number of the super block */
|
||||
#define SBSIZE DEV_BSIZE
|
||||
#define SUPERB ((daddr_t)0) /* block number of the super block */
|
||||
|
||||
#define ROOTINO ((ino_t)2) /* i number of all roots */
|
||||
#define LOSTFOUNDINO (ROOTINO + 1)
|
||||
#define ROOTINO ((ino_t)2) /* i number of all roots */
|
||||
#define LOSTFOUNDINO (ROOTINO + 1)
|
||||
|
||||
#define NICINOD 32 /* number of superblock inodes */
|
||||
#define NICFREE 200 /* number of superblock free blocks */
|
||||
#define NICINOD 32 /* number of superblock inodes */
|
||||
#define NICFREE 200 /* number of superblock free blocks */
|
||||
|
||||
/*
|
||||
* The path name on which the file system is mounted is maintained
|
||||
* in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
|
||||
* the super block for this name.
|
||||
*/
|
||||
#define MAXMNTLEN 28
|
||||
#define MAXMNTLEN 28
|
||||
|
||||
/*
|
||||
* Super block for a file system. NOTE: The 'fs_flock' and 'fs_ilock'
|
||||
* fields MUST be on an even byte boundary because they are used as sleep()
|
||||
* channels and odd values specify a network sleep().
|
||||
*/
|
||||
struct fs
|
||||
struct fs
|
||||
{
|
||||
u_int fs_magic1; /* magic word */
|
||||
u_int fs_isize; /* first block after i-list */
|
||||
u_int fs_fsize; /* size in blocks of entire volume */
|
||||
u_int fs_swapsz; /* size in blocks of swap area */
|
||||
int fs_nfree; /* number of addresses in fs_free */
|
||||
daddr_t fs_free [NICFREE]; /* free block list */
|
||||
int fs_ninode; /* number of inodes in fs_inode */
|
||||
ino_t fs_inode [NICINOD]; /* free inode list */
|
||||
int fs_flock; /* lock during free list manipulation */
|
||||
int fs_fmod; /* super block modified flag */
|
||||
int fs_ilock; /* lock during i-list manipulation */
|
||||
int fs_ronly; /* mounted read-only flag */
|
||||
time_t fs_time; /* last super block update */
|
||||
u_int fs_tfree; /* total free blocks */
|
||||
ino_t fs_tinode; /* total free inodes */
|
||||
char fs_fsmnt [MAXMNTLEN]; /* ordinary file mounted on */
|
||||
ino_t fs_lasti; /* start place for circular search */
|
||||
ino_t fs_nbehind; /* est # free inodes before s_lasti */
|
||||
u_int fs_flags; /* mount time flags */
|
||||
u_int fs_magic2; /* magic word */
|
||||
u_int fs_magic1; /* magic word */
|
||||
u_int fs_isize; /* first block after i-list */
|
||||
u_int fs_fsize; /* size in blocks of entire volume */
|
||||
u_int fs_swapsz; /* size in blocks of swap area */
|
||||
int fs_nfree; /* number of addresses in fs_free */
|
||||
daddr_t fs_free [NICFREE]; /* free block list */
|
||||
int fs_ninode; /* number of inodes in fs_inode */
|
||||
ino_t fs_inode [NICINOD]; /* free inode list */
|
||||
int fs_flock; /* lock during free list manipulation */
|
||||
int fs_fmod; /* super block modified flag */
|
||||
int fs_ilock; /* lock during i-list manipulation */
|
||||
int fs_ronly; /* mounted read-only flag */
|
||||
time_t fs_time; /* last super block update */
|
||||
u_int fs_tfree; /* total free blocks */
|
||||
ino_t fs_tinode; /* total free inodes */
|
||||
char fs_fsmnt [MAXMNTLEN]; /* ordinary file mounted on */
|
||||
ino_t fs_lasti; /* start place for circular search */
|
||||
ino_t fs_nbehind; /* est # free inodes before s_lasti */
|
||||
u_int fs_flags; /* mount time flags */
|
||||
u_int fs_magic2; /* magic word */
|
||||
/* actually longer */
|
||||
};
|
||||
|
||||
struct fblk {
|
||||
int df_nfree; /* number of addresses in df_free */
|
||||
daddr_t df_free [NICFREE]; /* free block list */
|
||||
struct fblk {
|
||||
int df_nfree; /* number of addresses in df_free */
|
||||
daddr_t df_free [NICFREE]; /* free block list */
|
||||
};
|
||||
|
||||
#define FSMAGIC1 ('F' | 'S'<<8 | '<'<<16 | '<'<<24)
|
||||
#define FSMAGIC2 ('>' | '>'<<8 | 'F'<<16 | 'S'<<24)
|
||||
#define FSMAGIC1 ('F' | 'S'<<8 | '<'<<16 | '<'<<24)
|
||||
#define FSMAGIC2 ('>' | '>'<<8 | 'F'<<16 | 'S'<<24)
|
||||
|
||||
/*
|
||||
* Turn file system block numbers into disk block addresses.
|
||||
* This maps file system blocks to device size blocks.
|
||||
*/
|
||||
#define fsbtodb(b) ((daddr_t) (b))
|
||||
#define dbtofsb(b) ((daddr_t) (b))
|
||||
#define fsbtodb(b) ((daddr_t) (b))
|
||||
#define dbtofsb(b) ((daddr_t) (b))
|
||||
|
||||
/*
|
||||
* Macros for handling inode numbers:
|
||||
* inode number to file system block offset.
|
||||
* inode number to file system block address.
|
||||
*/
|
||||
#define itoo(x) ((int)(((x) + INOPB - 1) % INOPB))
|
||||
#define itod(x) ((daddr_t)((((u_int)(x) + INOPB - 1) / INOPB)))
|
||||
#define itoo(x) ((int)(((x) + INOPB - 1) % INOPB))
|
||||
#define itod(x) ((daddr_t)((((u_int)(x) + INOPB - 1) / INOPB)))
|
||||
|
||||
/*
|
||||
* The following macros optimize certain frequently calculated
|
||||
* quantities by using shifts and masks in place of divisions
|
||||
* modulos and multiplications.
|
||||
*/
|
||||
#define blkoff(loc) /* calculates (loc % fs->fs_bsize) */ \
|
||||
((loc) & DEV_BMASK)
|
||||
#define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \
|
||||
((unsigned) (loc) >> DEV_BSHIFT)
|
||||
#define blkoff(loc) /* calculates (loc % fs->fs_bsize) */ \
|
||||
((loc) & DEV_BMASK)
|
||||
#define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \
|
||||
((unsigned) (loc) >> DEV_BSHIFT)
|
||||
|
||||
/*
|
||||
* Determine the number of available blocks given a
|
||||
* percentage to hold in reserve
|
||||
*/
|
||||
#define freespace(fs, percentreserved) \
|
||||
((fs)->fs_tfree - ((fs)->fs_fsize - \
|
||||
(fs)->fs_isize) * (percentreserved) / 100)
|
||||
((fs)->fs_tfree - ((fs)->fs_fsize - \
|
||||
(fs)->fs_isize) * (percentreserved) / 100)
|
||||
|
||||
/*
|
||||
* INOPB is the number of inodes in a secondary storage block.
|
||||
*/
|
||||
#define INOPB 16 /* MAXBSIZE / sizeof(dinode) */
|
||||
#define INOPB 16 /* MAXBSIZE / sizeof(dinode) */
|
||||
|
||||
/*
|
||||
* NINDIR is the number of indirects in a file system block.
|
||||
*/
|
||||
#define NINDIR (DEV_BSIZE / sizeof(daddr_t))
|
||||
#define NSHIFT 8 /* log2(NINDIR) */
|
||||
#define NMASK 0377L /* NINDIR - 1 */
|
||||
#define NINDIR (DEV_BSIZE / sizeof(daddr_t))
|
||||
#define NSHIFT 8 /* log2(NINDIR) */
|
||||
#define NMASK 0377L /* NINDIR - 1 */
|
||||
|
||||
/*
|
||||
* We continue to implement pipes within the file system because it would
|
||||
@@ -124,7 +124,7 @@ struct fblk {
|
||||
* bigger than 4096, pipes will be implemented with large files, which is
|
||||
* probably not good.
|
||||
*/
|
||||
#define MAXPIPSIZ (NDADDR * MAXBSIZE)
|
||||
#define MAXPIPSIZ (NDADDR * MAXBSIZE)
|
||||
|
||||
#ifdef KERNEL
|
||||
struct inode;
|
||||
@@ -140,7 +140,7 @@ struct fs *getfs (dev_t dev);
|
||||
struct fs *mountfs (dev_t dev, int flags, struct inode *ip);
|
||||
|
||||
void mount_updname (struct fs *fs, char *on, char *from,
|
||||
int lenon, int lenfrom);
|
||||
int lenon, int lenfrom);
|
||||
|
||||
/*
|
||||
* Sync a single filesystem.
|
||||
|
||||
@@ -3,38 +3,38 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)gpio.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
* @(#)gpio.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ioctl definitions
|
||||
*/
|
||||
#ifndef _GPIO_H
|
||||
#ifndef _GPIO_H
|
||||
#define _GPIO_H
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
/* control general-purpose i/o pins */
|
||||
#define GPIO_PORT(n) ((n) & 0xff) /* port number */
|
||||
#define GPIO_PORTA GPIO_PORT(0)
|
||||
#define GPIO_PORTB GPIO_PORT(1)
|
||||
#define GPIO_PORTC GPIO_PORT(2)
|
||||
#define GPIO_PORTD GPIO_PORT(3)
|
||||
#define GPIO_PORTE GPIO_PORT(4)
|
||||
#define GPIO_PORTF GPIO_PORT(5)
|
||||
#define GPIO_PORTG GPIO_PORT(6)
|
||||
#define GPIO_COMMAND 0x1fff0000 /* command mask */
|
||||
#define GPIO_CONFIN (IOC_VOID | 1 << 16 | 'g'<<8) /* configure as input */
|
||||
#define GPIO_PORT(n) ((n) & 0xff) /* port number */
|
||||
#define GPIO_PORTA GPIO_PORT(0)
|
||||
#define GPIO_PORTB GPIO_PORT(1)
|
||||
#define GPIO_PORTC GPIO_PORT(2)
|
||||
#define GPIO_PORTD GPIO_PORT(3)
|
||||
#define GPIO_PORTE GPIO_PORT(4)
|
||||
#define GPIO_PORTF GPIO_PORT(5)
|
||||
#define GPIO_PORTG GPIO_PORT(6)
|
||||
#define GPIO_COMMAND 0x1fff0000 /* command mask */
|
||||
#define GPIO_CONFIN (IOC_VOID | 1 << 16 | 'g'<<8) /* configure as input */
|
||||
#define GPIO_CONFOUT (IOC_VOID | 1 << 17 | 'g'<<8) /* configure as output */
|
||||
#define GPIO_CONFOD (IOC_VOID | 1 << 18 | 'g'<<8) /* configure as open drain */
|
||||
#define GPIO_DECONF (IOC_VOID | 1 << 19 | 'g'<<8) /* deconfigure */
|
||||
#define GPIO_STORE (IOC_VOID | 1 << 20 | 'g'<<8) /* store all outputs */
|
||||
#define GPIO_SET (IOC_VOID | 1 << 21 | 'g'<<8) /* set to 1 by mask */
|
||||
#define GPIO_CLEAR (IOC_VOID | 1 << 22 | 'g'<<8) /* set to 0 by mask */
|
||||
#define GPIO_INVERT (IOC_VOID | 1 << 23 | 'g'<<8) /* invert by mask */
|
||||
#define GPIO_POLL (IOC_VOID | 1 << 24 | 'g'<<8) /* poll */
|
||||
#define GPIO_LOL (IOC_IN | 1 << 25 | 'g'<<8) /* display lol picture */
|
||||
#define GPIO_CONFOD (IOC_VOID | 1 << 18 | 'g'<<8) /* configure as open drain */
|
||||
#define GPIO_DECONF (IOC_VOID | 1 << 19 | 'g'<<8) /* deconfigure */
|
||||
#define GPIO_STORE (IOC_VOID | 1 << 20 | 'g'<<8) /* store all outputs */
|
||||
#define GPIO_SET (IOC_VOID | 1 << 21 | 'g'<<8) /* set to 1 by mask */
|
||||
#define GPIO_CLEAR (IOC_VOID | 1 << 22 | 'g'<<8) /* set to 0 by mask */
|
||||
#define GPIO_INVERT (IOC_VOID | 1 << 23 | 'g'<<8) /* invert by mask */
|
||||
#define GPIO_POLL (IOC_VOID | 1 << 24 | 'g'<<8) /* poll */
|
||||
#define GPIO_LOL (IOC_IN | 1 << 25 | 'g'<<8) /* display lol picture */
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ extern void hx8357_putc(dev_t dev, char c);
|
||||
extern char hx8357_getc(dev_t dev);
|
||||
extern void hx8357_init();
|
||||
|
||||
|
||||
extern struct tty hx8357_ttys[1];
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,68 +16,68 @@
|
||||
* 28 of the di_addr address bytes are used; 7 addresses of 4
|
||||
* bytes each: 4 direct (4Kb directly accessible) and 3 indirect.
|
||||
*/
|
||||
#define NDADDR 4 /* direct addresses in inode */
|
||||
#define NIADDR 3 /* indirect addresses in inode */
|
||||
#define NADDR (NDADDR + NIADDR) /* total addresses in inode */
|
||||
#define NDADDR 4 /* direct addresses in inode */
|
||||
#define NIADDR 3 /* indirect addresses in inode */
|
||||
#define NADDR (NDADDR + NIADDR) /* total addresses in inode */
|
||||
|
||||
struct icommon1 {
|
||||
u_short ic_mode; /* mode and type of file */
|
||||
u_short ic_nlink; /* number of links to file */
|
||||
uid_t ic_uid; /* owner's user id */
|
||||
gid_t ic_gid; /* owner's group id */
|
||||
off_t ic_size; /* number of bytes in file */
|
||||
u_short ic_mode; /* mode and type of file */
|
||||
u_short ic_nlink; /* number of links to file */
|
||||
uid_t ic_uid; /* owner's user id */
|
||||
gid_t ic_gid; /* owner's group id */
|
||||
off_t ic_size; /* number of bytes in file */
|
||||
};
|
||||
|
||||
struct icommon2 {
|
||||
time_t ic_atime; /* time last accessed */
|
||||
time_t ic_mtime; /* time last modified */
|
||||
time_t ic_ctime; /* time created */
|
||||
time_t ic_atime; /* time last accessed */
|
||||
time_t ic_mtime; /* time last modified */
|
||||
time_t ic_ctime; /* time created */
|
||||
};
|
||||
|
||||
struct inode {
|
||||
struct inode *i_chain[2]; /* must be first */
|
||||
u_int i_flag;
|
||||
u_int i_count; /* reference count */
|
||||
dev_t i_dev; /* device where inode resides */
|
||||
ino_t i_number; /* i number, 1-to-1 with device address */
|
||||
u_int i_id; /* unique identifier */
|
||||
struct fs *i_fs; /* file sys associated with this inode */
|
||||
union {
|
||||
struct {
|
||||
u_short I_shlockc; /* count of shared locks */
|
||||
u_short I_exlockc; /* count of exclusive locks */
|
||||
} i_l;
|
||||
struct proc *I_rsel; /* pipe read select */
|
||||
} i_un0;
|
||||
union {
|
||||
struct proc *I_wsel; /* pipe write select */
|
||||
} i_un1;
|
||||
union {
|
||||
daddr_t I_addr[NADDR]; /* normal file/directory */
|
||||
struct {
|
||||
daddr_t I_db[NDADDR]; /* normal file/directory */
|
||||
daddr_t I_ib[NIADDR];
|
||||
} i_f;
|
||||
struct {
|
||||
/*
|
||||
* the dummy field is here so that the de/compression
|
||||
* part of the iget/iput routines works for special
|
||||
* files.
|
||||
*/
|
||||
u_int I_dummy;
|
||||
dev_t I_rdev; /* dev type */
|
||||
} i_d;
|
||||
} i_un2;
|
||||
union {
|
||||
daddr_t if_lastr; /* last read (read-ahead) */
|
||||
struct {
|
||||
struct inode *if_freef; /* free list forward */
|
||||
struct inode **if_freeb; /* free list back */
|
||||
} i_fr;
|
||||
} i_un3;
|
||||
struct icommon1 i_ic1;
|
||||
u_int i_flags; /* user changeable flags */
|
||||
struct icommon2 i_ic2;
|
||||
struct inode *i_chain[2]; /* must be first */
|
||||
u_int i_flag;
|
||||
u_int i_count; /* reference count */
|
||||
dev_t i_dev; /* device where inode resides */
|
||||
ino_t i_number; /* i number, 1-to-1 with device address */
|
||||
u_int i_id; /* unique identifier */
|
||||
struct fs *i_fs; /* file sys associated with this inode */
|
||||
union {
|
||||
struct {
|
||||
u_short I_shlockc; /* count of shared locks */
|
||||
u_short I_exlockc; /* count of exclusive locks */
|
||||
} i_l;
|
||||
struct proc *I_rsel; /* pipe read select */
|
||||
} i_un0;
|
||||
union {
|
||||
struct proc *I_wsel; /* pipe write select */
|
||||
} i_un1;
|
||||
union {
|
||||
daddr_t I_addr[NADDR]; /* normal file/directory */
|
||||
struct {
|
||||
daddr_t I_db[NDADDR]; /* normal file/directory */
|
||||
daddr_t I_ib[NIADDR];
|
||||
} i_f;
|
||||
struct {
|
||||
/*
|
||||
* the dummy field is here so that the de/compression
|
||||
* part of the iget/iput routines works for special
|
||||
* files.
|
||||
*/
|
||||
u_int I_dummy;
|
||||
dev_t I_rdev; /* dev type */
|
||||
} i_d;
|
||||
} i_un2;
|
||||
union {
|
||||
daddr_t if_lastr; /* last read (read-ahead) */
|
||||
struct {
|
||||
struct inode *if_freef; /* free list forward */
|
||||
struct inode **if_freeb; /* free list back */
|
||||
} i_fr;
|
||||
} i_un3;
|
||||
struct icommon1 i_ic1;
|
||||
u_int i_flags; /* user changeable flags */
|
||||
struct icommon2 i_ic2;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -85,46 +85,46 @@ struct inode {
|
||||
* a disk block.
|
||||
*/
|
||||
struct dinode {
|
||||
struct icommon1 di_icom1;
|
||||
daddr_t di_addr[NADDR]; /* 7 block addresses 4 bytes each */
|
||||
u_int di_reserved[1]; /* pad of 4 to make total size 64 */
|
||||
u_int di_flags;
|
||||
struct icommon2 di_icom2;
|
||||
struct icommon1 di_icom1;
|
||||
daddr_t di_addr[NADDR]; /* 7 block addresses 4 bytes each */
|
||||
u_int di_reserved[1]; /* pad of 4 to make total size 64 */
|
||||
u_int di_flags;
|
||||
struct icommon2 di_icom2;
|
||||
};
|
||||
|
||||
#define i_mode i_ic1.ic_mode
|
||||
#define i_nlink i_ic1.ic_nlink
|
||||
#define i_uid i_ic1.ic_uid
|
||||
#define i_gid i_ic1.ic_gid
|
||||
#define i_size i_ic1.ic_size
|
||||
#define i_shlockc i_un0.i_l.I_shlockc
|
||||
#define i_exlockc i_un0.i_l.I_exlockc
|
||||
#define i_rsel i_un0.I_rsel
|
||||
#define i_wsel i_un1.I_wsel
|
||||
#define i_db i_un2.i_f.I_db
|
||||
#define i_ib i_un2.i_f.I_ib
|
||||
#define i_atime i_ic2.ic_atime
|
||||
#define i_mtime i_ic2.ic_mtime
|
||||
#define i_ctime i_ic2.ic_ctime
|
||||
#define i_rdev i_un2.i_d.I_rdev
|
||||
#define i_addr i_un2.I_addr
|
||||
#define i_dummy i_un2.i_d.I_dummy
|
||||
#define i_lastr i_un3.if_lastr
|
||||
#define i_forw i_chain[0]
|
||||
#define i_back i_chain[1]
|
||||
#define i_freef i_un3.i_fr.if_freef
|
||||
#define i_freeb i_un3.i_fr.if_freeb
|
||||
#define i_mode i_ic1.ic_mode
|
||||
#define i_nlink i_ic1.ic_nlink
|
||||
#define i_uid i_ic1.ic_uid
|
||||
#define i_gid i_ic1.ic_gid
|
||||
#define i_size i_ic1.ic_size
|
||||
#define i_shlockc i_un0.i_l.I_shlockc
|
||||
#define i_exlockc i_un0.i_l.I_exlockc
|
||||
#define i_rsel i_un0.I_rsel
|
||||
#define i_wsel i_un1.I_wsel
|
||||
#define i_db i_un2.i_f.I_db
|
||||
#define i_ib i_un2.i_f.I_ib
|
||||
#define i_atime i_ic2.ic_atime
|
||||
#define i_mtime i_ic2.ic_mtime
|
||||
#define i_ctime i_ic2.ic_ctime
|
||||
#define i_rdev i_un2.i_d.I_rdev
|
||||
#define i_addr i_un2.I_addr
|
||||
#define i_dummy i_un2.i_d.I_dummy
|
||||
#define i_lastr i_un3.if_lastr
|
||||
#define i_forw i_chain[0]
|
||||
#define i_back i_chain[1]
|
||||
#define i_freef i_un3.i_fr.if_freef
|
||||
#define i_freeb i_un3.i_fr.if_freeb
|
||||
|
||||
#define di_ic1 di_icom1
|
||||
#define di_ic2 di_icom2
|
||||
#define di_mode di_ic1.ic_mode
|
||||
#define di_nlink di_ic1.ic_nlink
|
||||
#define di_uid di_ic1.ic_uid
|
||||
#define di_gid di_ic1.ic_gid
|
||||
#define di_size di_ic1.ic_size
|
||||
#define di_atime di_ic2.ic_atime
|
||||
#define di_mtime di_ic2.ic_mtime
|
||||
#define di_ctime di_ic2.ic_ctime
|
||||
#define di_ic1 di_icom1
|
||||
#define di_ic2 di_icom2
|
||||
#define di_mode di_ic1.ic_mode
|
||||
#define di_nlink di_ic1.ic_nlink
|
||||
#define di_uid di_ic1.ic_uid
|
||||
#define di_gid di_ic1.ic_gid
|
||||
#define di_size di_ic1.ic_size
|
||||
#define di_atime di_ic2.ic_atime
|
||||
#define di_mtime di_ic2.ic_mtime
|
||||
#define di_ctime di_ic2.ic_ctime
|
||||
|
||||
#ifdef KERNEL
|
||||
struct stat;
|
||||
@@ -140,14 +140,14 @@ struct stat;
|
||||
void cinvalall (void);
|
||||
|
||||
#define cacheinval(ip) \
|
||||
(ip)->i_id = ++nextinodeid; \
|
||||
if (nextinodeid == 0) \
|
||||
cinvalall();
|
||||
(ip)->i_id = ++nextinodeid; \
|
||||
if (nextinodeid == 0) \
|
||||
cinvalall();
|
||||
|
||||
u_int nextinodeid; /* unique id generator */
|
||||
u_int nextinodeid; /* unique id generator */
|
||||
|
||||
extern struct inode inode[]; /* the inode table itself */
|
||||
struct inode *rootdir; /* pointer to inode of root directory */
|
||||
extern struct inode inode[]; /* the inode table itself */
|
||||
struct inode *rootdir; /* pointer to inode of root directory */
|
||||
|
||||
/*
|
||||
* Initialize hash links for inodes and build inode free list.
|
||||
@@ -198,7 +198,7 @@ struct inode *namei (struct nameidata *ndp);
|
||||
|
||||
enum uio_rw;
|
||||
int rdwri (enum uio_rw rw, struct inode *ip, caddr_t base, int len,
|
||||
off_t offset, int ioflg, int *aresid);
|
||||
off_t offset, int ioflg, int *aresid);
|
||||
|
||||
struct uio;
|
||||
int rwip (struct inode *ip, struct uio *uio, int ioflag);
|
||||
@@ -239,7 +239,7 @@ void itrunc (struct inode *oip, u_long length, int ioflags);
|
||||
*/
|
||||
struct timeval;
|
||||
void iupdat (struct inode *ip, struct timeval *ta, struct timeval *tm,
|
||||
int waitfor);
|
||||
int waitfor);
|
||||
|
||||
void irele (struct inode *ip);
|
||||
|
||||
@@ -303,52 +303,52 @@ void nchinval (dev_t dev);
|
||||
#endif /* KERNEL */
|
||||
|
||||
/* i_flag */
|
||||
#define ILOCKED 0x1 /* inode is locked */
|
||||
#define IUPD 0x2 /* file has been modified */
|
||||
#define IACC 0x4 /* inode access time to be updated */
|
||||
#define IMOUNT 0x8 /* inode is mounted on */
|
||||
#define IWANT 0x10 /* some process waiting on lock */
|
||||
#define ITEXT 0x20 /* inode is pure text prototype */
|
||||
#define ICHG 0x40 /* inode has been changed */
|
||||
#define ISHLOCK 0x80 /* file has shared lock */
|
||||
#define IEXLOCK 0x100 /* file has exclusive lock */
|
||||
#define ILWAIT 0x200 /* someone waiting on file lock */
|
||||
#define IMOD 0x400 /* inode has been modified */
|
||||
#define IRENAME 0x800 /* inode is being renamed */
|
||||
#define IPIPE 0x1000 /* inode is a pipe */
|
||||
#define IRCOLL 0x2000 /* read select collision on pipe */
|
||||
#define IWCOLL 0x4000 /* write select collision on pipe */
|
||||
#define IXMOD 0x8000 /* inode is text, but impure (XXX) */
|
||||
#define ILOCKED 0x1 /* inode is locked */
|
||||
#define IUPD 0x2 /* file has been modified */
|
||||
#define IACC 0x4 /* inode access time to be updated */
|
||||
#define IMOUNT 0x8 /* inode is mounted on */
|
||||
#define IWANT 0x10 /* some process waiting on lock */
|
||||
#define ITEXT 0x20 /* inode is pure text prototype */
|
||||
#define ICHG 0x40 /* inode has been changed */
|
||||
#define ISHLOCK 0x80 /* file has shared lock */
|
||||
#define IEXLOCK 0x100 /* file has exclusive lock */
|
||||
#define ILWAIT 0x200 /* someone waiting on file lock */
|
||||
#define IMOD 0x400 /* inode has been modified */
|
||||
#define IRENAME 0x800 /* inode is being renamed */
|
||||
#define IPIPE 0x1000 /* inode is a pipe */
|
||||
#define IRCOLL 0x2000 /* read select collision on pipe */
|
||||
#define IWCOLL 0x4000 /* write select collision on pipe */
|
||||
#define IXMOD 0x8000 /* inode is text, but impure (XXX) */
|
||||
|
||||
/* i_mode */
|
||||
#define IFMT 0170000 /* type of file */
|
||||
#define IFCHR 0020000 /* character special */
|
||||
#define IFDIR 0040000 /* directory */
|
||||
#define IFBLK 0060000 /* block special */
|
||||
#define IFREG 0100000 /* regular */
|
||||
#define IFLNK 0120000 /* symbolic link */
|
||||
#define IFSOCK 0140000 /* socket */
|
||||
#define ISUID 04000 /* set user id on execution */
|
||||
#define ISGID 02000 /* set group id on execution */
|
||||
#define ISVTX 01000 /* save swapped text even after use */
|
||||
#define IREAD 0400 /* read, write, execute permissions */
|
||||
#define IWRITE 0200
|
||||
#define IEXEC 0100
|
||||
#define IFMT 0170000 /* type of file */
|
||||
#define IFCHR 0020000 /* character special */
|
||||
#define IFDIR 0040000 /* directory */
|
||||
#define IFBLK 0060000 /* block special */
|
||||
#define IFREG 0100000 /* regular */
|
||||
#define IFLNK 0120000 /* symbolic link */
|
||||
#define IFSOCK 0140000 /* socket */
|
||||
#define ISUID 04000 /* set user id on execution */
|
||||
#define ISGID 02000 /* set group id on execution */
|
||||
#define ISVTX 01000 /* save swapped text even after use */
|
||||
#define IREAD 0400 /* read, write, execute permissions */
|
||||
#define IWRITE 0200
|
||||
#define IEXEC 0100
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
* Flags for va_cflags.
|
||||
*/
|
||||
#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */
|
||||
#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */
|
||||
|
||||
/*
|
||||
* Flags for ioflag.
|
||||
*/
|
||||
#define IO_UNIT 0x01 /* do I/O as atomic unit */
|
||||
#define IO_APPEND 0x02 /* append write to end */
|
||||
#define IO_SYNC 0x04 /* do I/O synchronously */
|
||||
/*#define IO_NODELOCKED 0x08 not implemented */
|
||||
#define IO_NDELAY 0x10 /* FNDELAY flag set in file table */
|
||||
#define IO_UNIT 0x01 /* do I/O as atomic unit */
|
||||
#define IO_APPEND 0x02 /* append write to end */
|
||||
#define IO_SYNC 0x04 /* do I/O synchronously */
|
||||
/*#define IO_NODELOCKED 0x08 not implemented */
|
||||
#define IO_NDELAY 0x10 /* FNDELAY flag set in file table */
|
||||
|
||||
|
||||
/*
|
||||
@@ -361,33 +361,33 @@ void nchinval (dev_t dev);
|
||||
* do not have vnodes why initialize (and carry around) un-used members.
|
||||
*/
|
||||
struct vattr {
|
||||
mode_t va_mode;
|
||||
uid_t va_uid;
|
||||
gid_t va_gid;
|
||||
off_t va_size;
|
||||
time_t va_atime;
|
||||
time_t va_mtime;
|
||||
u_int va_flags;
|
||||
u_int va_vaflags;
|
||||
mode_t va_mode;
|
||||
uid_t va_uid;
|
||||
gid_t va_gid;
|
||||
off_t va_size;
|
||||
time_t va_atime;
|
||||
time_t va_mtime;
|
||||
u_int va_flags;
|
||||
u_int va_vaflags;
|
||||
};
|
||||
|
||||
/*
|
||||
* Token indicating no attribute value yet assigned.
|
||||
*/
|
||||
#define VNOVAL (-1)
|
||||
#define VNOVAL (-1)
|
||||
|
||||
/*
|
||||
* Initialize a inode attribute structure.
|
||||
*/
|
||||
#define VATTR_NULL(vp) { \
|
||||
(vp)->va_mode = VNOVAL; \
|
||||
(vp)->va_uid = VNOVAL; \
|
||||
(vp)->va_gid = VNOVAL; \
|
||||
(vp)->va_size = VNOVAL; \
|
||||
(vp)->va_atime = VNOVAL; \
|
||||
(vp)->va_mtime = VNOVAL; \
|
||||
(vp)->va_flags = VNOVAL; \
|
||||
(vp)->va_vaflags = VNOVAL; }
|
||||
#define VATTR_NULL(vp) { \
|
||||
(vp)->va_mode = VNOVAL; \
|
||||
(vp)->va_uid = VNOVAL; \
|
||||
(vp)->va_gid = VNOVAL; \
|
||||
(vp)->va_size = VNOVAL; \
|
||||
(vp)->va_atime = VNOVAL; \
|
||||
(vp)->va_mtime = VNOVAL; \
|
||||
(vp)->va_flags = VNOVAL; \
|
||||
(vp)->va_vaflags = VNOVAL; }
|
||||
|
||||
/*
|
||||
* N.B: If the above structure changes be sure to modify the function
|
||||
@@ -395,36 +395,36 @@ struct vattr {
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define ILOCK(ip) { \
|
||||
while ((ip)->i_flag & ILOCKED) { \
|
||||
(ip)->i_flag |= IWANT; \
|
||||
sleep((caddr_t)(ip), PINOD); \
|
||||
} \
|
||||
(ip)->i_flag |= ILOCKED; \
|
||||
#define ILOCK(ip) { \
|
||||
while ((ip)->i_flag & ILOCKED) { \
|
||||
(ip)->i_flag |= IWANT; \
|
||||
sleep((caddr_t)(ip), PINOD); \
|
||||
} \
|
||||
(ip)->i_flag |= ILOCKED; \
|
||||
}
|
||||
|
||||
#define IUNLOCK(ip) { \
|
||||
(ip)->i_flag &= ~ILOCKED; \
|
||||
if ((ip)->i_flag&IWANT) { \
|
||||
(ip)->i_flag &= ~IWANT; \
|
||||
wakeup((caddr_t)(ip)); \
|
||||
} \
|
||||
#define IUNLOCK(ip) { \
|
||||
(ip)->i_flag &= ~ILOCKED; \
|
||||
if ((ip)->i_flag&IWANT) { \
|
||||
(ip)->i_flag &= ~IWANT; \
|
||||
wakeup((caddr_t)(ip)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define IUPDAT(ip, t1, t2, waitfor) { \
|
||||
if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
|
||||
iupdat(ip, t1, t2, waitfor); \
|
||||
#define IUPDAT(ip, t1, t2, waitfor) { \
|
||||
if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
|
||||
iupdat(ip, t1, t2, waitfor); \
|
||||
}
|
||||
|
||||
#define ITIMES(ip, t1, t2) { \
|
||||
if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
|
||||
(ip)->i_flag |= IMOD; \
|
||||
if ((ip)->i_flag&IACC) \
|
||||
(ip)->i_atime = (t1)->tv_sec; \
|
||||
if ((ip)->i_flag&IUPD) \
|
||||
(ip)->i_mtime = (t2)->tv_sec; \
|
||||
if ((ip)->i_flag&ICHG) \
|
||||
(ip)->i_ctime = time.tv_sec; \
|
||||
(ip)->i_flag &= ~(IACC|IUPD|ICHG); \
|
||||
} \
|
||||
#define ITIMES(ip, t1, t2) { \
|
||||
if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
|
||||
(ip)->i_flag |= IMOD; \
|
||||
if ((ip)->i_flag&IACC) \
|
||||
(ip)->i_atime = (t1)->tv_sec; \
|
||||
if ((ip)->i_flag&IUPD) \
|
||||
(ip)->i_mtime = (t2)->tv_sec; \
|
||||
if ((ip)->i_flag&ICHG) \
|
||||
(ip)->i_ctime = time.tv_sec; \
|
||||
(ip)->i_flag &= ~(IACC|IUPD|ICHG); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)ioctl.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
* @(#)ioctl.h 1.4 (2.11BSD GTE) 1997/3/28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ioctl definitions
|
||||
*/
|
||||
#ifndef _IOCTL_
|
||||
#ifndef _IOCTL_
|
||||
#define _IOCTL_
|
||||
#ifdef KERNEL
|
||||
#include "ttychars.h"
|
||||
@@ -23,20 +23,20 @@ int ioctl (int d, int request, ...);
|
||||
#endif
|
||||
|
||||
struct tchars {
|
||||
char t_intrc; /* interrupt */
|
||||
char t_quitc; /* quit */
|
||||
char t_startc; /* start output */
|
||||
char t_stopc; /* stop output */
|
||||
char t_eofc; /* end-of-file */
|
||||
char t_brkc; /* input delimiter (like nl) */
|
||||
char t_intrc; /* interrupt */
|
||||
char t_quitc; /* quit */
|
||||
char t_startc; /* start output */
|
||||
char t_stopc; /* stop output */
|
||||
char t_eofc; /* end-of-file */
|
||||
char t_brkc; /* input delimiter (like nl) */
|
||||
};
|
||||
struct ltchars {
|
||||
char t_suspc; /* stop process signal */
|
||||
char t_dsuspc; /* delayed stop process signal */
|
||||
char t_rprntc; /* reprint line */
|
||||
char t_flushc; /* flush output (toggles) */
|
||||
char t_werasc; /* word erase */
|
||||
char t_lnextc; /* literal next character */
|
||||
char t_suspc; /* stop process signal */
|
||||
char t_dsuspc; /* delayed stop process signal */
|
||||
char t_rprntc; /* reprint line */
|
||||
char t_flushc; /* flush output (toggles) */
|
||||
char t_werasc; /* word erase */
|
||||
char t_lnextc; /* literal next character */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -46,11 +46,11 @@ struct ltchars {
|
||||
#ifndef _SGTTYB_
|
||||
#define _SGTTYB_
|
||||
struct sgttyb {
|
||||
char sg_ispeed; /* input speed */
|
||||
char sg_ospeed; /* output speed */
|
||||
char sg_erase; /* erase character */
|
||||
char sg_kill; /* kill character */
|
||||
short sg_flags; /* mode flags */
|
||||
char sg_ispeed; /* input speed */
|
||||
char sg_ospeed; /* output speed */
|
||||
char sg_erase; /* erase character */
|
||||
char sg_kill; /* kill character */
|
||||
short sg_flags; /* mode flags */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -63,23 +63,23 @@ struct sgttyb {
|
||||
* Type must be "unsigned short" so that types.h not required.
|
||||
*/
|
||||
struct winsize {
|
||||
unsigned short ws_row; /* rows, in characters */
|
||||
unsigned short ws_col; /* columns, in characters */
|
||||
unsigned short ws_xpixel; /* horizontal size, pixels */
|
||||
unsigned short ws_ypixel; /* vertical size, pixels */
|
||||
unsigned short ws_row; /* rows, in characters */
|
||||
unsigned short ws_col; /* columns, in characters */
|
||||
unsigned short ws_xpixel; /* horizontal size, pixels */
|
||||
unsigned short ws_ypixel; /* vertical size, pixels */
|
||||
};
|
||||
|
||||
/*
|
||||
* Pun for SUN.
|
||||
*/
|
||||
struct ttysize {
|
||||
unsigned short ts_lines;
|
||||
unsigned short ts_cols;
|
||||
unsigned short ts_xxx;
|
||||
unsigned short ts_yyy;
|
||||
unsigned short ts_lines;
|
||||
unsigned short ts_cols;
|
||||
unsigned short ts_xxx;
|
||||
unsigned short ts_yyy;
|
||||
};
|
||||
#define TIOCGSIZE TIOCGWINSZ
|
||||
#define TIOCSSIZE TIOCSWINSZ
|
||||
#define TIOCGSIZE TIOCGWINSZ
|
||||
#define TIOCSSIZE TIOCSWINSZ
|
||||
|
||||
#ifndef _IO
|
||||
/*
|
||||
@@ -89,171 +89,171 @@ struct ttysize {
|
||||
* to encode the in/out status of the parameter; for now
|
||||
* we restrict parameters to at most 256 bytes (disklabels are 216 bytes).
|
||||
*/
|
||||
#define IOCPARM_MASK 0xff /* parameters must be < 256 bytes */
|
||||
#define IOC_VOID 0x20000000 /* no parameters */
|
||||
#define IOC_OUT 0x40000000 /* copy out parameters */
|
||||
#define IOC_IN 0x80000000 /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
#define IOCPARM_MASK 0xff /* parameters must be < 256 bytes */
|
||||
#define IOC_VOID 0x20000000 /* no parameters */
|
||||
#define IOC_OUT 0x40000000 /* copy out parameters */
|
||||
#define IOC_IN 0x80000000 /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
|
||||
#define _IO(x,y) (IOC_VOID | ((x)<<8)|y)
|
||||
#define _IOR(x,y,t) (IOC_OUT |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _IOW(x,y,t) (IOC_IN |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _IO(x,y) (IOC_VOID | ((x)<<8)|y)
|
||||
#define _IOR(x,y,t) (IOC_OUT |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _IOW(x,y,t) (IOC_IN |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
/* this should be _IORW, but stdio got there first */
|
||||
#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _ION(x,y,n) (IOC_INOUT| (((n)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#define _ION(x,y,n) (IOC_INOUT| (((n)&IOCPARM_MASK)<<16)|((x)<<8)|y)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* tty ioctl commands
|
||||
*/
|
||||
#define TIOCGETD _IOR('t', 0, int) /* get line discipline */
|
||||
#define TIOCSETD _IOW('t', 1, int) /* set line discipline */
|
||||
#define TIOCHPCL _IO ('t', 2) /* hang up on last close */
|
||||
#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
|
||||
#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
|
||||
#define TIOCM_LE 0001 /* line enable */
|
||||
#define TIOCM_DTR 0002 /* data terminal ready */
|
||||
#define TIOCM_RTS 0004 /* request to send */
|
||||
#define TIOCM_ST 0010 /* secondary transmit */
|
||||
#define TIOCM_SR 0020 /* secondary receive */
|
||||
#define TIOCM_CTS 0040 /* clear to send */
|
||||
#define TIOCM_CAR 0100 /* carrier detect */
|
||||
#define TIOCM_CD TIOCM_CAR
|
||||
#define TIOCM_RNG 0200 /* ring */
|
||||
#define TIOCM_RI TIOCM_RNG
|
||||
#define TIOCM_DSR 0400 /* data set ready */
|
||||
#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
|
||||
#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
|
||||
#define TIOCSETN _IOW('t', 10,struct sgttyb)/* as above, but no flushtty */
|
||||
#define TIOCEXCL _IO ('t', 13) /* set exclusive use of tty */
|
||||
#define TIOCNXCL _IO ('t', 14) /* reset exclusive use of tty */
|
||||
#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
|
||||
#define TIOCSETC _IOW('t', 17,struct tchars)/* set special characters */
|
||||
#define TIOCGETC _IOR('t', 18,struct tchars)/* get special characters */
|
||||
#define TANDEM 0x00000001 /* send stopc on out q full */
|
||||
#define CBREAK 0x00000002 /* half-cooked mode */
|
||||
/* 0x4 (old LCASE) */
|
||||
#define ECHO 0x00000008 /* echo input */
|
||||
#define CRMOD 0x00000010 /* map \r to \r\n on output */
|
||||
#define RAW 0x00000020 /* no i/o processing */
|
||||
#define ODDP 0x00000040 /* get/send odd parity */
|
||||
#define EVENP 0x00000080 /* get/send even parity */
|
||||
#define ANYP 0x000000c0 /* get any parity/send none */
|
||||
/* 0x100 (old NLDELAY) */
|
||||
/* 0x200 */
|
||||
#define XTABS 0x00000400 /* expand tabs on output */
|
||||
/* 0x0800 (part of old XTABS) */
|
||||
/* 0x1000 (old CRDELAY) */
|
||||
/* 0x2000 */
|
||||
/* 0x4000 (old VTDELAY) */
|
||||
/* 0x8000 (old BSDELAY) */
|
||||
#define CRTBS 0x00010000 /* do backspacing for crt */
|
||||
#define PRTERA 0x00020000 /* \ ... / erase */
|
||||
#define CRTERA 0x00040000 /* " \b " to wipe out char */
|
||||
/* 0x00080000 (old TILDE) */
|
||||
#define MDMBUF 0x00100000 /* start/stop output on carrier intr */
|
||||
#define LITOUT 0x00200000 /* literal output */
|
||||
#define TOSTOP 0x00400000 /* SIGSTOP on background output */
|
||||
#define FLUSHO 0x00800000 /* flush output to terminal */
|
||||
#define NOHANG 0x01000000 /* no SIGHUP on carrier drop */
|
||||
#define RTSCTS 0x02000000 /* use RTS/CTS flow control */
|
||||
#define CRTKIL 0x04000000 /* kill line with " \b " */
|
||||
#define PASS8 0x08000000
|
||||
#define CTLECH 0x10000000 /* echo control chars as ^X */
|
||||
#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
|
||||
#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
|
||||
#define NOFLSH 0x80000000 /* no output flush on signal */
|
||||
#define TIOCGETD _IOR('t', 0, int) /* get line discipline */
|
||||
#define TIOCSETD _IOW('t', 1, int) /* set line discipline */
|
||||
#define TIOCHPCL _IO ('t', 2) /* hang up on last close */
|
||||
#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
|
||||
#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
|
||||
#define TIOCM_LE 0001 /* line enable */
|
||||
#define TIOCM_DTR 0002 /* data terminal ready */
|
||||
#define TIOCM_RTS 0004 /* request to send */
|
||||
#define TIOCM_ST 0010 /* secondary transmit */
|
||||
#define TIOCM_SR 0020 /* secondary receive */
|
||||
#define TIOCM_CTS 0040 /* clear to send */
|
||||
#define TIOCM_CAR 0100 /* carrier detect */
|
||||
#define TIOCM_CD TIOCM_CAR
|
||||
#define TIOCM_RNG 0200 /* ring */
|
||||
#define TIOCM_RI TIOCM_RNG
|
||||
#define TIOCM_DSR 0400 /* data set ready */
|
||||
#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
|
||||
#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
|
||||
#define TIOCSETN _IOW('t', 10,struct sgttyb)/* as above, but no flushtty */
|
||||
#define TIOCEXCL _IO ('t', 13) /* set exclusive use of tty */
|
||||
#define TIOCNXCL _IO ('t', 14) /* reset exclusive use of tty */
|
||||
#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
|
||||
#define TIOCSETC _IOW('t', 17,struct tchars)/* set special characters */
|
||||
#define TIOCGETC _IOR('t', 18,struct tchars)/* get special characters */
|
||||
#define TANDEM 0x00000001 /* send stopc on out q full */
|
||||
#define CBREAK 0x00000002 /* half-cooked mode */
|
||||
/* 0x4 (old LCASE) */
|
||||
#define ECHO 0x00000008 /* echo input */
|
||||
#define CRMOD 0x00000010 /* map \r to \r\n on output */
|
||||
#define RAW 0x00000020 /* no i/o processing */
|
||||
#define ODDP 0x00000040 /* get/send odd parity */
|
||||
#define EVENP 0x00000080 /* get/send even parity */
|
||||
#define ANYP 0x000000c0 /* get any parity/send none */
|
||||
/* 0x100 (old NLDELAY) */
|
||||
/* 0x200 */
|
||||
#define XTABS 0x00000400 /* expand tabs on output */
|
||||
/* 0x0800 (part of old XTABS) */
|
||||
/* 0x1000 (old CRDELAY) */
|
||||
/* 0x2000 */
|
||||
/* 0x4000 (old VTDELAY) */
|
||||
/* 0x8000 (old BSDELAY) */
|
||||
#define CRTBS 0x00010000 /* do backspacing for crt */
|
||||
#define PRTERA 0x00020000 /* \ ... / erase */
|
||||
#define CRTERA 0x00040000 /* " \b " to wipe out char */
|
||||
/* 0x00080000 (old TILDE) */
|
||||
#define MDMBUF 0x00100000 /* start/stop output on carrier intr */
|
||||
#define LITOUT 0x00200000 /* literal output */
|
||||
#define TOSTOP 0x00400000 /* SIGSTOP on background output */
|
||||
#define FLUSHO 0x00800000 /* flush output to terminal */
|
||||
#define NOHANG 0x01000000 /* no SIGHUP on carrier drop */
|
||||
#define RTSCTS 0x02000000 /* use RTS/CTS flow control */
|
||||
#define CRTKIL 0x04000000 /* kill line with " \b " */
|
||||
#define PASS8 0x08000000
|
||||
#define CTLECH 0x10000000 /* echo control chars as ^X */
|
||||
#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
|
||||
#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
|
||||
#define NOFLSH 0x80000000 /* no output flush on signal */
|
||||
/* locals, from 127 down */
|
||||
#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
|
||||
#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
|
||||
#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
|
||||
#define TIOCLGET _IOR('t', 124, int) /* get local modes */
|
||||
#define LCRTBS ((int)(CRTBS>>16))
|
||||
#define LPRTERA ((int)(PRTERA>>16))
|
||||
#define LCRTERA ((int)(CRTERA>>16))
|
||||
#define LMDMBUF ((int)(MDMBUF>>16))
|
||||
#define LLITOUT ((int)(LITOUT>>16))
|
||||
#define LTOSTOP ((int)(TOSTOP>>16))
|
||||
#define LFLUSHO ((int)(FLUSHO>>16))
|
||||
#define LNOHANG ((int)(NOHANG>>16))
|
||||
#define LRTSCTS ((int)(RTSCTS>>16))
|
||||
#define LCRTKIL ((int)(CRTKIL>>16))
|
||||
#define LPASS8 ((int)(PASS8>>16))
|
||||
#define LCTLECH ((int)(CTLECH>>16))
|
||||
#define LPENDIN ((int)(PENDIN>>16))
|
||||
#define LDECCTQ ((int)(DECCTQ>>16))
|
||||
#define LNOFLSH ((int)(NOFLSH>>16))
|
||||
#define TIOCSBRK _IO ('t', 123) /* set break bit */
|
||||
#define TIOCCBRK _IO ('t', 122) /* clear break bit */
|
||||
#define TIOCSDTR _IO ('t', 121) /* set data terminal ready */
|
||||
#define TIOCCDTR _IO ('t', 120) /* clear data terminal ready */
|
||||
#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
|
||||
#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
|
||||
#define TIOCSLTC _IOW('t', 117,struct ltchars)/* set local special chars */
|
||||
#define TIOCGLTC _IOR('t', 116,struct ltchars)/* get local special chars */
|
||||
#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
|
||||
#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
|
||||
#define TIOCNOTTY _IO ('t', 113) /* void tty association */
|
||||
#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
|
||||
#define TIOCPKT_DATA 0x00 /* data packet */
|
||||
#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
|
||||
#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
|
||||
#define TIOCPKT_STOP 0x04 /* stop output */
|
||||
#define TIOCPKT_START 0x08 /* start output */
|
||||
#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
|
||||
#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
|
||||
#define TIOCSTOP _IO ('t', 111) /* stop output, like ^S */
|
||||
#define TIOCSTART _IO ('t', 110) /* start output, like ^Q */
|
||||
#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
|
||||
#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
|
||||
#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
|
||||
#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
|
||||
#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
|
||||
#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
|
||||
#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
|
||||
#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
|
||||
#define UIOCCMD(n) _IO ('u', n) /* usr cntl op "n" */
|
||||
#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
|
||||
#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
|
||||
#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
|
||||
#define TIOCLGET _IOR('t', 124, int) /* get local modes */
|
||||
#define LCRTBS ((int)(CRTBS>>16))
|
||||
#define LPRTERA ((int)(PRTERA>>16))
|
||||
#define LCRTERA ((int)(CRTERA>>16))
|
||||
#define LMDMBUF ((int)(MDMBUF>>16))
|
||||
#define LLITOUT ((int)(LITOUT>>16))
|
||||
#define LTOSTOP ((int)(TOSTOP>>16))
|
||||
#define LFLUSHO ((int)(FLUSHO>>16))
|
||||
#define LNOHANG ((int)(NOHANG>>16))
|
||||
#define LRTSCTS ((int)(RTSCTS>>16))
|
||||
#define LCRTKIL ((int)(CRTKIL>>16))
|
||||
#define LPASS8 ((int)(PASS8>>16))
|
||||
#define LCTLECH ((int)(CTLECH>>16))
|
||||
#define LPENDIN ((int)(PENDIN>>16))
|
||||
#define LDECCTQ ((int)(DECCTQ>>16))
|
||||
#define LNOFLSH ((int)(NOFLSH>>16))
|
||||
#define TIOCSBRK _IO ('t', 123) /* set break bit */
|
||||
#define TIOCCBRK _IO ('t', 122) /* clear break bit */
|
||||
#define TIOCSDTR _IO ('t', 121) /* set data terminal ready */
|
||||
#define TIOCCDTR _IO ('t', 120) /* clear data terminal ready */
|
||||
#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
|
||||
#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
|
||||
#define TIOCSLTC _IOW('t', 117,struct ltchars)/* set local special chars */
|
||||
#define TIOCGLTC _IOR('t', 116,struct ltchars)/* get local special chars */
|
||||
#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
|
||||
#define TIOCSTI _IOW('t', 114, char)/* simulate terminal input */
|
||||
#define TIOCNOTTY _IO ('t', 113) /* void tty association */
|
||||
#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
|
||||
#define TIOCPKT_DATA 0x00 /* data packet */
|
||||
#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
|
||||
#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
|
||||
#define TIOCPKT_STOP 0x04 /* stop output */
|
||||
#define TIOCPKT_START 0x08 /* start output */
|
||||
#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
|
||||
#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
|
||||
#define TIOCSTOP _IO ('t', 111) /* stop output, like ^S */
|
||||
#define TIOCSTART _IO ('t', 110) /* start output, like ^Q */
|
||||
#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
|
||||
#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
|
||||
#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
|
||||
#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
|
||||
#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
|
||||
#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
|
||||
#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
|
||||
#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
|
||||
#define UIOCCMD(n) _IO ('u', n) /* usr cntl op "n" */
|
||||
|
||||
#define NTTYDISC 0 /* new tty discipline */
|
||||
#define NTTYDISC 0 /* new tty discipline */
|
||||
|
||||
#define FIOCLEX _IO('f', 1) /* set exclusive use on fd */
|
||||
#define FIONCLEX _IO('f', 2) /* remove exclusive use */
|
||||
#define FIOCLEX _IO('f', 1) /* set exclusive use on fd */
|
||||
#define FIONCLEX _IO('f', 2) /* remove exclusive use */
|
||||
/* another local */
|
||||
/* should use off_t for FIONREAD but that would require types.h */
|
||||
#define FIONREAD _IOR('f', 97, long) /* get # bytes to read */
|
||||
#define FIONBIO _IOW('f', 96, int) /* set/clear non-blocking i/o */
|
||||
#define FIOASYNC _IOW('f', 95, int) /* set/clear async i/o */
|
||||
#define FIOSETOWN _IOW('f', 94, int) /* set owner */
|
||||
#define FIOGETOWN _IOR('f', 93, int) /* get owner */
|
||||
#define FIONREAD _IOR('f', 97, long) /* get # bytes to read */
|
||||
#define FIONBIO _IOW('f', 96, int) /* set/clear non-blocking i/o */
|
||||
#define FIOASYNC _IOW('f', 95, int) /* set/clear async i/o */
|
||||
#define FIOSETOWN _IOW('f', 94, int) /* set owner */
|
||||
#define FIOGETOWN _IOR('f', 93, int) /* get owner */
|
||||
|
||||
/* socket i/o controls */
|
||||
#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
|
||||
#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
|
||||
#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
|
||||
#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
|
||||
#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
|
||||
#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
|
||||
#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
|
||||
#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
|
||||
#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
|
||||
#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
|
||||
#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
|
||||
#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
|
||||
#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
|
||||
#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
|
||||
|
||||
#define SIOCADDRT _IOW('r', 10, struct rtentry) /* add route */
|
||||
#define SIOCDELRT _IOW('r', 11, struct rtentry) /* delete route */
|
||||
#define SIOCADDRT _IOW('r', 10, struct rtentry) /* add route */
|
||||
#define SIOCDELRT _IOW('r', 11, struct rtentry) /* delete route */
|
||||
|
||||
#define SIOCSIFADDR _IOW ('i',12, struct ifreq) /* set ifnet address */
|
||||
#define SIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
|
||||
#define SIOCSIFDSTADDR _IOW ('i',14, struct ifreq) /* set p-p address */
|
||||
#define SIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
|
||||
#define SIOCSIFFLAGS _IOW ('i',16, struct ifreq) /* set ifnet flags */
|
||||
#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */
|
||||
#define SIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
|
||||
#define SIOCSIFBRDADDR _IOW ('i',19, struct ifreq) /* set broadcast addr */
|
||||
#define SIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
|
||||
#define SIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
|
||||
#define SIOCSIFNETMASK _IOW ('i',22, struct ifreq) /* set net addr mask */
|
||||
#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */
|
||||
#define SIOCSIFMETRIC _IOW ('i',24, struct ifreq) /* set IF metric */
|
||||
#define SIOCSIFADDR _IOW ('i',12, struct ifreq) /* set ifnet address */
|
||||
#define SIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
|
||||
#define SIOCSIFDSTADDR _IOW ('i',14, struct ifreq) /* set p-p address */
|
||||
#define SIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
|
||||
#define SIOCSIFFLAGS _IOW ('i',16, struct ifreq) /* set ifnet flags */
|
||||
#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */
|
||||
#define SIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
|
||||
#define SIOCSIFBRDADDR _IOW ('i',19, struct ifreq) /* set broadcast addr */
|
||||
#define SIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
|
||||
#define SIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
|
||||
#define SIOCSIFNETMASK _IOW ('i',22, struct ifreq) /* set net addr mask */
|
||||
#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */
|
||||
#define SIOCSIFMETRIC _IOW ('i',24, struct ifreq) /* set IF metric */
|
||||
|
||||
#define SIOCSARP _IOW ('i',30, struct arpreq) /* set arp entry */
|
||||
#define SIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
|
||||
#define SIOCDARP _IOW ('i',32, struct arpreq) /* delete arp entry */
|
||||
#define SIOCSARP _IOW ('i',30, struct arpreq) /* set arp entry */
|
||||
#define SIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
|
||||
#define SIOCDARP _IOW ('i',32, struct arpreq) /* delete arp entry */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
*/
|
||||
|
||||
/* 1.1 */
|
||||
long hostid;
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
int hostnamelen;
|
||||
long hostid;
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
int hostnamelen;
|
||||
|
||||
/* 1.2 */
|
||||
#include <sys/time.h>
|
||||
|
||||
struct timeval boottime;
|
||||
struct timeval time;
|
||||
struct timezone tz; /* XXX */
|
||||
int adjdelta;
|
||||
int hz;
|
||||
int usechz; /* # microseconds per hz */
|
||||
int lbolt; /* awoken once a second */
|
||||
struct timeval boottime;
|
||||
struct timeval time;
|
||||
struct timezone tz; /* XXX */
|
||||
int adjdelta;
|
||||
int hz;
|
||||
int usechz; /* # microseconds per hz */
|
||||
int lbolt; /* awoken once a second */
|
||||
|
||||
short avenrun[3];
|
||||
short avenrun[3];
|
||||
|
||||
@@ -21,19 +21,19 @@
|
||||
* as it is used internally by the resource map routines.
|
||||
*/
|
||||
struct map {
|
||||
struct mapent *m_map; /* start of the map */
|
||||
struct mapent *m_limit; /* address of last slot in map */
|
||||
char *m_name; /* name of resource */
|
||||
struct mapent *m_map; /* start of the map */
|
||||
struct mapent *m_limit; /* address of last slot in map */
|
||||
char *m_name; /* name of resource */
|
||||
/* we use m_name when the map overflows, in warning messages */
|
||||
};
|
||||
|
||||
struct mapent {
|
||||
size_t m_size; /* size of this segment of the map */
|
||||
size_t m_addr; /* resource-space addr of start of segment */
|
||||
size_t m_size; /* size of this segment of the map */
|
||||
size_t m_addr; /* resource-space addr of start of segment */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct map swapmap[]; /* space for swap allocation */
|
||||
extern struct map swapmap[]; /* space for swap allocation */
|
||||
|
||||
/*
|
||||
* Allocate units from the given map.
|
||||
|
||||
@@ -9,36 +9,36 @@
|
||||
*/
|
||||
#include <sys/fs.h>
|
||||
|
||||
#define MNAMELEN 90 /* length of buffer for returned name */
|
||||
#define MNAMELEN 90 /* length of buffer for returned name */
|
||||
|
||||
struct statfs {
|
||||
short f_type; /* type of filesystem (see below) */
|
||||
u_short f_flags; /* copy of mount flags */
|
||||
short f_bsize; /* fundamental file system block size */
|
||||
short f_iosize; /* optimal transfer block size */
|
||||
daddr_t f_blocks; /* total data blocks in file system */
|
||||
daddr_t f_bfree; /* free blocks in fs */
|
||||
daddr_t f_bavail; /* free blocks avail to non-superuser */
|
||||
ino_t f_files; /* total file nodes in file system */
|
||||
ino_t f_ffree; /* free file nodes in fs */
|
||||
long f_fsid[2]; /* file system id */
|
||||
long f_spare[5]; /* spare for later */
|
||||
char f_mntonname[MNAMELEN]; /* directory on which mounted */
|
||||
char f_mntfromname[MNAMELEN];/* mounted filesystem */
|
||||
short f_type; /* type of filesystem (see below) */
|
||||
u_short f_flags; /* copy of mount flags */
|
||||
short f_bsize; /* fundamental file system block size */
|
||||
short f_iosize; /* optimal transfer block size */
|
||||
daddr_t f_blocks; /* total data blocks in file system */
|
||||
daddr_t f_bfree; /* free blocks in fs */
|
||||
daddr_t f_bavail; /* free blocks avail to non-superuser */
|
||||
ino_t f_files; /* total file nodes in file system */
|
||||
ino_t f_ffree; /* free file nodes in fs */
|
||||
long f_fsid[2]; /* file system id */
|
||||
long f_spare[5]; /* spare for later */
|
||||
char f_mntonname[MNAMELEN]; /* directory on which mounted */
|
||||
char f_mntfromname[MNAMELEN];/* mounted filesystem */
|
||||
};
|
||||
|
||||
/*
|
||||
* File system types. Since only UFS is supported the others are not
|
||||
* specified at this time.
|
||||
*/
|
||||
#define MOUNT_NONE 0
|
||||
#define MOUNT_UFS 1 /* Fast Filesystem */
|
||||
#define MOUNT_MAXTYPE 1
|
||||
#define MOUNT_NONE 0
|
||||
#define MOUNT_UFS 1 /* Fast Filesystem */
|
||||
#define MOUNT_MAXTYPE 1
|
||||
|
||||
#define INITMOUNTNAMES { \
|
||||
"none", /* 0 MOUNT_NONE */ \
|
||||
"ufs", /* 1 MOUNT_UFS */ \
|
||||
0, \
|
||||
#define INITMOUNTNAMES { \
|
||||
"none", /* 0 MOUNT_NONE */ \
|
||||
"ufs", /* 1 MOUNT_UFS */ \
|
||||
0, \
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -46,40 +46,40 @@ struct statfs {
|
||||
* One allocated on every mount.
|
||||
* Used to find the super block.
|
||||
*/
|
||||
struct mount
|
||||
struct mount
|
||||
{
|
||||
dev_t m_dev; /* device mounted */
|
||||
struct fs m_filsys; /* superblock data */
|
||||
#define m_flags m_filsys.fs_flags
|
||||
struct inode *m_inodp; /* pointer to mounted on inode */
|
||||
struct inode *m_qinod; /* QUOTA: pointer to quota file */
|
||||
char m_mntfrom [MNAMELEN]; /* /dev/xxxx mounted from */
|
||||
char m_mnton [MNAMELEN]; /* directory mounted on - this is the
|
||||
* full(er) version of fs_fsmnt. */
|
||||
dev_t m_dev; /* device mounted */
|
||||
struct fs m_filsys; /* superblock data */
|
||||
#define m_flags m_filsys.fs_flags
|
||||
struct inode *m_inodp; /* pointer to mounted on inode */
|
||||
struct inode *m_qinod; /* QUOTA: pointer to quota file */
|
||||
char m_mntfrom [MNAMELEN]; /* /dev/xxxx mounted from */
|
||||
char m_mnton [MNAMELEN]; /* directory mounted on - this is the
|
||||
* full(er) version of fs_fsmnt. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Mount flags.
|
||||
*/
|
||||
#define MNT_RDONLY 0x0001 /* read only filesystem */
|
||||
#define MNT_SYNCHRONOUS 0x0002 /* file system written synchronously */
|
||||
#define MNT_NOEXEC 0x0004 /* can't exec from filesystem */
|
||||
#define MNT_NOSUID 0x0008 /* don't honor setuid bits on fs */
|
||||
#define MNT_NODEV 0x0010 /* don't interpret special files */
|
||||
#define MNT_QUOTA 0x0020 /* quotas are enabled on filesystem */
|
||||
#define MNT_ASYNC 0x0040 /* file system written asynchronously */
|
||||
#define MNT_NOATIME 0x0080 /* don't update access times */
|
||||
#define MNT_RDONLY 0x0001 /* read only filesystem */
|
||||
#define MNT_SYNCHRONOUS 0x0002 /* file system written synchronously */
|
||||
#define MNT_NOEXEC 0x0004 /* can't exec from filesystem */
|
||||
#define MNT_NOSUID 0x0008 /* don't honor setuid bits on fs */
|
||||
#define MNT_NODEV 0x0010 /* don't interpret special files */
|
||||
#define MNT_QUOTA 0x0020 /* quotas are enabled on filesystem */
|
||||
#define MNT_ASYNC 0x0040 /* file system written asynchronously */
|
||||
#define MNT_NOATIME 0x0080 /* don't update access times */
|
||||
|
||||
/*
|
||||
* Mask of flags that are visible to statfs().
|
||||
*/
|
||||
#define MNT_VISFLAGMASK 0x0fff
|
||||
#define MNT_VISFLAGMASK 0x0fff
|
||||
|
||||
/*
|
||||
* filesystem control flags. The high 4 bits are used for this. Since NFS
|
||||
* support will never be a problem we can avoid making the flags into a 'long.
|
||||
*/
|
||||
#define MNT_UPDATE 0x1000 /* not a real mount, just an update */
|
||||
#define MNT_UPDATE 0x1000 /* not a real mount, just an update */
|
||||
|
||||
/*
|
||||
* Flags for various system call interfaces.
|
||||
@@ -87,12 +87,12 @@ struct mount
|
||||
* These aren't used for anything in the system and are present only
|
||||
* for source code compatibility reasons.
|
||||
*/
|
||||
#define MNT_WAIT 1
|
||||
#define MNT_NOWAIT 2
|
||||
#define MNT_WAIT 1
|
||||
#define MNT_NOWAIT 2
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
struct mount mount[NMOUNT];
|
||||
struct mount mount[NMOUNT];
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#define MSG_MAGIC 0x063061
|
||||
#define MSG_BSIZE 2048
|
||||
#define MSG_MAGIC 0x063061
|
||||
#define MSG_BSIZE 2048
|
||||
|
||||
struct msgbuf {
|
||||
long msg_magic;
|
||||
int msg_bufx;
|
||||
int msg_bufr;
|
||||
char msg_bufc [MSG_BSIZE];
|
||||
struct msgbuf {
|
||||
long msg_magic;
|
||||
int msg_bufx;
|
||||
int msg_bufr;
|
||||
char msg_bufc [MSG_BSIZE];
|
||||
};
|
||||
|
||||
#define logMSG 0 /* /dev/klog */
|
||||
#define logMSG 0 /* /dev/klog */
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)mtio.h 7.1.2 (2.11BSD) 1998/3/7
|
||||
* @(#)mtio.h 7.1.2 (2.11BSD) 1998/3/7
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -11,36 +11,36 @@
|
||||
*/
|
||||
|
||||
/* structure for MTIOCTOP - mag tape op command */
|
||||
struct mtop {
|
||||
short mt_op; /* operations defined below */
|
||||
daddr_t mt_count; /* how many of them */
|
||||
struct mtop {
|
||||
short mt_op; /* operations defined below */
|
||||
daddr_t mt_count; /* how many of them */
|
||||
};
|
||||
|
||||
/* operations */
|
||||
#define MTWEOF 0 /* write an end-of-file record */
|
||||
#define MTFSF 1 /* forward space file */
|
||||
#define MTBSF 2 /* backward space file */
|
||||
#define MTFSR 3 /* forward space record */
|
||||
#define MTBSR 4 /* backward space record */
|
||||
#define MTREW 5 /* rewind */
|
||||
#define MTOFFL 6 /* rewind and put the drive offline */
|
||||
#define MTNOP 7 /* no operation, sets status only */
|
||||
#define MTCACHE 8 /* enable controller cache */
|
||||
#define MTNOCACHE 9 /* disable controller cache */
|
||||
#define MTFLUSH 10 /* flush cache */
|
||||
#define MTWEOF 0 /* write an end-of-file record */
|
||||
#define MTFSF 1 /* forward space file */
|
||||
#define MTBSF 2 /* backward space file */
|
||||
#define MTFSR 3 /* forward space record */
|
||||
#define MTBSR 4 /* backward space record */
|
||||
#define MTREW 5 /* rewind */
|
||||
#define MTOFFL 6 /* rewind and put the drive offline */
|
||||
#define MTNOP 7 /* no operation, sets status only */
|
||||
#define MTCACHE 8 /* enable controller cache */
|
||||
#define MTNOCACHE 9 /* disable controller cache */
|
||||
#define MTFLUSH 10 /* flush cache */
|
||||
|
||||
/* structure for MTIOCGET - mag tape get status command */
|
||||
|
||||
struct mtget {
|
||||
short mt_type; /* type of magtape device */
|
||||
struct mtget {
|
||||
short mt_type; /* type of magtape device */
|
||||
/* the following two registers are grossly device dependent */
|
||||
short mt_dsreg; /* ``drive status'' register */
|
||||
short mt_erreg; /* ``error'' register */
|
||||
short mt_dsreg; /* ``drive status'' register */
|
||||
short mt_erreg; /* ``error'' register */
|
||||
/* end device-dependent registers */
|
||||
short mt_resid; /* residual count */
|
||||
short mt_resid; /* residual count */
|
||||
/* the following two are not yet implemented */
|
||||
daddr_t mt_fileno; /* file number of current position */
|
||||
daddr_t mt_blkno; /* block number of current position */
|
||||
daddr_t mt_fileno; /* file number of current position */
|
||||
daddr_t mt_blkno; /* block number of current position */
|
||||
/* end not yet implemented */
|
||||
};
|
||||
|
||||
@@ -48,33 +48,33 @@ struct mtget {
|
||||
* Constants for mt_type byte. These are the same
|
||||
* for other controllers compatible with the types listed.
|
||||
*/
|
||||
#define MT_ISTS 0x01 /* TS-11 */
|
||||
#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */
|
||||
#define MT_ISTM 0x03 /* TM11/TE10 Unibus */
|
||||
#define MT_ISMT 0x04 /* TM78/TU78 Massbus */
|
||||
#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */
|
||||
#define MT_ISCPC 0x06 /* SUN */
|
||||
#define MT_ISAR 0x07 /* SUN */
|
||||
#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */
|
||||
#define MT_ISTS 0x01 /* TS-11 */
|
||||
#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */
|
||||
#define MT_ISTM 0x03 /* TM11/TE10 Unibus */
|
||||
#define MT_ISMT 0x04 /* TM78/TU78 Massbus */
|
||||
#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */
|
||||
#define MT_ISCPC 0x06 /* SUN */
|
||||
#define MT_ISAR 0x07 /* SUN */
|
||||
#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */
|
||||
|
||||
/*
|
||||
* At present only the TMSCP driver reports this information in the
|
||||
* high byte of the 'drive status' word. Other drives will (hopefully)
|
||||
* be updated in the future.
|
||||
*/
|
||||
#define MTF_BOM 0x01 /* At beginning of media */
|
||||
#define MTF_EOM 0x02 /* At the end of media */
|
||||
#define MTF_OFFLINE 0x04 /* Drive is offline */
|
||||
#define MTF_WRTLCK 0x08 /* Drive is write protected */
|
||||
#define MTF_WRITTEN 0x10 /* Tape has been written */
|
||||
#define MTF_BOM 0x01 /* At beginning of media */
|
||||
#define MTF_EOM 0x02 /* At the end of media */
|
||||
#define MTF_OFFLINE 0x04 /* Drive is offline */
|
||||
#define MTF_WRTLCK 0x08 /* Drive is write protected */
|
||||
#define MTF_WRITTEN 0x10 /* Tape has been written */
|
||||
|
||||
/* mag tape io control commands */
|
||||
#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */
|
||||
#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */
|
||||
#define MTIOCIEOT _IO ('m', 3) /* ignore EOT error */
|
||||
#define MTIOCEEOT _IO ('m', 4) /* enable EOT error */
|
||||
#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */
|
||||
#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */
|
||||
#define MTIOCIEOT _IO ('m', 3) /* ignore EOT error */
|
||||
#define MTIOCEEOT _IO ('m', 4) /* enable EOT error */
|
||||
|
||||
#ifndef KERNEL
|
||||
#define DEFTAPE "/dev/rmt8"
|
||||
#define MT_DEF "/dev/nrmt8"
|
||||
#define DEFTAPE "/dev/rmt8"
|
||||
#define MT_DEF "/dev/nrmt8"
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef _NAMEI_
|
||||
#define _NAMEI_
|
||||
#define _NAMEI_
|
||||
|
||||
#ifdef KERNEL
|
||||
#include "uio.h"
|
||||
@@ -18,54 +18,54 @@
|
||||
* minimize space allocated on the kernel stack.
|
||||
*/
|
||||
struct nameidata {
|
||||
caddr_t ni_dirp; /* pathname pointer */
|
||||
short ni_nameiop; /* see below */
|
||||
short ni_error; /* error return if any */
|
||||
off_t ni_endoff; /* end of useful stuff in directory */
|
||||
struct inode *ni_pdir; /* inode of parent directory of dirp */
|
||||
struct inode *ni_ip; /* inode of dirp */
|
||||
off_t ni_offset; /* offset in directory */
|
||||
u_short ni_count; /* offset of open slot (off_t?) */
|
||||
struct direct ni_dent; /* current directory entry */
|
||||
caddr_t ni_dirp; /* pathname pointer */
|
||||
short ni_nameiop; /* see below */
|
||||
short ni_error; /* error return if any */
|
||||
off_t ni_endoff; /* end of useful stuff in directory */
|
||||
struct inode *ni_pdir; /* inode of parent directory of dirp */
|
||||
struct inode *ni_ip; /* inode of dirp */
|
||||
off_t ni_offset; /* offset in directory */
|
||||
u_short ni_count; /* offset of open slot (off_t?) */
|
||||
struct direct ni_dent; /* current directory entry */
|
||||
};
|
||||
|
||||
/*
|
||||
* namei operations and modifiers
|
||||
*/
|
||||
#define LOOKUP 0 /* perform name lookup only */
|
||||
#define CREATE 1 /* setup for file creation */
|
||||
#define DELETE 2 /* setup for file deletion */
|
||||
#define LOCKPARENT 0x10 /* see the top of namei */
|
||||
#define NOCACHE 0x20 /* name must not be left in cache */
|
||||
#define FOLLOW 0x40 /* follow symbolic links */
|
||||
#define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */
|
||||
#define LOOKUP 0 /* perform name lookup only */
|
||||
#define CREATE 1 /* setup for file creation */
|
||||
#define DELETE 2 /* setup for file deletion */
|
||||
#define LOCKPARENT 0x10 /* see the top of namei */
|
||||
#define NOCACHE 0x20 /* name must not be left in cache */
|
||||
#define FOLLOW 0x40 /* follow symbolic links */
|
||||
#define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */
|
||||
|
||||
#define NDINIT(ndp,op,flags,namep) {\
|
||||
(ndp)->ni_nameiop = op | flags; \
|
||||
(ndp)->ni_dirp = namep; }
|
||||
#define NDINIT(ndp,op,flags,namep) {\
|
||||
(ndp)->ni_nameiop = op | flags; \
|
||||
(ndp)->ni_dirp = namep; }
|
||||
|
||||
/*
|
||||
* This structure describes the elements in the cache of recent
|
||||
* names looked up by namei.
|
||||
*/
|
||||
struct namecache {
|
||||
struct namecache *nc_forw; /* hash chain, MUST BE FIRST */
|
||||
struct namecache *nc_back; /* hash chain, MUST BE FIRST */
|
||||
struct namecache *nc_nxt; /* LRU chain */
|
||||
struct namecache **nc_prev; /* LRU chain */
|
||||
struct inode *nc_ip; /* inode the name refers to */
|
||||
ino_t nc_ino; /* ino of parent of name */
|
||||
dev_t nc_dev; /* dev of parent of name */
|
||||
dev_t nc_idev; /* dev of the name ref'd */
|
||||
u_short nc_id; /* referenced inode's id */
|
||||
char nc_nlen; /* length of name */
|
||||
#define NCHNAMLEN 15 /* maximum name segment length we bother with */
|
||||
char nc_name[NCHNAMLEN]; /* segment name */
|
||||
struct namecache {
|
||||
struct namecache *nc_forw; /* hash chain, MUST BE FIRST */
|
||||
struct namecache *nc_back; /* hash chain, MUST BE FIRST */
|
||||
struct namecache *nc_nxt; /* LRU chain */
|
||||
struct namecache **nc_prev; /* LRU chain */
|
||||
struct inode *nc_ip; /* inode the name refers to */
|
||||
ino_t nc_ino; /* ino of parent of name */
|
||||
dev_t nc_dev; /* dev of parent of name */
|
||||
dev_t nc_idev; /* dev of the name ref'd */
|
||||
u_short nc_id; /* referenced inode's id */
|
||||
char nc_nlen; /* length of name */
|
||||
#define NCHNAMLEN 15 /* maximum name segment length we bother with */
|
||||
char nc_name[NCHNAMLEN]; /* segment name */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct namecache namecache [];
|
||||
struct nchstats nchstats; /* cache effectiveness statistics */
|
||||
extern struct namecache namecache [];
|
||||
struct nchstats nchstats; /* cache effectiveness statistics */
|
||||
|
||||
/*
|
||||
* Name cache initialization.
|
||||
@@ -92,13 +92,13 @@ int dirremove (struct nameidata *ndp);
|
||||
/*
|
||||
* Stats on usefulness of namei caches.
|
||||
*/
|
||||
struct nchstats {
|
||||
long ncs_goodhits; /* hits that we can reall use */
|
||||
long ncs_badhits; /* hits we must drop */
|
||||
long ncs_falsehits; /* hits with id mismatch */
|
||||
long ncs_miss; /* misses */
|
||||
long ncs_long; /* long names that ignore cache */
|
||||
long ncs_pass2; /* names found with passes == 2 */
|
||||
long ncs_2passes; /* number of times we attempt it */
|
||||
struct nchstats {
|
||||
long ncs_goodhits; /* hits that we can reall use */
|
||||
long ncs_badhits; /* hits we must drop */
|
||||
long ncs_falsehits; /* hits with id mismatch */
|
||||
long ncs_miss; /* misses */
|
||||
long ncs_long; /* long names that ignore cache */
|
||||
long ncs_pass2; /* names found with passes == 2 */
|
||||
long ncs_2passes; /* number of times we attempt it */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#define BSD 211 /* 2.11 * 100, as cpp doesn't do floats */
|
||||
#define BSD 211 /* 2.11 * 100, as cpp doesn't do floats */
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
@@ -18,53 +18,53 @@
|
||||
* Machine-independent constants
|
||||
*/
|
||||
#ifndef NMOUNT
|
||||
#define NMOUNT 2 /* number of mountable file systems */
|
||||
#define NMOUNT 2 /* number of mountable file systems */
|
||||
#endif
|
||||
|
||||
#define MAXUPRC 20 /* max processes per user */
|
||||
#define NOFILE 30 /* max open files per process */
|
||||
#define NCARGS 5120 /* # characters in exec arglist */
|
||||
#define NGROUPS 16 /* max number groups */
|
||||
#define MAXUPRC 20 /* max processes per user */
|
||||
#define NOFILE 30 /* max open files per process */
|
||||
#define NCARGS 5120 /* # characters in exec arglist */
|
||||
#define NGROUPS 16 /* max number groups */
|
||||
|
||||
#define NOGROUP 65535 /* marker for empty group set member */
|
||||
#define NOGROUP 65535 /* marker for empty group set member */
|
||||
|
||||
/*
|
||||
* Priorities
|
||||
*/
|
||||
#define PSWP 0
|
||||
#define PINOD 10
|
||||
#define PRIBIO 20
|
||||
#define PRIUBA 24
|
||||
#define PZERO 25
|
||||
#define PPIPE 26
|
||||
#define PSOCK 26
|
||||
#define PWAIT 30
|
||||
#define PLOCK 35
|
||||
#define PPAUSE 40
|
||||
#define PUSER 50
|
||||
#define PSWP 0
|
||||
#define PINOD 10
|
||||
#define PRIBIO 20
|
||||
#define PRIUBA 24
|
||||
#define PZERO 25
|
||||
#define PPIPE 26
|
||||
#define PSOCK 26
|
||||
#define PWAIT 30
|
||||
#define PLOCK 35
|
||||
#define PPAUSE 40
|
||||
#define PUSER 50
|
||||
|
||||
#define NZERO 0
|
||||
#define NZERO 0
|
||||
|
||||
#define PRIMASK 0xff
|
||||
#define PCATCH 0x100
|
||||
#define PRIMASK 0xff
|
||||
#define PCATCH 0x100
|
||||
|
||||
/*
|
||||
* Signals
|
||||
*/
|
||||
#include <signal.h>
|
||||
|
||||
#define NBPW sizeof(int) /* number of bytes in an integer */
|
||||
#define NBPW sizeof(int) /* number of bytes in an integer */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#define CMASK 026 /* default mask for file creation */
|
||||
#define NODEV (dev_t)(-1)
|
||||
#define CMASK 026 /* default mask for file creation */
|
||||
#define NODEV (dev_t)(-1)
|
||||
|
||||
/* CBLOCK is the size of a clist block, must be power of 2 */
|
||||
#define CBLOCK 32
|
||||
#define CBSIZE (CBLOCK - sizeof(struct cblock *)) /* data chars/clist */
|
||||
#define CROUND (CBLOCK - 1) /* clist rounding */
|
||||
#define CBLOCK 32
|
||||
#define CBSIZE (CBLOCK - sizeof(struct cblock *)) /* data chars/clist */
|
||||
#define CROUND (CBLOCK - 1) /* clist rounding */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
*
|
||||
* The file system is made out of blocks of most MAXBSIZE units.
|
||||
*/
|
||||
#define MAXBSIZE 1024
|
||||
#define MAXBSIZE 1024
|
||||
|
||||
/*
|
||||
* MAXPATHLEN defines the longest permissable path length
|
||||
@@ -86,29 +86,29 @@
|
||||
* enough to allow all legitimate uses, but halt infinite loops
|
||||
* reasonably quickly.
|
||||
*/
|
||||
#define MAXPATHLEN 256
|
||||
#define MAXSYMLINKS 8
|
||||
#define MAXPATHLEN 256
|
||||
#define MAXSYMLINKS 8
|
||||
|
||||
/*
|
||||
* Macros for fast min/max.
|
||||
*/
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for counting and rounding.
|
||||
*/
|
||||
#ifndef howmany
|
||||
# define howmany(x,y) (((x)+((y)-1))/(y))
|
||||
# define howmany(x,y) (((x)+((y)-1))/(y))
|
||||
#endif
|
||||
#define roundup(x,y) ((((x)+((y)-1))/(y))*(y))
|
||||
#define roundup(x,y) ((((x)+((y)-1))/(y))*(y))
|
||||
|
||||
/*
|
||||
* Maximum size of hostname recognized and stored in the kernel.
|
||||
*/
|
||||
#define MAXHOSTNAMELEN 64
|
||||
#define MAXHOSTNAMELEN 64
|
||||
|
||||
#if defined(KERNEL) && defined(INET)
|
||||
# include "machine/net_mac.h"
|
||||
@@ -117,9 +117,9 @@
|
||||
/*
|
||||
* MAXMEM is the maximum core per process is allowed. First number is Kb.
|
||||
*/
|
||||
#define MAXMEM (96*1024)
|
||||
#define MAXMEM (96*1024)
|
||||
|
||||
/*
|
||||
* Max length of a user login name.
|
||||
*/
|
||||
#define MAXLOGNAME 16
|
||||
#define MAXLOGNAME 16
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
#define SPI_FGCOLOR 0x86
|
||||
#define SPI_BGCOLOR 0x87
|
||||
|
||||
#define FONT_SINCLAIR 0x00
|
||||
#define FONT_TOPAZ 0x01
|
||||
#define FONT_SINCLAIR 0x00
|
||||
#define FONT_TOPAZ 0x01
|
||||
|
||||
#define UP 0
|
||||
#define DOWN 1
|
||||
#define LEFT 2
|
||||
#define RIGHT 3
|
||||
#define UP 0
|
||||
#define DOWN 1
|
||||
#define LEFT 2
|
||||
#define RIGHT 3
|
||||
|
||||
struct coord2 {
|
||||
unsigned short x;
|
||||
@@ -95,6 +95,6 @@ extern int picga_write(dev_t dev, struct uio *uio, int flag);
|
||||
extern int picga_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag);
|
||||
#endif
|
||||
|
||||
#define PICGA_CLS _IO('g', 1)
|
||||
#define PICGA_CLS _IO('g', 1)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef _SYS_PROC_H_
|
||||
#define _SYS_PROC_H_
|
||||
#ifndef _SYS_PROC_H_
|
||||
#define _SYS_PROC_H_
|
||||
|
||||
/*
|
||||
* One structure allocated per active
|
||||
@@ -14,89 +14,89 @@
|
||||
* Other per process data (user.h)
|
||||
* is swapped with the process.
|
||||
*/
|
||||
struct proc {
|
||||
struct proc *p_nxt; /* linked list of allocated proc slots */
|
||||
struct proc **p_prev; /* also zombies, and free proc's */
|
||||
struct proc *p_pptr; /* pointer to process structure of parent */
|
||||
short p_flag;
|
||||
short p_uid; /* user id, used to direct tty signals */
|
||||
short p_pid; /* unique process id */
|
||||
short p_ppid; /* process id of parent */
|
||||
long p_sig; /* signals pending to this process */
|
||||
int p_stat;
|
||||
struct proc {
|
||||
struct proc *p_nxt; /* linked list of allocated proc slots */
|
||||
struct proc **p_prev; /* also zombies, and free proc's */
|
||||
struct proc *p_pptr; /* pointer to process structure of parent */
|
||||
short p_flag;
|
||||
short p_uid; /* user id, used to direct tty signals */
|
||||
short p_pid; /* unique process id */
|
||||
short p_ppid; /* process id of parent */
|
||||
long p_sig; /* signals pending to this process */
|
||||
int p_stat;
|
||||
|
||||
/*
|
||||
* Union to overwrite information no longer needed by ZOMBIED
|
||||
* process with exit information for the parent process. The
|
||||
* two structures have been carefully set up to use the same
|
||||
* amount of memory. Must be very careful that any values in
|
||||
* p_alive are not used for zombies (zombproc).
|
||||
*/
|
||||
union {
|
||||
struct {
|
||||
char P_pri; /* priority, negative is high */
|
||||
char P_cpu; /* cpu usage for scheduling */
|
||||
char P_time; /* resident time for scheduling */
|
||||
char P_nice; /* nice for cpu usage */
|
||||
char P_slptime; /* secs sleeping */
|
||||
char P_ptracesig; /* used between parent & traced child */
|
||||
struct proc *P_hash; /* hashed based on p_pid */
|
||||
long P_sigmask; /* current signal mask */
|
||||
long P_sigignore; /* signals being ignored */
|
||||
long P_sigcatch; /* signals being caught by user */
|
||||
short P_pgrp; /* name of process group leader */
|
||||
struct proc *P_link; /* linked list of running processes */
|
||||
size_t P_addr; /* address of u. area */
|
||||
size_t P_daddr; /* address of data area */
|
||||
size_t P_saddr; /* address of stack area */
|
||||
size_t P_dsize; /* size of data area (clicks) */
|
||||
size_t P_ssize; /* size of stack segment (clicks) */
|
||||
caddr_t P_wchan; /* event process is awaiting */
|
||||
struct k_itimerval P_realtimer;
|
||||
} p_alive;
|
||||
struct {
|
||||
int P_xstat; /* exit status for wait */
|
||||
struct k_rusage P_ru; /* exit information */
|
||||
} p_dead;
|
||||
} p_un;
|
||||
/*
|
||||
* Union to overwrite information no longer needed by ZOMBIED
|
||||
* process with exit information for the parent process. The
|
||||
* two structures have been carefully set up to use the same
|
||||
* amount of memory. Must be very careful that any values in
|
||||
* p_alive are not used for zombies (zombproc).
|
||||
*/
|
||||
union {
|
||||
struct {
|
||||
char P_pri; /* priority, negative is high */
|
||||
char P_cpu; /* cpu usage for scheduling */
|
||||
char P_time; /* resident time for scheduling */
|
||||
char P_nice; /* nice for cpu usage */
|
||||
char P_slptime; /* secs sleeping */
|
||||
char P_ptracesig; /* used between parent & traced child */
|
||||
struct proc *P_hash; /* hashed based on p_pid */
|
||||
long P_sigmask; /* current signal mask */
|
||||
long P_sigignore; /* signals being ignored */
|
||||
long P_sigcatch; /* signals being caught by user */
|
||||
short P_pgrp; /* name of process group leader */
|
||||
struct proc *P_link; /* linked list of running processes */
|
||||
size_t P_addr; /* address of u. area */
|
||||
size_t P_daddr; /* address of data area */
|
||||
size_t P_saddr; /* address of stack area */
|
||||
size_t P_dsize; /* size of data area (clicks) */
|
||||
size_t P_ssize; /* size of stack segment (clicks) */
|
||||
caddr_t P_wchan; /* event process is awaiting */
|
||||
struct k_itimerval P_realtimer;
|
||||
} p_alive;
|
||||
struct {
|
||||
int P_xstat; /* exit status for wait */
|
||||
struct k_rusage P_ru; /* exit information */
|
||||
} p_dead;
|
||||
} p_un;
|
||||
};
|
||||
#define p_pri p_un.p_alive.P_pri
|
||||
#define p_cpu p_un.p_alive.P_cpu
|
||||
#define p_time p_un.p_alive.P_time
|
||||
#define p_nice p_un.p_alive.P_nice
|
||||
#define p_slptime p_un.p_alive.P_slptime
|
||||
#define p_hash p_un.p_alive.P_hash
|
||||
#define p_ptracesig p_un.p_alive.P_ptracesig
|
||||
#define p_sigmask p_un.p_alive.P_sigmask
|
||||
#define p_sigignore p_un.p_alive.P_sigignore
|
||||
#define p_sigcatch p_un.p_alive.P_sigcatch
|
||||
#define p_pgrp p_un.p_alive.P_pgrp
|
||||
#define p_link p_un.p_alive.P_link
|
||||
#define p_addr p_un.p_alive.P_addr
|
||||
#define p_daddr p_un.p_alive.P_daddr
|
||||
#define p_saddr p_un.p_alive.P_saddr
|
||||
#define p_dsize p_un.p_alive.P_dsize
|
||||
#define p_ssize p_un.p_alive.P_ssize
|
||||
#define p_wchan p_un.p_alive.P_wchan
|
||||
#define p_realtimer p_un.p_alive.P_realtimer
|
||||
#define p_clktim p_realtimer.it_value
|
||||
#define p_pri p_un.p_alive.P_pri
|
||||
#define p_cpu p_un.p_alive.P_cpu
|
||||
#define p_time p_un.p_alive.P_time
|
||||
#define p_nice p_un.p_alive.P_nice
|
||||
#define p_slptime p_un.p_alive.P_slptime
|
||||
#define p_hash p_un.p_alive.P_hash
|
||||
#define p_ptracesig p_un.p_alive.P_ptracesig
|
||||
#define p_sigmask p_un.p_alive.P_sigmask
|
||||
#define p_sigignore p_un.p_alive.P_sigignore
|
||||
#define p_sigcatch p_un.p_alive.P_sigcatch
|
||||
#define p_pgrp p_un.p_alive.P_pgrp
|
||||
#define p_link p_un.p_alive.P_link
|
||||
#define p_addr p_un.p_alive.P_addr
|
||||
#define p_daddr p_un.p_alive.P_daddr
|
||||
#define p_saddr p_un.p_alive.P_saddr
|
||||
#define p_dsize p_un.p_alive.P_dsize
|
||||
#define p_ssize p_un.p_alive.P_ssize
|
||||
#define p_wchan p_un.p_alive.P_wchan
|
||||
#define p_realtimer p_un.p_alive.P_realtimer
|
||||
#define p_clktim p_realtimer.it_value
|
||||
|
||||
#define p_xstat p_un.p_dead.P_xstat
|
||||
#define p_ru p_un.p_dead.P_ru
|
||||
#define p_xstat p_un.p_dead.P_xstat
|
||||
#define p_ru p_un.p_dead.P_ru
|
||||
|
||||
#define PIDHSZ 16
|
||||
#define PIDHASH(pid) ((pid) & (PIDHSZ - 1))
|
||||
#define PIDHSZ 16
|
||||
#define PIDHASH(pid) ((pid) & (PIDHSZ - 1))
|
||||
|
||||
/* arguments to swapout: */
|
||||
#define X_OLDSIZE (-1) /* the old size is the same as current */
|
||||
#define X_DONTFREE 0 /* save core image (for parent in newproc) */
|
||||
#define X_FREECORE 1 /* free core space after swap */
|
||||
#define X_OLDSIZE (-1) /* the old size is the same as current */
|
||||
#define X_DONTFREE 0 /* save core image (for parent in newproc) */
|
||||
#define X_FREECORE 1 /* free core space after swap */
|
||||
|
||||
#ifdef KERNEL
|
||||
struct proc *pidhash [PIDHSZ];
|
||||
extern struct proc proc[]; /* the proc table itself */
|
||||
struct proc *freeproc, *zombproc, *allproc, *qs;
|
||||
/* lists of procs in various states */
|
||||
struct proc *pidhash [PIDHSZ];
|
||||
extern struct proc proc[]; /* the proc table itself */
|
||||
struct proc *freeproc, *zombproc, *allproc, *qs;
|
||||
/* lists of procs in various states */
|
||||
extern int nproc;
|
||||
|
||||
/*
|
||||
@@ -277,31 +277,31 @@ void execsigs(register struct proc *p);
|
||||
#endif /* KERMEL */
|
||||
|
||||
/* stat codes */
|
||||
#define SSLEEP 1 /* awaiting an event */
|
||||
#define SWAIT 2 /* (abandoned state) */
|
||||
#define SRUN 3 /* running */
|
||||
#define SIDL 4 /* intermediate state in process creation */
|
||||
#define SZOMB 5 /* intermediate state in process termination */
|
||||
#define SSTOP 6 /* process being traced */
|
||||
#define SSLEEP 1 /* awaiting an event */
|
||||
#define SWAIT 2 /* (abandoned state) */
|
||||
#define SRUN 3 /* running */
|
||||
#define SIDL 4 /* intermediate state in process creation */
|
||||
#define SZOMB 5 /* intermediate state in process termination */
|
||||
#define SSTOP 6 /* process being traced */
|
||||
|
||||
/* flag codes */
|
||||
#define SLOAD 0x0001 /* in core */
|
||||
#define SSYS 0x0002 /* swapper or pager process */
|
||||
#define SLOCK 0x0004 /* process being swapped out */
|
||||
#define SSWAP 0x0008 /* save area flag */
|
||||
#define P_TRACED 0x0010 /* process is being traced */
|
||||
#define P_WAITED 0x0020 /* another tracing flag */
|
||||
#define P_SINTR 0x0080 /* sleeping interruptibly */
|
||||
#define SVFORK 0x0100 /* process resulted from vfork() */
|
||||
#define SVFPRNT 0x0200 /* parent in vfork, waiting for child */
|
||||
#define SVFDONE 0x0400 /* parent has released child in vfork */
|
||||
/* 0x0800 unused */
|
||||
#define P_TIMEOUT 0x1000 /* tsleep timeout expired */
|
||||
#define P_NOCLDSTOP 0x2000 /* no SIGCHLD signal to parent */
|
||||
#define P_SELECT 0x4000 /* selecting; wakeup/waiting danger */
|
||||
/* 0x8000 unused */
|
||||
#define SLOAD 0x0001 /* in core */
|
||||
#define SSYS 0x0002 /* swapper or pager process */
|
||||
#define SLOCK 0x0004 /* process being swapped out */
|
||||
#define SSWAP 0x0008 /* save area flag */
|
||||
#define P_TRACED 0x0010 /* process is being traced */
|
||||
#define P_WAITED 0x0020 /* another tracing flag */
|
||||
#define P_SINTR 0x0080 /* sleeping interruptibly */
|
||||
#define SVFORK 0x0100 /* process resulted from vfork() */
|
||||
#define SVFPRNT 0x0200 /* parent in vfork, waiting for child */
|
||||
#define SVFDONE 0x0400 /* parent has released child in vfork */
|
||||
/* 0x0800 unused */
|
||||
#define P_TIMEOUT 0x1000 /* tsleep timeout expired */
|
||||
#define P_NOCLDSTOP 0x2000 /* no SIGCHLD signal to parent */
|
||||
#define P_SELECT 0x4000 /* selecting; wakeup/waiting danger */
|
||||
/* 0x8000 unused */
|
||||
|
||||
#define S_DATA 0 /* specified segment */
|
||||
#define S_STACK 1
|
||||
#define S_DATA 0 /* specified segment */
|
||||
#define S_STACK 1
|
||||
|
||||
#endif /* !_SYS_PROC_H_ */
|
||||
#endif /* !_SYS_PROC_H_ */
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
#ifndef _PTRACE_
|
||||
#define _PTRACE_
|
||||
|
||||
#define PT_TRACE_ME 0 /* child declares it's being traced */
|
||||
#define PT_READ_I 1 /* read word in child's I space */
|
||||
#define PT_READ_D 2 /* read word in child's D space */
|
||||
#define PT_READ_U 3 /* read word in child's user structure */
|
||||
#define PT_WRITE_I 4 /* write word in child's I space */
|
||||
#define PT_WRITE_D 5 /* write word in child's D space */
|
||||
#define PT_WRITE_U 6 /* write word in child's user structure */
|
||||
#define PT_CONTINUE 7 /* continue the child */
|
||||
#define PT_KILL 8 /* kill the child process */
|
||||
#define PT_STEP 9 /* single step the child */
|
||||
#define PT_TRACE_ME 0 /* child declares it's being traced */
|
||||
#define PT_READ_I 1 /* read word in child's I space */
|
||||
#define PT_READ_D 2 /* read word in child's D space */
|
||||
#define PT_READ_U 3 /* read word in child's user structure */
|
||||
#define PT_WRITE_I 4 /* write word in child's I space */
|
||||
#define PT_WRITE_D 5 /* write word in child's D space */
|
||||
#define PT_WRITE_U 6 /* write word in child's user structure */
|
||||
#define PT_CONTINUE 7 /* continue the child */
|
||||
#define PT_KILL 8 /* kill the child process */
|
||||
#define PT_STEP 9 /* single step the child */
|
||||
|
||||
/*
|
||||
* Tracing variables.
|
||||
@@ -27,10 +27,10 @@
|
||||
* per user.
|
||||
*/
|
||||
struct ipc {
|
||||
int ip_lock;
|
||||
int ip_req;
|
||||
int *ip_addr;
|
||||
int ip_data;
|
||||
int ip_lock;
|
||||
int ip_req;
|
||||
int *ip_addr;
|
||||
int ip_data;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef _PTY_H
|
||||
#define _PTY_H
|
||||
|
||||
#define PF_RCOLL 0x01
|
||||
#define PF_WCOLL 0x02
|
||||
#define PF_PKT 0x08 /* packet mode */
|
||||
#define PF_STOPPED 0x10 /* user told stopped */
|
||||
#define PF_REMOTE 0x20 /* remote and flow controlled input */
|
||||
#define PF_NOSTOP 0x40
|
||||
#define PF_UCNTL 0x80 /* user control mode */
|
||||
#define PF_RCOLL 0x01
|
||||
#define PF_WCOLL 0x02
|
||||
#define PF_PKT 0x08 /* packet mode */
|
||||
#define PF_STOPPED 0x10 /* user told stopped */
|
||||
#define PF_REMOTE 0x20 /* remote and flow controlled input */
|
||||
#define PF_NOSTOP 0x40
|
||||
#define PF_UCNTL 0x80 /* user control mode */
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
struct pwm_state {
|
||||
int mode;
|
||||
int pwm_duty;
|
||||
int mode;
|
||||
int pwm_duty;
|
||||
};
|
||||
|
||||
#define PWM_MAX_DEV 5
|
||||
#define PWM_MAX_DEV 5
|
||||
|
||||
#define PWM_MODE_PWM 0x0001
|
||||
#define PWM_MODE_PWM 0x0001
|
||||
|
||||
#define PWM_SET_MODE _IOW('i',1,int)
|
||||
#define PWM_DUTY _IOW('i',2,int)
|
||||
#define PWM_SET_MODE _IOW('i',1,int)
|
||||
#define PWM_DUTY _IOW('i',2,int)
|
||||
|
||||
#ifdef KERNEL
|
||||
#include "conf.h"
|
||||
|
||||
@@ -3,70 +3,70 @@
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#define RDISK_FS 0xB7
|
||||
#define RDISK_SWAP 0xB8
|
||||
#define RDISK_FS 0xB7
|
||||
#define RDISK_SWAP 0xB8
|
||||
|
||||
#define RD_DEFAULT 0x00000000UL
|
||||
#define RD_READONLY 0x00000001UL
|
||||
#define RD_PREPART 0x00000002UL
|
||||
#define RD_DEFAULT 0x00000000UL
|
||||
#define RD_READONLY 0x00000001UL
|
||||
#define RD_PREPART 0x00000002UL
|
||||
|
||||
#define S_SILENT 0x8000
|
||||
#define S_SILENT 0x8000
|
||||
|
||||
#define RAMDISK_PARTSPEC(n,t,s,l) \
|
||||
m->partitions[n].type=t; \
|
||||
m->partitions[n].lbastart=s; \
|
||||
m->partitions[n].lbalength=l;
|
||||
#define RAMDISK_PARTSPEC(n, t, s, l) \
|
||||
m->partitions[n].type = t; \
|
||||
m->partitions[n].lbastart = s; \
|
||||
m->partitions[n].lbalength = l;
|
||||
|
||||
struct diskentry {
|
||||
void (*pre_init)(int unit);
|
||||
int (*init)(int unit,int flag);
|
||||
int (*deinit)(int unit);
|
||||
int (*open)(int unit, int mode, int flags);
|
||||
int (*size)(int unit);
|
||||
int (*read)(int unit, unsigned int offset, char *data, unsigned int bcount);
|
||||
int (*write)(int unit, unsigned int offset, char *data, unsigned int bcount);
|
||||
unsigned char unit;
|
||||
unsigned int settings;
|
||||
void (*pre_init)(int unit);
|
||||
int (*init)(int unit,int flag);
|
||||
int (*deinit)(int unit);
|
||||
int (*open)(int unit, int mode, int flags);
|
||||
int (*size)(int unit);
|
||||
int (*read)(int unit, unsigned int offset, char *data, unsigned int bcount);
|
||||
int (*write)(int unit, unsigned int offset, char *data, unsigned int bcount);
|
||||
unsigned char unit;
|
||||
unsigned int settings;
|
||||
};
|
||||
|
||||
struct diskflags {
|
||||
unsigned char opens;
|
||||
unsigned int start[4];
|
||||
unsigned int len[4];
|
||||
unsigned int blocks;
|
||||
unsigned char opens;
|
||||
unsigned int start[4];
|
||||
unsigned int len[4];
|
||||
unsigned int blocks;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct chs {
|
||||
unsigned char head;
|
||||
struct {
|
||||
unsigned cylhigh:2;
|
||||
unsigned sector:6;
|
||||
} __attribute__((packed));
|
||||
unsigned char cyllow;
|
||||
unsigned char head;
|
||||
struct {
|
||||
unsigned cylhigh : 2;
|
||||
unsigned sector : 6;
|
||||
} __attribute__((packed));
|
||||
unsigned char cyllow;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct partition {
|
||||
#define P_ACTIVE 0x80
|
||||
unsigned char status;
|
||||
struct chs start;
|
||||
unsigned char type;
|
||||
struct chs end;
|
||||
unsigned long lbastart;
|
||||
unsigned long lbalength;
|
||||
#define P_ACTIVE 0x80
|
||||
unsigned char status;
|
||||
struct chs start;
|
||||
unsigned char type;
|
||||
struct chs end;
|
||||
unsigned long lbastart;
|
||||
unsigned long lbalength;
|
||||
};
|
||||
|
||||
struct mbr {
|
||||
unsigned char bootstrap1[218];
|
||||
unsigned short pad0000;
|
||||
unsigned char biosdrive;
|
||||
unsigned char secs;
|
||||
unsigned char mins;
|
||||
unsigned char hours;
|
||||
unsigned char bootstrap2[216];
|
||||
unsigned int sig;
|
||||
unsigned short pad0001;
|
||||
struct partition partitions[4];
|
||||
unsigned short bootsig;
|
||||
unsigned char bootstrap1[218];
|
||||
unsigned short pad0000;
|
||||
unsigned char biosdrive;
|
||||
unsigned char secs;
|
||||
unsigned char mins;
|
||||
unsigned char hours;
|
||||
unsigned char bootstrap2[216];
|
||||
unsigned int sig;
|
||||
unsigned short pad0001;
|
||||
struct partition partitions[4];
|
||||
unsigned short bootsig;
|
||||
}__attribute__((packed));
|
||||
|
||||
#ifdef KERNEL
|
||||
@@ -89,9 +89,9 @@ extern const struct devspec rd0devs[];
|
||||
extern const struct devspec rd1devs[];
|
||||
extern const struct devspec rd2devs[];
|
||||
extern const struct devspec rd3devs[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define RDGETMEDIASIZE _IOR('r',1,int)
|
||||
#define RDREINIT _IO('r',2)
|
||||
#define RDGETMEDIASIZE _IOR('r', 1, int)
|
||||
#define RDREINIT _IO('r', 2)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)reboot.h 1.2 (2.11BSD GTE) 1996/5/9
|
||||
* @(#)reboot.h 1.2 (2.11BSD GTE) 1996/5/9
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -11,21 +11,21 @@
|
||||
* These are passed to boot program in r4,
|
||||
* and on to init.
|
||||
*/
|
||||
#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
|
||||
#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
|
||||
|
||||
#define RB_ASKNAME 0x001 /* ask for file name to reboot from */
|
||||
#define RB_SINGLE 0x002 /* reboot to single user only */
|
||||
#define RB_NOSYNC 0x004 /* dont sync before reboot */
|
||||
#define RB_HALT 0x008 /* don't reboot, just halt */
|
||||
#define RB_INITNAME 0x010 /* name given for /etc/init */
|
||||
#define RB_DFLTROOT 0x020 /* use compiled-in rootdev */
|
||||
#define RB_DUMP 0x040 /* take a dump before rebooting */
|
||||
#define RB_NOFSCK 0x080 /* don't perform fsck's on reboot */
|
||||
#define RB_POWRFAIL 0x100 /* reboot caused by power failure */
|
||||
#define RB_RDONLY 0x200 /* mount root fs read-only */
|
||||
#define RB_AUTODEBUG 0x400 /* init runs autoconfig with "-d" (debug) */
|
||||
#define RB_POWEROFF 0x800 /* signal PSU to switch off power */
|
||||
#define RB_BOOTLOADER 0x1000 /* reboot into the bootloader */
|
||||
#define RB_ASKNAME 0x001 /* ask for file name to reboot from */
|
||||
#define RB_SINGLE 0x002 /* reboot to single user only */
|
||||
#define RB_NOSYNC 0x004 /* dont sync before reboot */
|
||||
#define RB_HALT 0x008 /* don't reboot, just halt */
|
||||
#define RB_INITNAME 0x010 /* name given for /etc/init */
|
||||
#define RB_DFLTROOT 0x020 /* use compiled-in rootdev */
|
||||
#define RB_DUMP 0x040 /* take a dump before rebooting */
|
||||
#define RB_NOFSCK 0x080 /* don't perform fsck's on reboot */
|
||||
#define RB_POWRFAIL 0x100 /* reboot caused by power failure */
|
||||
#define RB_RDONLY 0x200 /* mount root fs read-only */
|
||||
#define RB_AUTODEBUG 0x400 /* init runs autoconfig with "-d" (debug) */
|
||||
#define RB_POWEROFF 0x800 /* signal PSU to switch off power */
|
||||
#define RB_BOOTLOADER 0x1000 /* reboot into the bootloader */
|
||||
|
||||
#define RB_PANIC 0 /* reboot due to panic */
|
||||
#define RB_BOOT 1 /* reboot due to boot() */
|
||||
#define RB_PANIC 0 /* reboot due to panic */
|
||||
#define RB_BOOT 1 /* reboot due to boot() */
|
||||
|
||||
@@ -3,88 +3,88 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)resource.h 1.3 (2.11BSD GTE) 1997/2/14
|
||||
* @(#)resource.h 1.3 (2.11BSD GTE) 1997/2/14
|
||||
*/
|
||||
|
||||
#ifndef _SYS_RESOURCE_H_
|
||||
#define _SYS_RESOURCE_H_
|
||||
#ifndef _SYS_RESOURCE_H_
|
||||
#define _SYS_RESOURCE_H_
|
||||
|
||||
/*
|
||||
* Process priority specifications to get/setpriority.
|
||||
*/
|
||||
#define PRIO_MIN -20
|
||||
#define PRIO_MAX 20
|
||||
#define PRIO_MIN -20
|
||||
#define PRIO_MAX 20
|
||||
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
|
||||
/*
|
||||
* Resource utilization information.
|
||||
*/
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN -1
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN -1
|
||||
|
||||
struct rusage {
|
||||
struct timeval ru_utime; /* user time used */
|
||||
struct timeval ru_stime; /* system time used */
|
||||
long ru_maxrss;
|
||||
#define ru_first ru_ixrss
|
||||
long ru_ixrss; /* integral shared memory size */
|
||||
long ru_idrss; /* integral unshared data " */
|
||||
long ru_isrss; /* integral unshared stack " */
|
||||
long ru_minflt; /* page reclaims */
|
||||
long ru_majflt; /* page faults */
|
||||
long ru_nswap; /* swaps */
|
||||
long ru_inblock; /* block input operations */
|
||||
long ru_oublock; /* block output operations */
|
||||
long ru_msgsnd; /* messages sent */
|
||||
long ru_msgrcv; /* messages received */
|
||||
long ru_nsignals; /* signals received */
|
||||
long ru_nvcsw; /* voluntary context switches */
|
||||
long ru_nivcsw; /* involuntary " */
|
||||
#define ru_last ru_nivcsw
|
||||
struct rusage {
|
||||
struct timeval ru_utime; /* user time used */
|
||||
struct timeval ru_stime; /* system time used */
|
||||
long ru_maxrss;
|
||||
#define ru_first ru_ixrss
|
||||
long ru_ixrss; /* integral shared memory size */
|
||||
long ru_idrss; /* integral unshared data " */
|
||||
long ru_isrss; /* integral unshared stack " */
|
||||
long ru_minflt; /* page reclaims */
|
||||
long ru_majflt; /* page faults */
|
||||
long ru_nswap; /* swaps */
|
||||
long ru_inblock; /* block input operations */
|
||||
long ru_oublock; /* block output operations */
|
||||
long ru_msgsnd; /* messages sent */
|
||||
long ru_msgrcv; /* messages received */
|
||||
long ru_nsignals; /* signals received */
|
||||
long ru_nvcsw; /* voluntary context switches */
|
||||
long ru_nivcsw; /* involuntary " */
|
||||
#define ru_last ru_nivcsw
|
||||
};
|
||||
|
||||
struct k_rusage { /* KERNEL RUSAGE STRUCTURE */
|
||||
#define k_ru_first ru_utime
|
||||
long ru_utime; /* user time used ('hz' ticks) */
|
||||
long ru_stime; /* system time used ('hz' ticks) */
|
||||
long ru_nswap; /* swaps */
|
||||
long ru_inblock; /* block input operations */
|
||||
long ru_oublock; /* block output operations */
|
||||
long ru_msgsnd; /* messages sent */
|
||||
long ru_msgrcv; /* messages received */
|
||||
long ru_nsignals; /* signals received */
|
||||
long ru_nvcsw; /* voluntary context switches */
|
||||
long ru_nivcsw; /* involuntary " */
|
||||
#define k_ru_last ru_nivcsw
|
||||
struct k_rusage { /* KERNEL RUSAGE STRUCTURE */
|
||||
#define k_ru_first ru_utime
|
||||
long ru_utime; /* user time used ('hz' ticks) */
|
||||
long ru_stime; /* system time used ('hz' ticks) */
|
||||
long ru_nswap; /* swaps */
|
||||
long ru_inblock; /* block input operations */
|
||||
long ru_oublock; /* block output operations */
|
||||
long ru_msgsnd; /* messages sent */
|
||||
long ru_msgrcv; /* messages received */
|
||||
long ru_nsignals; /* signals received */
|
||||
long ru_nvcsw; /* voluntary context switches */
|
||||
long ru_nivcsw; /* involuntary " */
|
||||
#define k_ru_last ru_nivcsw
|
||||
};
|
||||
|
||||
/*
|
||||
* Resource limits
|
||||
*/
|
||||
#define RLIMIT_CPU 0 /* cpu time in milliseconds */
|
||||
#define RLIMIT_FSIZE 1 /* maximum file size */
|
||||
#define RLIMIT_DATA 2 /* data size */
|
||||
#define RLIMIT_STACK 3 /* stack size */
|
||||
#define RLIMIT_CORE 4 /* core file size */
|
||||
#define RLIMIT_RSS 5 /* resident set size */
|
||||
#define RLIMIT_CPU 0 /* cpu time in milliseconds */
|
||||
#define RLIMIT_FSIZE 1 /* maximum file size */
|
||||
#define RLIMIT_DATA 2 /* data size */
|
||||
#define RLIMIT_STACK 3 /* stack size */
|
||||
#define RLIMIT_CORE 4 /* core file size */
|
||||
#define RLIMIT_RSS 5 /* resident set size */
|
||||
|
||||
#define RLIM_NLIMITS 6 /* number of resource limits */
|
||||
#define RLIM_NLIMITS 6 /* number of resource limits */
|
||||
|
||||
#define RLIM_INFINITY 0x7fffffff
|
||||
#define RLIM_INFINITY 0x7fffffff
|
||||
|
||||
struct rlimit {
|
||||
long rlim_cur; /* current (soft) limit */
|
||||
long rlim_max; /* maximum value for rlim_cur */
|
||||
long rlim_cur; /* current (soft) limit */
|
||||
long rlim_max; /* maximum value for rlim_cur */
|
||||
};
|
||||
|
||||
/* Load average structure. */
|
||||
struct loadavg {
|
||||
short ldavg[3];
|
||||
int fscale;
|
||||
short ldavg[3];
|
||||
int fscale;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
@@ -104,4 +104,4 @@ int getrusage (int who, struct rusage *usage);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_RESOURCE_H_ */
|
||||
#endif /* !_SYS_RESOURCE_H_ */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -12,8 +12,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -30,11 +30,11 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)select.h 8.2.1 (2.11BSD) 2000/2/28
|
||||
* @(#)select.h 8.2.1 (2.11BSD) 2000/2/28
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SELECT_H_
|
||||
#define _SYS_SELECT_H_
|
||||
#define _SYS_SELECT_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -44,21 +44,21 @@
|
||||
* FD_SETSIZE may be defined by the user, but the default here
|
||||
* should be >= NOFILE (param.h).
|
||||
*/
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 32
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 32
|
||||
#endif
|
||||
|
||||
typedef long fd_mask;
|
||||
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
|
||||
typedef long fd_mask;
|
||||
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
|
||||
|
||||
typedef struct fd_set {
|
||||
fd_mask fds_bits[1];
|
||||
typedef struct fd_set {
|
||||
fd_mask fds_bits[1];
|
||||
} fd_set;
|
||||
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef CROSS
|
||||
@@ -68,7 +68,7 @@ void bzero(void *, unsigned long);
|
||||
/* According to POSIX.1-2001 */
|
||||
struct timeval;
|
||||
int select (int nfds, fd_set *readfds, fd_set *writefds,
|
||||
fd_set *exceptfds, struct timeval *timeout);
|
||||
fd_set *exceptfds, struct timeval *timeout);
|
||||
|
||||
#endif /* !KERNEL */
|
||||
|
||||
|
||||
@@ -3,104 +3,104 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef NSIG
|
||||
#ifndef NSIG
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NSIG 32
|
||||
#define NSIG 32
|
||||
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt */
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGIOT 6 /* IOT instruction */
|
||||
#define SIGABRT SIGIOT /* compatibility */
|
||||
#define SIGEMT 7 /* EMT instruction */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGSYS 12 /* bad argument to system call */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
#define SIGURG 16 /* urgent condition on IO channel */
|
||||
#define SIGSTOP 17 /* sendable stop signal not from tty */
|
||||
#define SIGTSTP 18 /* stop signal from tty */
|
||||
#define SIGCONT 19 /* continue a stopped process */
|
||||
#define SIGCHLD 20 /* to parent on child stop or exit */
|
||||
#define SIGCLD SIGCHLD /* compatibility */
|
||||
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
||||
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
||||
#define SIGIO 23 /* input/output possible signal */
|
||||
#define SIGXCPU 24 /* exceeded CPU time limit */
|
||||
#define SIGXFSZ 25 /* exceeded file size limit */
|
||||
#define SIGVTALRM 26 /* virtual time alarm */
|
||||
#define SIGPROF 27 /* profiling time alarm */
|
||||
#define SIGWINCH 28 /* window size changes */
|
||||
#define SIGUSR1 30 /* user defined signal 1 */
|
||||
#define SIGUSR2 31 /* user defined signal 2 */
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt */
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGIOT 6 /* IOT instruction */
|
||||
#define SIGABRT SIGIOT /* compatibility */
|
||||
#define SIGEMT 7 /* EMT instruction */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGSYS 12 /* bad argument to system call */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
#define SIGURG 16 /* urgent condition on IO channel */
|
||||
#define SIGSTOP 17 /* sendable stop signal not from tty */
|
||||
#define SIGTSTP 18 /* stop signal from tty */
|
||||
#define SIGCONT 19 /* continue a stopped process */
|
||||
#define SIGCHLD 20 /* to parent on child stop or exit */
|
||||
#define SIGCLD SIGCHLD /* compatibility */
|
||||
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
||||
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
||||
#define SIGIO 23 /* input/output possible signal */
|
||||
#define SIGXCPU 24 /* exceeded CPU time limit */
|
||||
#define SIGXFSZ 25 /* exceeded file size limit */
|
||||
#define SIGVTALRM 26 /* virtual time alarm */
|
||||
#define SIGPROF 27 /* profiling time alarm */
|
||||
#define SIGWINCH 28 /* window size changes */
|
||||
#define SIGUSR1 30 /* user defined signal 1 */
|
||||
#define SIGUSR2 31 /* user defined signal 2 */
|
||||
|
||||
typedef void (*sig_t) (int); /* type of signal function */
|
||||
typedef void (*sig_t) (int); /* type of signal function */
|
||||
|
||||
#define SIG_ERR (sig_t) -1
|
||||
#define SIG_DFL (sig_t) 0
|
||||
#define SIG_IGN (sig_t) 1
|
||||
#define SIG_ERR (sig_t) -1
|
||||
#define SIG_DFL (sig_t) 0
|
||||
#define SIG_IGN (sig_t) 1
|
||||
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
/*
|
||||
* Signal vector "template" used in sigaction call.
|
||||
*/
|
||||
struct sigaction {
|
||||
sig_t sa_handler; /* signal handler */
|
||||
sigset_t sa_mask; /* signal mask to apply */
|
||||
int sa_flags; /* see signal options below */
|
||||
struct sigaction {
|
||||
sig_t sa_handler; /* signal handler */
|
||||
sigset_t sa_mask; /* signal mask to apply */
|
||||
int sa_flags; /* see signal options below */
|
||||
};
|
||||
|
||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
||||
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
|
||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
||||
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
|
||||
|
||||
/*
|
||||
* Flags for sigprocmask:
|
||||
*/
|
||||
#define SIG_BLOCK 1 /* block specified signal set */
|
||||
#define SIG_UNBLOCK 2 /* unblock specified signal set */
|
||||
#define SIG_SETMASK 3 /* set specified signal set */
|
||||
#define SIG_BLOCK 1 /* block specified signal set */
|
||||
#define SIG_UNBLOCK 2 /* unblock specified signal set */
|
||||
#define SIG_SETMASK 3 /* set specified signal set */
|
||||
|
||||
/*
|
||||
* Structure used in sigaltstack call.
|
||||
*/
|
||||
struct sigaltstack {
|
||||
char *ss_base; /* signal stack base */
|
||||
int ss_size; /* signal stack length */
|
||||
int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */
|
||||
struct sigaltstack {
|
||||
char *ss_base; /* signal stack base */
|
||||
int ss_size; /* signal stack length */
|
||||
int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */
|
||||
};
|
||||
#define MINSIGSTKSZ 128 /* minimum allowable stack */
|
||||
#define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */
|
||||
#define MINSIGSTKSZ 128 /* minimum allowable stack */
|
||||
#define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */
|
||||
|
||||
/*
|
||||
* 4.3 compatibility:
|
||||
* Signal vector "template" used in sigvec call.
|
||||
*/
|
||||
struct sigvec {
|
||||
sig_t sv_handler; /* signal handler */
|
||||
long sv_mask; /* signal mask to apply */
|
||||
int sv_flags; /* see signal options below */
|
||||
struct sigvec {
|
||||
sig_t sv_handler; /* signal handler */
|
||||
long sv_mask; /* signal mask to apply */
|
||||
int sv_flags; /* see signal options below */
|
||||
};
|
||||
#define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */
|
||||
#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
|
||||
#define sv_onstack sv_flags /* isn't compatibility wonderful! */
|
||||
#define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */
|
||||
#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
|
||||
#define sv_onstack sv_flags /* isn't compatibility wonderful! */
|
||||
|
||||
/*
|
||||
* 4.3 compatibility:
|
||||
* Structure used in sigstack call.
|
||||
*/
|
||||
struct sigstack {
|
||||
char *ss_sp; /* signal stack pointer */
|
||||
int ss_onstack; /* current status */
|
||||
struct sigstack {
|
||||
char *ss_sp; /* signal stack pointer */
|
||||
int ss_onstack; /* current status */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -110,51 +110,51 @@ struct sigstack {
|
||||
* to the handler to allow it to properly restore state if
|
||||
* a non-standard exit is performed.
|
||||
*/
|
||||
struct sigcontext {
|
||||
int sc_onstack; /* sigstack state to restore */
|
||||
long sc_mask; /* signal mask to restore */
|
||||
int sc_r1; /* r1 to restore */
|
||||
int sc_r2; /* and other registers */
|
||||
int sc_r3;
|
||||
int sc_r4;
|
||||
int sc_r5;
|
||||
int sc_r6;
|
||||
int sc_r7;
|
||||
int sc_r8;
|
||||
int sc_r9;
|
||||
int sc_r10;
|
||||
int sc_r11;
|
||||
int sc_r12;
|
||||
int sc_r13;
|
||||
int sc_r14;
|
||||
int sc_r15;
|
||||
int sc_r16;
|
||||
int sc_r17;
|
||||
int sc_r18;
|
||||
int sc_r19;
|
||||
int sc_r20;
|
||||
int sc_r21;
|
||||
int sc_r22;
|
||||
int sc_r23;
|
||||
int sc_r24;
|
||||
int sc_r25;
|
||||
int sc_gp;
|
||||
int sc_sp; /* sp to restore */
|
||||
int sc_fp;
|
||||
int sc_ra;
|
||||
int sc_lo;
|
||||
int sc_hi;
|
||||
int sc_pc; /* pc to restore */
|
||||
struct sigcontext {
|
||||
int sc_onstack; /* sigstack state to restore */
|
||||
long sc_mask; /* signal mask to restore */
|
||||
int sc_r1; /* r1 to restore */
|
||||
int sc_r2; /* and other registers */
|
||||
int sc_r3;
|
||||
int sc_r4;
|
||||
int sc_r5;
|
||||
int sc_r6;
|
||||
int sc_r7;
|
||||
int sc_r8;
|
||||
int sc_r9;
|
||||
int sc_r10;
|
||||
int sc_r11;
|
||||
int sc_r12;
|
||||
int sc_r13;
|
||||
int sc_r14;
|
||||
int sc_r15;
|
||||
int sc_r16;
|
||||
int sc_r17;
|
||||
int sc_r18;
|
||||
int sc_r19;
|
||||
int sc_r20;
|
||||
int sc_r21;
|
||||
int sc_r22;
|
||||
int sc_r23;
|
||||
int sc_r24;
|
||||
int sc_r25;
|
||||
int sc_gp;
|
||||
int sc_sp; /* sp to restore */
|
||||
int sc_fp;
|
||||
int sc_ra;
|
||||
int sc_lo;
|
||||
int sc_hi;
|
||||
int sc_pc; /* pc to restore */
|
||||
};
|
||||
|
||||
/*
|
||||
* Macro for converting signal number to a mask suitable for
|
||||
* sigblock().
|
||||
*/
|
||||
#define sigmask(m) (1L << ((m)-1))
|
||||
#define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0)
|
||||
#define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0)
|
||||
#define sigemptyset(set) (*(set) = (sigset_t)0, (int)0)
|
||||
#define sigmask(m) (1L << ((m)-1))
|
||||
#define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0)
|
||||
#define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0)
|
||||
#define sigemptyset(set) (*(set) = (sigset_t)0, (int)0)
|
||||
#define sigfillset(set) (*(set) = ~(sigset_t)0, (int)0)
|
||||
#define sigismember(set, signo) ((*(set) & (1L << ((signo) - 1))) != 0)
|
||||
|
||||
@@ -182,8 +182,6 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oldset);
|
||||
int siginterrupt (int sig, int flag);
|
||||
int sigsuspend (const sigset_t *mask);
|
||||
|
||||
#define BADSIG SIG_ERR
|
||||
|
||||
#endif /* KERNEL */
|
||||
|
||||
#endif /* NSIG */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -12,8 +12,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -30,8 +30,8 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
|
||||
#define _SYS_SIGNALVAR_H_
|
||||
#ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
|
||||
#define _SYS_SIGNALVAR_H_
|
||||
|
||||
/*
|
||||
* Kernel signal definitions and data structures,
|
||||
@@ -41,12 +41,12 @@
|
||||
*/
|
||||
|
||||
/* signal flags */
|
||||
#define SAS_OLDMASK 0x01 /* need to restore mask before pause */
|
||||
#define SAS_ALTSTACK 0x02 /* have alternate signal stack */
|
||||
#define SAS_OLDMASK 0x01 /* need to restore mask before pause */
|
||||
#define SAS_ALTSTACK 0x02 /* have alternate signal stack */
|
||||
|
||||
/* additional signal action values, used only temporarily/internally */
|
||||
#define SIG_CATCH (sig_t) 2
|
||||
#define SIG_HOLD (sig_t) 3
|
||||
#define SIG_CATCH (sig_t) 2
|
||||
#define SIG_HOLD (sig_t) 3
|
||||
|
||||
/*
|
||||
* Determine signal that should be delivered to process p, the current
|
||||
@@ -56,65 +56,64 @@
|
||||
* This probably should be a routine (assembly) instead of a macro due
|
||||
* to the voluminous code generated by all of the 'long' operations.
|
||||
*/
|
||||
#define CURSIG(p) \
|
||||
(((p)->p_sig == 0 || \
|
||||
(((p)->p_flag & P_TRACED) == 0 && \
|
||||
((p)->p_sig & ~(p)->p_sigmask) == 0)) ? \
|
||||
0 : issignal(p))
|
||||
#define CURSIG(p) (((p)->p_sig == 0 || \
|
||||
(((p)->p_flag & P_TRACED) == 0 && \
|
||||
((p)->p_sig & ~(p)->p_sigmask) == 0)) ? \
|
||||
0 : issignal(p))
|
||||
|
||||
/*
|
||||
* Signal properties and actions.
|
||||
* The array below categorizes the signals and their default actions
|
||||
* according to the following properties:
|
||||
*/
|
||||
#define SA_KILL 0x01 /* terminates process by default */
|
||||
#define SA_CORE 0x02 /* ditto and coredumps */
|
||||
#define SA_STOP 0x04 /* suspend process */
|
||||
#define SA_TTYSTOP 0x08 /* ditto, from tty */
|
||||
#define SA_IGNORE 0x10 /* ignore by default */
|
||||
#define SA_CONT 0x20 /* continue if suspended */
|
||||
#define SA_KILL 0x01 /* terminates process by default */
|
||||
#define SA_CORE 0x02 /* ditto and coredumps */
|
||||
#define SA_STOP 0x04 /* suspend process */
|
||||
#define SA_TTYSTOP 0x08 /* ditto, from tty */
|
||||
#define SA_IGNORE 0x10 /* ignore by default */
|
||||
#define SA_CONT 0x20 /* continue if suspended */
|
||||
|
||||
#ifdef SIGPROP
|
||||
#ifdef SIGPROP
|
||||
const char sigprop [NSIG + 1] = {
|
||||
0, /* unused */
|
||||
SA_KILL, /* SIGHUP */
|
||||
SA_KILL, /* SIGINT */
|
||||
SA_KILL | SA_CORE, /* SIGQUIT */
|
||||
SA_KILL | SA_CORE, /* SIGILL */
|
||||
SA_KILL | SA_CORE, /* SIGTRAP */
|
||||
SA_KILL | SA_CORE, /* SIGABRT */
|
||||
SA_KILL | SA_CORE, /* SIGEMT */
|
||||
SA_KILL | SA_CORE, /* SIGFPE */
|
||||
SA_KILL, /* SIGKILL */
|
||||
SA_KILL | SA_CORE, /* SIGBUS */
|
||||
SA_KILL | SA_CORE, /* SIGSEGV */
|
||||
SA_KILL | SA_CORE, /* SIGSYS */
|
||||
SA_KILL, /* SIGPIPE */
|
||||
SA_KILL, /* SIGALRM */
|
||||
SA_KILL, /* SIGTERM */
|
||||
SA_IGNORE, /* SIGURG */
|
||||
SA_STOP, /* SIGSTOP */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTSTP */
|
||||
SA_IGNORE | SA_CONT, /* SIGCONT */
|
||||
SA_IGNORE, /* SIGCHLD */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTTIN */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTTOU */
|
||||
SA_IGNORE, /* SIGIO */
|
||||
SA_KILL, /* SIGXCPU */
|
||||
SA_KILL, /* SIGXFSZ */
|
||||
SA_KILL, /* SIGVTALRM */
|
||||
SA_KILL, /* SIGPROF */
|
||||
SA_IGNORE, /* SIGWINCH */
|
||||
SA_IGNORE, /* SIGINFO */
|
||||
SA_KILL, /* SIGUSR1 */
|
||||
SA_KILL, /* SIGUSR2 */
|
||||
0, /* unused */
|
||||
SA_KILL, /* SIGHUP */
|
||||
SA_KILL, /* SIGINT */
|
||||
SA_KILL | SA_CORE, /* SIGQUIT */
|
||||
SA_KILL | SA_CORE, /* SIGILL */
|
||||
SA_KILL | SA_CORE, /* SIGTRAP */
|
||||
SA_KILL | SA_CORE, /* SIGABRT */
|
||||
SA_KILL | SA_CORE, /* SIGEMT */
|
||||
SA_KILL | SA_CORE, /* SIGFPE */
|
||||
SA_KILL, /* SIGKILL */
|
||||
SA_KILL | SA_CORE, /* SIGBUS */
|
||||
SA_KILL | SA_CORE, /* SIGSEGV */
|
||||
SA_KILL | SA_CORE, /* SIGSYS */
|
||||
SA_KILL, /* SIGPIPE */
|
||||
SA_KILL, /* SIGALRM */
|
||||
SA_KILL, /* SIGTERM */
|
||||
SA_IGNORE, /* SIGURG */
|
||||
SA_STOP, /* SIGSTOP */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTSTP */
|
||||
SA_IGNORE | SA_CONT, /* SIGCONT */
|
||||
SA_IGNORE, /* SIGCHLD */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTTIN */
|
||||
SA_STOP | SA_TTYSTOP, /* SIGTTOU */
|
||||
SA_IGNORE, /* SIGIO */
|
||||
SA_KILL, /* SIGXCPU */
|
||||
SA_KILL, /* SIGXFSZ */
|
||||
SA_KILL, /* SIGVTALRM */
|
||||
SA_KILL, /* SIGPROF */
|
||||
SA_IGNORE, /* SIGWINCH */
|
||||
SA_IGNORE, /* SIGINFO */
|
||||
SA_KILL, /* SIGUSR1 */
|
||||
SA_KILL, /* SIGUSR2 */
|
||||
};
|
||||
#endif /* SIGPROP */
|
||||
|
||||
#ifdef KERNEL
|
||||
#define contsigmask (sigmask(SIGCONT))
|
||||
#define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
|
||||
sigmask(SIGTTIN) | sigmask(SIGTTOU))
|
||||
#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
|
||||
#ifdef KERNEL
|
||||
#define contsigmask (sigmask(SIGCONT))
|
||||
#define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
|
||||
sigmask(SIGTTIN) | sigmask(SIGTTOU))
|
||||
#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
|
||||
#endif
|
||||
#endif /* !_SYS_SIGNALVAR_H_ */
|
||||
#endif /* !_SYS_SIGNALVAR_H_ */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/*
|
||||
* Ioctl definitions for SPI driver.
|
||||
*/
|
||||
#ifndef _SPI_H
|
||||
#ifndef _SPI_H
|
||||
#define _SPI_H
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
@@ -20,17 +20,17 @@
|
||||
#define SPICTL_IO16(n) _ION('p', 4, n) /* transfer n*16 bits */
|
||||
#define SPICTL_IO32(n) _ION('p', 5, n) /* transfer n*32 bits */
|
||||
|
||||
#define SPICTL_IO8R(n) _ION('p', 6, n) /* transfer R n*8 bits */
|
||||
#define SPICTL_IO16R(n) _ION('p', 7, n) /* transfer R n*16 bits */
|
||||
#define SPICTL_IO32R(n) _ION('p', 8, n) /* transfer R n*32 bits */
|
||||
#define SPICTL_IO8R(n) _ION('p', 6, n) /* transfer R n*8 bits */
|
||||
#define SPICTL_IO16R(n) _ION('p', 7, n) /* transfer R n*16 bits */
|
||||
#define SPICTL_IO32R(n) _ION('p', 8, n) /* transfer R n*32 bits */
|
||||
|
||||
#define SPICTL_IO8W(n) _ION('p', 9, n) /* transfer W n*8 bits */
|
||||
#define SPICTL_IO16W(n) _ION('p', 10, n) /* transfer W n*16 bits */
|
||||
#define SPICTL_IO32W(n) _ION('p', 11, n) /* transfer W n*32 bits */
|
||||
#define SPICTL_IO8W(n) _ION('p', 9, n) /* transfer W n*8 bits */
|
||||
#define SPICTL_IO16W(n) _ION('p', 10, n) /* transfer W n*16 bits */
|
||||
#define SPICTL_IO32W(n) _ION('p', 11, n) /* transfer W n*32 bits */
|
||||
|
||||
#define SPICTL_IO32B(n) _ION('p', 12, n) /* transfer BE n*32 bits */
|
||||
#define SPICTL_IO32RB(n) _ION('p', 13, n) /* transfer RBE n*32 bits */
|
||||
#define SPICTL_IO32WB(n) _ION('p', 14, n) /* transfer WBE n*32 bits */
|
||||
#define SPICTL_IO32B(n) _ION('p', 12, n) /* transfer BE n*32 bits */
|
||||
#define SPICTL_IO32RB(n) _ION('p', 13, n) /* transfer RBE n*32 bits */
|
||||
#define SPICTL_IO32WB(n) _ION('p', 14, n) /* transfer WBE n*32 bits */
|
||||
|
||||
#ifdef KERNEL
|
||||
#include "conf.h"
|
||||
|
||||
@@ -4,30 +4,30 @@
|
||||
#ifdef KERNEL
|
||||
|
||||
struct spireg {
|
||||
volatile unsigned con; /* Control */
|
||||
volatile unsigned con; /* Control */
|
||||
volatile unsigned conclr;
|
||||
volatile unsigned conset;
|
||||
volatile unsigned coninv;
|
||||
volatile unsigned stat; /* Status */
|
||||
volatile unsigned stat; /* Status */
|
||||
volatile unsigned statclr;
|
||||
volatile unsigned statset;
|
||||
volatile unsigned statinv;
|
||||
volatile unsigned buf; /* Transmit and receive buffer */
|
||||
volatile unsigned buf; /* Transmit and receive buffer */
|
||||
volatile unsigned unused1;
|
||||
volatile unsigned unused2;
|
||||
volatile unsigned unused3;
|
||||
volatile unsigned brg; /* Baud rate generator */
|
||||
volatile unsigned brg; /* Baud rate generator */
|
||||
volatile unsigned brgclr;
|
||||
volatile unsigned brgset;
|
||||
volatile unsigned brginv;
|
||||
};
|
||||
|
||||
struct spi_dev {
|
||||
struct spireg *bus;
|
||||
unsigned int *cs_tris;
|
||||
unsigned int cs_pin;
|
||||
unsigned int baud;
|
||||
unsigned int mode;
|
||||
struct spireg *bus;
|
||||
unsigned int *cs_tris;
|
||||
unsigned int cs_pin;
|
||||
unsigned int baud;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
extern int spi_open(unsigned int bus, unsigned int *tris, unsigned int pin);
|
||||
|
||||
@@ -3,70 +3,70 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
#ifndef _STAT_H_
|
||||
#define _STAT_H_
|
||||
#ifndef _STAT_H_
|
||||
#define _STAT_H_
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
struct stat
|
||||
struct stat
|
||||
{
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
u_int st_mode;
|
||||
int st_nlink;
|
||||
uid_t st_uid;
|
||||
gid_t st_gid;
|
||||
dev_t st_rdev;
|
||||
off_t st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
long st_blksize;
|
||||
long st_blocks;
|
||||
u_int st_flags;
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
u_int st_mode;
|
||||
int st_nlink;
|
||||
uid_t st_uid;
|
||||
gid_t st_gid;
|
||||
dev_t st_rdev;
|
||||
off_t st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
long st_blksize;
|
||||
long st_blocks;
|
||||
u_int st_flags;
|
||||
};
|
||||
|
||||
#define S_IFMT 0170000 /* type of file */
|
||||
#define S_IFDIR 0040000 /* directory */
|
||||
#define S_IFCHR 0020000 /* character special */
|
||||
#define S_IFBLK 0060000 /* block special */
|
||||
#define S_IFREG 0100000 /* regular */
|
||||
#define S_IFLNK 0120000 /* symbolic link */
|
||||
#define S_IFSOCK 0140000/* socket */
|
||||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#define S_ISGID 0002000 /* set group id on execution */
|
||||
#define S_ISVTX 0001000 /* save swapped text even after use */
|
||||
#define S_IREAD 0000400 /* read permission, owner */
|
||||
#define S_IWRITE 0000200 /* write permission, owner */
|
||||
#define S_IEXEC 0000100 /* execute/search permission, owner */
|
||||
#define S_IFMT 0170000 /* type of file */
|
||||
#define S_IFDIR 0040000 /* directory */
|
||||
#define S_IFCHR 0020000 /* character special */
|
||||
#define S_IFBLK 0060000 /* block special */
|
||||
#define S_IFREG 0100000 /* regular */
|
||||
#define S_IFLNK 0120000 /* symbolic link */
|
||||
#define S_IFSOCK 0140000 /* socket */
|
||||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#define S_ISGID 0002000 /* set group id on execution */
|
||||
#define S_ISVTX 0001000 /* save swapped text even after use */
|
||||
#define S_IREAD 0000400 /* read permission, owner */
|
||||
#define S_IWRITE 0000200 /* write permission, owner */
|
||||
#define S_IEXEC 0000100 /* execute/search permission, owner */
|
||||
|
||||
/*
|
||||
* Definitions of flags in mode that are 4.4 compatible.
|
||||
*/
|
||||
|
||||
#define S_IFIFO 0010000 /* named pipe (fifo) - Not used by 2.11BSD */
|
||||
#define S_IFIFO 0010000 /* named pipe (fifo) - Not used by 2.11BSD */
|
||||
|
||||
#define S_IRWXU 0000700 /* RWX mask for owner */
|
||||
#define S_IRUSR 0000400 /* R for owner */
|
||||
#define S_IWUSR 0000200 /* W for owner */
|
||||
#define S_IXUSR 0000100 /* X for owner */
|
||||
#define S_IRWXU 0000700 /* RWX mask for owner */
|
||||
#define S_IRUSR 0000400 /* R for owner */
|
||||
#define S_IWUSR 0000200 /* W for owner */
|
||||
#define S_IXUSR 0000100 /* X for owner */
|
||||
|
||||
#define S_IRWXG 0000070 /* RWX mask for group */
|
||||
#define S_IRGRP 0000040 /* R for group */
|
||||
#define S_IWGRP 0000020 /* W for group */
|
||||
#define S_IXGRP 0000010 /* X for group */
|
||||
#define S_IRWXG 0000070 /* RWX mask for group */
|
||||
#define S_IRGRP 0000040 /* R for group */
|
||||
#define S_IWGRP 0000020 /* W for group */
|
||||
#define S_IXGRP 0000010 /* X for group */
|
||||
|
||||
#define S_IRWXO 0000007 /* RWX mask for other */
|
||||
#define S_IROTH 0000004 /* R for other */
|
||||
#define S_IWOTH 0000002 /* W for other */
|
||||
#define S_IXOTH 0000001 /* X for other */
|
||||
#define S_IRWXO 0000007 /* RWX mask for other */
|
||||
#define S_IROTH 0000004 /* R for other */
|
||||
#define S_IWOTH 0000002 /* W for other */
|
||||
#define S_IXOTH 0000001 /* X for other */
|
||||
|
||||
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* directory */
|
||||
#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* character special */
|
||||
#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* block special */
|
||||
#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* regular */
|
||||
#define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) /* symbolic link */
|
||||
#define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) /* socket */
|
||||
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* directory */
|
||||
#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* character special */
|
||||
#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* block special */
|
||||
#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* regular */
|
||||
#define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) /* symbolic link */
|
||||
#define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) /* socket */
|
||||
|
||||
/*
|
||||
* Definitions of flags stored in file flags word. Different from 4.4 because
|
||||
@@ -76,24 +76,24 @@ struct stat
|
||||
*
|
||||
* Super-user and owner changeable flags.
|
||||
*/
|
||||
#define UF_SETTABLE 0x00ff /* mask of owner changeable flags */
|
||||
#define UF_NODUMP 0x0001 /* do not dump file */
|
||||
#define UF_IMMUTABLE 0x0002 /* file may not be changed */
|
||||
#define UF_APPEND 0x0004 /* writes to file may only append */
|
||||
#define UF_SETTABLE 0x00ff /* mask of owner changeable flags */
|
||||
#define UF_NODUMP 0x0001 /* do not dump file */
|
||||
#define UF_IMMUTABLE 0x0002 /* file may not be changed */
|
||||
#define UF_APPEND 0x0004 /* writes to file may only append */
|
||||
/*
|
||||
* Super-user changeable flags.
|
||||
*/
|
||||
#define SF_SETTABLE 0xff00 /* mask of superuser changeable flags */
|
||||
#define SF_ARCHIVED 0x0100 /* file is archived */
|
||||
#define SF_IMMUTABLE 0x0200 /* file may not be changed */
|
||||
#define SF_APPEND 0x0400 /* writes to file may only append */
|
||||
#define SF_SETTABLE 0xff00 /* mask of superuser changeable flags */
|
||||
#define SF_ARCHIVED 0x0100 /* file is archived */
|
||||
#define SF_IMMUTABLE 0x0200 /* file may not be changed */
|
||||
#define SF_APPEND 0x0400 /* writes to file may only append */
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
* Shorthand abbreviations of above.
|
||||
*/
|
||||
#define APPEND (UF_APPEND | SF_APPEND)
|
||||
#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
|
||||
#define APPEND (UF_APPEND | SF_APPEND)
|
||||
#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
|
||||
#else
|
||||
|
||||
int chmod (const char *path, mode_t mode);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Mike Karels at Berkeley Software Design, Inc.
|
||||
@@ -15,8 +15,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _SYS_SYSCTL_H_
|
||||
#define _SYS_SYSCTL_H_
|
||||
#define _SYS_SYSCTL_H_
|
||||
|
||||
/*
|
||||
* These are for the eproc, etext, einode, efile and map structures.
|
||||
@@ -58,7 +58,7 @@
|
||||
* respective subsystem header files.
|
||||
*/
|
||||
|
||||
#define CTL_MAXNAME 12 /* largest number of components supported */
|
||||
#define CTL_MAXNAME 12 /* largest number of components supported */
|
||||
|
||||
/*
|
||||
* Each subsystem defined by sysctl defines a list of variables
|
||||
@@ -68,219 +68,219 @@
|
||||
* pairs to be used by sysctl(1) in manipulating the subsystem.
|
||||
*/
|
||||
struct ctlname {
|
||||
char *ctl_name; /* subsystem name */
|
||||
int ctl_type; /* type of name */
|
||||
char *ctl_name; /* subsystem name */
|
||||
int ctl_type; /* type of name */
|
||||
};
|
||||
#define CTLTYPE_NODE 1 /* name is a node */
|
||||
#define CTLTYPE_INT 2 /* name describes a 16-bit integer */
|
||||
#define CTLTYPE_STRING 3 /* name describes a string */
|
||||
#define CTLTYPE_LONG 4 /* name describes a 32-bit number */
|
||||
#define CTLTYPE_STRUCT 5 /* name describes a structure */
|
||||
#define CTLTYPE_NODE 1 /* name is a node */
|
||||
#define CTLTYPE_INT 2 /* name describes a 16-bit integer */
|
||||
#define CTLTYPE_STRING 3 /* name describes a string */
|
||||
#define CTLTYPE_LONG 4 /* name describes a 32-bit number */
|
||||
#define CTLTYPE_STRUCT 5 /* name describes a structure */
|
||||
|
||||
/*
|
||||
* Top-level identifiers
|
||||
*/
|
||||
#define CTL_UNSPEC 0 /* unused */
|
||||
#define CTL_KERN 1 /* "high kernel": proc, limits */
|
||||
#define CTL_VM 2 /* virtual memory */
|
||||
#define CTL_FS 3 /* file system, mount type is next */
|
||||
#define CTL_NET 4 /* network, see socket.h */
|
||||
#define CTL_DEBUG 5 /* debugging parameters */
|
||||
#define CTL_HW 6 /* generic cpu/io */
|
||||
#define CTL_MACHDEP 7 /* machine dependent */
|
||||
#define CTL_USER 8 /* user-level */
|
||||
#define CTL_MAXID 9 /* number of valid top-level ids */
|
||||
#define CTL_UNSPEC 0 /* unused */
|
||||
#define CTL_KERN 1 /* "high kernel": proc, limits */
|
||||
#define CTL_VM 2 /* virtual memory */
|
||||
#define CTL_FS 3 /* file system, mount type is next */
|
||||
#define CTL_NET 4 /* network, see socket.h */
|
||||
#define CTL_DEBUG 5 /* debugging parameters */
|
||||
#define CTL_HW 6 /* generic cpu/io */
|
||||
#define CTL_MACHDEP 7 /* machine dependent */
|
||||
#define CTL_USER 8 /* user-level */
|
||||
#define CTL_MAXID 9 /* number of valid top-level ids */
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
#define CTL_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "kern", CTLTYPE_NODE }, \
|
||||
{ "vm", CTLTYPE_NODE }, \
|
||||
{ "fs", CTLTYPE_NODE }, \
|
||||
{ "net", CTLTYPE_NODE }, \
|
||||
{ "debug", CTLTYPE_NODE }, \
|
||||
{ "hw", CTLTYPE_NODE }, \
|
||||
{ "machdep", CTLTYPE_NODE }, \
|
||||
{ "user", CTLTYPE_NODE }, \
|
||||
{ 0, 0 }, \
|
||||
{ "kern", CTLTYPE_NODE }, \
|
||||
{ "vm", CTLTYPE_NODE }, \
|
||||
{ "fs", CTLTYPE_NODE }, \
|
||||
{ "net", CTLTYPE_NODE }, \
|
||||
{ "debug", CTLTYPE_NODE }, \
|
||||
{ "hw", CTLTYPE_NODE }, \
|
||||
{ "machdep", CTLTYPE_NODE }, \
|
||||
{ "user", CTLTYPE_NODE }, \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CTL_KERN identifiers
|
||||
*/
|
||||
#define KERN_OSTYPE 1 /* string: system version */
|
||||
#define KERN_OSRELEASE 2 /* string: system release */
|
||||
#define KERN_OSREV 3 /* int: system revision */
|
||||
#define KERN_VERSION 4 /* string: compile time info */
|
||||
#define KERN_MAXINODES 5 /* int: max inodes */
|
||||
#define KERN_MAXPROC 6 /* int: max processes */
|
||||
#define KERN_MAXFILES 7 /* int: max open files */
|
||||
#define KERN_ARGMAX 8 /* int: max arguments to exec */
|
||||
#define KERN_SECURELVL 9 /* int: system security level */
|
||||
#define KERN_HOSTNAME 10 /* string: hostname */
|
||||
#define KERN_HOSTID 11 /* int: host identifier */
|
||||
#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
|
||||
#define KERN_INODE 13 /* struct: inode structures */
|
||||
#define KERN_PROC 14 /* struct: process entries */
|
||||
#define KERN_FILE 15 /* struct: file entries */
|
||||
#define KERN_PROF 16 /* node: kernel profiling info */
|
||||
#define KERN_POSIX1 17 /* int: POSIX.1 version */
|
||||
#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
|
||||
#define KERN_JOB_CONTROL 19 /* int: is job control available */
|
||||
#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
|
||||
#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
|
||||
#define KERN_MAXTEXTS 22 /* int: # of text entries */
|
||||
#define KERN_TEXT 23 /* struct: text entries */
|
||||
#define KERN_ACCTTHRESH 24 /* int: accounting daemon threshold */
|
||||
#define KERN_MAXID 25 /* number of valid kern ids */
|
||||
#define KERN_OSTYPE 1 /* string: system version */
|
||||
#define KERN_OSRELEASE 2 /* string: system release */
|
||||
#define KERN_OSREV 3 /* int: system revision */
|
||||
#define KERN_VERSION 4 /* string: compile time info */
|
||||
#define KERN_MAXINODES 5 /* int: max inodes */
|
||||
#define KERN_MAXPROC 6 /* int: max processes */
|
||||
#define KERN_MAXFILES 7 /* int: max open files */
|
||||
#define KERN_ARGMAX 8 /* int: max arguments to exec */
|
||||
#define KERN_SECURELVL 9 /* int: system security level */
|
||||
#define KERN_HOSTNAME 10 /* string: hostname */
|
||||
#define KERN_HOSTID 11 /* int: host identifier */
|
||||
#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
|
||||
#define KERN_INODE 13 /* struct: inode structures */
|
||||
#define KERN_PROC 14 /* struct: process entries */
|
||||
#define KERN_FILE 15 /* struct: file entries */
|
||||
#define KERN_PROF 16 /* node: kernel profiling info */
|
||||
#define KERN_POSIX1 17 /* int: POSIX.1 version */
|
||||
#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
|
||||
#define KERN_JOB_CONTROL 19 /* int: is job control available */
|
||||
#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
|
||||
#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
|
||||
#define KERN_MAXTEXTS 22 /* int: # of text entries */
|
||||
#define KERN_TEXT 23 /* struct: text entries */
|
||||
#define KERN_ACCTTHRESH 24 /* int: accounting daemon threshold */
|
||||
#define KERN_MAXID 25 /* number of valid kern ids */
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
#define CTL_KERN_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "ostype", CTLTYPE_STRING }, \
|
||||
{ "osrelease", CTLTYPE_STRING }, \
|
||||
{ "osrevision", CTLTYPE_LONG }, \
|
||||
{ "version", CTLTYPE_STRING }, \
|
||||
{ "maxinodes", CTLTYPE_INT }, \
|
||||
{ "maxproc", CTLTYPE_INT }, \
|
||||
{ "maxfiles", CTLTYPE_INT }, \
|
||||
{ "argmax", CTLTYPE_INT }, \
|
||||
{ "securelevel", CTLTYPE_INT }, \
|
||||
{ "hostname", CTLTYPE_STRING }, \
|
||||
{ "hostid", CTLTYPE_LONG }, \
|
||||
{ "clockrate", CTLTYPE_STRUCT }, \
|
||||
{ "inode", CTLTYPE_STRUCT }, \
|
||||
{ "proc", CTLTYPE_STRUCT }, \
|
||||
{ "file", CTLTYPE_STRUCT }, \
|
||||
{ "profiling", CTLTYPE_NODE }, \
|
||||
{ "posix1version", CTLTYPE_INT }, \
|
||||
{ "ngroups", CTLTYPE_INT }, \
|
||||
{ "job_control", CTLTYPE_INT }, \
|
||||
{ "saved_ids", CTLTYPE_INT }, \
|
||||
{ "boottime", CTLTYPE_STRUCT }, \
|
||||
{ "maxtexts", CTLTYPE_INT }, \
|
||||
{ "text", CTLTYPE_STRUCT }, \
|
||||
{ "acctthresh", CTLTYPE_INT }, \
|
||||
{ 0, 0 }, \
|
||||
{ "ostype", CTLTYPE_STRING }, \
|
||||
{ "osrelease", CTLTYPE_STRING }, \
|
||||
{ "osrevision", CTLTYPE_LONG }, \
|
||||
{ "version", CTLTYPE_STRING }, \
|
||||
{ "maxinodes", CTLTYPE_INT }, \
|
||||
{ "maxproc", CTLTYPE_INT }, \
|
||||
{ "maxfiles", CTLTYPE_INT }, \
|
||||
{ "argmax", CTLTYPE_INT }, \
|
||||
{ "securelevel", CTLTYPE_INT }, \
|
||||
{ "hostname", CTLTYPE_STRING }, \
|
||||
{ "hostid", CTLTYPE_LONG }, \
|
||||
{ "clockrate", CTLTYPE_STRUCT }, \
|
||||
{ "inode", CTLTYPE_STRUCT }, \
|
||||
{ "proc", CTLTYPE_STRUCT }, \
|
||||
{ "file", CTLTYPE_STRUCT }, \
|
||||
{ "profiling", CTLTYPE_NODE }, \
|
||||
{ "posix1version", CTLTYPE_INT }, \
|
||||
{ "ngroups", CTLTYPE_INT }, \
|
||||
{ "job_control", CTLTYPE_INT }, \
|
||||
{ "saved_ids", CTLTYPE_INT }, \
|
||||
{ "boottime", CTLTYPE_STRUCT }, \
|
||||
{ "maxtexts", CTLTYPE_INT }, \
|
||||
{ "text", CTLTYPE_STRUCT }, \
|
||||
{ "acctthresh", CTLTYPE_INT }, \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* KERN_PROC subtypes
|
||||
*/
|
||||
#define KERN_PROC_ALL 0 /* everything */
|
||||
#define KERN_PROC_PID 1 /* by process id */
|
||||
#define KERN_PROC_PGRP 2 /* by process group id */
|
||||
#define KERN_PROC_SESSION 3 /* by session of pid - NOT IN 2.11 */
|
||||
#define KERN_PROC_TTY 4 /* by controlling tty */
|
||||
#define KERN_PROC_UID 5 /* by effective uid */
|
||||
#define KERN_PROC_RUID 6 /* by real uid */
|
||||
#define KERN_PROC_ALL 0 /* everything */
|
||||
#define KERN_PROC_PID 1 /* by process id */
|
||||
#define KERN_PROC_PGRP 2 /* by process group id */
|
||||
#define KERN_PROC_SESSION 3 /* by session of pid - NOT IN 2.11 */
|
||||
#define KERN_PROC_TTY 4 /* by controlling tty */
|
||||
#define KERN_PROC_UID 5 /* by effective uid */
|
||||
#define KERN_PROC_RUID 6 /* by real uid */
|
||||
|
||||
/*
|
||||
* KERN_PROC subtype ops return arrays of augmented proc structures:
|
||||
*/
|
||||
struct kinfo_proc {
|
||||
struct proc kp_proc; /* proc structure */
|
||||
struct eproc {
|
||||
struct proc *e_paddr; /* address of proc */
|
||||
dev_t e_tdev; /* controlling tty dev */
|
||||
pid_t e_tpgid; /* tty process group id */
|
||||
uid_t e_ruid; /* real uid */
|
||||
} kp_eproc;
|
||||
struct proc kp_proc; /* proc structure */
|
||||
struct eproc {
|
||||
struct proc *e_paddr; /* address of proc */
|
||||
dev_t e_tdev; /* controlling tty dev */
|
||||
pid_t e_tpgid; /* tty process group id */
|
||||
uid_t e_ruid; /* real uid */
|
||||
} kp_eproc;
|
||||
};
|
||||
|
||||
/*
|
||||
* KERN_INODE returns an array of augmented inode structures:
|
||||
*/
|
||||
struct kinfo_inode {
|
||||
struct inode *kp_inodep; /* address of inode */
|
||||
struct inode kp_inode; /* inode structure */
|
||||
struct kinfo_inode {
|
||||
struct inode *kp_inodep; /* address of inode */
|
||||
struct inode kp_inode; /* inode structure */
|
||||
};
|
||||
|
||||
/*
|
||||
* KERN_FILE returns an array of augmented file structures:
|
||||
*/
|
||||
struct kinfo_file {
|
||||
struct file *kp_filep; /* address of file */
|
||||
struct file kp_file; /* file structure */
|
||||
struct kinfo_file {
|
||||
struct file *kp_filep; /* address of file */
|
||||
struct file kp_file; /* file structure */
|
||||
};
|
||||
|
||||
/*
|
||||
* CTL_HW identifiers
|
||||
*/
|
||||
#define HW_MACHINE 1 /* string: machine class */
|
||||
#define HW_MODEL 2 /* string: specific machine model */
|
||||
#define HW_NCPU 3 /* int: number of cpus */
|
||||
#define HW_BYTEORDER 4 /* int: machine byte order */
|
||||
#define HW_PHYSMEM 5 /* int: total memory */
|
||||
#define HW_USERMEM 6 /* int: non-kernel memory */
|
||||
#define HW_PAGESIZE 7 /* int: software page size */
|
||||
#define HW_DISKNAMES 8 /* strings: disk drive names */
|
||||
#define HW_DISKSTATS 9 /* struct: diskstats[] */
|
||||
#define HW_MAXID 10 /* number of valid hw ids */
|
||||
#define HW_MACHINE 1 /* string: machine class */
|
||||
#define HW_MODEL 2 /* string: specific machine model */
|
||||
#define HW_NCPU 3 /* int: number of cpus */
|
||||
#define HW_BYTEORDER 4 /* int: machine byte order */
|
||||
#define HW_PHYSMEM 5 /* int: total memory */
|
||||
#define HW_USERMEM 6 /* int: non-kernel memory */
|
||||
#define HW_PAGESIZE 7 /* int: software page size */
|
||||
#define HW_DISKNAMES 8 /* strings: disk drive names */
|
||||
#define HW_DISKSTATS 9 /* struct: diskstats[] */
|
||||
#define HW_MAXID 10 /* number of valid hw ids */
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
#define CTL_HW_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "machine", CTLTYPE_STRING }, \
|
||||
{ "model", CTLTYPE_STRING }, \
|
||||
{ "ncpu", CTLTYPE_INT }, \
|
||||
{ "byteorder", CTLTYPE_INT }, \
|
||||
{ "physmem", CTLTYPE_LONG }, \
|
||||
{ "usermem", CTLTYPE_LONG }, \
|
||||
{ "pagesize", CTLTYPE_INT }, \
|
||||
{ "disknames", CTLTYPE_STRUCT }, \
|
||||
{ "diskstats", CTLTYPE_STRUCT }, \
|
||||
{ 0, 0 }, \
|
||||
{ "machine", CTLTYPE_STRING }, \
|
||||
{ "model", CTLTYPE_STRING }, \
|
||||
{ "ncpu", CTLTYPE_INT }, \
|
||||
{ "byteorder", CTLTYPE_INT }, \
|
||||
{ "physmem", CTLTYPE_LONG }, \
|
||||
{ "usermem", CTLTYPE_LONG }, \
|
||||
{ "pagesize", CTLTYPE_INT }, \
|
||||
{ "disknames", CTLTYPE_STRUCT }, \
|
||||
{ "diskstats", CTLTYPE_STRUCT }, \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
/*
|
||||
* CTL_USER definitions
|
||||
*/
|
||||
#define USER_CS_PATH 1 /* string: _CS_PATH */
|
||||
#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
|
||||
#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
|
||||
#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
|
||||
#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
|
||||
#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
|
||||
#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
|
||||
#define USER_LINE_MAX 8 /* int: LINE_MAX */
|
||||
#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
|
||||
#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
|
||||
#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
|
||||
#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
|
||||
#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
|
||||
#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
|
||||
#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
|
||||
#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
|
||||
#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
|
||||
#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
|
||||
#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
|
||||
#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
|
||||
#define USER_MAXID 21 /* number of valid user ids */
|
||||
#define USER_CS_PATH 1 /* string: _CS_PATH */
|
||||
#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
|
||||
#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
|
||||
#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
|
||||
#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
|
||||
#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
|
||||
#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
|
||||
#define USER_LINE_MAX 8 /* int: LINE_MAX */
|
||||
#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
|
||||
#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
|
||||
#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
|
||||
#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
|
||||
#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
|
||||
#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
|
||||
#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
|
||||
#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
|
||||
#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
|
||||
#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
|
||||
#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
|
||||
#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
|
||||
#define USER_MAXID 21 /* number of valid user ids */
|
||||
|
||||
#define CTL_USER_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "cs_path", CTLTYPE_STRING }, \
|
||||
{ "bc_base_max", CTLTYPE_INT }, \
|
||||
{ "bc_dim_max", CTLTYPE_INT }, \
|
||||
{ "bc_scale_max", CTLTYPE_INT }, \
|
||||
{ "bc_string_max", CTLTYPE_INT }, \
|
||||
{ "coll_weights_max", CTLTYPE_INT }, \
|
||||
{ "expr_nest_max", CTLTYPE_INT }, \
|
||||
{ "line_max", CTLTYPE_INT }, \
|
||||
{ "re_dup_max", CTLTYPE_INT }, \
|
||||
{ "posix2_version", CTLTYPE_INT }, \
|
||||
{ "posix2_c_bind", CTLTYPE_INT }, \
|
||||
{ "posix2_c_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_char_term", CTLTYPE_INT }, \
|
||||
{ "posix2_fort_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_fort_run", CTLTYPE_INT }, \
|
||||
{ "posix2_localedef", CTLTYPE_INT }, \
|
||||
{ "posix2_sw_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_upe", CTLTYPE_INT }, \
|
||||
{ "stream_max", CTLTYPE_INT }, \
|
||||
{ "tzname_max", CTLTYPE_INT }, \
|
||||
#define CTL_USER_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "cs_path", CTLTYPE_STRING }, \
|
||||
{ "bc_base_max", CTLTYPE_INT }, \
|
||||
{ "bc_dim_max", CTLTYPE_INT }, \
|
||||
{ "bc_scale_max", CTLTYPE_INT }, \
|
||||
{ "bc_string_max", CTLTYPE_INT }, \
|
||||
{ "coll_weights_max", CTLTYPE_INT }, \
|
||||
{ "expr_nest_max", CTLTYPE_INT }, \
|
||||
{ "line_max", CTLTYPE_INT }, \
|
||||
{ "re_dup_max", CTLTYPE_INT }, \
|
||||
{ "posix2_version", CTLTYPE_INT }, \
|
||||
{ "posix2_c_bind", CTLTYPE_INT }, \
|
||||
{ "posix2_c_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_char_term", CTLTYPE_INT }, \
|
||||
{ "posix2_fort_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_fort_run", CTLTYPE_INT }, \
|
||||
{ "posix2_localedef", CTLTYPE_INT }, \
|
||||
{ "posix2_sw_dev", CTLTYPE_INT }, \
|
||||
{ "posix2_upe", CTLTYPE_INT }, \
|
||||
{ "stream_max", CTLTYPE_INT }, \
|
||||
{ "tzname_max", CTLTYPE_INT }, \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -290,22 +290,22 @@ struct kinfo_file {
|
||||
* Second level identifier specifies which debug variable.
|
||||
* Third level identifier specifies which stucture component.
|
||||
*/
|
||||
#define CTL_DEBUG_NAME 0 /* string: variable name */
|
||||
#define CTL_DEBUG_VALUE 1 /* int: variable value */
|
||||
#define CTL_DEBUG_MAXID 20
|
||||
#define CTL_DEBUG_NAME 0 /* string: variable name */
|
||||
#define CTL_DEBUG_VALUE 1 /* int: variable value */
|
||||
#define CTL_DEBUG_MAXID 20
|
||||
|
||||
/*
|
||||
* Locking and stats
|
||||
*/
|
||||
struct sysctl_lock {
|
||||
int sl_lock;
|
||||
int sl_want;
|
||||
int sl_locked;
|
||||
int sl_lock;
|
||||
int sl_want;
|
||||
int sl_locked;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
#ifdef KERNEL
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* CTL_DEBUG variables.
|
||||
*
|
||||
@@ -319,34 +319,34 @@ struct sysctl_lock {
|
||||
* entered into the array.
|
||||
*/
|
||||
struct ctldebug {
|
||||
char *debugname; /* name of debugging variable */
|
||||
int *debugvar; /* pointer to debugging variable */
|
||||
char *debugname; /* name of debugging variable */
|
||||
int *debugvar; /* pointer to debugging variable */
|
||||
};
|
||||
extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
|
||||
extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
|
||||
extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
|
||||
extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
|
||||
#endif /* DEBUG */
|
||||
#endif /* DEBUG */
|
||||
|
||||
struct sysctl_lock memlock;
|
||||
|
||||
/*
|
||||
* Internal sysctl function calling convention:
|
||||
*
|
||||
* (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
|
||||
* (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
|
||||
*
|
||||
* The name parameter points at the next component of the name to be
|
||||
* interpreted. The namelen parameter is the number of integers in
|
||||
* the name.
|
||||
*/
|
||||
typedef int (sysctlfn) (int *name, u_int namelen,
|
||||
void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
||||
void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
||||
|
||||
/*
|
||||
* Get old / set new parameters for an integer value.
|
||||
*/
|
||||
int sysctl_int (void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen, int *valp);
|
||||
void *newp, size_t newlen, int *valp);
|
||||
|
||||
/*
|
||||
* As above, but read-only.
|
||||
@@ -357,7 +357,7 @@ int sysctl_rdint (void *oldp, size_t *oldlenp, void *newp, int val);
|
||||
* Get old / set new parameters for an long value.
|
||||
*/
|
||||
int sysctl_long (void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen, long *valp);
|
||||
void *newp, size_t newlen, long *valp);
|
||||
|
||||
/*
|
||||
* As above, but read-only.
|
||||
@@ -365,10 +365,10 @@ int sysctl_long (void *oldp, size_t *oldlenp,
|
||||
int sysctl_rdlong (void *oldp, size_t *oldlenp, void *newp, long val);
|
||||
|
||||
/*
|
||||
* Get old / set new parameters for a string value.
|
||||
* Get old / set new parameters for a string value.
|
||||
*/
|
||||
int sysctl_string (void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen, char *str, int maxlen);
|
||||
void *newp, size_t newlen, char *str, int maxlen);
|
||||
|
||||
/*
|
||||
* As above, but read-only.
|
||||
@@ -379,15 +379,15 @@ int sysctl_rdstring (void *oldp, size_t *oldlenp, void *newp, const char *str);
|
||||
* Get old parameters for a structure.
|
||||
*/
|
||||
int sysctl_rdstruct (void *oldp, size_t *oldlenp,
|
||||
void *newp, void *sp, int len);
|
||||
void *newp, void *sp, int len);
|
||||
|
||||
#else /* !KERNEL */
|
||||
#else /* !KERNEL */
|
||||
|
||||
int sysctl (int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen);
|
||||
void *newp, size_t newlen);
|
||||
|
||||
int __sysctl (int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen);
|
||||
void *newp, size_t newlen);
|
||||
|
||||
#endif /* KERNEL */
|
||||
#endif /* !_SYS_SYSCTL_H_ */
|
||||
#endif /* KERNEL */
|
||||
#endif /* !_SYS_SYSCTL_H_ */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -12,8 +12,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -30,14 +30,14 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)syslog.h 8.1.2 (2.11BSD) 1999/06/18
|
||||
* @(#)syslog.h 8.1.2 (2.11BSD) 1999/06/18
|
||||
* $Id: syslog.h,v 1.4 1994/08/21 04:42:00 paul Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSLOG_H_
|
||||
#define _SYS_SYSLOG_H_
|
||||
|
||||
#define _PATH_LOG "/dev/log"
|
||||
#define _PATH_LOG "/dev/log"
|
||||
|
||||
/*
|
||||
* priorities/facilities are encoded into a single 16-bit quantity, where the
|
||||
@@ -48,101 +48,101 @@
|
||||
*
|
||||
* priorities (these are ordered)
|
||||
*/
|
||||
#define LOG_EMERG 0 /* system is unusable */
|
||||
#define LOG_ALERT 1 /* action must be taken immediately */
|
||||
#define LOG_CRIT 2 /* critical conditions */
|
||||
#define LOG_ERR 3 /* error conditions */
|
||||
#define LOG_WARNING 4 /* warning conditions */
|
||||
#define LOG_NOTICE 5 /* normal but significant condition */
|
||||
#define LOG_INFO 6 /* informational */
|
||||
#define LOG_DEBUG 7 /* debug-level messages */
|
||||
#define LOG_EMERG 0 /* system is unusable */
|
||||
#define LOG_ALERT 1 /* action must be taken immediately */
|
||||
#define LOG_CRIT 2 /* critical conditions */
|
||||
#define LOG_ERR 3 /* error conditions */
|
||||
#define LOG_WARNING 4 /* warning conditions */
|
||||
#define LOG_NOTICE 5 /* normal but significant condition */
|
||||
#define LOG_INFO 6 /* informational */
|
||||
#define LOG_DEBUG 7 /* debug-level messages */
|
||||
|
||||
#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
||||
/* extract priority */
|
||||
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
|
||||
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
|
||||
#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
||||
/* extract priority */
|
||||
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
|
||||
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
|
||||
|
||||
#ifdef SYSLOG_NAMES
|
||||
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
|
||||
/* mark "facility" */
|
||||
#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0)
|
||||
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
|
||||
/* mark "facility" */
|
||||
#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0)
|
||||
typedef struct _code {
|
||||
char *c_name;
|
||||
int c_val;
|
||||
char *c_name;
|
||||
int c_val;
|
||||
} CODE;
|
||||
|
||||
CODE prioritynames[] = {
|
||||
"alert", LOG_ALERT,
|
||||
"crit", LOG_CRIT,
|
||||
"debug", LOG_DEBUG,
|
||||
"emerg", LOG_EMERG,
|
||||
"err", LOG_ERR,
|
||||
"info", LOG_INFO,
|
||||
"none", INTERNAL_NOPRI, /* INTERNAL */
|
||||
"notice", LOG_NOTICE,
|
||||
"warning", LOG_WARNING,
|
||||
NULL, -1,
|
||||
"alert", LOG_ALERT,
|
||||
"crit", LOG_CRIT,
|
||||
"debug", LOG_DEBUG,
|
||||
"emerg", LOG_EMERG,
|
||||
"err", LOG_ERR,
|
||||
"info", LOG_INFO,
|
||||
"none", INTERNAL_NOPRI, /* INTERNAL */
|
||||
"notice", LOG_NOTICE,
|
||||
"warning", LOG_WARNING,
|
||||
NULL, -1,
|
||||
};
|
||||
#endif
|
||||
|
||||
/* facility codes */
|
||||
#define LOG_KERN (0<<3) /* kernel messages */
|
||||
#define LOG_USER (1<<3) /* random user-level messages */
|
||||
#define LOG_MAIL (2<<3) /* mail system */
|
||||
#define LOG_DAEMON (3<<3) /* system daemons */
|
||||
#define LOG_AUTH (4<<3) /* security/authorization messages */
|
||||
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
|
||||
#define LOG_LPR (6<<3) /* line printer subsystem */
|
||||
#define LOG_NEWS (7<<3) /* network news subsystem */
|
||||
#define LOG_UUCP (8<<3) /* UUCP subsystem */
|
||||
#define LOG_CRON (9<<3) /* clock daemon */
|
||||
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
|
||||
#define LOG_FTP (11<<3) /* ftp daemon */
|
||||
#define LOG_KERN (0<<3) /* kernel messages */
|
||||
#define LOG_USER (1<<3) /* random user-level messages */
|
||||
#define LOG_MAIL (2<<3) /* mail system */
|
||||
#define LOG_DAEMON (3<<3) /* system daemons */
|
||||
#define LOG_AUTH (4<<3) /* security/authorization messages */
|
||||
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
|
||||
#define LOG_LPR (6<<3) /* line printer subsystem */
|
||||
#define LOG_NEWS (7<<3) /* network news subsystem */
|
||||
#define LOG_UUCP (8<<3) /* UUCP subsystem */
|
||||
#define LOG_CRON (9<<3) /* clock daemon */
|
||||
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
|
||||
#define LOG_FTP (11<<3) /* ftp daemon */
|
||||
|
||||
/* other codes through 15 reserved for system use */
|
||||
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL3 (19<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL4 (20<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL5 (21<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL6 (22<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL7 (23<<3) /* reserved for local use */
|
||||
/* other codes through 15 reserved for system use */
|
||||
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL3 (19<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL4 (20<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL5 (21<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL6 (22<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL7 (23<<3) /* reserved for local use */
|
||||
|
||||
#define LOG_NFACILITIES 24 /* current number of facilities */
|
||||
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
|
||||
/* facility of pri */
|
||||
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
|
||||
#define LOG_NFACILITIES 24 /* current number of facilities */
|
||||
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
|
||||
/* facility of pri */
|
||||
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
|
||||
|
||||
#ifdef SYSLOG_NAMES
|
||||
CODE facilitynames[] = {
|
||||
"auth", LOG_AUTH,
|
||||
"authpriv", LOG_AUTHPRIV,
|
||||
"cron", LOG_CRON,
|
||||
"daemon", LOG_DAEMON,
|
||||
"ftp", LOG_FTP,
|
||||
"kern", LOG_KERN,
|
||||
"lpr", LOG_LPR,
|
||||
"mail", LOG_MAIL,
|
||||
"mark", INTERNAL_MARK, /* INTERNAL */
|
||||
"news", LOG_NEWS,
|
||||
"syslog", LOG_SYSLOG,
|
||||
"user", LOG_USER,
|
||||
"uucp", LOG_UUCP,
|
||||
"local0", LOG_LOCAL0,
|
||||
"local1", LOG_LOCAL1,
|
||||
"local2", LOG_LOCAL2,
|
||||
"local3", LOG_LOCAL3,
|
||||
"local4", LOG_LOCAL4,
|
||||
"local5", LOG_LOCAL5,
|
||||
"local6", LOG_LOCAL6,
|
||||
"local7", LOG_LOCAL7,
|
||||
NULL, -1,
|
||||
"auth", LOG_AUTH,
|
||||
"authpriv", LOG_AUTHPRIV,
|
||||
"cron", LOG_CRON,
|
||||
"daemon", LOG_DAEMON,
|
||||
"ftp", LOG_FTP,
|
||||
"kern", LOG_KERN,
|
||||
"lpr", LOG_LPR,
|
||||
"mail", LOG_MAIL,
|
||||
"mark", INTERNAL_MARK, /* INTERNAL */
|
||||
"news", LOG_NEWS,
|
||||
"syslog", LOG_SYSLOG,
|
||||
"user", LOG_USER,
|
||||
"uucp", LOG_UUCP,
|
||||
"local0", LOG_LOCAL0,
|
||||
"local1", LOG_LOCAL1,
|
||||
"local2", LOG_LOCAL2,
|
||||
"local3", LOG_LOCAL3,
|
||||
"local4", LOG_LOCAL4,
|
||||
"local5", LOG_LOCAL5,
|
||||
"local6", LOG_LOCAL6,
|
||||
"local7", LOG_LOCAL7,
|
||||
NULL, -1,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL
|
||||
#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
|
||||
#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
|
||||
#else
|
||||
void syslog (int pri, const char *fmt, ...);
|
||||
void openlog (const char *ident, int logstat, int logfac);
|
||||
@@ -152,8 +152,8 @@ void closelog (void);
|
||||
/*
|
||||
* arguments to setlogmask.
|
||||
*/
|
||||
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
|
||||
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
|
||||
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
|
||||
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
|
||||
|
||||
/*
|
||||
* Option flags for openlog.
|
||||
@@ -161,11 +161,11 @@ void closelog (void);
|
||||
* LOG_ODELAY no longer does anything.
|
||||
* LOG_NDELAY is the inverse of what it used to be.
|
||||
*/
|
||||
#define LOG_PID 0x01 /* log the pid with each message */
|
||||
#define LOG_CONS 0x02 /* log on the console if errors in sending */
|
||||
#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
|
||||
#define LOG_NDELAY 0x08 /* don't delay open */
|
||||
#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
|
||||
#define LOG_PERROR 0x20 /* log to stderr as well */
|
||||
#define LOG_PID 0x01 /* log the pid with each message */
|
||||
#define LOG_CONS 0x02 /* log on the console if errors in sending */
|
||||
#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
|
||||
#define LOG_NDELAY 0x08 /* don't delay open */
|
||||
#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
|
||||
#define LOG_PERROR 0x20 /* log to stderr as well */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
* It can only be decreased by process 1 (/sbin/init).
|
||||
*
|
||||
* Security levels are as follows:
|
||||
* -1 permannently insecure mode - always run system in level 0 mode.
|
||||
* 0 insecure mode - immutable and append-only flags make be turned off.
|
||||
* All devices may be read or written subject to permission modes.
|
||||
* 1 secure mode - immutable and append-only flags may not be changed;
|
||||
* raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
|
||||
* read-only.
|
||||
* 2 highly secure mode - same as (1) plus raw disks are always
|
||||
* read-only whether mounted or not. This level precludes tampering
|
||||
* with filesystems by unmounting them, but also inhibits running
|
||||
* newfs while the system is secured.
|
||||
* -1 permannently insecure mode - always run system in level 0 mode.
|
||||
* 0 insecure mode - immutable and append-only flags make be turned off.
|
||||
* All devices may be read or written subject to permission modes.
|
||||
* 1 secure mode - immutable and append-only flags may not be changed;
|
||||
* raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
|
||||
* read-only.
|
||||
* 2 highly secure mode - same as (1) plus raw disks are always
|
||||
* read-only whether mounted or not. This level precludes tampering
|
||||
* with filesystems by unmounting them, but also inhibits running
|
||||
* newfs while the system is secured.
|
||||
*
|
||||
* In normal operation, the system runs in level 0 mode while single user
|
||||
* and in level 1 mode while multiuser. If level 2 mode is desired while
|
||||
@@ -32,9 +32,10 @@
|
||||
* patched by a stalking hacker.
|
||||
*/
|
||||
#include "conf.h"
|
||||
extern int securelevel; /* system security level */
|
||||
|
||||
extern const char version[]; /* system version */
|
||||
extern int securelevel; /* system security level */
|
||||
|
||||
extern const char version[]; /* system version */
|
||||
|
||||
/*
|
||||
* Nblkdev is the number of entries (rows) in the block switch.
|
||||
@@ -52,23 +53,23 @@ extern const int nchrdev;
|
||||
*/
|
||||
extern const int nsysent;
|
||||
|
||||
extern int mpid; /* generic for unique process id's */
|
||||
extern char runin; /* scheduling flag */
|
||||
extern char runout; /* scheduling flag */
|
||||
extern int runrun; /* scheduling flag */
|
||||
extern char curpri; /* more scheduling */
|
||||
extern int mpid; /* generic for unique process id's */
|
||||
extern char runin; /* scheduling flag */
|
||||
extern char runout; /* scheduling flag */
|
||||
extern int runrun; /* scheduling flag */
|
||||
extern char curpri; /* more scheduling */
|
||||
|
||||
extern u_int swapstart, nswap; /* start and size of swap space */
|
||||
extern int updlock; /* lock for sync */
|
||||
extern daddr_t rablock; /* block to be read ahead */
|
||||
extern dev_t rootdev; /* device of the root */
|
||||
extern dev_t dumpdev; /* device to take dumps on */
|
||||
extern long dumplo; /* offset into dumpdev */
|
||||
extern dev_t swapdev; /* swapping device */
|
||||
extern dev_t pipedev; /* pipe device */
|
||||
extern u_int swapstart, nswap; /* start and size of swap space */
|
||||
extern int updlock; /* lock for sync */
|
||||
extern daddr_t rablock; /* block to be read ahead */
|
||||
extern dev_t rootdev; /* device of the root */
|
||||
extern dev_t dumpdev; /* device to take dumps on */
|
||||
extern long dumplo; /* offset into dumpdev */
|
||||
extern dev_t swapdev; /* swapping device */
|
||||
extern dev_t pipedev; /* pipe device */
|
||||
|
||||
extern const char icode[]; /* user init code */
|
||||
extern const char icodeend[]; /* its end */
|
||||
extern const char icode[]; /* user init code */
|
||||
extern const char icodeend[]; /* its end */
|
||||
|
||||
struct inode;
|
||||
daddr_t bmap (struct inode *ip, daddr_t bn, int rwflg, int flags);
|
||||
@@ -80,26 +81,26 @@ extern void kmemdev();
|
||||
*/
|
||||
extern const struct sysent
|
||||
{
|
||||
int sy_narg; /* total number of arguments */
|
||||
void (*sy_call) (void); /* handler */
|
||||
int sy_narg; /* total number of arguments */
|
||||
void (*sy_call) (void); /* handler */
|
||||
} sysent[];
|
||||
|
||||
extern const char *syscallnames[];
|
||||
|
||||
extern int noproc; /* no one is running just now */
|
||||
extern char *panicstr;
|
||||
extern int boothowto; /* reboot flags, from boot */
|
||||
extern int selwait;
|
||||
extern size_t physmem; /* total amount of physical memory */
|
||||
extern int noproc; /* no one is running just now */
|
||||
extern char *panicstr;
|
||||
extern int boothowto; /* reboot flags, from boot */
|
||||
extern int selwait;
|
||||
extern size_t physmem; /* total amount of physical memory */
|
||||
|
||||
extern dev_t get_cdev_by_name(char *);
|
||||
extern char *cdevname(dev_t dev);
|
||||
|
||||
void panic (char *msg);
|
||||
void printf (char *fmt, ...);
|
||||
void uprintf (char *fmt, ...); /* print to the current user's terminal */
|
||||
void uprintf (char *fmt, ...); /* print to the current user's terminal */
|
||||
struct tty;
|
||||
void tprintf (struct tty *tp, char *fmt, ...); /* print to the specified terminal */
|
||||
void tprintf (struct tty *tp, char *fmt, ...); /* print to the specified terminal */
|
||||
int loginit (void);
|
||||
void log (int level, char *fmt, ...);
|
||||
int logwrt (char *buf, int len, int log);
|
||||
@@ -109,8 +110,8 @@ void cninit (void);
|
||||
void cnidentify (void);
|
||||
void cnputc (char c);
|
||||
int cngetc (void);
|
||||
int baduaddr (caddr_t addr); /* detect bad user address */
|
||||
int badkaddr (caddr_t addr); /* detect bad kernel address */
|
||||
int baduaddr (caddr_t addr); /* detect bad user address */
|
||||
int badkaddr (caddr_t addr); /* detect bad kernel address */
|
||||
|
||||
int strncmp (const char *s1, const char *s2, size_t n);
|
||||
void bzero (void *s, size_t nbytes);
|
||||
@@ -118,14 +119,14 @@ void bcopy (const void *src, void *dest, size_t nbytes);
|
||||
int bcmp (const void *a, const void *b, size_t nbytes);
|
||||
int copystr (caddr_t src, caddr_t dest, u_int maxlen, u_int *copied);
|
||||
size_t strlen (const char *s);
|
||||
int ffs (u_long i); /* find the index of the lsb set bit */
|
||||
int ffs (u_long i); /* find the index of the lsb set bit */
|
||||
void insque (void *element, void *pred);
|
||||
void remque (void *element);
|
||||
|
||||
void startup (void); /* machine-dependent startup code */
|
||||
int chrtoblk (dev_t dev); /* convert from character to block device number */
|
||||
int isdisk (dev_t dev, int type); /* determine if a device is a disk */
|
||||
int iskmemdev (dev_t dev); /* identify /dev/mem and /dev/kmem */
|
||||
void startup (void); /* machine-dependent startup code */
|
||||
int chrtoblk (dev_t dev); /* convert from character to block device number */
|
||||
int isdisk (dev_t dev, int type); /* determine if a device is a disk */
|
||||
int iskmemdev (dev_t dev); /* identify /dev/mem and /dev/kmem */
|
||||
void boot (dev_t dev, int howto);
|
||||
|
||||
/*
|
||||
@@ -165,69 +166,69 @@ void coutinit (void);
|
||||
/*
|
||||
* Syscalls.
|
||||
*/
|
||||
void nosys (void);
|
||||
void nosys (void);
|
||||
|
||||
/* 1.1 processes and protection */
|
||||
void getpid (void);
|
||||
void getppid (void), fork (void), rexit (void), execv (void), execve (void);
|
||||
void wait4 (void), getuid (void), getgid (void), getgroups (void), setgroups (void);
|
||||
void geteuid (void), getegid (void);
|
||||
void getpgrp (void), setpgrp (void);
|
||||
void setgid (void), setegid (void), setuid (void), seteuid (void);
|
||||
void ucall (void); /* 2BSD calls */
|
||||
void getpid (void);
|
||||
void getppid (void), fork (void), rexit (void), execv (void), execve (void);
|
||||
void wait4 (void), getuid (void), getgid (void), getgroups (void), setgroups (void);
|
||||
void geteuid (void), getegid (void);
|
||||
void getpgrp (void), setpgrp (void);
|
||||
void setgid (void), setegid (void), setuid (void), seteuid (void);
|
||||
void ucall (void); /* 2BSD calls */
|
||||
|
||||
/* 1.2 memory management */
|
||||
void brk (void);
|
||||
void ustore (void); /* 2BSD calls */
|
||||
void ufetch (void); /* 2BSD calls */
|
||||
void brk (void);
|
||||
void ustore (void); /* 2BSD calls */
|
||||
void ufetch (void); /* 2BSD calls */
|
||||
|
||||
/* 1.3 signals */
|
||||
void sigstack (void), sigreturn (void);
|
||||
void sigaction (void), sigprocmask (void), sigpending (void), sigaltstack (void), sigsuspend (void);
|
||||
void sigwait (void), kill (void), killpg (void);
|
||||
void sigstack (void), sigreturn (void);
|
||||
void sigaction (void), sigprocmask (void), sigpending (void), sigaltstack (void), sigsuspend (void);
|
||||
void sigwait (void), kill (void), killpg (void);
|
||||
|
||||
/* 1.4 timing and statistics */
|
||||
void gettimeofday (void), settimeofday (void);
|
||||
void getitimer (void), setitimer (void);
|
||||
void adjtime (void);
|
||||
void gettimeofday (void), settimeofday (void);
|
||||
void getitimer (void), setitimer (void);
|
||||
void adjtime (void);
|
||||
|
||||
/* 1.5 descriptors */
|
||||
void getdtablesize (void), dup (void), dup2 (void), close (void);
|
||||
void pselect (void), select (void), fcntl (void), flock (void);
|
||||
void getdtablesize (void), dup (void), dup2 (void), close (void);
|
||||
void pselect (void), select (void), fcntl (void), flock (void);
|
||||
|
||||
/* 1.6 resource controls */
|
||||
void getpriority (void), setpriority (void), getrusage (void), getrlimit (void), setrlimit (void);
|
||||
void getpriority (void), setpriority (void), getrusage (void), getrlimit (void), setrlimit (void);
|
||||
|
||||
/* 1.7 system operation support */
|
||||
void umount (void), smount (void);
|
||||
void sync (void), reboot (void), __sysctl (void);
|
||||
void umount (void), smount (void);
|
||||
void sync (void), reboot (void), __sysctl (void);
|
||||
|
||||
/* 2.1 generic operations */
|
||||
void read (void), write (void), readv (void), writev (void), ioctl (void);
|
||||
void read (void), write (void), readv (void), writev (void), ioctl (void);
|
||||
|
||||
/* 2.2 file system */
|
||||
void chdir (void), fchdir (void), chroot (void);
|
||||
void mkdir (void), rmdir (void), chflags (void), fchflags (void);
|
||||
void open (void), mknod (void), unlink (void), stat (void), fstat (void), lstat (void);
|
||||
void chown (void), fchown (void), chmod (void), fchmod (void), utimes (void);
|
||||
void link (void), symlink (void), readlink (void), rename (void);
|
||||
void lseek (void), truncate (void), ftruncate (void), saccess (void), fsync (void);
|
||||
void statfs (void), fstatfs (void), getfsstat (void);
|
||||
void chdir (void), fchdir (void), chroot (void);
|
||||
void mkdir (void), rmdir (void), chflags (void), fchflags (void);
|
||||
void open (void), mknod (void), unlink (void), stat (void), fstat (void), lstat (void);
|
||||
void chown (void), fchown (void), chmod (void), fchmod (void), utimes (void);
|
||||
void link (void), symlink (void), readlink (void), rename (void);
|
||||
void lseek (void), truncate (void), ftruncate (void), saccess (void), fsync (void);
|
||||
void statfs (void), fstatfs (void), getfsstat (void);
|
||||
|
||||
/* 2.3 communications */
|
||||
void socket (void), bind (void), listen (void), accept (void), connect (void);
|
||||
void socketpair (void), sendto (void), send (void), recvfrom (void), recv (void);
|
||||
void sendmsg (void), recvmsg (void), shutdown (void), setsockopt (void), getsockopt (void);
|
||||
void getsockname (void), getpeername (void), pipe (void);
|
||||
void socket (void), bind (void), listen (void), accept (void), connect (void);
|
||||
void socketpair (void), sendto (void), send (void), recvfrom (void), recv (void);
|
||||
void sendmsg (void), recvmsg (void), shutdown (void), setsockopt (void), getsockopt (void);
|
||||
void getsockname (void), getpeername (void), pipe (void);
|
||||
|
||||
void umask (void); /* XXX */
|
||||
void umask (void); /* XXX */
|
||||
|
||||
/* 2.4 processes */
|
||||
void ptrace (void);
|
||||
void ptrace (void);
|
||||
|
||||
void profil (void); /* 'cuz sys calls are interruptible */
|
||||
void vhangup (void); /* should just do in exit (void) */
|
||||
void vfork (void); /* awaiting fork w/ copy on write */
|
||||
void profil (void); /* 'cuz sys calls are interruptible */
|
||||
void vhangup (void); /* should just do in exit (void) */
|
||||
void vfork (void); /* awaiting fork w/ copy on write */
|
||||
|
||||
/*
|
||||
* Drivers.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H_
|
||||
#define _SYS_TIME_H_
|
||||
#ifndef _SYS_TIME_H_
|
||||
#define _SYS_TIME_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* and used in other calls.
|
||||
*/
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -24,49 +24,50 @@ struct timeval {
|
||||
* same makes life simpler than changing the names.
|
||||
*/
|
||||
struct timespec {
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* and nanoseconds */
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* and nanoseconds */
|
||||
};
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
#define DST_NONE 0 /* not on dst */
|
||||
#define DST_USA 1 /* USA style dst */
|
||||
#define DST_AUST 2 /* Australian style dst */
|
||||
#define DST_WET 3 /* Western European dst */
|
||||
#define DST_MET 4 /* Middle European dst */
|
||||
#define DST_EET 5 /* Eastern European dst */
|
||||
#define DST_CAN 6 /* Canada */
|
||||
#define DST_NONE 0 /* not on dst */
|
||||
#define DST_USA 1 /* USA style dst */
|
||||
#define DST_AUST 2 /* Australian style dst */
|
||||
#define DST_WET 3 /* Western European dst */
|
||||
#define DST_MET 4 /* Middle European dst */
|
||||
#define DST_EET 5 /* Eastern European dst */
|
||||
#define DST_CAN 6 /* Canada */
|
||||
|
||||
/*
|
||||
* Operations on timevals.
|
||||
*
|
||||
* NB: timercmp does not work for >= or <=.
|
||||
*/
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
||||
(tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
||||
(tvp)->tv_sec == (uvp)->tv_sec && \
|
||||
(tvp)->tv_usec cmp (uvp)->tv_usec)
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||
|
||||
/*
|
||||
* Names of the interval timers, and structure
|
||||
* defining a timer setting.
|
||||
*/
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
struct k_itimerval {
|
||||
long it_interval; /* timer interval */
|
||||
long it_value; /* current value */
|
||||
struct k_itimerval {
|
||||
long it_interval; /* timer interval */
|
||||
long it_value; /* current value */
|
||||
};
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval; /* timer interval */
|
||||
struct timeval it_value; /* current value */
|
||||
struct itimerval {
|
||||
struct timeval it_interval; /* timer interval */
|
||||
struct timeval it_value; /* current value */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
@@ -93,7 +94,7 @@ int gettimeofday (struct timeval *tv, struct timezone *tz);
|
||||
int utimes (const char *filename, const struct timeval times[2]);
|
||||
int getitimer (int which, struct itimerval *curr_value);
|
||||
int setitimer (int which, const struct itimerval *new_value,
|
||||
struct itimerval *old_value);
|
||||
struct itimerval *old_value);
|
||||
int getpriority (int which, int who);
|
||||
int setpriority (int which, int who, int prio);
|
||||
char *tztab (int zone, int dst);
|
||||
@@ -104,11 +105,11 @@ char *tztab (int zone, int dst);
|
||||
* Getkerninfo clock information structure
|
||||
*/
|
||||
struct clockinfo {
|
||||
int hz; /* clock frequency */
|
||||
int tick; /* micro-seconds per hz tick */
|
||||
int stathz; /* statistics clock frequency */
|
||||
int profhz; /* profiling clock frequency */
|
||||
int hz; /* clock frequency */
|
||||
int tick; /* micro-seconds per hz tick */
|
||||
int stathz; /* statistics clock frequency */
|
||||
int profhz; /* profiling clock frequency */
|
||||
};
|
||||
|
||||
extern unsigned int msec();
|
||||
#endif /* !_SYS_TIME_H_ */
|
||||
#endif /* !_SYS_TIME_H_ */
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)times.h 7.1 (Berkeley) 6/4/86
|
||||
* @(#)times.h 7.1 (Berkeley) 6/4/86
|
||||
*/
|
||||
|
||||
/*
|
||||
* Structure returned by times()
|
||||
*/
|
||||
struct tms {
|
||||
time_t tms_utime; /* user time */
|
||||
time_t tms_stime; /* system time */
|
||||
time_t tms_cutime; /* user time, children */
|
||||
time_t tms_cstime; /* system time, children */
|
||||
time_t tms_utime; /* user time */
|
||||
time_t tms_stime; /* system time */
|
||||
time_t tms_cutime; /* user time, children */
|
||||
time_t tms_cstime; /* system time, children */
|
||||
};
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986 Regents of the University of California.
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File system buffer tracing points; all trace <pack(dev, size), bn>
|
||||
*
|
||||
* Slipped into 2.10 in about 15 minutes. Bears only a casual
|
||||
* relationship to the 4.X code, we just used the same names so
|
||||
* someone could do it right if they felt like it. Note that
|
||||
* the #defines aren't even sequentially numbered.
|
||||
*/
|
||||
#define TR_BREADHIT 0 /* buffer read found in cache */
|
||||
#define TR_BREADMISS 1 /* buffer read not in cache */
|
||||
#define TR_BWRITE 2 /* buffer written */
|
||||
#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */
|
||||
#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */
|
||||
#define TR_BRELSE 5 /* brelse */
|
||||
#define TR_SWAPIO 6 /* swap i/o request arrives */
|
||||
#define TR_NUM_210 7 /* size of array for 2.10BSD */
|
||||
|
||||
#define TR_XFODMISS 5 /* exe fod read */
|
||||
#define TR_XFODHIT 6 /* exe fod read */
|
||||
#define TR_BREALLOC 8 /* expand/contract a buffer */
|
||||
|
||||
/*
|
||||
* Memory allocator trace points; all trace the amount of memory involved
|
||||
*/
|
||||
#define TR_MALL 10 /* memory allocated */
|
||||
|
||||
/*
|
||||
* Paging trace points: all are <vaddr, pid>
|
||||
*/
|
||||
#define TR_INTRANS 20 /* page intransit block */
|
||||
#define TR_EINTRANS 21 /* page intransit wait done */
|
||||
#define TR_FRECLAIM 22 /* reclaim from free list */
|
||||
#define TR_RECLAIM 23 /* reclaim from loop */
|
||||
#define TR_XSFREC 24 /* reclaim from free list instead of drum */
|
||||
#define TR_XIFREC 25 /* reclaim from free list instead of fsys */
|
||||
#define TR_WAITMEM 26 /* wait for memory in pagein */
|
||||
#define TR_EWAITMEM 27 /* end memory wait in pagein */
|
||||
#define TR_ZFOD 28 /* zfod page fault */
|
||||
#define TR_EXFOD 29 /* exec fod page fault */
|
||||
#define TR_VRFOD 30 /* vread fod page fault */
|
||||
#define TR_CACHEFOD 31 /* fod in file system cache */
|
||||
#define TR_SWAPIN 32 /* drum page fault */
|
||||
#define TR_PGINDONE 33 /* page in done */
|
||||
|
||||
/*
|
||||
* System call trace points.
|
||||
*/
|
||||
#define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */
|
||||
|
||||
/*
|
||||
* This defines the size of the trace flags array.
|
||||
*/
|
||||
#define TR_NFLAGS 100 /* generous */
|
||||
|
||||
#define TRCSIZ 4096
|
||||
|
||||
/*
|
||||
* Specifications of the vtrace() system call, which takes one argument.
|
||||
*/
|
||||
#define VTRACE 64+51
|
||||
|
||||
#define VTR_DISABLE 0 /* set a trace flag to 0 */
|
||||
#define VTR_ENABLE 1 /* set a trace flag to 1 */
|
||||
#define VTR_VALUE 2 /* return value of a trace flag */
|
||||
#define VTR_UALARM 3 /* set alarm to go off (sig 16) */
|
||||
/* in specified number of hz */
|
||||
#define VTR_STAMP 4 /* user specified stamp */
|
||||
|
||||
#if defined(KERNEL) && defined(UCB_METER)
|
||||
u_long tracebuf[TR_NUM_210];
|
||||
#define trace(a) tracebuf[a]++;
|
||||
#else
|
||||
#define trace(a) ;
|
||||
#endif
|
||||
@@ -24,9 +24,9 @@
|
||||
* The routines in tty_subr.c manipulate these structures.
|
||||
*/
|
||||
struct clist {
|
||||
int c_cc; /* character count */
|
||||
char *c_cf; /* pointer to first char */
|
||||
char *c_cl; /* pointer to last char */
|
||||
int c_cc; /* character count */
|
||||
char *c_cf; /* pointer to first char */
|
||||
char *c_cl; /* pointer to last char */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -37,74 +37,74 @@ struct clist {
|
||||
* (low, high, timeout).
|
||||
*/
|
||||
struct tty {
|
||||
union {
|
||||
struct {
|
||||
struct clist T_rawq;
|
||||
struct clist T_canq;
|
||||
} t_t;
|
||||
#define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */
|
||||
#define t_canq t_nu.t_t.T_canq /* raw characters or partial line */
|
||||
struct {
|
||||
struct buf *T_bufp;
|
||||
char *T_cp;
|
||||
int T_inbuf;
|
||||
int T_rec;
|
||||
} t_n;
|
||||
#define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */
|
||||
#define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */
|
||||
#define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */
|
||||
#define t_rec t_nu.t_n.T_rec /* have a complete record */
|
||||
} t_nu;
|
||||
struct clist t_outq; /* device */
|
||||
void (*t_oproc) (struct tty*);
|
||||
struct proc *t_rsel; /* tty */
|
||||
struct proc *t_wsel;
|
||||
caddr_t T_LINEP; /* ### */
|
||||
caddr_t t_addr; /* ??? */
|
||||
dev_t t_dev; /* device */
|
||||
long t_flags; /* some of both */
|
||||
long t_state; /* some of both */
|
||||
int t_pgrp; /* tty */
|
||||
int t_delct; /* tty */
|
||||
int t_col; /* tty */
|
||||
int t_ispeed, t_ospeed; /* device */
|
||||
int t_rocount, t_rocol; /* tty */
|
||||
struct ttychars t_chars; /* tty */
|
||||
struct winsize t_winsize; /* window size */
|
||||
union {
|
||||
struct {
|
||||
struct clist T_rawq;
|
||||
struct clist T_canq;
|
||||
} t_t;
|
||||
#define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */
|
||||
#define t_canq t_nu.t_t.T_canq /* raw characters or partial line */
|
||||
struct {
|
||||
struct buf *T_bufp;
|
||||
char *T_cp;
|
||||
int T_inbuf;
|
||||
int T_rec;
|
||||
} t_n;
|
||||
#define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */
|
||||
#define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */
|
||||
#define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */
|
||||
#define t_rec t_nu.t_n.T_rec /* have a complete record */
|
||||
} t_nu;
|
||||
struct clist t_outq; /* device */
|
||||
void (*t_oproc) (struct tty*);
|
||||
struct proc *t_rsel; /* tty */
|
||||
struct proc *t_wsel;
|
||||
caddr_t T_LINEP; /* ### */
|
||||
caddr_t t_addr; /* ??? */
|
||||
dev_t t_dev; /* device */
|
||||
long t_flags; /* some of both */
|
||||
long t_state; /* some of both */
|
||||
int t_pgrp; /* tty */
|
||||
int t_delct; /* tty */
|
||||
int t_col; /* tty */
|
||||
int t_ispeed, t_ospeed; /* device */
|
||||
int t_rocount, t_rocol; /* tty */
|
||||
struct ttychars t_chars; /* tty */
|
||||
struct winsize t_winsize; /* window size */
|
||||
/* be careful of tchars & co. */
|
||||
#define t_erase t_chars.tc_erase
|
||||
#define t_kill t_chars.tc_kill
|
||||
#define t_intrc t_chars.tc_intrc
|
||||
#define t_quitc t_chars.tc_quitc
|
||||
#define t_startc t_chars.tc_startc
|
||||
#define t_stopc t_chars.tc_stopc
|
||||
#define t_eofc t_chars.tc_eofc
|
||||
#define t_brkc t_chars.tc_brkc
|
||||
#define t_suspc t_chars.tc_suspc
|
||||
#define t_dsuspc t_chars.tc_dsuspc
|
||||
#define t_rprntc t_chars.tc_rprntc
|
||||
#define t_flushc t_chars.tc_flushc
|
||||
#define t_werasc t_chars.tc_werasc
|
||||
#define t_lnextc t_chars.tc_lnextc
|
||||
#define t_erase t_chars.tc_erase
|
||||
#define t_kill t_chars.tc_kill
|
||||
#define t_intrc t_chars.tc_intrc
|
||||
#define t_quitc t_chars.tc_quitc
|
||||
#define t_startc t_chars.tc_startc
|
||||
#define t_stopc t_chars.tc_stopc
|
||||
#define t_eofc t_chars.tc_eofc
|
||||
#define t_brkc t_chars.tc_brkc
|
||||
#define t_suspc t_chars.tc_suspc
|
||||
#define t_dsuspc t_chars.tc_dsuspc
|
||||
#define t_rprntc t_chars.tc_rprntc
|
||||
#define t_flushc t_chars.tc_flushc
|
||||
#define t_werasc t_chars.tc_werasc
|
||||
#define t_lnextc t_chars.tc_lnextc
|
||||
};
|
||||
|
||||
#define TTIPRI 28
|
||||
#define TTOPRI 29
|
||||
#define TTIPRI 28
|
||||
#define TTOPRI 29
|
||||
|
||||
/* limits */
|
||||
#define NSPEEDS 29
|
||||
#define TTMASK 15
|
||||
#define OBUFSIZ 100
|
||||
#define NSPEEDS 29
|
||||
#define TTMASK 15
|
||||
#define OBUFSIZ 100
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
extern const int tthiwat[NSPEEDS], ttlowat[NSPEEDS];
|
||||
extern int q_to_b(register struct clist *q, char *cp, int cc);
|
||||
|
||||
#define TTHIWAT(tp) tthiwat[(tp)->t_ospeed&TTMASK]
|
||||
#define TTLOWAT(tp) ttlowat[(tp)->t_ospeed&TTMASK]
|
||||
#define TTHIWAT(tp) tthiwat[(tp)->t_ospeed&TTMASK]
|
||||
#define TTLOWAT(tp) ttlowat[(tp)->t_ospeed&TTMASK]
|
||||
|
||||
extern int nldisp; /* number of line disciplines */
|
||||
extern int nldisp; /* number of line disciplines */
|
||||
|
||||
/*
|
||||
* Set t_chars to default values.
|
||||
@@ -219,34 +219,34 @@ void ttywflush (struct tty *tp);
|
||||
#endif /* KERNEL */
|
||||
|
||||
/* internal state bits */
|
||||
#define TS_TIMEOUT 0x000001L /* delay timeout in progress */
|
||||
#define TS_WOPEN 0x000002L /* waiting for open to complete */
|
||||
#define TS_ISOPEN 0x000004L /* device is open */
|
||||
#define TS_FLUSH 0x000008L /* outq has been flushed during DMA */
|
||||
#define TS_CARR_ON 0x000010L /* software copy of carrier-present */
|
||||
#define TS_BUSY 0x000020L /* output in progress */
|
||||
#define TS_ASLEEP 0x000040L /* wakeup when output done */
|
||||
#define TS_XCLUDE 0x000080L /* exclusive-use flag against open */
|
||||
#define TS_TTSTOP 0x000100L /* output stopped by ctl-s */
|
||||
#define TS_HUPCLS 0x000200L /* hang up upon last close */
|
||||
#define TS_TBLOCK 0x000400L /* tandem queue blocked */
|
||||
#define TS_RCOLL 0x000800L /* collision in read select */
|
||||
#define TS_WCOLL 0x001000L /* collision in write select */
|
||||
#define TS_ASYNC 0x004000L /* tty in async i/o mode */
|
||||
#define TS_TIMEOUT 0x000001L /* delay timeout in progress */
|
||||
#define TS_WOPEN 0x000002L /* waiting for open to complete */
|
||||
#define TS_ISOPEN 0x000004L /* device is open */
|
||||
#define TS_FLUSH 0x000008L /* outq has been flushed during DMA */
|
||||
#define TS_CARR_ON 0x000010L /* software copy of carrier-present */
|
||||
#define TS_BUSY 0x000020L /* output in progress */
|
||||
#define TS_ASLEEP 0x000040L /* wakeup when output done */
|
||||
#define TS_XCLUDE 0x000080L /* exclusive-use flag against open */
|
||||
#define TS_TTSTOP 0x000100L /* output stopped by ctl-s */
|
||||
#define TS_HUPCLS 0x000200L /* hang up upon last close */
|
||||
#define TS_TBLOCK 0x000400L /* tandem queue blocked */
|
||||
#define TS_RCOLL 0x000800L /* collision in read select */
|
||||
#define TS_WCOLL 0x001000L /* collision in write select */
|
||||
#define TS_ASYNC 0x004000L /* tty in async i/o mode */
|
||||
/* state for intra-line fancy editing work */
|
||||
#define TS_ERASE 0x040000L /* within a \.../ for PRTRUB */
|
||||
#define TS_LNCH 0x080000L /* next character is literal */
|
||||
#define TS_TYPEN 0x100000L /* retyping suspended input (PENDIN) */
|
||||
#define TS_CNTTB 0x200000L /* counting tab width; leave FLUSHO alone */
|
||||
#define TS_ERASE 0x040000L /* within a \.../ for PRTRUB */
|
||||
#define TS_LNCH 0x080000L /* next character is literal */
|
||||
#define TS_TYPEN 0x100000L /* retyping suspended input (PENDIN) */
|
||||
#define TS_CNTTB 0x200000L /* counting tab width; leave FLUSHO alone */
|
||||
|
||||
#define TS_LOCAL (TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
|
||||
#define TS_LOCAL (TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
|
||||
|
||||
/* define partab character types */
|
||||
#define ORDINARY 0
|
||||
#define CONTROL 1
|
||||
#define BACKSPACE 2
|
||||
#define NEWLINE 3
|
||||
#define TAB 4
|
||||
#define VTAB 5
|
||||
#define RETURN 6
|
||||
#define ORDINARY 0
|
||||
#define CONTROL 1
|
||||
#define BACKSPACE 2
|
||||
#define NEWLINE 3
|
||||
#define TAB 4
|
||||
#define VTAB 5
|
||||
#define RETURN 6
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)ttychars.h 7.2 (2.11BSD) 1997/4/15
|
||||
* @(#)ttychars.h 7.2 (2.11BSD) 1997/4/15
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -11,42 +11,42 @@
|
||||
* related to terminal handling.
|
||||
*/
|
||||
#ifndef _TTYCHARS_
|
||||
#define _TTYCHARS_
|
||||
#define _TTYCHARS_
|
||||
struct ttychars {
|
||||
char tc_erase; /* erase last character */
|
||||
char tc_kill; /* erase entire line */
|
||||
char tc_intrc; /* interrupt */
|
||||
char tc_quitc; /* quit */
|
||||
char tc_startc; /* start output */
|
||||
char tc_stopc; /* stop output */
|
||||
char tc_eofc; /* end-of-file */
|
||||
char tc_brkc; /* input delimiter (like nl) */
|
||||
char tc_suspc; /* stop process signal */
|
||||
char tc_dsuspc; /* delayed stop process signal */
|
||||
char tc_rprntc; /* reprint line */
|
||||
char tc_flushc; /* flush output (toggles) */
|
||||
char tc_werasc; /* word erase */
|
||||
char tc_lnextc; /* literal next character */
|
||||
char tc_erase; /* erase last character */
|
||||
char tc_kill; /* erase entire line */
|
||||
char tc_intrc; /* interrupt */
|
||||
char tc_quitc; /* quit */
|
||||
char tc_startc; /* start output */
|
||||
char tc_stopc; /* stop output */
|
||||
char tc_eofc; /* end-of-file */
|
||||
char tc_brkc; /* input delimiter (like nl) */
|
||||
char tc_suspc; /* stop process signal */
|
||||
char tc_dsuspc; /* delayed stop process signal */
|
||||
char tc_rprntc; /* reprint line */
|
||||
char tc_flushc; /* flush output (toggles) */
|
||||
char tc_werasc; /* word erase */
|
||||
char tc_lnextc; /* literal next character */
|
||||
};
|
||||
|
||||
#define CTRL(c) (c & 037)
|
||||
#define _POSIX_VDISABLE ((unsigned char)'\377')
|
||||
#define CCEQ(val,c) (c == val ? val != _POSIX_VDISABLE : 0)
|
||||
#define CTRL(c) (c & 037)
|
||||
#define _POSIX_VDISABLE ((unsigned char)'\377')
|
||||
#define CCEQ(val,c) (c == val ? val != _POSIX_VDISABLE : 0)
|
||||
|
||||
/* default special characters */
|
||||
#define CERASE 0177
|
||||
#define CKILL CTRL('u')
|
||||
#define CINTR CTRL('c')
|
||||
#define CQUIT CTRL('\\')
|
||||
#define CSTART CTRL('q')
|
||||
#define CSTOP CTRL('s')
|
||||
#define CEOF CTRL('d')
|
||||
#define CEOT CEOF
|
||||
#define CBRK _POSIX_VDISABLE
|
||||
#define CSUSP CTRL('z')
|
||||
#define CDSUSP CTRL('y')
|
||||
#define CRPRNT CTRL('r')
|
||||
#define CFLUSH CTRL('o')
|
||||
#define CWERASE CTRL('w')
|
||||
#define CLNEXT CTRL('v')
|
||||
#define CERASE 0177
|
||||
#define CKILL CTRL('u')
|
||||
#define CINTR CTRL('c')
|
||||
#define CQUIT CTRL('\\')
|
||||
#define CSTART CTRL('q')
|
||||
#define CSTOP CTRL('s')
|
||||
#define CEOF CTRL('d')
|
||||
#define CEOT CEOF
|
||||
#define CBRK _POSIX_VDISABLE
|
||||
#define CSUSP CTRL('z')
|
||||
#define CDSUSP CTRL('y')
|
||||
#define CRPRNT CTRL('r')
|
||||
#define CFLUSH CTRL('o')
|
||||
#define CWERASE CTRL('w')
|
||||
#define CLNEXT CTRL('v')
|
||||
#endif /* _TTYCHARS_ */
|
||||
|
||||
@@ -3,55 +3,55 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)ttydev.h 7.1 (Berkeley) 6/4/86
|
||||
* @(#)ttydev.h 7.1 (Berkeley) 6/4/86
|
||||
*/
|
||||
|
||||
/*
|
||||
* Terminal definitions related to underlying hardware.
|
||||
*/
|
||||
#ifndef _TTYDEV_
|
||||
#define _TTYDEV_
|
||||
#define _TTYDEV_
|
||||
|
||||
/*
|
||||
* Speeds
|
||||
*/
|
||||
#define B0 0
|
||||
#define B50 1
|
||||
#define B75 2
|
||||
#define B150 3
|
||||
#define B200 4
|
||||
#define B300 5
|
||||
#define B600 6
|
||||
#define B1200 7
|
||||
#define B1800 8
|
||||
#define B2400 9
|
||||
#define B4800 10
|
||||
#define B9600 11
|
||||
#define B19200 12
|
||||
#define B38400 13
|
||||
#define B57600 14
|
||||
#define B115200 15
|
||||
#define B230400 16
|
||||
#define B460800 17
|
||||
#define B500000 18
|
||||
#define B576000 19
|
||||
#define B921600 20
|
||||
#define B1000000 21
|
||||
#define B1152000 22
|
||||
#define B1500000 23
|
||||
#define B2000000 24
|
||||
#define B2500000 25
|
||||
#define B3000000 26
|
||||
#define B3500000 27
|
||||
#define B4000000 28
|
||||
#define B0 0
|
||||
#define B50 1
|
||||
#define B75 2
|
||||
#define B150 3
|
||||
#define B200 4
|
||||
#define B300 5
|
||||
#define B600 6
|
||||
#define B1200 7
|
||||
#define B1800 8
|
||||
#define B2400 9
|
||||
#define B4800 10
|
||||
#define B9600 11
|
||||
#define B19200 12
|
||||
#define B38400 13
|
||||
#define B57600 14
|
||||
#define B115200 15
|
||||
#define B230400 16
|
||||
#define B460800 17
|
||||
#define B500000 18
|
||||
#define B576000 19
|
||||
#define B921600 20
|
||||
#define B1000000 21
|
||||
#define B1152000 22
|
||||
#define B1500000 23
|
||||
#define B2000000 24
|
||||
#define B2500000 25
|
||||
#define B3000000 26
|
||||
#define B3500000 27
|
||||
#define B4000000 28
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
* Modem control commands.
|
||||
*/
|
||||
#define DMSET 0
|
||||
#define DMBIS 1
|
||||
#define DMBIC 2
|
||||
#define DMGET 3
|
||||
#define DMSET 0
|
||||
#define DMBIS 1
|
||||
#define DMBIC 2
|
||||
#define DMGET 3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -5,43 +5,43 @@
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TYPES_H_
|
||||
#define _SYS_TYPES_H_
|
||||
#define _SYS_TYPES_H_
|
||||
|
||||
/*
|
||||
* Basic system types and major/minor device constructing/busting macros.
|
||||
*/
|
||||
|
||||
/* major part of a device */
|
||||
#define major(x) ((int)(((int)(x)>>8)&0377))
|
||||
#define major(x) ((int)(((int)(x)>>8)&0377))
|
||||
|
||||
/* minor part of a device */
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
|
||||
/* make a device number */
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long; /* see this! unsigned longs at last! */
|
||||
typedef unsigned short ushort; /* sys III compat */
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long; /* see this! unsigned longs at last! */
|
||||
typedef unsigned short ushort; /* sys III compat */
|
||||
|
||||
#ifdef pdp11
|
||||
typedef struct label_t {
|
||||
int val[7]; /* regs 2-7 and super SP */
|
||||
typedef struct label_t {
|
||||
int val[7]; /* regs 2-7 and super SP */
|
||||
} label_t;
|
||||
#endif
|
||||
#ifdef __mips__
|
||||
typedef struct label_t {
|
||||
unsigned val[12]; /* regs S0-S8, RA, GP and SP */
|
||||
typedef struct label_t {
|
||||
unsigned val[12]; /* regs S0-S8, RA, GP and SP */
|
||||
} label_t;
|
||||
#endif
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
typedef u_int ino_t;
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
typedef u_int ino_t;
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef u_int size_t;
|
||||
typedef u_int size_t;
|
||||
#endif
|
||||
#ifndef __ssize_t_defined
|
||||
#ifndef _SSIZE_T
|
||||
@@ -52,18 +52,18 @@ typedef int ssize_t;
|
||||
#endif
|
||||
#ifndef _TIME_T
|
||||
#define _TIME_T
|
||||
typedef long time_t;
|
||||
typedef long time_t;
|
||||
#endif
|
||||
typedef int dev_t;
|
||||
#ifndef _OFF_T
|
||||
#define _OFF_T
|
||||
typedef long off_t;
|
||||
typedef int dev_t;
|
||||
#ifndef _OFF_T
|
||||
#define _OFF_T
|
||||
typedef long off_t;
|
||||
#endif
|
||||
typedef u_int uid_t;
|
||||
typedef u_int gid_t;
|
||||
typedef int pid_t;
|
||||
typedef u_int mode_t;
|
||||
typedef int bool_t; /* boolean */
|
||||
typedef u_int uid_t;
|
||||
typedef u_int gid_t;
|
||||
typedef int pid_t;
|
||||
typedef u_int mode_t;
|
||||
typedef int bool_t; /* boolean */
|
||||
#define _PID_T
|
||||
#define _UID_T
|
||||
#define _GID_T
|
||||
@@ -72,10 +72,10 @@ typedef int bool_t; /* boolean */
|
||||
#define _TIME_T
|
||||
#define _MODE_T
|
||||
|
||||
#define NBBY 8 /* number of bits in a byte */
|
||||
#define NBBY 8 /* number of bits in a byte */
|
||||
|
||||
#ifndef howmany
|
||||
#define howmany(x, y) (((x)+((y)-1))/(y))
|
||||
#define howmany(x, y) (((x)+((y)-1))/(y))
|
||||
#endif
|
||||
|
||||
#include <sys/select.h>
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include "conf.h"
|
||||
|
||||
struct uart_irq {
|
||||
int er;
|
||||
int rx;
|
||||
int tx;
|
||||
int er;
|
||||
int rx;
|
||||
int tx;
|
||||
};
|
||||
|
||||
extern const struct uart_irq uirq[NUART];
|
||||
@@ -21,26 +21,26 @@ extern const struct uart_irq uirq[NUART];
|
||||
* PIC32 UART registers.
|
||||
*/
|
||||
struct uartreg {
|
||||
volatile unsigned mode; /* Mode */
|
||||
volatile unsigned modeclr;
|
||||
volatile unsigned modeset;
|
||||
volatile unsigned modeinv;
|
||||
volatile unsigned sta; /* Status and control */
|
||||
volatile unsigned staclr;
|
||||
volatile unsigned staset;
|
||||
volatile unsigned stainv;
|
||||
volatile unsigned txreg; /* Transmit */
|
||||
volatile unsigned unused1;
|
||||
volatile unsigned unused2;
|
||||
volatile unsigned unused3;
|
||||
volatile unsigned rxreg; /* Receive */
|
||||
volatile unsigned unused4;
|
||||
volatile unsigned unused5;
|
||||
volatile unsigned unused6;
|
||||
volatile unsigned brg; /* Baud rate */
|
||||
volatile unsigned brgclr;
|
||||
volatile unsigned brgset;
|
||||
volatile unsigned brginv;
|
||||
volatile unsigned mode; /* Mode */
|
||||
volatile unsigned modeclr;
|
||||
volatile unsigned modeset;
|
||||
volatile unsigned modeinv;
|
||||
volatile unsigned sta; /* Status and control */
|
||||
volatile unsigned staclr;
|
||||
volatile unsigned staset;
|
||||
volatile unsigned stainv;
|
||||
volatile unsigned txreg; /* Transmit */
|
||||
volatile unsigned unused1;
|
||||
volatile unsigned unused2;
|
||||
volatile unsigned unused3;
|
||||
volatile unsigned rxreg; /* Receive */
|
||||
volatile unsigned unused4;
|
||||
volatile unsigned unused5;
|
||||
volatile unsigned unused6;
|
||||
volatile unsigned brg; /* Baud rate */
|
||||
volatile unsigned brgclr;
|
||||
volatile unsigned brgset;
|
||||
volatile unsigned brginv;
|
||||
};
|
||||
|
||||
extern struct tty uartttys[NUART];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -12,8 +12,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UIO_H_
|
||||
#define _SYS_UIO_H_
|
||||
#define _SYS_UIO_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -45,18 +45,18 @@
|
||||
* iov_base should be a void *.
|
||||
*/
|
||||
struct iovec {
|
||||
char *iov_base; /* Base address. */
|
||||
size_t iov_len; /* Length. */
|
||||
char *iov_base; /* Base address. */
|
||||
size_t iov_len; /* Length. */
|
||||
};
|
||||
|
||||
enum uio_rw { UIO_READ, UIO_WRITE };
|
||||
enum uio_rw { UIO_READ, UIO_WRITE };
|
||||
|
||||
struct uio {
|
||||
struct iovec *uio_iov;
|
||||
int uio_iovcnt;
|
||||
off_t uio_offset;
|
||||
u_int uio_resid;
|
||||
enum uio_rw uio_rw;
|
||||
struct iovec *uio_iov;
|
||||
int uio_iovcnt;
|
||||
off_t uio_offset;
|
||||
u_int uio_resid;
|
||||
enum uio_rw uio_rw;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
@@ -21,89 +21,89 @@
|
||||
* 0x80007400; contains the system stack (and possibly network stack) per
|
||||
* user; is cross referenced with the proc structure for the same process.
|
||||
*/
|
||||
#define MAXCOMLEN MAXNAMLEN /* <= MAXNAMLEN, >= sizeof(ac_comm) */
|
||||
#define MAXCOMLEN MAXNAMLEN /* <= MAXNAMLEN, >= sizeof(ac_comm) */
|
||||
|
||||
struct user {
|
||||
struct proc *u_procp; /* pointer to proc structure */
|
||||
int *u_frame; /* address of users saved frame */
|
||||
char u_comm[MAXCOMLEN + 1]; /* command file name */
|
||||
label_t u_qsave; /* for non-local gotos on interrupts */
|
||||
label_t u_rsave; /* save info when exchanging stacks */
|
||||
label_t u_ssave; /* label variable for swapping */
|
||||
struct proc *u_procp; /* pointer to proc structure */
|
||||
int *u_frame; /* address of users saved frame */
|
||||
char u_comm[MAXCOMLEN + 1]; /* command file name */
|
||||
label_t u_qsave; /* for non-local gotos on interrupts */
|
||||
label_t u_rsave; /* save info when exchanging stacks */
|
||||
label_t u_ssave; /* label variable for swapping */
|
||||
|
||||
/* syscall parameters and results */
|
||||
int u_arg[6]; /* arguments to current system call */
|
||||
int u_rval; /* return value */
|
||||
int u_error; /* return error code */
|
||||
int u_arg[6]; /* arguments to current system call */
|
||||
int u_rval; /* return value */
|
||||
int u_error; /* return error code */
|
||||
|
||||
/* 1.1 - processes and protection */
|
||||
uid_t u_uid; /* effective user id */
|
||||
uid_t u_svuid; /* saved user id */
|
||||
uid_t u_ruid; /* real user id */
|
||||
gid_t u_svgid; /* saved group id */
|
||||
gid_t u_rgid; /* real group id */
|
||||
gid_t u_groups[NGROUPS]; /* groups, 0 terminated */
|
||||
uid_t u_uid; /* effective user id */
|
||||
uid_t u_svuid; /* saved user id */
|
||||
uid_t u_ruid; /* real user id */
|
||||
gid_t u_svgid; /* saved group id */
|
||||
gid_t u_rgid; /* real group id */
|
||||
gid_t u_groups[NGROUPS]; /* groups, 0 terminated */
|
||||
|
||||
/* 1.2 - memory management */
|
||||
size_t u_tsize; /* text size (clicks) */
|
||||
size_t u_dsize; /* data size (clicks) */
|
||||
size_t u_ssize; /* stack size (clicks) */
|
||||
size_t u_tsize; /* text size (clicks) */
|
||||
size_t u_dsize; /* data size (clicks) */
|
||||
size_t u_ssize; /* stack size (clicks) */
|
||||
|
||||
/* 1.3 - signal management */
|
||||
sig_t u_signal[NSIG]; /* disposition of signals */
|
||||
long u_sigmask[NSIG]; /* signals to be blocked */
|
||||
long u_sigonstack; /* signals to take on sigstack */
|
||||
long u_sigintr; /* signals that interrupt syscalls */
|
||||
long u_oldmask; /* saved mask from before sigpause */
|
||||
int u_code; /* ``code'' to trap */
|
||||
int u_psflags; /* Process Signal flags */
|
||||
struct sigaltstack u_sigstk; /* signal stack info */
|
||||
u_int u_sigtramp; /* pointer to trampoline code in user space */
|
||||
sig_t u_signal[NSIG]; /* disposition of signals */
|
||||
long u_sigmask[NSIG]; /* signals to be blocked */
|
||||
long u_sigonstack; /* signals to take on sigstack */
|
||||
long u_sigintr; /* signals that interrupt syscalls */
|
||||
long u_oldmask; /* saved mask from before sigpause */
|
||||
int u_code; /* ``code'' to trap */
|
||||
int u_psflags; /* Process Signal flags */
|
||||
struct sigaltstack u_sigstk; /* signal stack info */
|
||||
u_int u_sigtramp; /* pointer to trampoline code in user space */
|
||||
|
||||
/* 1.4 - descriptor management */
|
||||
struct file *u_ofile[NOFILE]; /* file structures for open files */
|
||||
char u_pofile[NOFILE]; /* per-process flags of open files */
|
||||
int u_lastfile; /* high-water mark of u_ofile */
|
||||
#define UF_EXCLOSE 0x1 /* auto-close on exec */
|
||||
#define UF_MAPPED 0x2 /* mapped from device */
|
||||
struct inode *u_cdir; /* current directory */
|
||||
struct inode *u_rdir; /* root directory of current process */
|
||||
struct tty *u_ttyp; /* controlling tty pointer */
|
||||
dev_t u_ttyd; /* controlling tty dev */
|
||||
int u_cmask; /* mask for file creation */
|
||||
struct file *u_ofile[NOFILE]; /* file structures for open files */
|
||||
char u_pofile[NOFILE]; /* per-process flags of open files */
|
||||
int u_lastfile; /* high-water mark of u_ofile */
|
||||
#define UF_EXCLOSE 0x1 /* auto-close on exec */
|
||||
#define UF_MAPPED 0x2 /* mapped from device */
|
||||
struct inode *u_cdir; /* current directory */
|
||||
struct inode *u_rdir; /* root directory of current process */
|
||||
struct tty *u_ttyp; /* controlling tty pointer */
|
||||
dev_t u_ttyd; /* controlling tty dev */
|
||||
int u_cmask; /* mask for file creation */
|
||||
|
||||
/* 1.5 - timing and statistics */
|
||||
struct k_rusage u_ru; /* stats for this proc */
|
||||
struct k_rusage u_cru; /* sum of stats for reaped children */
|
||||
struct k_itimerval u_timer[2]; /* profile/virtual timers */
|
||||
long u_start;
|
||||
int u_dupfd; /* XXX - see kern_descrip.c/fdopen */
|
||||
struct k_rusage u_ru; /* stats for this proc */
|
||||
struct k_rusage u_cru; /* sum of stats for reaped children */
|
||||
struct k_itimerval u_timer[2]; /* profile/virtual timers */
|
||||
long u_start;
|
||||
int u_dupfd; /* XXX - see kern_descrip.c/fdopen */
|
||||
|
||||
struct uprof { /* profile arguments */
|
||||
unsigned *pr_base; /* buffer base */
|
||||
unsigned pr_size; /* buffer size */
|
||||
unsigned pr_off; /* pc offset */
|
||||
unsigned pr_scale; /* pc scaling */
|
||||
} u_prof;
|
||||
struct uprof { /* profile arguments */
|
||||
unsigned *pr_base; /* buffer base */
|
||||
unsigned pr_size; /* buffer size */
|
||||
unsigned pr_off; /* pc offset */
|
||||
unsigned pr_scale; /* pc scaling */
|
||||
} u_prof;
|
||||
|
||||
/* 1.6 - resource controls */
|
||||
struct rlimit u_rlimit[RLIM_NLIMITS];
|
||||
struct rlimit u_rlimit[RLIM_NLIMITS];
|
||||
|
||||
/* namei & co. */
|
||||
struct nameicache { /* last successful directory search */
|
||||
off_t nc_prevoffset; /* offset at which last entry found */
|
||||
ino_t nc_inumber; /* inum of cached directory */
|
||||
dev_t nc_dev; /* dev of cached directory */
|
||||
} u_ncache;
|
||||
int u_stack[1]; /* kernel stack per user
|
||||
* extends from u + USIZE
|
||||
* backward not to reach here */
|
||||
struct nameicache { /* last successful directory search */
|
||||
off_t nc_prevoffset; /* offset at which last entry found */
|
||||
ino_t nc_inumber; /* inum of cached directory */
|
||||
dev_t nc_dev; /* dev of cached directory */
|
||||
} u_ncache;
|
||||
int u_stack[1]; /* kernel stack per user
|
||||
* extends from u + USIZE
|
||||
* backward not to reach here */
|
||||
};
|
||||
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct user u, u0;
|
||||
extern struct user u, u0;
|
||||
|
||||
/*
|
||||
* Increment user profiling counters.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chuck Karish of Mindcraft, Inc.
|
||||
@@ -15,8 +15,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -33,17 +33,17 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _SYS_UTSNAME_H
|
||||
#define _SYS_UTSNAME_H
|
||||
#ifndef _SYS_UTSNAME_H
|
||||
#define _SYS_UTSNAME_H
|
||||
|
||||
struct utsname {
|
||||
char sysname[128]; /* Name of this OS. */
|
||||
char nodename[128]; /* Name of this network node. */
|
||||
char release[128]; /* Release level. */
|
||||
char version[128]; /* Version level. */
|
||||
char machine[128]; /* Hardware type. */
|
||||
char sysname[128]; /* Name of this OS. */
|
||||
char nodename[128]; /* Name of this network node. */
|
||||
char release[128]; /* Release level. */
|
||||
char version[128]; /* Version level. */
|
||||
char machine[128]; /* Hardware type. */
|
||||
};
|
||||
|
||||
int uname (struct utsname *name);
|
||||
|
||||
#endif /* !_SYS_UTSNAME_H */
|
||||
#endif /* !_SYS_UTSNAME_H */
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)vmmac.h 1.1 (2.10 Berkeley) 12/1/86
|
||||
* @(#)vmmac.h 1.1 (2.10 Berkeley) 12/1/86
|
||||
*/
|
||||
|
||||
/* Average new into old with aging factor time */
|
||||
#define ave(smooth, cnt, time) \
|
||||
smooth = ((time - 1) * (smooth) + (cnt)) / (time)
|
||||
#define ave(smooth, cnt, time) \
|
||||
smooth = ((time - 1) * (smooth) + (cnt)) / (time)
|
||||
|
||||
@@ -9,57 +9,57 @@
|
||||
*/
|
||||
struct vmrate
|
||||
{
|
||||
#define v_first v_swtch
|
||||
u_short v_swtch; /* context switches */
|
||||
u_short v_trap; /* calls to trap */
|
||||
u_short v_syscall; /* calls to syscall() */
|
||||
u_short v_intr; /* device interrupts */
|
||||
u_short v_soft; /* software interrupts */
|
||||
u_short v_fpsim; /* floating point simulator faults */
|
||||
u_short v_kbin; /* kbytes swapped in */
|
||||
u_short v_kbout; /* kbytes swapped out */
|
||||
u_short v_swpin; /* swapins */
|
||||
u_short v_swpout; /* swapouts */
|
||||
#define v_last v_swpout
|
||||
#define v_first v_swtch
|
||||
u_short v_swtch; /* context switches */
|
||||
u_short v_trap; /* calls to trap */
|
||||
u_short v_syscall; /* calls to syscall() */
|
||||
u_short v_intr; /* device interrupts */
|
||||
u_short v_soft; /* software interrupts */
|
||||
u_short v_fpsim; /* floating point simulator faults */
|
||||
u_short v_kbin; /* kbytes swapped in */
|
||||
u_short v_kbout; /* kbytes swapped out */
|
||||
u_short v_swpin; /* swapins */
|
||||
u_short v_swpout; /* swapouts */
|
||||
#define v_last v_swpout
|
||||
};
|
||||
|
||||
struct vmsum
|
||||
{
|
||||
long v_swtch; /* context switches */
|
||||
long v_trap; /* calls to trap */
|
||||
long v_syscall; /* calls to syscall() */
|
||||
long v_intr; /* device interrupts */
|
||||
long v_soft; /* software interrupts */
|
||||
long v_fpsim; /* floating point simulator faults */
|
||||
long v_kbin; /* kbytes swapped in */
|
||||
long v_kbout; /* kbytes swapped out */
|
||||
long v_swpin; /* swapins */
|
||||
long v_swpout; /* swapouts */
|
||||
long v_swtch; /* context switches */
|
||||
long v_trap; /* calls to trap */
|
||||
long v_syscall; /* calls to syscall() */
|
||||
long v_intr; /* device interrupts */
|
||||
long v_soft; /* software interrupts */
|
||||
long v_fpsim; /* floating point simulator faults */
|
||||
long v_kbin; /* kbytes swapped in */
|
||||
long v_kbout; /* kbytes swapped out */
|
||||
long v_swpin; /* swapins */
|
||||
long v_swpout; /* swapouts */
|
||||
};
|
||||
#if defined(KERNEL) && defined(UCB_METER)
|
||||
struct vmrate cnt, rate;
|
||||
struct vmsum sum;
|
||||
struct vmrate cnt, rate;
|
||||
struct vmsum sum;
|
||||
#endif
|
||||
|
||||
/* systemwide totals computed every five seconds */
|
||||
struct vmtotal
|
||||
{
|
||||
short t_rq; /* length of the run queue */
|
||||
short t_dw; /* jobs in ``disk wait'' (neg priority) */
|
||||
short t_sl; /* jobs sleeping in core */
|
||||
short t_sw; /* swapped out runnable/short block jobs */
|
||||
long t_vm; /* total virtual memory, clicks */
|
||||
long t_avm; /* active virtual memory, clicks */
|
||||
size_t t_rm; /* total real memory, clicks */
|
||||
size_t t_arm; /* active real memory, clicks */
|
||||
long t_vmtxt; /* virtual memory used by text, clicks */
|
||||
long t_avmtxt; /* active virtual memory used by text, clicks */
|
||||
size_t t_rmtxt; /* real memory used by text, clicks */
|
||||
size_t t_armtxt; /* active real memory used by text, clicks */
|
||||
size_t t_free; /* free memory, kb */
|
||||
short t_rq; /* length of the run queue */
|
||||
short t_dw; /* jobs in ``disk wait'' (neg priority) */
|
||||
short t_sl; /* jobs sleeping in core */
|
||||
short t_sw; /* swapped out runnable/short block jobs */
|
||||
long t_vm; /* total virtual memory, clicks */
|
||||
long t_avm; /* active virtual memory, clicks */
|
||||
size_t t_rm; /* total real memory, clicks */
|
||||
size_t t_arm; /* active real memory, clicks */
|
||||
long t_vmtxt; /* virtual memory used by text, clicks */
|
||||
long t_avmtxt; /* active virtual memory used by text, clicks */
|
||||
size_t t_rmtxt; /* real memory used by text, clicks */
|
||||
size_t t_armtxt; /* active real memory used by text, clicks */
|
||||
size_t t_free; /* free memory, kb */
|
||||
};
|
||||
#ifdef KERNEL
|
||||
struct vmtotal total;
|
||||
struct vmtotal total;
|
||||
|
||||
/*
|
||||
* Count up various things once a second
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
/*
|
||||
* CTL_VM identifiers
|
||||
*/
|
||||
#define VM_METER 1 /* struct vmmeter */
|
||||
#define VM_LOADAVG 2 /* struct loadavg */
|
||||
#define VM_SWAPMAP 3 /* struct mapent _swapmap[] */
|
||||
#define VM_MAXID 5 /* number of valid vm ids */
|
||||
#define VM_METER 1 /* struct vmmeter */
|
||||
#define VM_LOADAVG 2 /* struct loadavg */
|
||||
#define VM_SWAPMAP 3 /* struct mapent _swapmap[] */
|
||||
#define VM_MAXID 5 /* number of valid vm ids */
|
||||
|
||||
#ifndef KERNEL
|
||||
#ifndef KERNEL
|
||||
#define CTL_VM_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "vmmeter", CTLTYPE_STRUCT }, \
|
||||
{ "loadavg", CTLTYPE_STRUCT }, \
|
||||
{ "swapmap", CTLTYPE_STRUCT }, \
|
||||
{ 0, 0 }, \
|
||||
{ "vmmeter", CTLTYPE_STRUCT }, \
|
||||
{ "loadavg", CTLTYPE_STRUCT }, \
|
||||
{ "swapmap", CTLTYPE_STRUCT }, \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)vmsystm.h 7.2.1 (2.11BSD GTE) 1/15/95
|
||||
* @(#)vmsystm.h 7.2.1 (2.11BSD GTE) 1/15/95
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -11,25 +11,26 @@
|
||||
*/
|
||||
|
||||
#if defined(KERNEL) && defined(UCB_METER) && !defined(SUPERVISOR)
|
||||
size_t freemem; /* remaining clicks of free memory */
|
||||
size_t freemem; /* remaining clicks of free memory */
|
||||
|
||||
u_short avefree; /* moving average of remaining free clicks */
|
||||
u_short avefree30; /* 30 sec (avefree is 5 sec) moving average */
|
||||
u_short avefree; /* moving average of remaining free clicks */
|
||||
u_short avefree30; /* 30 sec (avefree is 5 sec) moving average */
|
||||
|
||||
/* writable copies of tunables */
|
||||
int maxslp; /* max sleep time before very swappable */
|
||||
int maxslp; /* max sleep time before very swappable */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fork/vfork accounting.
|
||||
*/
|
||||
struct forkstat
|
||||
struct forkstat
|
||||
{
|
||||
long cntfork;
|
||||
long cntvfork;
|
||||
long sizfork;
|
||||
long sizvfork;
|
||||
long cntfork;
|
||||
long cntvfork;
|
||||
long sizfork;
|
||||
long sizvfork;
|
||||
};
|
||||
|
||||
#if defined(KERNEL) && defined(UCB_METER) && !defined(SUPERVISOR)
|
||||
struct forkstat forkstat;
|
||||
struct forkstat forkstat;
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)wait.h 7.2.1 (2.11BSD GTE) 1995/06/23
|
||||
* @(#)wait.h 7.2.1 (2.11BSD GTE) 1995/06/23
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -20,33 +20,33 @@
|
||||
* wait and wait3. If w_stopval==WSTOPPED, then the second structure
|
||||
* describes the information returned, else the first. See WUNTRACED below.
|
||||
*/
|
||||
union wait {
|
||||
int w_status; /* used in syscall */
|
||||
/*
|
||||
* Terminated process status.
|
||||
*/
|
||||
struct {
|
||||
unsigned w_Termsig :7; /* termination signal */
|
||||
unsigned w_Coredump :1; /* core dump indicator */
|
||||
unsigned w_Retcode :8; /* exit code if w_termsig==0 */
|
||||
} w_T;
|
||||
/*
|
||||
* Stopped process status. Returned
|
||||
* only for traced children unless requested
|
||||
* with the WUNTRACED option bit.
|
||||
*/
|
||||
struct {
|
||||
unsigned w_Stopval :8; /* == W_STOPPED if stopped */
|
||||
unsigned w_Stopsig :8; /* signal that stopped us */
|
||||
} w_S;
|
||||
union wait {
|
||||
int w_status; /* used in syscall */
|
||||
/*
|
||||
* Terminated process status.
|
||||
*/
|
||||
struct {
|
||||
unsigned w_Termsig :7; /* termination signal */
|
||||
unsigned w_Coredump :1; /* core dump indicator */
|
||||
unsigned w_Retcode :8; /* exit code if w_termsig==0 */
|
||||
} w_T;
|
||||
/*
|
||||
* Stopped process status. Returned
|
||||
* only for traced children unless requested
|
||||
* with the WUNTRACED option bit.
|
||||
*/
|
||||
struct {
|
||||
unsigned w_Stopval :8; /* == W_STOPPED if stopped */
|
||||
unsigned w_Stopsig :8; /* signal that stopped us */
|
||||
} w_S;
|
||||
};
|
||||
#define w_termsig w_T.w_Termsig
|
||||
#define w_coredump w_T.w_Coredump
|
||||
#define w_retcode w_T.w_Retcode
|
||||
#define w_stopval w_S.w_Stopval
|
||||
#define w_stopsig w_S.w_Stopsig
|
||||
#define w_termsig w_T.w_Termsig
|
||||
#define w_coredump w_T.w_Coredump
|
||||
#define w_retcode w_T.w_Retcode
|
||||
#define w_stopval w_S.w_Stopval
|
||||
#define w_stopsig w_S.w_Stopsig
|
||||
|
||||
#define WSTOPPED 0177 /* value of s.stopval if process is stopped */
|
||||
#define WSTOPPED 0177 /* value of s.stopval if process is stopped */
|
||||
|
||||
/*
|
||||
* Option bits for the second argument of wait3. WNOHANG causes the
|
||||
@@ -57,24 +57,24 @@ union wait {
|
||||
* this option is done, it is as though they were still running... nothing
|
||||
* about them is returned.
|
||||
*/
|
||||
#define WNOHANG 1 /* dont hang in wait */
|
||||
#define WUNTRACED 2 /* tell about stopped, untraced children */
|
||||
#define WNOHANG 1 /* dont hang in wait */
|
||||
#define WUNTRACED 2 /* tell about stopped, untraced children */
|
||||
|
||||
#define WIFSTOPPED(x) (((union wait*)&(x))->w_stopval == WSTOPPED)
|
||||
#define WIFSIGNALED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\
|
||||
#define WIFSTOPPED(x) (((union wait*)&(x))->w_stopval == WSTOPPED)
|
||||
#define WIFSIGNALED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\
|
||||
(((union wait*)&(x))->w_termsig != 0))
|
||||
#define WIFEXITED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\
|
||||
#define WIFEXITED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\
|
||||
(((union wait*)&(x))->w_termsig == 0))
|
||||
#define WEXITSTATUS(x) (((union wait*)&(x))->w_retcode)
|
||||
#define WTERMSIG(x) (((union wait*)&(x))->w_termsig)
|
||||
#define WCOREDUMP(x) (((union wait*)&(x))->w_coredump)
|
||||
#define WSTOPSIG(x) (((union wait*)&(x))->w_stopsig)
|
||||
#define WEXITSTATUS(x) (((union wait*)&(x))->w_retcode)
|
||||
#define WTERMSIG(x) (((union wait*)&(x))->w_termsig)
|
||||
#define WCOREDUMP(x) (((union wait*)&(x))->w_coredump)
|
||||
#define WSTOPSIG(x) (((union wait*)&(x))->w_stopsig)
|
||||
|
||||
#define W_STOPCODE(sig) ((sig << 8) | WSTOPPED)
|
||||
#define W_EXITCODE(ret,sig) ((ret << 8) | (sig))
|
||||
#define W_STOPCODE(sig) ((sig << 8) | WSTOPPED)
|
||||
#define W_EXITCODE(ret,sig) ((ret << 8) | (sig))
|
||||
|
||||
#define WAIT_ANY (-1)
|
||||
#define WAIT_MYPGRP 0
|
||||
#define WAIT_ANY (-1)
|
||||
#define WAIT_MYPGRP 0
|
||||
|
||||
#ifndef KERNEL
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -18,78 +18,78 @@
|
||||
|
||||
int exec_aout_check(struct exec_params *epp)
|
||||
{
|
||||
int error;
|
||||
int error;
|
||||
|
||||
if (epp->hdr_len < sizeof(struct exec))
|
||||
return ENOEXEC;
|
||||
if (!(N_GETMID(epp->hdr.aout) == MID_ZERO &&
|
||||
N_GETFLAG(epp->hdr.aout) == 0))
|
||||
return ENOEXEC;
|
||||
if (epp->hdr_len < sizeof(struct exec))
|
||||
return ENOEXEC;
|
||||
if (!(N_GETMID(epp->hdr.aout) == MID_ZERO &&
|
||||
N_GETFLAG(epp->hdr.aout) == 0))
|
||||
return ENOEXEC;
|
||||
|
||||
switch (N_GETMAGIC(epp->hdr.aout)) {
|
||||
case OMAGIC:
|
||||
epp->hdr.aout.a_data += epp->hdr.aout.a_text;
|
||||
epp->hdr.aout.a_text = 0;
|
||||
break;
|
||||
default:
|
||||
printf("Bad a.out magic = %0o\n", N_GETMAGIC(epp->hdr.aout));
|
||||
return ENOEXEC;
|
||||
}
|
||||
switch (N_GETMAGIC(epp->hdr.aout)) {
|
||||
case OMAGIC:
|
||||
epp->hdr.aout.a_data += epp->hdr.aout.a_text;
|
||||
epp->hdr.aout.a_text = 0;
|
||||
break;
|
||||
default:
|
||||
printf("Bad a.out magic = %0o\n", N_GETMAGIC(epp->hdr.aout));
|
||||
return ENOEXEC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save arglist
|
||||
*/
|
||||
exec_save_args(epp);
|
||||
/*
|
||||
* Save arglist
|
||||
*/
|
||||
exec_save_args(epp);
|
||||
|
||||
DEBUG("Exec file header:\n");
|
||||
DEBUG("a_midmag = %#x\n", epp->hdr.aout.a_midmag); /* magic number */
|
||||
DEBUG("a_text = %d\n", epp->hdr.aout.a_text); /* size of text segment */
|
||||
DEBUG("a_data = %d\n", epp->hdr.aout.a_data); /* size of initialized data */
|
||||
DEBUG("a_bss = %d\n", epp->hdr.aout.a_bss); /* size of uninitialized data */
|
||||
DEBUG("a_reltext = %d\n", epp->hdr.aout.a_reltext); /* size of text relocation info */
|
||||
DEBUG("a_reldata = %d\n", epp->hdr.aout.a_reldata); /* size of data relocation info */
|
||||
DEBUG("a_syms = %d\n", epp->hdr.aout.a_syms); /* size of symbol table */
|
||||
DEBUG("a_entry = %#x\n", epp->hdr.aout.a_entry); /* entry point */
|
||||
DEBUG("Exec file header:\n");
|
||||
DEBUG("a_midmag = %#x\n", epp->hdr.aout.a_midmag); /* magic number */
|
||||
DEBUG("a_text = %d\n", epp->hdr.aout.a_text); /* size of text segment */
|
||||
DEBUG("a_data = %d\n", epp->hdr.aout.a_data); /* size of initialized data */
|
||||
DEBUG("a_bss = %d\n", epp->hdr.aout.a_bss); /* size of uninitialized data */
|
||||
DEBUG("a_reltext = %d\n", epp->hdr.aout.a_reltext); /* size of text relocation info */
|
||||
DEBUG("a_reldata = %d\n", epp->hdr.aout.a_reldata); /* size of data relocation info */
|
||||
DEBUG("a_syms = %d\n", epp->hdr.aout.a_syms); /* size of symbol table */
|
||||
DEBUG("a_entry = %#x\n", epp->hdr.aout.a_entry); /* entry point */
|
||||
|
||||
/*
|
||||
* Set up memory allocation
|
||||
*/
|
||||
epp->text.vaddr = epp->heap.vaddr = NO_ADDR;
|
||||
epp->text.len = epp->heap.len = 0;
|
||||
/*
|
||||
* Set up memory allocation
|
||||
*/
|
||||
epp->text.vaddr = epp->heap.vaddr = NO_ADDR;
|
||||
epp->text.len = epp->heap.len = 0;
|
||||
|
||||
epp->data.vaddr = (caddr_t)USER_DATA_START;
|
||||
epp->data.len = epp->hdr.aout.a_data;
|
||||
epp->bss.vaddr = epp->data.vaddr + epp->data.len;
|
||||
epp->bss.len = epp->hdr.aout.a_bss;
|
||||
epp->heap.vaddr = epp->bss.vaddr + epp->bss.len;
|
||||
epp->heap.len = 0;
|
||||
epp->stack.len = SSIZE + roundup(epp->argbc + epp->envbc, NBPW) + (epp->argc + epp->envc+4)*NBPW;
|
||||
epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len;
|
||||
epp->data.vaddr = (caddr_t)USER_DATA_START;
|
||||
epp->data.len = epp->hdr.aout.a_data;
|
||||
epp->bss.vaddr = epp->data.vaddr + epp->data.len;
|
||||
epp->bss.len = epp->hdr.aout.a_bss;
|
||||
epp->heap.vaddr = epp->bss.vaddr + epp->bss.len;
|
||||
epp->heap.len = 0;
|
||||
epp->stack.len = SSIZE + roundup(epp->argbc + epp->envbc, NBPW) + (epp->argc + epp->envc+4)*NBPW;
|
||||
epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len;
|
||||
|
||||
/*
|
||||
* Allocate core at this point, committed to the new image.
|
||||
* TODO: What to do for errors?
|
||||
*/
|
||||
exec_estab(epp);
|
||||
/*
|
||||
* Allocate core at this point, committed to the new image.
|
||||
* TODO: What to do for errors?
|
||||
*/
|
||||
exec_estab(epp);
|
||||
|
||||
/* read in text and data */
|
||||
DEBUG("reading a.out image\n");
|
||||
error = rdwri (UIO_READ, epp->ip,
|
||||
(caddr_t)epp->data.vaddr, epp->hdr.aout.a_data,
|
||||
sizeof(struct exec) + epp->hdr.aout.a_text, IO_UNIT, 0);
|
||||
if (error)
|
||||
DEBUG("read image returned error=%d\n", error);
|
||||
if (error) {
|
||||
/*
|
||||
* Error - all is lost, when the old image is possible corrupt
|
||||
* and we could not load a new.
|
||||
*/
|
||||
psignal (u.u_procp, SIGSEGV);
|
||||
return error;
|
||||
}
|
||||
/* read in text and data */
|
||||
DEBUG("reading a.out image\n");
|
||||
error = rdwri (UIO_READ, epp->ip,
|
||||
(caddr_t)epp->data.vaddr, epp->hdr.aout.a_data,
|
||||
sizeof(struct exec) + epp->hdr.aout.a_text, IO_UNIT, 0);
|
||||
if (error)
|
||||
DEBUG("read image returned error=%d\n", error);
|
||||
if (error) {
|
||||
/*
|
||||
* Error - all is lost, when the old image is possible corrupt
|
||||
* and we could not load a new.
|
||||
*/
|
||||
psignal (u.u_procp, SIGSEGV);
|
||||
return error;
|
||||
}
|
||||
|
||||
exec_clear(epp);
|
||||
exec_setupstack(epp->hdr.aout.a_entry, epp);
|
||||
exec_clear(epp);
|
||||
exec_setupstack(epp->hdr.aout.a_entry, epp);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_conf.c,v 1.43 2000/06/09 22:38:57 oki Exp $ */
|
||||
/* $NetBSD: exec_conf.c,v 1.43 2000/06/09 22:38:57 oki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
@@ -46,13 +46,13 @@ int exec_elf_check(struct exec_params *epp);
|
||||
|
||||
const struct execsw execsw[] = {
|
||||
#ifdef EXEC_AOUT
|
||||
{ exec_aout_check, "a.out" }, /* a.out binaries */
|
||||
{ exec_aout_check, "a.out" }, /* a.out binaries */
|
||||
#endif
|
||||
#ifdef EXEC_ELF
|
||||
{ exec_elf_check, "elf" }, /* 32bit ELF bins */
|
||||
{ exec_elf_check, "elf" }, /* 32bit ELF bins */
|
||||
#endif
|
||||
#ifdef EXEC_SCRIPT
|
||||
{ exec_script_check, "script" }, /* shell scripts */
|
||||
{ exec_script_check, "script" }, /* shell scripts */
|
||||
#endif
|
||||
};
|
||||
int nexecs = (sizeof(execsw) / sizeof(*execsw));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_elf32.c,v 1.49.2.2 2000/11/03 20:00:38 tv Exp $ */
|
||||
/* $NetBSD: exec_elf32.c,v 1.49.2.2 2000/11/03 20:00:38 tv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@@ -17,8 +17,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
@@ -70,24 +70,20 @@
|
||||
#include "map.h"
|
||||
#include "user.h"
|
||||
#include "proc.h"
|
||||
//#include "malloc.h"
|
||||
#include "inode.h"
|
||||
#include "namei.h"
|
||||
//#include "vnode.h"
|
||||
#include "exec.h"
|
||||
#include "exec_elf.h"
|
||||
#include "fcntl.h"
|
||||
//#include "syscall.h"
|
||||
#include "signalvar.h"
|
||||
#include "mount.h"
|
||||
#include "stat.h"
|
||||
|
||||
|
||||
extern char sigcode[], esigcode[];
|
||||
|
||||
/* round up and down to page boundaries. */
|
||||
#define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1))
|
||||
#define ELF_TRUNC(a, b) ((a) & ~((b) - 1))
|
||||
#define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1))
|
||||
#define ELF_TRUNC(a, b) ((a) & ~((b) - 1))
|
||||
|
||||
/*
|
||||
* elf_check(): Prepare an Elf binary's exec package
|
||||
@@ -101,107 +97,107 @@ extern char sigcode[], esigcode[];
|
||||
int
|
||||
exec_elf_check(struct exec_params *epp)
|
||||
{
|
||||
struct elf_phdr *ph;
|
||||
int error, i, phsize;
|
||||
struct elf_phdr *ph;
|
||||
int error, i, phsize;
|
||||
|
||||
const char elfident[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3,
|
||||
ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_SYSV, 0};
|
||||
const char elfident[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3,
|
||||
ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_SYSV, 0};
|
||||
|
||||
/*
|
||||
* Check that this is an ELF file that we can handle,
|
||||
* and do some sanity checks on the header
|
||||
*/
|
||||
if (epp->hdr_len < sizeof(struct elf_ehdr))
|
||||
return ENOEXEC;
|
||||
for (i = 0; i < sizeof elfident; i++)
|
||||
if (epp->hdr.elf.e_ident[i] != elfident[i])
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_type != ET_EXEC)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_machine != EM_MIPS || epp->hdr.elf.e_version != EV_CURRENT)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_phentsize != sizeof(struct elf_phdr) || epp->hdr.elf.e_phoff == 0 || epp->hdr.elf.e_phnum == 0)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_shnum == 0 || epp->hdr.elf.e_shentsize != sizeof(struct elf_shdr))
|
||||
return ENOEXEC;
|
||||
/*
|
||||
* Check that this is an ELF file that we can handle,
|
||||
* and do some sanity checks on the header
|
||||
*/
|
||||
if (epp->hdr_len < sizeof(struct elf_ehdr))
|
||||
return ENOEXEC;
|
||||
for (i = 0; i < sizeof elfident; i++)
|
||||
if (epp->hdr.elf.e_ident[i] != elfident[i])
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_type != ET_EXEC)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_machine != EM_MIPS || epp->hdr.elf.e_version != EV_CURRENT)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_phentsize != sizeof(struct elf_phdr) || epp->hdr.elf.e_phoff == 0 || epp->hdr.elf.e_phnum == 0)
|
||||
return ENOEXEC;
|
||||
if (epp->hdr.elf.e_shnum == 0 || epp->hdr.elf.e_shentsize != sizeof(struct elf_shdr))
|
||||
return ENOEXEC;
|
||||
|
||||
/*
|
||||
* Read program headers
|
||||
*/
|
||||
phsize = epp->hdr.elf.e_phnum * sizeof(struct elf_phdr);
|
||||
ph = exec_alloc(phsize, NBPW, epp);
|
||||
if (ph == NULL) {
|
||||
printf("can't alloc ph[] sz=%d\n", phsize);
|
||||
return ENOEXEC;
|
||||
}
|
||||
if ((error = rdwri(UIO_READ, epp->ip, (caddr_t)ph, phsize, epp->hdr.elf.e_phoff, IO_UNIT, 0)) != 0)
|
||||
return ENOEXEC;
|
||||
/*
|
||||
* Read program headers
|
||||
*/
|
||||
phsize = epp->hdr.elf.e_phnum * sizeof(struct elf_phdr);
|
||||
ph = exec_alloc(phsize, NBPW, epp);
|
||||
if (ph == NULL) {
|
||||
printf("can't alloc ph[] sz=%d\n", phsize);
|
||||
return ENOEXEC;
|
||||
}
|
||||
if ((error = rdwri(UIO_READ, epp->ip, (caddr_t)ph, phsize, epp->hdr.elf.e_phoff, IO_UNIT, 0)) != 0)
|
||||
return ENOEXEC;
|
||||
|
||||
epp->text.len = epp->data.len = epp->bss.len = epp->stack.len = epp->heap.len = 0;
|
||||
epp->text.vaddr = epp->data.vaddr = epp->bss.vaddr = epp->stack.vaddr = epp->heap.vaddr = NO_ADDR;
|
||||
epp->text.len = epp->data.len = epp->bss.len = epp->stack.len = epp->heap.len = 0;
|
||||
epp->text.vaddr = epp->data.vaddr = epp->bss.vaddr = epp->stack.vaddr = epp->heap.vaddr = NO_ADDR;
|
||||
|
||||
if (epp->hdr.elf.e_phnum == 1 && ph[0].p_type == PT_LOAD && ph[0].p_flags == (PF_R|PF_W|PF_X)) {
|
||||
/*
|
||||
* In the simple a.out type link, in elf format, there is only
|
||||
* one loadable segment that is RWE containing everything
|
||||
* Here we fix the memory allocation, and we are done.
|
||||
*/
|
||||
epp->data.vaddr = (caddr_t)ph[0].p_vaddr;
|
||||
epp->data.len = ph[0].p_memsz;
|
||||
epp->heap.vaddr = (caddr_t)ph[0].p_vaddr + ph[0].p_memsz;
|
||||
epp->heap.len = 0;
|
||||
epp->stack.len = SSIZE + epp->argbc + epp->envbc + (epp->argc+epp->envc+4)*NBPW;
|
||||
epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len;
|
||||
if (epp->hdr.elf.e_phnum == 1 && ph[0].p_type == PT_LOAD && ph[0].p_flags == (PF_R|PF_W|PF_X)) {
|
||||
/*
|
||||
* In the simple a.out type link, in elf format, there is only
|
||||
* one loadable segment that is RWE containing everything
|
||||
* Here we fix the memory allocation, and we are done.
|
||||
*/
|
||||
epp->data.vaddr = (caddr_t)ph[0].p_vaddr;
|
||||
epp->data.len = ph[0].p_memsz;
|
||||
epp->heap.vaddr = (caddr_t)ph[0].p_vaddr + ph[0].p_memsz;
|
||||
epp->heap.len = 0;
|
||||
epp->stack.len = SSIZE + epp->argbc + epp->envbc + (epp->argc+epp->envc+4)*NBPW;
|
||||
epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len;
|
||||
|
||||
/*
|
||||
* We assume .bss is the different between the memory data
|
||||
* section size and the file size.
|
||||
*/
|
||||
epp->bss.vaddr = epp->data.vaddr + ph[0].p_filesz;
|
||||
epp->bss.len = ph[0].p_memsz - ph[0].p_filesz;
|
||||
epp->data.len = epp->bss.vaddr - epp->data.vaddr;
|
||||
} else {
|
||||
/*
|
||||
* At the current moment we don't handle anything else
|
||||
* The rest of the code is implemented as need arise.
|
||||
*/
|
||||
return ENOEXEC;
|
||||
}
|
||||
/*
|
||||
* We assume .bss is the different between the memory data
|
||||
* section size and the file size.
|
||||
*/
|
||||
epp->bss.vaddr = epp->data.vaddr + ph[0].p_filesz;
|
||||
epp->bss.len = ph[0].p_memsz - ph[0].p_filesz;
|
||||
epp->data.len = epp->bss.vaddr - epp->data.vaddr;
|
||||
} else {
|
||||
/*
|
||||
* At the current moment we don't handle anything else
|
||||
* The rest of the code is implemented as need arise.
|
||||
*/
|
||||
return ENOEXEC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save arglist
|
||||
*/
|
||||
exec_save_args(epp);
|
||||
/*
|
||||
* Save arglist
|
||||
*/
|
||||
exec_save_args(epp);
|
||||
|
||||
/*
|
||||
* Establish memory
|
||||
*/
|
||||
if ((error = exec_estab(epp)) != 0)
|
||||
return error;
|
||||
/*
|
||||
* Establish memory
|
||||
*/
|
||||
if ((error = exec_estab(epp)) != 0)
|
||||
return error;
|
||||
|
||||
/*
|
||||
* Now load the program sections into memory
|
||||
*/
|
||||
for (i = 0; i < epp->hdr.elf.e_phnum; i++) {
|
||||
if (ph[i].p_type != PT_LOAD)
|
||||
continue;
|
||||
/*
|
||||
* Sanity check that the load is to our intended address space.
|
||||
*/
|
||||
if (!((epp->text.vaddr != NO_ADDR
|
||||
&& ((caddr_t)ph[i].p_vaddr >= epp->text.vaddr
|
||||
&& (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->text.vaddr + epp->text.len))
|
||||
|| (epp->data.vaddr != NO_ADDR
|
||||
&& (caddr_t)ph[i].p_vaddr >= epp->data.vaddr
|
||||
&& (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->data.vaddr + epp->data.len))
|
||||
|| ph[i].p_filesz >= ph[i].p_memsz || ph[i].p_filesz <= 0)
|
||||
return ENOEXEC;
|
||||
|
||||
error = rdwri(UIO_READ, epp->ip, (caddr_t)ph[i].p_vaddr, ph[i].p_filesz, ph[i].p_offset, IO_UNIT, 0);
|
||||
}
|
||||
/*
|
||||
* Now load the program sections into memory
|
||||
*/
|
||||
for (i = 0; i < epp->hdr.elf.e_phnum; i++) {
|
||||
if (ph[i].p_type != PT_LOAD)
|
||||
continue;
|
||||
/*
|
||||
* Sanity check that the load is to our intended address space.
|
||||
*/
|
||||
if (!((epp->text.vaddr != NO_ADDR
|
||||
&& ((caddr_t)ph[i].p_vaddr >= epp->text.vaddr
|
||||
&& (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->text.vaddr + epp->text.len))
|
||||
|| (epp->data.vaddr != NO_ADDR
|
||||
&& (caddr_t)ph[i].p_vaddr >= epp->data.vaddr
|
||||
&& (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->data.vaddr + epp->data.len))
|
||||
|| ph[i].p_filesz >= ph[i].p_memsz || ph[i].p_filesz <= 0)
|
||||
return ENOEXEC;
|
||||
|
||||
exec_clear(epp);
|
||||
exec_setupstack(epp->hdr.elf.e_entry, epp);
|
||||
|
||||
return 0;
|
||||
error = rdwri(UIO_READ, epp->ip, (caddr_t)ph[i].p_vaddr, ph[i].p_filesz, ph[i].p_offset, IO_UNIT, 0);
|
||||
}
|
||||
|
||||
exec_clear(epp);
|
||||
exec_setupstack(epp->hdr.elf.e_entry, epp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,88 +9,88 @@
|
||||
int
|
||||
exec_script_check(struct exec_params *epp)
|
||||
{
|
||||
char *cp;
|
||||
struct nameidata nd;
|
||||
struct nameidata *ndp;
|
||||
int error;
|
||||
struct inode *ip = 0;
|
||||
char *cp;
|
||||
struct nameidata nd;
|
||||
struct nameidata *ndp;
|
||||
int error;
|
||||
struct inode *ip = 0;
|
||||
|
||||
/*
|
||||
* We come here with the first line of the executable
|
||||
* script file.
|
||||
* Check is to see if it starts with the magic marker: #!
|
||||
*/
|
||||
if (epp->hdr.sh[0] != '#' || epp->hdr.sh[1] != '!' || epp->sh.interpreted)
|
||||
return ENOEXEC;
|
||||
epp->sh.interpreted = 1;
|
||||
/*
|
||||
* We come here with the first line of the executable
|
||||
* script file.
|
||||
* Check is to see if it starts with the magic marker: #!
|
||||
*/
|
||||
if (epp->hdr.sh[0] != '#' || epp->hdr.sh[1] != '!' || epp->sh.interpreted)
|
||||
return ENOEXEC;
|
||||
epp->sh.interpreted = 1;
|
||||
|
||||
/*
|
||||
* If setuid/gid scripts were to be disallowed this is where it would
|
||||
* have to be done.
|
||||
* u.u_uid = uid;
|
||||
* u.u_gid = u_groups[0];
|
||||
*/
|
||||
/*
|
||||
* If setuid/gid scripts were to be disallowed this is where it would
|
||||
* have to be done.
|
||||
* u.u_uid = uid;
|
||||
* u.u_gid = u_groups[0];
|
||||
*/
|
||||
|
||||
/*
|
||||
* The first line of the text file
|
||||
* should be one line on the format:
|
||||
* #! <interpreter-name> <interpreter-argument>\n
|
||||
*/
|
||||
cp = &epp->hdr.sh[2];
|
||||
while (cp < &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) {
|
||||
if (*cp == '\t')
|
||||
*cp = ' ';
|
||||
else if (*cp == '\n') {
|
||||
*cp = '\0';
|
||||
break;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
if (cp == &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)])
|
||||
return ENOEXEC;
|
||||
/*
|
||||
* The first line of the text file
|
||||
* should be one line on the format:
|
||||
* #! <interpreter-name> <interpreter-argument>\n
|
||||
*/
|
||||
cp = &epp->hdr.sh[2];
|
||||
while (cp < &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) {
|
||||
if (*cp == '\t')
|
||||
*cp = ' ';
|
||||
else if (*cp == '\n') {
|
||||
*cp = '\0';
|
||||
break;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
if (cp == &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)])
|
||||
return ENOEXEC;
|
||||
|
||||
/*
|
||||
* Pick up script interpreter file name
|
||||
*/
|
||||
cp = &epp->hdr.sh[2];
|
||||
while (*cp == ' ')
|
||||
cp++;
|
||||
if (!*cp)
|
||||
return ENOEXEC;
|
||||
bzero(&nd, sizeof nd);
|
||||
ndp = &nd;
|
||||
ndp->ni_dirp = cp;
|
||||
while (*cp && *cp != ' ')
|
||||
cp++;
|
||||
if (*cp != '\0') {
|
||||
*cp++ = 0;
|
||||
while (*cp && *cp == ' ')
|
||||
cp++;
|
||||
if (*cp) {
|
||||
if ((error = copystr(cp, epp->sh.interparg, sizeof epp->sh.interparg, NULL)))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Pick up script interpreter file name
|
||||
*/
|
||||
cp = &epp->hdr.sh[2];
|
||||
while (*cp == ' ')
|
||||
cp++;
|
||||
if (!*cp)
|
||||
return ENOEXEC;
|
||||
bzero(&nd, sizeof nd);
|
||||
ndp = &nd;
|
||||
ndp->ni_dirp = cp;
|
||||
while (*cp && *cp != ' ')
|
||||
cp++;
|
||||
if (*cp != '\0') {
|
||||
*cp++ = 0;
|
||||
while (*cp && *cp == ' ')
|
||||
cp++;
|
||||
if (*cp) {
|
||||
if ((error = copystr(cp, epp->sh.interparg, sizeof epp->sh.interparg, NULL)))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* the interpreter is the new file to exec
|
||||
*/
|
||||
ndp->ni_nameiop = LOOKUP | FOLLOW;
|
||||
ip = namei (ndp);
|
||||
if (ip == NULL)
|
||||
return u.u_error;
|
||||
if ((error = copystr(ndp->ni_dent.d_name, epp->sh.interpname, sizeof epp->sh.interpname, NULL)))
|
||||
goto done;
|
||||
/*
|
||||
* the interpreter is the new file to exec
|
||||
*/
|
||||
ndp->ni_nameiop = LOOKUP | FOLLOW;
|
||||
ip = namei (ndp);
|
||||
if (ip == NULL)
|
||||
return u.u_error;
|
||||
if ((error = copystr(ndp->ni_dent.d_name, epp->sh.interpname, sizeof epp->sh.interpname, NULL)))
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Everything set up, do the recursive exec()
|
||||
*/
|
||||
if (epp->ip)
|
||||
iput(epp->ip);
|
||||
epp->ip = ip;
|
||||
error = exec_check(epp);
|
||||
/*
|
||||
* Everything set up, do the recursive exec()
|
||||
*/
|
||||
if (epp->ip)
|
||||
iput(epp->ip);
|
||||
epp->ip = ip;
|
||||
error = exec_check(epp);
|
||||
done:
|
||||
if (ip)
|
||||
iput(ip);
|
||||
return error;
|
||||
if (ip)
|
||||
iput(ip);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -20,38 +20,37 @@
|
||||
*
|
||||
* var a:
|
||||
* USER_DATA_END: !----------!
|
||||
* ! +P_ssize ! stack
|
||||
* p_saddr -> ¡----------!
|
||||
* ! +P_ssize ! stack
|
||||
* p_saddr -> ¡----------!
|
||||
*
|
||||
* !----------!
|
||||
* ! +P_dsize ! .data + .bss + heap
|
||||
* P_daddr -> !----------!
|
||||
* !----------!
|
||||
* ! +P_dsize ! .data + .bss + heap
|
||||
* P_daddr -> !----------!
|
||||
*
|
||||
* var b:
|
||||
*
|
||||
* USER_DATA_END: !--------!
|
||||
* ! +ssize ! stack
|
||||
* saddr -> ¡--------!
|
||||
* ! +hsize ! heap
|
||||
* haddr -> !--------!
|
||||
* ! +dsize ! .data + .bss
|
||||
* daddr -> !--------!
|
||||
* ! +tsize ! .text
|
||||
* taddr -> !--------!
|
||||
* ! +ssize ! stack
|
||||
* saddr -> ¡--------!
|
||||
* ! +hsize ! heap
|
||||
* haddr -> !--------!
|
||||
* ! +dsize ! .data + .bss
|
||||
* daddr -> !--------!
|
||||
* ! +tsize ! .text
|
||||
* taddr -> !--------!
|
||||
* paddr -> +psize
|
||||
*
|
||||
* var c:
|
||||
* !--------!
|
||||
* ! +tsize ! .text (read only section)
|
||||
* taddr -> !--------!
|
||||
* ! +ssize ! stack
|
||||
* saddr -> ¡--------!
|
||||
* ! +hsize ! heap
|
||||
* haddr -> !--------!
|
||||
* ! +dsize ! .data + .bss
|
||||
* daddr -> !--------!
|
||||
* ! +tsize ! .text (read only section)
|
||||
* taddr -> !--------!
|
||||
* ! +ssize ! stack
|
||||
* saddr -> ¡--------!
|
||||
* ! +hsize ! heap
|
||||
* haddr -> !--------!
|
||||
* ! +dsize ! .data + .bss
|
||||
* daddr -> !--------!
|
||||
* paddr -> +psize
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -59,91 +58,91 @@
|
||||
*
|
||||
* The following is a key to top of the stack and the variables used.
|
||||
*
|
||||
* topp-> [argv] top word for /bin/ps
|
||||
* <0>
|
||||
* n
|
||||
* g
|
||||
* r
|
||||
* a
|
||||
* ...
|
||||
* <0>
|
||||
* 0
|
||||
* g
|
||||
* r
|
||||
* ucp -> a
|
||||
* [0]
|
||||
* [envn]
|
||||
* ...
|
||||
* envp -> [env0]
|
||||
* [0]
|
||||
* [argn] ptr to argn
|
||||
* ...
|
||||
* argp -> [arg0] ptr to arg0
|
||||
* []
|
||||
* []
|
||||
* []
|
||||
* sp -> []
|
||||
* topp-> [argv] top word for /bin/ps
|
||||
* <0>
|
||||
* n
|
||||
* g
|
||||
* r
|
||||
* a
|
||||
* ...
|
||||
* <0>
|
||||
* 0
|
||||
* g
|
||||
* r
|
||||
* ucp -> a
|
||||
* [0]
|
||||
* [envn]
|
||||
* ...
|
||||
* envp -> [env0]
|
||||
* [0]
|
||||
* [argn] ptr to argn
|
||||
* ...
|
||||
* argp -> [arg0] ptr to arg0
|
||||
* []
|
||||
* []
|
||||
* []
|
||||
* sp -> []
|
||||
*
|
||||
*/
|
||||
void exec_setupstack(unsigned entryaddr, struct exec_params *epp)
|
||||
{
|
||||
int nc,i;
|
||||
u_int len;
|
||||
char *ucp;
|
||||
char **argp, **envp, ***topp;
|
||||
int nc,i;
|
||||
u_int len;
|
||||
char *ucp;
|
||||
char **argp, **envp, ***topp;
|
||||
|
||||
DEBUG("exec_setupstack:\n");
|
||||
DEBUG("exec_setupstack:\n");
|
||||
|
||||
/*
|
||||
* Set up top of stack structure as above
|
||||
* This depends on that kernel and user spaces
|
||||
* map to the same addresses.
|
||||
*/
|
||||
topp = (char ***)(epp->stack.vaddr + epp->stack.len - NBPW); /* Last word of RAM */
|
||||
ucp = (char *)((unsigned)topp - roundup(epp->envbc + epp->argbc,NBPW)); /* arg string space */
|
||||
envp = (char **)(ucp - (epp->envc+1)*NBPW); /* Make place for envp[...], +1 for the 0 */
|
||||
argp = envp - (epp->argc+1)*NBPW; /* Make place for argv[...] */
|
||||
u.u_frame [FRAME_SP] = (int)(argp-16);
|
||||
u.u_frame [FRAME_R4] = epp->argc; /* $a0 := argc */
|
||||
u.u_frame [FRAME_R5] = (int)argp; /* $a1 := argp */
|
||||
u.u_frame [FRAME_R6] = (int)envp; /* $a2 := env */
|
||||
*topp = argp; /* for /bin/ps */
|
||||
/*
|
||||
* Set up top of stack structure as above
|
||||
* This depends on that kernel and user spaces
|
||||
* map to the same addresses.
|
||||
*/
|
||||
topp = (char ***)(epp->stack.vaddr + epp->stack.len - NBPW); /* Last word of RAM */
|
||||
ucp = (char *)((unsigned)topp - roundup(epp->envbc + epp->argbc,NBPW)); /* arg string space */
|
||||
envp = (char **)(ucp - (epp->envc+1)*NBPW); /* Make place for envp[...], +1 for the 0 */
|
||||
argp = envp - (epp->argc+1)*NBPW; /* Make place for argv[...] */
|
||||
u.u_frame [FRAME_SP] = (int)(argp-16);
|
||||
u.u_frame [FRAME_R4] = epp->argc; /* $a0 := argc */
|
||||
u.u_frame [FRAME_R5] = (int)argp; /* $a1 := argp */
|
||||
u.u_frame [FRAME_R6] = (int)envp; /* $a2 := env */
|
||||
*topp = argp; /* for /bin/ps */
|
||||
|
||||
/*
|
||||
* copy the arguments into the structure
|
||||
*/
|
||||
nc = 0;
|
||||
for (i = 0; i < epp->argc; i++) {
|
||||
argp[i] = (caddr_t)ucp;
|
||||
if (copystr((caddr_t)epp->argp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) {
|
||||
nc += len;
|
||||
ucp += len;
|
||||
}
|
||||
}
|
||||
argp[epp->argc] = NULL;
|
||||
/*
|
||||
* copy the arguments into the structure
|
||||
*/
|
||||
nc = 0;
|
||||
for (i = 0; i < epp->argc; i++) {
|
||||
argp[i] = (caddr_t)ucp;
|
||||
if (copystr((caddr_t)epp->argp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) {
|
||||
nc += len;
|
||||
ucp += len;
|
||||
}
|
||||
}
|
||||
argp[epp->argc] = NULL;
|
||||
|
||||
for (i = 0; i < epp->envc; i++) {
|
||||
envp[i] = ucp;
|
||||
if (copystr((caddr_t)epp->envp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) {
|
||||
nc += len;
|
||||
ucp += len;
|
||||
}
|
||||
}
|
||||
envp[epp->envc] = NULL;
|
||||
for (i = 0; i < epp->envc; i++) {
|
||||
envp[i] = ucp;
|
||||
if (copystr((caddr_t)epp->envp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) {
|
||||
nc += len;
|
||||
ucp += len;
|
||||
}
|
||||
}
|
||||
envp[epp->envc] = NULL;
|
||||
|
||||
ucp = (caddr_t)roundup((unsigned)ucp, NBPW);
|
||||
if ((caddr_t)ucp != (caddr_t)topp) {
|
||||
DEBUG("Copying of arg list went wrong, ucp=%#x, topp=%#x\n", ucp, topp);
|
||||
panic("exec check");
|
||||
}
|
||||
ucp = (caddr_t)roundup((unsigned)ucp, NBPW);
|
||||
if ((caddr_t)ucp != (caddr_t)topp) {
|
||||
DEBUG("Copying of arg list went wrong, ucp=%#x, topp=%#x\n", ucp, topp);
|
||||
panic("exec check");
|
||||
}
|
||||
|
||||
u.u_frame [FRAME_PC] = entryaddr;
|
||||
DEBUG("Setting up new PC=%#x\n", entryaddr);
|
||||
u.u_frame [FRAME_PC] = entryaddr;
|
||||
DEBUG("Setting up new PC=%#x\n", entryaddr);
|
||||
|
||||
/*
|
||||
* Remember file name for accounting.
|
||||
*/
|
||||
(void) copystr(argp[0], u.u_comm, MAXCOMLEN, 0);
|
||||
/*
|
||||
* Remember file name for accounting.
|
||||
*/
|
||||
(void) copystr(argp[0], u.u_comm, MAXCOMLEN, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -157,26 +156,26 @@ void exec_setupstack(unsigned entryaddr, struct exec_params *epp)
|
||||
*/
|
||||
void *exec_alloc(int size, int ru, struct exec_params *epp)
|
||||
{
|
||||
char *cp;
|
||||
int i;
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXALLOCBUF; i++)
|
||||
if (MAXBSIZE - (ru<=1?epp->alloc[i].fill:roundup(epp->alloc[i].fill,ru)) >= size)
|
||||
break;
|
||||
if (i == MAXALLOCBUF)
|
||||
return NULL;
|
||||
if (epp->alloc[i].bp == NULL) {
|
||||
if ((epp->alloc[i].bp = geteblk()) == NULL) {
|
||||
DEBUG("exec_alloc: no buf\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (ru > 1)
|
||||
epp->alloc[i].fill = roundup(epp->alloc[i].fill, ru);
|
||||
cp = epp->alloc[i].bp->b_addr + epp->alloc[i].fill;
|
||||
epp->alloc[i].fill += size;
|
||||
bzero (cp, size);
|
||||
return cp;
|
||||
for (i = 0; i < MAXALLOCBUF; i++)
|
||||
if (MAXBSIZE - (ru<=1?epp->alloc[i].fill:roundup(epp->alloc[i].fill,ru)) >= size)
|
||||
break;
|
||||
if (i == MAXALLOCBUF)
|
||||
return NULL;
|
||||
if (epp->alloc[i].bp == NULL) {
|
||||
if ((epp->alloc[i].bp = geteblk()) == NULL) {
|
||||
DEBUG("exec_alloc: no buf\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (ru > 1)
|
||||
epp->alloc[i].fill = roundup(epp->alloc[i].fill, ru);
|
||||
cp = epp->alloc[i].bp->b_addr + epp->alloc[i].fill;
|
||||
epp->alloc[i].fill += size;
|
||||
bzero (cp, size);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -184,14 +183,14 @@ void *exec_alloc(int size, int ru, struct exec_params *epp)
|
||||
*/
|
||||
void exec_alloc_freeall(struct exec_params *epp)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAXALLOCBUF; i++) {
|
||||
if (epp->alloc[i].bp) {
|
||||
brelse(epp->alloc[i].bp);
|
||||
epp->alloc[i].bp = NULL;
|
||||
epp->alloc[i].fill = 0;
|
||||
}
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < MAXALLOCBUF; i++) {
|
||||
if (epp->alloc[i].bp) {
|
||||
brelse(epp->alloc[i].bp);
|
||||
epp->alloc[i].bp = NULL;
|
||||
epp->alloc[i].fill = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -201,46 +200,46 @@ void exec_alloc_freeall(struct exec_params *epp)
|
||||
*/
|
||||
int exec_estab(struct exec_params *epp)
|
||||
{
|
||||
DEBUG("text = %#x..%#x, len=%d\n", epp->text.vaddr, epp->text.vaddr+epp->text.len, epp->text.len);
|
||||
DEBUG("data = %#x..%#x, len=%d\n", epp->data.vaddr, epp->data.vaddr+epp->data.len, epp->data.len);
|
||||
DEBUG("bss = %#x..%#x, len=%d\n", epp->bss.vaddr, epp->bss.vaddr+epp->bss.len, epp->bss.len);
|
||||
DEBUG("heap = %#x..%#x, len=%d\n", epp->heap.vaddr, epp->heap.vaddr+epp->heap.len, epp->heap.len);
|
||||
DEBUG("stack = %#x..%#x, len=%d\n", epp->stack.vaddr, epp->stack.vaddr+epp->stack.len, epp->stack.len);
|
||||
DEBUG("text = %#x..%#x, len=%d\n", epp->text.vaddr, epp->text.vaddr+epp->text.len, epp->text.len);
|
||||
DEBUG("data = %#x..%#x, len=%d\n", epp->data.vaddr, epp->data.vaddr+epp->data.len, epp->data.len);
|
||||
DEBUG("bss = %#x..%#x, len=%d\n", epp->bss.vaddr, epp->bss.vaddr+epp->bss.len, epp->bss.len);
|
||||
DEBUG("heap = %#x..%#x, len=%d\n", epp->heap.vaddr, epp->heap.vaddr+epp->heap.len, epp->heap.len);
|
||||
DEBUG("stack = %#x..%#x, len=%d\n", epp->stack.vaddr, epp->stack.vaddr+epp->stack.len, epp->stack.len);
|
||||
|
||||
/*
|
||||
* Right now we can only handle the simple original a.out
|
||||
* case, so we double check for that case here.
|
||||
*/
|
||||
if (epp->text.vaddr != NO_ADDR || epp->data.vaddr == NO_ADDR
|
||||
|| epp->data.vaddr != (caddr_t)USER_DATA_START || epp->stack.vaddr != (caddr_t)USER_DATA_END - epp->stack.len)
|
||||
return ENOMEM;
|
||||
/*
|
||||
* Right now we can only handle the simple original a.out
|
||||
* case, so we double check for that case here.
|
||||
*/
|
||||
if (epp->text.vaddr != NO_ADDR || epp->data.vaddr == NO_ADDR
|
||||
|| epp->data.vaddr != (caddr_t)USER_DATA_START || epp->stack.vaddr != (caddr_t)USER_DATA_END - epp->stack.len)
|
||||
return ENOMEM;
|
||||
|
||||
/*
|
||||
* Try out for overflow
|
||||
*/
|
||||
if (epp->text.len + epp->data.len + epp->heap.len + epp->stack.len > MAXMEM)
|
||||
return ENOMEM;
|
||||
/*
|
||||
* Try out for overflow
|
||||
*/
|
||||
if (epp->text.len + epp->data.len + epp->heap.len + epp->stack.len > MAXMEM)
|
||||
return ENOMEM;
|
||||
|
||||
if (roundup((unsigned)epp->data.vaddr + epp->data.len, NBPW) != roundup((unsigned)epp->bss.vaddr, NBPW)) {
|
||||
DEBUG(".bss do not follow .data\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
if (roundup((unsigned)epp->data.vaddr + epp->data.len, NBPW) != roundup((unsigned)epp->bss.vaddr, NBPW)) {
|
||||
DEBUG(".bss do not follow .data\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate core at this point, committed to the new image.
|
||||
*/
|
||||
u.u_prof.pr_scale = 0;
|
||||
if (u.u_procp->p_flag & SVFORK)
|
||||
endvfork();
|
||||
u.u_procp->p_dsize = epp->data.len + epp->bss.len;
|
||||
u.u_procp->p_daddr = (size_t)epp->data.vaddr;
|
||||
u.u_procp->p_ssize = epp->stack.len;
|
||||
u.u_procp->p_saddr = (size_t)epp->stack.vaddr;
|
||||
/*
|
||||
* Allocate core at this point, committed to the new image.
|
||||
*/
|
||||
u.u_prof.pr_scale = 0;
|
||||
if (u.u_procp->p_flag & SVFORK)
|
||||
endvfork();
|
||||
u.u_procp->p_dsize = epp->data.len + epp->bss.len;
|
||||
u.u_procp->p_daddr = (size_t)epp->data.vaddr;
|
||||
u.u_procp->p_ssize = epp->stack.len;
|
||||
u.u_procp->p_saddr = (size_t)epp->stack.vaddr;
|
||||
|
||||
DEBUG("core allocation: \n");
|
||||
DEBUG("daddr =%#x..%#x\n", u.u_procp->p_daddr, u.u_procp->p_daddr + u.u_procp->p_dsize);
|
||||
DEBUG("saddr =%#x..%#x\n", u.u_procp->p_saddr, u.u_procp->p_saddr + u.u_procp->p_ssize);
|
||||
return 0;
|
||||
DEBUG("core allocation: \n");
|
||||
DEBUG("daddr =%#x..%#x\n", u.u_procp->p_daddr, u.u_procp->p_daddr + u.u_procp->p_dsize);
|
||||
DEBUG("saddr =%#x..%#x\n", u.u_procp->p_saddr, u.u_procp->p_saddr + u.u_procp->p_ssize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,177 +248,170 @@ int exec_estab(struct exec_params *epp)
|
||||
*/
|
||||
void exec_save_args(struct exec_params *epp)
|
||||
{
|
||||
unsigned len;
|
||||
caddr_t cp;
|
||||
int argc, i, l;
|
||||
char **argp, *ap;
|
||||
unsigned len;
|
||||
caddr_t cp;
|
||||
int argc, i, l;
|
||||
char **argp, *ap;
|
||||
|
||||
epp->argc = epp->envc = 0;
|
||||
epp->argbc = epp->envbc = 0;
|
||||
epp->argc = epp->envc = 0;
|
||||
epp->argbc = epp->envbc = 0;
|
||||
|
||||
argc = 0;
|
||||
if ((argp = epp->userargp) != NULL)
|
||||
while (argp[argc])
|
||||
argc++;
|
||||
argc = 0;
|
||||
if ((argp = epp->userargp) != NULL)
|
||||
while (argp[argc])
|
||||
argc++;
|
||||
#ifdef EXEC_SCRIPT
|
||||
if (epp->sh.interpreted) {
|
||||
argc++;
|
||||
if (epp->sh.interparg[0])
|
||||
argc++;
|
||||
}
|
||||
if (epp->sh.interpreted) {
|
||||
argc++;
|
||||
if (epp->sh.interparg[0])
|
||||
argc++;
|
||||
}
|
||||
#endif
|
||||
if (argc != 0) {
|
||||
if ((epp->argp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL)
|
||||
return;
|
||||
for (;;) {
|
||||
/*
|
||||
* For a interpreter script, the arg list is changed to
|
||||
* #! <interpreter name> <interpreter arg>
|
||||
* arg[0] - the interpreter executable name (path)
|
||||
* arg[1] - interpreter arg (optional)
|
||||
* arg[2 or 1] - script name
|
||||
* arg[3 or 2...] - script arg[1...]
|
||||
*/
|
||||
if (argp)
|
||||
ap = *argp++;
|
||||
else
|
||||
ap = NULL;
|
||||
if (argc != 0) {
|
||||
if ((epp->argp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL)
|
||||
return;
|
||||
for (;;) {
|
||||
/*
|
||||
* For a interpreter script, the arg list is changed to
|
||||
* #! <interpreter name> <interpreter arg>
|
||||
* arg[0] - the interpreter executable name (path)
|
||||
* arg[1] - interpreter arg (optional)
|
||||
* arg[2 or 1] - script name
|
||||
* arg[3 or 2...] - script arg[1...]
|
||||
*/
|
||||
if (argp)
|
||||
ap = *argp++;
|
||||
else
|
||||
ap = NULL;
|
||||
#ifdef EXEC_SCRIPT
|
||||
if (epp->sh.interpreted) {
|
||||
if (epp->argc == 0)
|
||||
ap = epp->sh.interpname;
|
||||
else if (epp->argc == 1 && epp->sh.interparg[0]) {
|
||||
ap = epp->sh.interparg;
|
||||
--argp;
|
||||
} else if ((epp->argc == 1 || (epp->argc == 2 && epp->sh.interparg[0]))) {
|
||||
ap = epp->userfname;
|
||||
--argp;
|
||||
}
|
||||
}
|
||||
if (epp->sh.interpreted) {
|
||||
if (epp->argc == 0)
|
||||
ap = epp->sh.interpname;
|
||||
else if (epp->argc == 1 && epp->sh.interparg[0]) {
|
||||
ap = epp->sh.interparg;
|
||||
--argp;
|
||||
} else if ((epp->argc == 1 || (epp->argc == 2 && epp->sh.interparg[0]))) {
|
||||
ap = epp->userfname;
|
||||
--argp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ap == 0)
|
||||
break;
|
||||
l = strlen(ap)+1;
|
||||
if ((cp = exec_alloc(l, 1, epp)) == NULL)
|
||||
return;
|
||||
if (copystr(ap, cp, l, &len) != 0)
|
||||
return;
|
||||
epp->argp[epp->argc++] = cp;
|
||||
epp->argbc += len;;
|
||||
}
|
||||
}
|
||||
argc = 0;
|
||||
if ((argp = epp->userenvp) != NULL)
|
||||
while (argp[argc])
|
||||
argc++;
|
||||
epp->envc = 0;
|
||||
epp->envbc = 0;
|
||||
if (argc != 0) {
|
||||
if ((epp->envp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL)
|
||||
return;
|
||||
for (;;) {
|
||||
if (argp)
|
||||
ap = *argp++;
|
||||
else
|
||||
ap = NULL;
|
||||
if (ap == 0)
|
||||
break;
|
||||
l = strlen(ap)+1;
|
||||
if ((cp = exec_alloc(l, 1, epp)) == NULL)
|
||||
return;
|
||||
if (copystr(ap, cp, l, &len) != 0)
|
||||
return;
|
||||
epp->envp[epp->envc++] = cp;
|
||||
epp->envbc += len;
|
||||
}
|
||||
}
|
||||
if (ap == 0)
|
||||
break;
|
||||
l = strlen(ap)+1;
|
||||
if ((cp = exec_alloc(l, 1, epp)) == NULL)
|
||||
return;
|
||||
if (copystr(ap, cp, l, &len) != 0)
|
||||
return;
|
||||
epp->argp[epp->argc++] = cp;
|
||||
epp->argbc += len;;
|
||||
}
|
||||
}
|
||||
argc = 0;
|
||||
if ((argp = epp->userenvp) != NULL)
|
||||
while (argp[argc])
|
||||
argc++;
|
||||
epp->envc = 0;
|
||||
epp->envbc = 0;
|
||||
if (argc != 0) {
|
||||
if ((epp->envp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL)
|
||||
return;
|
||||
for (;;) {
|
||||
if (argp)
|
||||
ap = *argp++;
|
||||
else
|
||||
ap = NULL;
|
||||
if (ap == 0)
|
||||
break;
|
||||
l = strlen(ap)+1;
|
||||
if ((cp = exec_alloc(l, 1, epp)) == NULL)
|
||||
return;
|
||||
if (copystr(ap, cp, l, &len) != 0)
|
||||
return;
|
||||
epp->envp[epp->envc++] = cp;
|
||||
epp->envbc += len;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < epp->argc; i++)
|
||||
DEBUG("arg[%d] = \"%s\"\n", i, epp->argp[i]);
|
||||
for (i = 0; i < epp->argc; i++)
|
||||
DEBUG("arg[%d] = \"%s\"\n", i, epp->argp[i]);
|
||||
|
||||
for (i = 0; i < epp->envc; i++)
|
||||
DEBUG("env[%d] = \"%s\"\n", i, epp->envp[i]);
|
||||
|
||||
|
||||
/*
|
||||
* Number of string pool chars needed for this arg list
|
||||
*/
|
||||
// return (bc + NBPW-1) & ~(NBPW-1);
|
||||
return;
|
||||
for (i = 0; i < epp->envc; i++)
|
||||
DEBUG("env[%d] = \"%s\"\n", i, epp->envp[i]);
|
||||
}
|
||||
|
||||
void exec_clear(struct exec_params *epp)
|
||||
{
|
||||
char *cp;
|
||||
int cc;
|
||||
char *cp;
|
||||
int cc;
|
||||
|
||||
/* clear BSS */
|
||||
if (epp->bss.len > 0)
|
||||
bzero((void *)epp->bss.vaddr, epp->bss.len);
|
||||
if (epp->heap.len > 0)
|
||||
bzero((void *)epp->heap.vaddr, epp->heap.len);
|
||||
/* Clear stack */
|
||||
bzero((void *)epp->stack.vaddr, epp->stack.len);
|
||||
/* clear BSS */
|
||||
if (epp->bss.len > 0)
|
||||
bzero((void *)epp->bss.vaddr, epp->bss.len);
|
||||
if (epp->heap.len > 0)
|
||||
bzero((void *)epp->heap.vaddr, epp->heap.len);
|
||||
/* Clear stack */
|
||||
bzero((void *)epp->stack.vaddr, epp->stack.len);
|
||||
|
||||
/*
|
||||
* set SUID/SGID protections, if no tracing
|
||||
*/
|
||||
if ((u.u_procp->p_flag & P_TRACED) == 0) {
|
||||
u.u_uid = epp->uid;
|
||||
u.u_procp->p_uid = epp->uid;
|
||||
u.u_groups[0] = epp->gid;
|
||||
} else
|
||||
psignal (u.u_procp, SIGTRAP);
|
||||
u.u_svuid = u.u_uid;
|
||||
u.u_svgid = u.u_groups[0];
|
||||
/*
|
||||
* set SUID/SGID protections, if no tracing
|
||||
*/
|
||||
if ((u.u_procp->p_flag & P_TRACED) == 0) {
|
||||
u.u_uid = epp->uid;
|
||||
u.u_procp->p_uid = epp->uid;
|
||||
u.u_groups[0] = epp->gid;
|
||||
} else
|
||||
psignal (u.u_procp, SIGTRAP);
|
||||
u.u_svuid = u.u_uid;
|
||||
u.u_svgid = u.u_groups[0];
|
||||
|
||||
u.u_tsize = epp->text.len;
|
||||
u.u_dsize = epp->data.len + epp->bss.len;
|
||||
u.u_ssize = epp->stack.len;
|
||||
u.u_tsize = epp->text.len;
|
||||
u.u_dsize = epp->data.len + epp->bss.len;
|
||||
u.u_ssize = epp->stack.len;
|
||||
|
||||
/*
|
||||
* Clear registers.
|
||||
*/
|
||||
u.u_frame [FRAME_R1] = 0; /* $at */
|
||||
u.u_frame [FRAME_R2] = 0; /* $v0 */
|
||||
u.u_frame [FRAME_R3] = 0; /* $v1 */
|
||||
u.u_frame [FRAME_R7] = 0; /* $a3 */
|
||||
u.u_frame [FRAME_R8] = 0; /* $t0 */
|
||||
u.u_frame [FRAME_R9] = 0; /* $t1 */
|
||||
u.u_frame [FRAME_R10] = 0; /* $t2 */
|
||||
u.u_frame [FRAME_R11] = 0; /* $t3 */
|
||||
u.u_frame [FRAME_R12] = 0; /* $t4 */
|
||||
u.u_frame [FRAME_R13] = 0; /* $t5 */
|
||||
u.u_frame [FRAME_R14] = 0; /* $t6 */
|
||||
u.u_frame [FRAME_R15] = 0; /* $t7 */
|
||||
u.u_frame [FRAME_R16] = 0; /* $s0 */
|
||||
u.u_frame [FRAME_R17] = 0; /* $s1 */
|
||||
u.u_frame [FRAME_R18] = 0; /* $s2 */
|
||||
u.u_frame [FRAME_R19] = 0; /* $s3 */
|
||||
u.u_frame [FRAME_R20] = 0; /* $s4 */
|
||||
u.u_frame [FRAME_R21] = 0; /* $s5 */
|
||||
u.u_frame [FRAME_R22] = 0; /* $s6 */
|
||||
u.u_frame [FRAME_R23] = 0; /* $s7 */
|
||||
u.u_frame [FRAME_R24] = 0; /* $t8 */
|
||||
u.u_frame [FRAME_R25] = 0; /* $t9 */
|
||||
u.u_frame [FRAME_FP] = 0;
|
||||
u.u_frame [FRAME_RA] = 0;
|
||||
u.u_frame [FRAME_LO] = 0;
|
||||
u.u_frame [FRAME_HI] = 0;
|
||||
u.u_frame [FRAME_GP] = 0;
|
||||
/*
|
||||
* Clear registers.
|
||||
*/
|
||||
u.u_frame [FRAME_R1] = 0; /* $at */
|
||||
u.u_frame [FRAME_R2] = 0; /* $v0 */
|
||||
u.u_frame [FRAME_R3] = 0; /* $v1 */
|
||||
u.u_frame [FRAME_R7] = 0; /* $a3 */
|
||||
u.u_frame [FRAME_R8] = 0; /* $t0 */
|
||||
u.u_frame [FRAME_R9] = 0; /* $t1 */
|
||||
u.u_frame [FRAME_R10] = 0; /* $t2 */
|
||||
u.u_frame [FRAME_R11] = 0; /* $t3 */
|
||||
u.u_frame [FRAME_R12] = 0; /* $t4 */
|
||||
u.u_frame [FRAME_R13] = 0; /* $t5 */
|
||||
u.u_frame [FRAME_R14] = 0; /* $t6 */
|
||||
u.u_frame [FRAME_R15] = 0; /* $t7 */
|
||||
u.u_frame [FRAME_R16] = 0; /* $s0 */
|
||||
u.u_frame [FRAME_R17] = 0; /* $s1 */
|
||||
u.u_frame [FRAME_R18] = 0; /* $s2 */
|
||||
u.u_frame [FRAME_R19] = 0; /* $s3 */
|
||||
u.u_frame [FRAME_R20] = 0; /* $s4 */
|
||||
u.u_frame [FRAME_R21] = 0; /* $s5 */
|
||||
u.u_frame [FRAME_R22] = 0; /* $s6 */
|
||||
u.u_frame [FRAME_R23] = 0; /* $s7 */
|
||||
u.u_frame [FRAME_R24] = 0; /* $t8 */
|
||||
u.u_frame [FRAME_R25] = 0; /* $t9 */
|
||||
u.u_frame [FRAME_FP] = 0;
|
||||
u.u_frame [FRAME_RA] = 0;
|
||||
u.u_frame [FRAME_LO] = 0;
|
||||
u.u_frame [FRAME_HI] = 0;
|
||||
u.u_frame [FRAME_GP] = 0;
|
||||
|
||||
execsigs (u.u_procp);
|
||||
execsigs (u.u_procp);
|
||||
|
||||
/*
|
||||
* Clear (close) files
|
||||
*/
|
||||
for (cp = u.u_pofile, cc = 0; cc <= u.u_lastfile; cc++, cp++) {
|
||||
if (*cp & UF_EXCLOSE) {
|
||||
(void) closef (u.u_ofile [cc]);
|
||||
u.u_ofile [cc] = NULL;
|
||||
*cp = 0;
|
||||
}
|
||||
}
|
||||
while (u.u_lastfile >= 0 && u.u_ofile [u.u_lastfile] == NULL)
|
||||
u.u_lastfile--;
|
||||
/*
|
||||
* Clear (close) files
|
||||
*/
|
||||
for (cp = u.u_pofile, cc = 0; cc <= u.u_lastfile; cc++, cp++) {
|
||||
if (*cp & UF_EXCLOSE) {
|
||||
(void) closef (u.u_ofile [cc]);
|
||||
u.u_ofile [cc] = NULL;
|
||||
*cp = 0;
|
||||
}
|
||||
}
|
||||
while (u.u_lastfile >= 0 && u.u_ofile [u.u_lastfile] == NULL)
|
||||
u.u_lastfile--;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#include "stat.h"
|
||||
#include "rdisk.h"
|
||||
|
||||
u_int swapstart, nswap; /* start and size of swap space */
|
||||
size_t physmem; /* total amount of physical memory */
|
||||
int boothowto; /* reboot flags, from boot */
|
||||
u_int swapstart, nswap; /* start and size of swap space */
|
||||
size_t physmem; /* total amount of physical memory */
|
||||
int boothowto; /* reboot flags, from boot */
|
||||
|
||||
/*
|
||||
* Initialize hash links for buffers.
|
||||
@@ -33,11 +33,11 @@ int boothowto; /* reboot flags, from boot */
|
||||
static void
|
||||
bhinit()
|
||||
{
|
||||
register int i;
|
||||
register struct bufhd *bp;
|
||||
register int i;
|
||||
register struct bufhd *bp;
|
||||
|
||||
for (bp = bufhash, i = 0; i < BUFHSZ; i++, bp++)
|
||||
bp->b_forw = bp->b_back = (struct buf *)bp;
|
||||
for (bp = bufhash, i = 0; i < BUFHSZ; i++, bp++)
|
||||
bp->b_forw = bp->b_back = (struct buf *)bp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -47,22 +47,22 @@ bhinit()
|
||||
static void
|
||||
binit()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register int i;
|
||||
caddr_t paddr;
|
||||
register struct buf *bp;
|
||||
register int i;
|
||||
caddr_t paddr;
|
||||
|
||||
for (bp = bfreelist; bp < &bfreelist[BQUEUES]; bp++)
|
||||
bp->b_forw = bp->b_back = bp->av_forw = bp->av_back = bp;
|
||||
paddr = bufdata;
|
||||
for (i = 0; i < NBUF; i++, paddr += MAXBSIZE) {
|
||||
bp = &buf[i];
|
||||
bp->b_dev = NODEV;
|
||||
bp->b_bcount = 0;
|
||||
bp->b_addr = paddr;
|
||||
binshash(bp, &bfreelist[BQ_AGE]);
|
||||
bp->b_flags = B_BUSY|B_INVAL;
|
||||
brelse(bp);
|
||||
}
|
||||
for (bp = bfreelist; bp < &bfreelist[BQUEUES]; bp++)
|
||||
bp->b_forw = bp->b_back = bp->av_forw = bp->av_back = bp;
|
||||
paddr = bufdata;
|
||||
for (i = 0; i < NBUF; i++, paddr += MAXBSIZE) {
|
||||
bp = &buf[i];
|
||||
bp->b_dev = NODEV;
|
||||
bp->b_bcount = 0;
|
||||
bp->b_addr = paddr;
|
||||
binshash(bp, &bfreelist[BQ_AGE]);
|
||||
bp->b_flags = B_BUSY|B_INVAL;
|
||||
brelse(bp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -72,16 +72,16 @@ binit()
|
||||
static void
|
||||
cinit()
|
||||
{
|
||||
register int ccp;
|
||||
register struct cblock *cp;
|
||||
register int ccp;
|
||||
register struct cblock *cp;
|
||||
|
||||
ccp = (int)cfree;
|
||||
ccp = (ccp + CROUND) & ~CROUND;
|
||||
for (cp = (struct cblock *)ccp; cp <= &cfree[NCLIST - 1]; cp++) {
|
||||
cp->c_next = cfreelist;
|
||||
cfreelist = cp;
|
||||
cfreecount += CBSIZE;
|
||||
}
|
||||
ccp = (int)cfree;
|
||||
ccp = (ccp + CROUND) & ~CROUND;
|
||||
for (cp = (struct cblock *)ccp; cp <= &cfree[NCLIST - 1]; cp++) {
|
||||
cp->c_next = cfreelist;
|
||||
cfreelist = cp;
|
||||
cfreecount += CBSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -90,252 +90,252 @@ cinit()
|
||||
* soon as a stack and segmentation
|
||||
* have been established.
|
||||
* Functions:
|
||||
* clear and free user core
|
||||
* turn on clock
|
||||
* hand craft 0th process
|
||||
* call all initialization routines
|
||||
* fork - process 0 to schedule
|
||||
* - process 1 execute bootstrap
|
||||
* clear and free user core
|
||||
* turn on clock
|
||||
* hand craft 0th process
|
||||
* call all initialization routines
|
||||
* fork - process 0 to schedule
|
||||
* - process 1 execute bootstrap
|
||||
*/
|
||||
int
|
||||
main()
|
||||
{
|
||||
register struct proc *p;
|
||||
register int i;
|
||||
register struct fs *fs = NULL;
|
||||
char inbuf[4];
|
||||
char inch;
|
||||
int s __attribute__((unused));
|
||||
register struct proc *p;
|
||||
register int i;
|
||||
register struct fs *fs = NULL;
|
||||
char inbuf[4];
|
||||
char inch;
|
||||
int s __attribute__((unused));
|
||||
|
||||
startup();
|
||||
printf ("\n%s", version);
|
||||
cpuidentify();
|
||||
cnidentify();
|
||||
startup();
|
||||
printf ("\n%s", version);
|
||||
cpuidentify();
|
||||
cnidentify();
|
||||
|
||||
/*
|
||||
* Set up system process 0 (swapper).
|
||||
*/
|
||||
p = &proc[0];
|
||||
p->p_addr = (size_t) &u;
|
||||
p->p_stat = SRUN;
|
||||
p->p_flag |= SLOAD | SSYS;
|
||||
p->p_nice = NZERO;
|
||||
/*
|
||||
* Set up system process 0 (swapper).
|
||||
*/
|
||||
p = &proc[0];
|
||||
p->p_addr = (size_t) &u;
|
||||
p->p_stat = SRUN;
|
||||
p->p_flag |= SLOAD | SSYS;
|
||||
p->p_nice = NZERO;
|
||||
|
||||
u.u_procp = p; /* init user structure */
|
||||
u.u_cmask = CMASK;
|
||||
u.u_lastfile = -1;
|
||||
for (i = 1; i < NGROUPS; i++)
|
||||
u.u_groups[i] = NOGROUP;
|
||||
for (i = 0; i < sizeof(u.u_rlimit)/sizeof(u.u_rlimit[0]); i++)
|
||||
u.u_rlimit[i].rlim_cur = u.u_rlimit[i].rlim_max =
|
||||
RLIM_INFINITY;
|
||||
u.u_procp = p; /* init user structure */
|
||||
u.u_cmask = CMASK;
|
||||
u.u_lastfile = -1;
|
||||
for (i = 1; i < NGROUPS; i++)
|
||||
u.u_groups[i] = NOGROUP;
|
||||
for (i = 0; i < sizeof(u.u_rlimit)/sizeof(u.u_rlimit[0]); i++)
|
||||
u.u_rlimit[i].rlim_cur = u.u_rlimit[i].rlim_max =
|
||||
RLIM_INFINITY;
|
||||
|
||||
/* Initialize signal state for process 0 */
|
||||
siginit (p);
|
||||
/* Initialize signal state for process 0 */
|
||||
siginit (p);
|
||||
|
||||
/*
|
||||
* Initialize tables, protocols, and set up well-known inodes.
|
||||
*/
|
||||
/*
|
||||
* Initialize tables, protocols, and set up well-known inodes.
|
||||
*/
|
||||
#ifdef LOG_ENABLED
|
||||
loginit();
|
||||
loginit();
|
||||
#endif
|
||||
coutinit();
|
||||
cinit();
|
||||
pqinit();
|
||||
ihinit();
|
||||
bhinit();
|
||||
binit();
|
||||
nchinit();
|
||||
clkstart();
|
||||
s = spl0();
|
||||
rdisk_init();
|
||||
coutinit();
|
||||
cinit();
|
||||
pqinit();
|
||||
ihinit();
|
||||
bhinit();
|
||||
binit();
|
||||
nchinit();
|
||||
clkstart();
|
||||
s = spl0();
|
||||
rdisk_init();
|
||||
|
||||
pipedev = rootdev = get_boot_device();
|
||||
swapdev = get_swap_device();
|
||||
pipedev = rootdev = get_boot_device();
|
||||
swapdev = get_swap_device();
|
||||
|
||||
/* Mount a root filesystem. */
|
||||
for (;;) {
|
||||
if(rootdev!=-1)
|
||||
{
|
||||
fs = mountfs (rootdev, (boothowto & RB_RDONLY) ? MNT_RDONLY : 0,
|
||||
(struct inode*) 0);
|
||||
}
|
||||
if (fs)
|
||||
break;
|
||||
printf ("No root filesystem available!\n");
|
||||
// rdisk_list_partitions(RDISK_FS);
|
||||
/* Mount a root filesystem. */
|
||||
for (;;) {
|
||||
if(rootdev!=-1)
|
||||
{
|
||||
fs = mountfs (rootdev, (boothowto & RB_RDONLY) ? MNT_RDONLY : 0,
|
||||
(struct inode*) 0);
|
||||
}
|
||||
if (fs)
|
||||
break;
|
||||
printf ("No root filesystem available!\n");
|
||||
// rdisk_list_partitions(RDISK_FS);
|
||||
retry:
|
||||
printf ("Please enter device to boot from (press ? to list): ");
|
||||
inch=0;
|
||||
inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
|
||||
while((inch=cngetc()) != '\r')
|
||||
{
|
||||
switch(inch)
|
||||
{
|
||||
case '?':
|
||||
printf("?\n");
|
||||
rdisk_list_partitions(RDISK_FS);
|
||||
printf ("Please enter device to boot from (press ? to list): ");
|
||||
break;
|
||||
default:
|
||||
printf("%c",inch);
|
||||
inbuf[0] = inbuf[1];
|
||||
inbuf[1] = inbuf[2];
|
||||
inbuf[2] = inbuf[3];
|
||||
inbuf[3] = inch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inch = 0;
|
||||
if(inbuf[0]=='r' && inbuf[1]=='d')
|
||||
{
|
||||
if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
|
||||
{
|
||||
if(inbuf[3]>='a' && inbuf[3]<='d')
|
||||
{
|
||||
rootdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
} else if(inbuf[1]=='r' && inbuf[2]=='d') {
|
||||
if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
|
||||
{
|
||||
rootdev=makedev(inbuf[3]-'0',0);
|
||||
inch = 1;
|
||||
}
|
||||
} else if(inbuf[3] == 0) {
|
||||
inch = 1;
|
||||
}
|
||||
if(inch==0)
|
||||
{
|
||||
printf("\nUnknown device.\n\n");
|
||||
goto retry;
|
||||
}
|
||||
printf ("\n\n");
|
||||
printf ("Please enter device to boot from (press ? to list): ");
|
||||
inch=0;
|
||||
inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
|
||||
while((inch=cngetc()) != '\r')
|
||||
{
|
||||
switch(inch)
|
||||
{
|
||||
case '?':
|
||||
printf("?\n");
|
||||
rdisk_list_partitions(RDISK_FS);
|
||||
printf ("Please enter device to boot from (press ? to list): ");
|
||||
break;
|
||||
default:
|
||||
printf("%c",inch);
|
||||
inbuf[0] = inbuf[1];
|
||||
inbuf[1] = inbuf[2];
|
||||
inbuf[2] = inbuf[3];
|
||||
inbuf[3] = inch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf ("phys mem = %u kbytes\n", physmem / 1024);
|
||||
printf ("user mem = %u kbytes\n", MAXMEM / 1024);
|
||||
if(minor(rootdev)==0)
|
||||
{
|
||||
printf ("root dev = rd%d (%d,%d)\n",
|
||||
major(rootdev),
|
||||
major(rootdev), minor(rootdev)
|
||||
);
|
||||
} else {
|
||||
printf ("root dev = rd%d%c (%d,%d)\n",
|
||||
major(rootdev), 'a'+minor(rootdev)-1,
|
||||
major(rootdev), minor(rootdev)
|
||||
);
|
||||
}
|
||||
|
||||
printf ("root size = %u kbytes\n", fs->fs_fsize * DEV_BSIZE / 1024);
|
||||
mount[0].m_inodp = (struct inode*) 1; /* XXX */
|
||||
mount_updname (fs, "/", "root", 1, 4);
|
||||
time.tv_sec = fs->fs_time;
|
||||
boottime = time;
|
||||
|
||||
/* Find a swap file. */
|
||||
swapstart = 1;
|
||||
while(swapdev == -1)
|
||||
{
|
||||
printf("Please enter swap device (press ? to list): ");
|
||||
inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
|
||||
while((inch = cngetc())!='\r')
|
||||
{
|
||||
switch(inch)
|
||||
{
|
||||
case '?':
|
||||
printf("?\n");
|
||||
rdisk_list_partitions(RDISK_SWAP);
|
||||
printf("Please enter swap device (press ? to list): ");
|
||||
break;
|
||||
default:
|
||||
printf("%c",inch);
|
||||
inbuf[0] = inbuf[1];
|
||||
inbuf[1] = inbuf[2];
|
||||
inbuf[2] = inbuf[3];
|
||||
inbuf[3] = inch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
inch = 0;
|
||||
if(inbuf[0]=='r' && inbuf[1]=='d')
|
||||
{
|
||||
if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
|
||||
{
|
||||
if(inbuf[3]>='a' && inbuf[3]<='d')
|
||||
{
|
||||
swapdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
} else if(inbuf[1]=='r' && inbuf[2]=='d') {
|
||||
if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
|
||||
{
|
||||
swapdev=makedev(inbuf[3]-'0',0);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(minor(swapdev)!=0)
|
||||
{
|
||||
if(partition_type(swapdev)!=RDISK_SWAP)
|
||||
{
|
||||
printf("\nNot a swap partition!\n\n");
|
||||
swapdev=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
nswap = rdsize(swapdev);
|
||||
|
||||
if(minor(swapdev)==0)
|
||||
{
|
||||
printf ("swap dev = rd%d (%d,%d)\n",
|
||||
major(swapdev),
|
||||
major(swapdev), minor(swapdev)
|
||||
);
|
||||
} else {
|
||||
printf ("swap dev = rd%d%c (%d,%d)\n",
|
||||
major(swapdev), 'a'+minor(swapdev)-1,
|
||||
major(swapdev), minor(swapdev)
|
||||
);
|
||||
}
|
||||
(*bdevsw[major(swapdev)].d_open)(swapdev, FREAD|FWRITE, S_IFBLK);
|
||||
printf ("swap size = %u kbytes\n", nswap * DEV_BSIZE / 1024);
|
||||
if (nswap <= 0)
|
||||
panic ("zero swap size"); /* don't want to panic, but what ? */
|
||||
mfree (swapmap, nswap, swapstart);
|
||||
|
||||
/* Kick off timeout driven events by calling first time. */
|
||||
schedcpu (0);
|
||||
|
||||
/* Set up the root file system. */
|
||||
rootdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
|
||||
iunlock (rootdir);
|
||||
u.u_cdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
|
||||
iunlock (u.u_cdir);
|
||||
u.u_rdir = NULL;
|
||||
|
||||
/*
|
||||
* Make init process.
|
||||
*/
|
||||
if (newproc (0) == 0) {
|
||||
/* Parent process with pid 0: swapper.
|
||||
* No return from sched. */
|
||||
sched();
|
||||
inch = 0;
|
||||
if(inbuf[0]=='r' && inbuf[1]=='d')
|
||||
{
|
||||
if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
|
||||
{
|
||||
if(inbuf[3]>='a' && inbuf[3]<='d')
|
||||
{
|
||||
rootdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
} else if(inbuf[1]=='r' && inbuf[2]=='d') {
|
||||
if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
|
||||
{
|
||||
rootdev=makedev(inbuf[3]-'0',0);
|
||||
inch = 1;
|
||||
}
|
||||
} else if(inbuf[3] == 0) {
|
||||
inch = 1;
|
||||
}
|
||||
/* Child process with pid 1: init. */
|
||||
s = splhigh();
|
||||
p = u.u_procp;
|
||||
p->p_dsize = icodeend - icode;
|
||||
p->p_daddr = USER_DATA_START;
|
||||
p->p_ssize = 1024; /* one kbyte of stack */
|
||||
p->p_saddr = USER_DATA_END - 1024;
|
||||
bcopy ((caddr_t) icode, (caddr_t) USER_DATA_START, icodeend - icode);
|
||||
/*
|
||||
* return goes to location 0 of user init code
|
||||
* just copied out.
|
||||
*/
|
||||
return 0;
|
||||
if(inch==0)
|
||||
{
|
||||
printf("\nUnknown device.\n\n");
|
||||
goto retry;
|
||||
}
|
||||
printf ("\n\n");
|
||||
}
|
||||
printf ("phys mem = %u kbytes\n", physmem / 1024);
|
||||
printf ("user mem = %u kbytes\n", MAXMEM / 1024);
|
||||
if(minor(rootdev)==0)
|
||||
{
|
||||
printf ("root dev = rd%d (%d,%d)\n",
|
||||
major(rootdev),
|
||||
major(rootdev), minor(rootdev)
|
||||
);
|
||||
} else {
|
||||
printf ("root dev = rd%d%c (%d,%d)\n",
|
||||
major(rootdev), 'a'+minor(rootdev)-1,
|
||||
major(rootdev), minor(rootdev)
|
||||
);
|
||||
}
|
||||
|
||||
printf ("root size = %u kbytes\n", fs->fs_fsize * DEV_BSIZE / 1024);
|
||||
mount[0].m_inodp = (struct inode*) 1; /* XXX */
|
||||
mount_updname (fs, "/", "root", 1, 4);
|
||||
time.tv_sec = fs->fs_time;
|
||||
boottime = time;
|
||||
|
||||
/* Find a swap file. */
|
||||
swapstart = 1;
|
||||
while(swapdev == -1)
|
||||
{
|
||||
printf("Please enter swap device (press ? to list): ");
|
||||
inbuf[0] = inbuf[1] = inbuf[2] = inbuf[3] = 0;
|
||||
while((inch = cngetc())!='\r')
|
||||
{
|
||||
switch(inch)
|
||||
{
|
||||
case '?':
|
||||
printf("?\n");
|
||||
rdisk_list_partitions(RDISK_SWAP);
|
||||
printf("Please enter swap device (press ? to list): ");
|
||||
break;
|
||||
default:
|
||||
printf("%c",inch);
|
||||
inbuf[0] = inbuf[1];
|
||||
inbuf[1] = inbuf[2];
|
||||
inbuf[2] = inbuf[3];
|
||||
inbuf[3] = inch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
inch = 0;
|
||||
if(inbuf[0]=='r' && inbuf[1]=='d')
|
||||
{
|
||||
if(inbuf[2]>='0' && inbuf[2] < '0'+rdisk_num_disks())
|
||||
{
|
||||
if(inbuf[3]>='a' && inbuf[3]<='d')
|
||||
{
|
||||
swapdev=makedev(inbuf[2]-'0',inbuf[3]-'a'+1);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
} else if(inbuf[1]=='r' && inbuf[2]=='d') {
|
||||
if(inbuf[3]>='0' && inbuf[3] < '0'+rdisk_num_disks())
|
||||
{
|
||||
swapdev=makedev(inbuf[3]-'0',0);
|
||||
inch = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(minor(swapdev)!=0)
|
||||
{
|
||||
if(partition_type(swapdev)!=RDISK_SWAP)
|
||||
{
|
||||
printf("\nNot a swap partition!\n\n");
|
||||
swapdev=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
nswap = rdsize(swapdev);
|
||||
|
||||
if(minor(swapdev)==0)
|
||||
{
|
||||
printf ("swap dev = rd%d (%d,%d)\n",
|
||||
major(swapdev),
|
||||
major(swapdev), minor(swapdev)
|
||||
);
|
||||
} else {
|
||||
printf ("swap dev = rd%d%c (%d,%d)\n",
|
||||
major(swapdev), 'a'+minor(swapdev)-1,
|
||||
major(swapdev), minor(swapdev)
|
||||
);
|
||||
}
|
||||
(*bdevsw[major(swapdev)].d_open)(swapdev, FREAD|FWRITE, S_IFBLK);
|
||||
printf ("swap size = %u kbytes\n", nswap * DEV_BSIZE / 1024);
|
||||
if (nswap <= 0)
|
||||
panic ("zero swap size"); /* don't want to panic, but what ? */
|
||||
mfree (swapmap, nswap, swapstart);
|
||||
|
||||
/* Kick off timeout driven events by calling first time. */
|
||||
schedcpu (0);
|
||||
|
||||
/* Set up the root file system. */
|
||||
rootdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
|
||||
iunlock (rootdir);
|
||||
u.u_cdir = iget (rootdev, &mount[0].m_filsys, (ino_t) ROOTINO);
|
||||
iunlock (u.u_cdir);
|
||||
u.u_rdir = NULL;
|
||||
|
||||
/*
|
||||
* Make init process.
|
||||
*/
|
||||
if (newproc (0) == 0) {
|
||||
/* Parent process with pid 0: swapper.
|
||||
* No return from sched. */
|
||||
sched();
|
||||
}
|
||||
/* Child process with pid 1: init. */
|
||||
s = splhigh();
|
||||
p = u.u_procp;
|
||||
p->p_dsize = icodeend - icode;
|
||||
p->p_daddr = USER_DATA_START;
|
||||
p->p_ssize = 1024; /* one kbyte of stack */
|
||||
p->p_saddr = USER_DATA_END - 1024;
|
||||
bcopy ((caddr_t) icode, (caddr_t) USER_DATA_START, icodeend - icode);
|
||||
/*
|
||||
* return goes to location 0 of user init code
|
||||
* just copied out.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "glob.h"
|
||||
|
||||
#ifdef INET
|
||||
# define ifnet(narg, name) narg, name
|
||||
# define errnet(narg, name) narg, name
|
||||
# define ifnet(narg, name) narg, name
|
||||
# define errnet(narg, name) narg, name
|
||||
#else
|
||||
# define ifnet(narg, name) 0, nosys
|
||||
# define errnet(narg, name) 0, nonet
|
||||
# define ifnet(narg, name) 0, nosys
|
||||
# define errnet(narg, name) 0, nonet
|
||||
#endif
|
||||
|
||||
extern void sc_msec();
|
||||
@@ -36,176 +36,176 @@ extern void sc_msec();
|
||||
* are encoded in the lower byte of the trap instruction -- see trap.c.
|
||||
*/
|
||||
const struct sysent sysent[] = {
|
||||
{ 1, nosys }, /* 0 = out-of-range */
|
||||
{ 1, rexit }, /* 1 = exit */
|
||||
{ 0, fork }, /* 2 = fork */
|
||||
{ 3, read }, /* 3 = read */
|
||||
{ 3, write }, /* 4 = write */
|
||||
{ 3, open }, /* 5 = open */
|
||||
{ 1, close }, /* 6 = close */
|
||||
{ 4, wait4 }, /* 7 = wait4 */
|
||||
{ 0, nosys }, /* 8 = (old creat) */
|
||||
{ 2, link }, /* 9 = link */
|
||||
{ 1, unlink }, /* 10 = unlink */
|
||||
{ 2, execv }, /* 11 = execv */
|
||||
{ 1, chdir }, /* 12 = chdir */
|
||||
{ 1, fchdir }, /* 13 = fchdir */
|
||||
{ 3, mknod }, /* 14 = mknod */
|
||||
{ 2, chmod }, /* 15 = chmod */
|
||||
{ 3, chown }, /* 16 = chown; now 3 args */
|
||||
{ 2, chflags }, /* 17 = chflags */
|
||||
{ 2, fchflags }, /* 18 = fchflags */
|
||||
{ 4, lseek }, /* 19 = lseek */
|
||||
{ 0, getpid }, /* 20 = getpid */
|
||||
{ 3, smount }, /* 21 = mount */
|
||||
{ 1, umount }, /* 22 = umount */
|
||||
{ 6, __sysctl }, /* 23 = __sysctl */
|
||||
{ 0, getuid }, /* 24 = getuid */
|
||||
{ 0, geteuid }, /* 25 = geteuid */
|
||||
{ 4, ptrace }, /* 26 = ptrace */
|
||||
{ 0, getppid }, /* 27 = getppid */
|
||||
{ 2, statfs }, /* 28 = statfs */
|
||||
{ 2, fstatfs }, /* 29 = fstatfs */
|
||||
{ 3, getfsstat }, /* 30 = getfsstat */
|
||||
{ 4, sigaction }, /* 31 = sigaction */
|
||||
{ 3, sigprocmask }, /* 32 = sigprocmask */
|
||||
{ 2, saccess }, /* 33 = access */
|
||||
{ 1, sigpending }, /* 34 = sigpending */
|
||||
{ 2, sigaltstack }, /* 35 = sigaltstack */
|
||||
{ 0, sync }, /* 36 = sync */
|
||||
{ 2, kill }, /* 37 = kill */
|
||||
{ 2, stat }, /* 38 = stat */
|
||||
{ 2, nosys }, /* 39 = getlogin */
|
||||
{ 2, lstat }, /* 40 = lstat */
|
||||
{ 1, dup }, /* 41 = dup */
|
||||
{ 0, pipe }, /* 42 = pipe */
|
||||
{ 1, nosys }, /* 43 = setlogin */
|
||||
{ 4, profil }, /* 44 = profil */
|
||||
{ 1, setuid }, /* 45 = setuid */
|
||||
{ 1, seteuid }, /* 46 = seteuid */
|
||||
{ 0, getgid }, /* 47 = getgid */
|
||||
{ 0, getegid }, /* 48 = getegid */
|
||||
{ 1, setgid }, /* 49 = setgid */
|
||||
{ 1, setegid }, /* 50 = setegid */
|
||||
{ 0, kmemdev }, /* 51 = kmemdev */
|
||||
{ 3, nosys }, /* 52 = (2.9) set phys addr */
|
||||
{ 1, nosys }, /* 53 = (2.9) lock in core */
|
||||
{ 4, ioctl }, /* 54 = ioctl */
|
||||
{ 1, reboot }, /* 55 = reboot */
|
||||
{ 2, sigwait }, /* 56 = sigwait */
|
||||
{ 2, symlink }, /* 57 = symlink */
|
||||
{ 3, readlink }, /* 58 = readlink */
|
||||
{ 3, execve }, /* 59 = execve */
|
||||
{ 1, umask }, /* 60 = umask */
|
||||
{ 1, chroot }, /* 61 = chroot */
|
||||
{ 2, fstat }, /* 62 = fstat */
|
||||
{ 0, nosys }, /* 63 = reserved */
|
||||
{ 0, nosys }, /* 64 = (old getpagesize) */
|
||||
{ 6, pselect }, /* 65 = pselect */
|
||||
{ 0, vfork }, /* 66 = vfork */
|
||||
{ 0, nosys }, /* 67 = unused */
|
||||
{ 0, nosys }, /* 68 = unused */
|
||||
{ 1, brk }, /* 69 = brk */
|
||||
{ 1, nosys }, /* 0 = out-of-range */
|
||||
{ 1, rexit }, /* 1 = exit */
|
||||
{ 0, fork }, /* 2 = fork */
|
||||
{ 3, read }, /* 3 = read */
|
||||
{ 3, write }, /* 4 = write */
|
||||
{ 3, open }, /* 5 = open */
|
||||
{ 1, close }, /* 6 = close */
|
||||
{ 4, wait4 }, /* 7 = wait4 */
|
||||
{ 0, nosys }, /* 8 = (old creat) */
|
||||
{ 2, link }, /* 9 = link */
|
||||
{ 1, unlink }, /* 10 = unlink */
|
||||
{ 2, execv }, /* 11 = execv */
|
||||
{ 1, chdir }, /* 12 = chdir */
|
||||
{ 1, fchdir }, /* 13 = fchdir */
|
||||
{ 3, mknod }, /* 14 = mknod */
|
||||
{ 2, chmod }, /* 15 = chmod */
|
||||
{ 3, chown }, /* 16 = chown; now 3 args */
|
||||
{ 2, chflags }, /* 17 = chflags */
|
||||
{ 2, fchflags }, /* 18 = fchflags */
|
||||
{ 4, lseek }, /* 19 = lseek */
|
||||
{ 0, getpid }, /* 20 = getpid */
|
||||
{ 3, smount }, /* 21 = mount */
|
||||
{ 1, umount }, /* 22 = umount */
|
||||
{ 6, __sysctl }, /* 23 = __sysctl */
|
||||
{ 0, getuid }, /* 24 = getuid */
|
||||
{ 0, geteuid }, /* 25 = geteuid */
|
||||
{ 4, ptrace }, /* 26 = ptrace */
|
||||
{ 0, getppid }, /* 27 = getppid */
|
||||
{ 2, statfs }, /* 28 = statfs */
|
||||
{ 2, fstatfs }, /* 29 = fstatfs */
|
||||
{ 3, getfsstat }, /* 30 = getfsstat */
|
||||
{ 4, sigaction }, /* 31 = sigaction */
|
||||
{ 3, sigprocmask }, /* 32 = sigprocmask */
|
||||
{ 2, saccess }, /* 33 = access */
|
||||
{ 1, sigpending }, /* 34 = sigpending */
|
||||
{ 2, sigaltstack }, /* 35 = sigaltstack */
|
||||
{ 0, sync }, /* 36 = sync */
|
||||
{ 2, kill }, /* 37 = kill */
|
||||
{ 2, stat }, /* 38 = stat */
|
||||
{ 2, nosys }, /* 39 = getlogin */
|
||||
{ 2, lstat }, /* 40 = lstat */
|
||||
{ 1, dup }, /* 41 = dup */
|
||||
{ 0, pipe }, /* 42 = pipe */
|
||||
{ 1, nosys }, /* 43 = setlogin */
|
||||
{ 4, profil }, /* 44 = profil */
|
||||
{ 1, setuid }, /* 45 = setuid */
|
||||
{ 1, seteuid }, /* 46 = seteuid */
|
||||
{ 0, getgid }, /* 47 = getgid */
|
||||
{ 0, getegid }, /* 48 = getegid */
|
||||
{ 1, setgid }, /* 49 = setgid */
|
||||
{ 1, setegid }, /* 50 = setegid */
|
||||
{ 0, kmemdev }, /* 51 = kmemdev */
|
||||
{ 3, nosys }, /* 52 = (2.9) set phys addr */
|
||||
{ 1, nosys }, /* 53 = (2.9) lock in core */
|
||||
{ 4, ioctl }, /* 54 = ioctl */
|
||||
{ 1, reboot }, /* 55 = reboot */
|
||||
{ 2, sigwait }, /* 56 = sigwait */
|
||||
{ 2, symlink }, /* 57 = symlink */
|
||||
{ 3, readlink }, /* 58 = readlink */
|
||||
{ 3, execve }, /* 59 = execve */
|
||||
{ 1, umask }, /* 60 = umask */
|
||||
{ 1, chroot }, /* 61 = chroot */
|
||||
{ 2, fstat }, /* 62 = fstat */
|
||||
{ 0, nosys }, /* 63 = reserved */
|
||||
{ 0, nosys }, /* 64 = (old getpagesize) */
|
||||
{ 6, pselect }, /* 65 = pselect */
|
||||
{ 0, vfork }, /* 66 = vfork */
|
||||
{ 0, nosys }, /* 67 = unused */
|
||||
{ 0, nosys }, /* 68 = unused */
|
||||
{ 1, brk }, /* 69 = brk */
|
||||
#ifdef GLOB_ENABLED
|
||||
{ 1, rdglob }, /* 70 = read from global */
|
||||
{ 2, wrglob }, /* 71 = write to global */
|
||||
{ 1, rdglob }, /* 70 = read from global */
|
||||
{ 2, wrglob }, /* 71 = write to global */
|
||||
#else
|
||||
{ 1, nosys },
|
||||
{ 2, nosys },
|
||||
#endif
|
||||
{ 0, sc_msec }, /* 72 = msec */
|
||||
{ 0, nosys }, /* 73 = unused */
|
||||
{ 0, nosys }, /* 74 = unused */
|
||||
{ 0, nosys }, /* 75 = unused */
|
||||
{ 0, vhangup }, /* 76 = vhangup */
|
||||
{ 0, nosys }, /* 77 = unused */
|
||||
{ 0, nosys }, /* 78 = unused */
|
||||
{ 2, getgroups }, /* 79 = getgroups */
|
||||
{ 2, setgroups }, /* 80 = setgroups */
|
||||
{ 1, getpgrp }, /* 81 = getpgrp */
|
||||
{ 2, setpgrp }, /* 82 = setpgrp */
|
||||
{ 3, setitimer }, /* 83 = setitimer */
|
||||
{ 0, nosys }, /* 84 = (old wait,wait3) */
|
||||
{ 0, nosys }, /* 85 = unused */
|
||||
{ 2, getitimer }, /* 86 = getitimer */
|
||||
{ 0, nosys }, /* 87 = (old gethostname) */
|
||||
{ 0, nosys }, /* 88 = (old sethostname) */
|
||||
{ 0, getdtablesize }, /* 89 = getdtablesize */
|
||||
{ 2, dup2 }, /* 90 = dup2 */
|
||||
{ 0, nosys }, /* 91 = unused */
|
||||
{ 3, fcntl }, /* 92 = fcntl */
|
||||
{ 5, select }, /* 93 = select */
|
||||
{ 0, nosys }, /* 94 = unused */
|
||||
{ 1, fsync }, /* 95 = fsync */
|
||||
{ 3, setpriority }, /* 96 = setpriority */
|
||||
{ errnet(3, socket) }, /* 97 = socket */
|
||||
{ ifnet(3, connect) }, /* 98 = connect */
|
||||
{ ifnet(3, accept) }, /* 99 = accept */
|
||||
{ 2, getpriority }, /* 100 = getpriority */
|
||||
{ ifnet(4, send) }, /* 101 = send */
|
||||
{ ifnet(4, recv) }, /* 102 = recv */
|
||||
{ 1, sigreturn }, /* 103 = sigreturn */
|
||||
{ ifnet(3, bind) }, /* 104 = bind */
|
||||
{ ifnet(5, setsockopt) }, /* 105 = setsockopt */
|
||||
{ ifnet(2, listen) }, /* 106 = listen */
|
||||
{ 1, sigsuspend }, /* 107 = sigsuspend */
|
||||
{ 0, nosys }, /* 108 = (old sigvec) */
|
||||
{ 0, nosys }, /* 109 = (old sigblock) */
|
||||
{ 0, nosys }, /* 110 = (old sigsetmask) */
|
||||
{ 0, nosys }, /* 111 = (old sigpause) */
|
||||
{ 2, sigstack }, /* 112 = sigstack COMPAT-43 */
|
||||
{ ifnet(3, recvmsg) }, /* 113 = recvmsg */
|
||||
{ ifnet(3, sendmsg) }, /* 114 = sendmsg */
|
||||
{ 0, nosys }, /* 115 = unused */
|
||||
{ 2, gettimeofday }, /* 116 = gettimeofday */
|
||||
{ 2, getrusage }, /* 117 = getrusage */
|
||||
{ ifnet(5, getsockopt) }, /* 118 = getsockopt */
|
||||
{ 0, nosys }, /* 119 = unused */
|
||||
{ 3, readv }, /* 120 = readv */
|
||||
{ 3, writev }, /* 121 = writev */
|
||||
{ 2, settimeofday }, /* 122 = settimeofday */
|
||||
{ 3, fchown }, /* 123 = fchown */
|
||||
{ 2, fchmod }, /* 124 = fchmod */
|
||||
{ ifnet(6, recvfrom) }, /* 125 = recvfrom */
|
||||
{ 0, nosys }, /* 126 = (old setreuid) */
|
||||
{ 0, nosys }, /* 127 = (old setregid) */
|
||||
{ 2, rename }, /* 128 = rename */
|
||||
{ 3, truncate }, /* 129 = truncate */
|
||||
{ 3, ftruncate }, /* 130 = ftruncate */
|
||||
{ 2, flock }, /* 131 = flock */
|
||||
{ 0, nosys }, /* 132 = nosys */
|
||||
{ ifnet(6, sendto) }, /* 133 = sendto */
|
||||
{ ifnet(2, shutdown) }, /* 134 = shutdown */
|
||||
{ errnet(4, socketpair) }, /* 135 = socketpair */
|
||||
{ 2, mkdir }, /* 136 = mkdir */
|
||||
{ 1, rmdir }, /* 137 = rmdir */
|
||||
{ 2, utimes }, /* 138 = utimes */
|
||||
{ 0, nosys }, /* 139 = unused */
|
||||
{ 2, adjtime }, /* 140 = adjtime */
|
||||
{ ifnet(3, getpeername) }, /* 141 = getpeername */
|
||||
{ 0, nosys }, /* 142 = (old gethostid) */
|
||||
{ 0, nosys }, /* 143 = (old sethostid) */
|
||||
{ 2, getrlimit }, /* 144 = getrlimit */
|
||||
{ 2, setrlimit }, /* 145 = setrlimit */
|
||||
{ 2, killpg }, /* 146 = killpg */
|
||||
{ 0, nosys }, /* 147 = nosys */
|
||||
{ 2, nosys }, /* 148 = quota */
|
||||
{ 4, nosys }, /* 149 = qquota */
|
||||
{ ifnet(3, getsockname) }, /* 150 = getsockname */
|
||||
/*
|
||||
* Syscalls 151-180 inclusive are reserved for vendor-specific
|
||||
* system calls. (This includes various calls added for compatibity
|
||||
* with other Unix variants.)
|
||||
*/
|
||||
{ 0, sc_msec }, /* 72 = msec */
|
||||
{ 0, nosys }, /* 73 = unused */
|
||||
{ 0, nosys }, /* 74 = unused */
|
||||
{ 0, nosys }, /* 75 = unused */
|
||||
{ 0, vhangup }, /* 76 = vhangup */
|
||||
{ 0, nosys }, /* 77 = unused */
|
||||
{ 0, nosys }, /* 78 = unused */
|
||||
{ 2, getgroups }, /* 79 = getgroups */
|
||||
{ 2, setgroups }, /* 80 = setgroups */
|
||||
{ 1, getpgrp }, /* 81 = getpgrp */
|
||||
{ 2, setpgrp }, /* 82 = setpgrp */
|
||||
{ 3, setitimer }, /* 83 = setitimer */
|
||||
{ 0, nosys }, /* 84 = (old wait,wait3) */
|
||||
{ 0, nosys }, /* 85 = unused */
|
||||
{ 2, getitimer }, /* 86 = getitimer */
|
||||
{ 0, nosys }, /* 87 = (old gethostname) */
|
||||
{ 0, nosys }, /* 88 = (old sethostname) */
|
||||
{ 0, getdtablesize }, /* 89 = getdtablesize */
|
||||
{ 2, dup2 }, /* 90 = dup2 */
|
||||
{ 0, nosys }, /* 91 = unused */
|
||||
{ 3, fcntl }, /* 92 = fcntl */
|
||||
{ 5, select }, /* 93 = select */
|
||||
{ 0, nosys }, /* 94 = unused */
|
||||
{ 1, fsync }, /* 95 = fsync */
|
||||
{ 3, setpriority }, /* 96 = setpriority */
|
||||
{ errnet(3, socket) }, /* 97 = socket */
|
||||
{ ifnet(3, connect) }, /* 98 = connect */
|
||||
{ ifnet(3, accept) }, /* 99 = accept */
|
||||
{ 2, getpriority }, /* 100 = getpriority */
|
||||
{ ifnet(4, send) }, /* 101 = send */
|
||||
{ ifnet(4, recv) }, /* 102 = recv */
|
||||
{ 1, sigreturn }, /* 103 = sigreturn */
|
||||
{ ifnet(3, bind) }, /* 104 = bind */
|
||||
{ ifnet(5, setsockopt) }, /* 105 = setsockopt */
|
||||
{ ifnet(2, listen) }, /* 106 = listen */
|
||||
{ 1, sigsuspend }, /* 107 = sigsuspend */
|
||||
{ 0, nosys }, /* 108 = (old sigvec) */
|
||||
{ 0, nosys }, /* 109 = (old sigblock) */
|
||||
{ 0, nosys }, /* 110 = (old sigsetmask) */
|
||||
{ 0, nosys }, /* 111 = (old sigpause) */
|
||||
{ 2, sigstack }, /* 112 = sigstack COMPAT-43 */
|
||||
{ ifnet(3, recvmsg) }, /* 113 = recvmsg */
|
||||
{ ifnet(3, sendmsg) }, /* 114 = sendmsg */
|
||||
{ 0, nosys }, /* 115 = unused */
|
||||
{ 2, gettimeofday }, /* 116 = gettimeofday */
|
||||
{ 2, getrusage }, /* 117 = getrusage */
|
||||
{ ifnet(5, getsockopt) }, /* 118 = getsockopt */
|
||||
{ 0, nosys }, /* 119 = unused */
|
||||
{ 3, readv }, /* 120 = readv */
|
||||
{ 3, writev }, /* 121 = writev */
|
||||
{ 2, settimeofday }, /* 122 = settimeofday */
|
||||
{ 3, fchown }, /* 123 = fchown */
|
||||
{ 2, fchmod }, /* 124 = fchmod */
|
||||
{ ifnet(6, recvfrom) }, /* 125 = recvfrom */
|
||||
{ 0, nosys }, /* 126 = (old setreuid) */
|
||||
{ 0, nosys }, /* 127 = (old setregid) */
|
||||
{ 2, rename }, /* 128 = rename */
|
||||
{ 3, truncate }, /* 129 = truncate */
|
||||
{ 3, ftruncate }, /* 130 = ftruncate */
|
||||
{ 2, flock }, /* 131 = flock */
|
||||
{ 0, nosys }, /* 132 = nosys */
|
||||
{ ifnet(6, sendto) }, /* 133 = sendto */
|
||||
{ ifnet(2, shutdown) }, /* 134 = shutdown */
|
||||
{ errnet(4, socketpair) }, /* 135 = socketpair */
|
||||
{ 2, mkdir }, /* 136 = mkdir */
|
||||
{ 1, rmdir }, /* 137 = rmdir */
|
||||
{ 2, utimes }, /* 138 = utimes */
|
||||
{ 0, nosys }, /* 139 = unused */
|
||||
{ 2, adjtime }, /* 140 = adjtime */
|
||||
{ ifnet(3, getpeername) }, /* 141 = getpeername */
|
||||
{ 0, nosys }, /* 142 = (old gethostid) */
|
||||
{ 0, nosys }, /* 143 = (old sethostid) */
|
||||
{ 2, getrlimit }, /* 144 = getrlimit */
|
||||
{ 2, setrlimit }, /* 145 = setrlimit */
|
||||
{ 2, killpg }, /* 146 = killpg */
|
||||
{ 0, nosys }, /* 147 = nosys */
|
||||
{ 2, nosys }, /* 148 = quota */
|
||||
{ 4, nosys }, /* 149 = qquota */
|
||||
{ ifnet(3, getsockname) }, /* 150 = getsockname */
|
||||
/*
|
||||
* Syscalls 151-180 inclusive are reserved for vendor-specific
|
||||
* system calls. (This includes various calls added for compatibity
|
||||
* with other Unix variants.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* 2BSD special calls
|
||||
*/
|
||||
{ 0, nosys }, /* 151 = unused */
|
||||
{ 2, ustore }, /* 152 = ustore */
|
||||
{ 1, ufetch }, /* 153 = ufetch */
|
||||
{ 4, ucall }, /* 154 = ucall */
|
||||
{ 0, nosys }, /* 155 = fperr */
|
||||
/*
|
||||
* 2BSD special calls
|
||||
*/
|
||||
{ 0, nosys }, /* 151 = unused */
|
||||
{ 2, ustore }, /* 152 = ustore */
|
||||
{ 1, ufetch }, /* 153 = ufetch */
|
||||
{ 4, ucall }, /* 154 = ucall */
|
||||
{ 0, nosys }, /* 155 = fperr */
|
||||
};
|
||||
|
||||
const int nsysent = sizeof (sysent) / sizeof (sysent[0]);
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "kernel.h"
|
||||
#include "systm.h"
|
||||
|
||||
int noproc; /* no one is running just now */
|
||||
int noproc; /* no one is running just now */
|
||||
|
||||
struct callout *callfree, calltodo;
|
||||
struct callout *callfree, calltodo;
|
||||
|
||||
#ifdef UCB_METER
|
||||
int dk_ndrive = DK_NDRIVE;
|
||||
int dk_ndrive = DK_NDRIVE;
|
||||
|
||||
/*
|
||||
* Gather statistics on resource utilization.
|
||||
@@ -29,44 +29,44 @@ int dk_ndrive = DK_NDRIVE;
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
gatherstats(pc, ps)
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
{
|
||||
register int cpstate;
|
||||
register int cpstate;
|
||||
|
||||
/*
|
||||
* Determine what state the cpu is in.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
/*
|
||||
* CPU was in user state.
|
||||
*/
|
||||
if (u.u_procp->p_nice > NZERO)
|
||||
cpstate = CP_NICE;
|
||||
else
|
||||
cpstate = CP_USER;
|
||||
} else {
|
||||
/*
|
||||
* CPU was in system state. If profiling kernel
|
||||
* increment a counter. If no process is running
|
||||
* then this is a system tick if we were running
|
||||
* at a non-zero IPL (in a driver). If a process is running,
|
||||
* then we charge it with system time even if we were
|
||||
* at a non-zero IPL, since the system often runs
|
||||
* this way during processing of system calls.
|
||||
* This is approximate, but the lack of true interval
|
||||
* timers makes doing anything else difficult.
|
||||
*/
|
||||
cpstate = CP_SYS;
|
||||
if (noproc && BASEPRI(ps))
|
||||
cpstate = CP_IDLE;
|
||||
}
|
||||
/*
|
||||
* We maintain statistics shown by user-level statistics
|
||||
* programs: the amount of time in each cpu state, and
|
||||
* the amount of time each of DK_NDRIVE ``drives'' is busy.
|
||||
*/
|
||||
cp_time[cpstate]++;
|
||||
/*
|
||||
* Determine what state the cpu is in.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
/*
|
||||
* CPU was in user state.
|
||||
*/
|
||||
if (u.u_procp->p_nice > NZERO)
|
||||
cpstate = CP_NICE;
|
||||
else
|
||||
cpstate = CP_USER;
|
||||
} else {
|
||||
/*
|
||||
* CPU was in system state. If profiling kernel
|
||||
* increment a counter. If no process is running
|
||||
* then this is a system tick if we were running
|
||||
* at a non-zero IPL (in a driver). If a process is running,
|
||||
* then we charge it with system time even if we were
|
||||
* at a non-zero IPL, since the system often runs
|
||||
* this way during processing of system calls.
|
||||
* This is approximate, but the lack of true interval
|
||||
* timers makes doing anything else difficult.
|
||||
*/
|
||||
cpstate = CP_SYS;
|
||||
if (noproc && BASEPRI(ps))
|
||||
cpstate = CP_IDLE;
|
||||
}
|
||||
/*
|
||||
* We maintain statistics shown by user-level statistics
|
||||
* programs: the amount of time in each cpu state, and
|
||||
* the amount of time each of DK_NDRIVE ``drives'' is busy.
|
||||
*/
|
||||
cp_time[cpstate]++;
|
||||
}
|
||||
#endif /* UCB_METER */
|
||||
|
||||
@@ -76,49 +76,49 @@ gatherstats(pc, ps)
|
||||
*/
|
||||
void
|
||||
softclock(pc, ps)
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
{
|
||||
for (;;) {
|
||||
register struct callout *p1;
|
||||
register caddr_t arg;
|
||||
register void (*func) (caddr_t);
|
||||
register int s;
|
||||
for (;;) {
|
||||
register struct callout *p1;
|
||||
register caddr_t arg;
|
||||
register void (*func) (caddr_t);
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
if ((p1 = calltodo.c_next) == 0 || p1->c_time > 0) {
|
||||
splx(s);
|
||||
break;
|
||||
}
|
||||
arg = p1->c_arg;
|
||||
func = p1->c_func;
|
||||
calltodo.c_next = p1->c_next;
|
||||
p1->c_next = callfree;
|
||||
callfree = p1;
|
||||
splx(s);
|
||||
(*func) (arg);
|
||||
}
|
||||
/*
|
||||
* If trapped user-mode and profiling, give it
|
||||
* a profiling tick.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
register struct proc *p = u.u_procp;
|
||||
s = splhigh();
|
||||
if ((p1 = calltodo.c_next) == 0 || p1->c_time > 0) {
|
||||
splx(s);
|
||||
break;
|
||||
}
|
||||
arg = p1->c_arg;
|
||||
func = p1->c_func;
|
||||
calltodo.c_next = p1->c_next;
|
||||
p1->c_next = callfree;
|
||||
callfree = p1;
|
||||
splx(s);
|
||||
(*func) (arg);
|
||||
}
|
||||
/*
|
||||
* If trapped user-mode and profiling, give it
|
||||
* a profiling tick.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
if (u.u_prof.pr_scale)
|
||||
addupc(pc, &u.u_prof, 1);
|
||||
/*
|
||||
* Check to see if process has accumulated
|
||||
* more than 10 minutes of user time. If so
|
||||
* reduce priority to give others a chance.
|
||||
*/
|
||||
if (u.u_prof.pr_scale)
|
||||
addupc(pc, &u.u_prof, 1);
|
||||
/*
|
||||
* Check to see if process has accumulated
|
||||
* more than 10 minutes of user time. If so
|
||||
* reduce priority to give others a chance.
|
||||
*/
|
||||
|
||||
if (p->p_uid && p->p_nice == NZERO &&
|
||||
u.u_ru.ru_utime > 10L * 60L * hz) {
|
||||
p->p_nice = NZERO+4;
|
||||
(void) setpri(p);
|
||||
}
|
||||
}
|
||||
if (p->p_uid && p->p_nice == NZERO &&
|
||||
u.u_ru.ru_utime > 10L * 60L * hz) {
|
||||
p->p_nice = NZERO+4;
|
||||
(void) setpri(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -126,124 +126,124 @@ softclock(pc, ps)
|
||||
* We update the events relating to real time.
|
||||
* Also gather statistics.
|
||||
*
|
||||
* reprime clock
|
||||
* implement callouts
|
||||
* maintain user/system times
|
||||
* maintain date
|
||||
* profile
|
||||
* reprime clock
|
||||
* implement callouts
|
||||
* maintain user/system times
|
||||
* maintain date
|
||||
* profile
|
||||
*/
|
||||
void
|
||||
hardclock(pc, ps)
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
caddr_t pc;
|
||||
int ps;
|
||||
{
|
||||
register struct callout *p1;
|
||||
register struct proc *p;
|
||||
register int needsoft = 0;
|
||||
register struct callout *p1;
|
||||
register struct proc *p;
|
||||
register int needsoft = 0;
|
||||
|
||||
/*
|
||||
* Update real-time timeout queue.
|
||||
* At front of queue are some number of events which are ``due''.
|
||||
* The time to these is <= 0 and if negative represents the
|
||||
* number of ticks which have passed since it was supposed to happen.
|
||||
* The rest of the q elements (times > 0) are events yet to happen,
|
||||
* where the time for each is given as a delta from the previous.
|
||||
* Decrementing just the first of these serves to decrement the time
|
||||
* to all events.
|
||||
*/
|
||||
p1 = calltodo.c_next;
|
||||
while (p1) {
|
||||
if (--p1->c_time > 0)
|
||||
break;
|
||||
needsoft = 1;
|
||||
if (p1->c_time == 0)
|
||||
break;
|
||||
p1 = p1->c_next;
|
||||
}
|
||||
/*
|
||||
* Update real-time timeout queue.
|
||||
* At front of queue are some number of events which are ``due''.
|
||||
* The time to these is <= 0 and if negative represents the
|
||||
* number of ticks which have passed since it was supposed to happen.
|
||||
* The rest of the q elements (times > 0) are events yet to happen,
|
||||
* where the time for each is given as a delta from the previous.
|
||||
* Decrementing just the first of these serves to decrement the time
|
||||
* to all events.
|
||||
*/
|
||||
p1 = calltodo.c_next;
|
||||
while (p1) {
|
||||
if (--p1->c_time > 0)
|
||||
break;
|
||||
needsoft = 1;
|
||||
if (p1->c_time == 0)
|
||||
break;
|
||||
p1 = p1->c_next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Charge the time out based on the mode the cpu is in.
|
||||
* Here again we fudge for the lack of proper interval timers
|
||||
* assuming that the current state has been around at least
|
||||
* one tick.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
if (u.u_prof.pr_scale)
|
||||
needsoft = 1;
|
||||
/*
|
||||
* CPU was in user state. Increment
|
||||
* user time counter, and process process-virtual time
|
||||
* interval timer.
|
||||
*/
|
||||
u.u_ru.ru_utime++;
|
||||
if (u.u_timer[ITIMER_VIRTUAL - 1].it_value &&
|
||||
!--u.u_timer[ITIMER_VIRTUAL - 1].it_value) {
|
||||
psignal(u.u_procp, SIGVTALRM);
|
||||
u.u_timer[ITIMER_VIRTUAL - 1].it_value =
|
||||
u.u_timer[ITIMER_VIRTUAL - 1].it_interval;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* CPU was in system state.
|
||||
*/
|
||||
if (!noproc)
|
||||
u.u_ru.ru_stime++;
|
||||
}
|
||||
/*
|
||||
* Charge the time out based on the mode the cpu is in.
|
||||
* Here again we fudge for the lack of proper interval timers
|
||||
* assuming that the current state has been around at least
|
||||
* one tick.
|
||||
*/
|
||||
if (USERMODE(ps)) {
|
||||
if (u.u_prof.pr_scale)
|
||||
needsoft = 1;
|
||||
/*
|
||||
* CPU was in user state. Increment
|
||||
* user time counter, and process process-virtual time
|
||||
* interval timer.
|
||||
*/
|
||||
u.u_ru.ru_utime++;
|
||||
if (u.u_timer[ITIMER_VIRTUAL - 1].it_value &&
|
||||
!--u.u_timer[ITIMER_VIRTUAL - 1].it_value) {
|
||||
psignal(u.u_procp, SIGVTALRM);
|
||||
u.u_timer[ITIMER_VIRTUAL - 1].it_value =
|
||||
u.u_timer[ITIMER_VIRTUAL - 1].it_interval;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* CPU was in system state.
|
||||
*/
|
||||
if (!noproc)
|
||||
u.u_ru.ru_stime++;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the cpu is currently scheduled to a process, then
|
||||
* charge it with resource utilization for a tick, updating
|
||||
* statistics which run in (user+system) virtual time,
|
||||
* such as the cpu time limit and profiling timers.
|
||||
* This assumes that the current process has been running
|
||||
* the entire last tick.
|
||||
*/
|
||||
if (noproc == 0) {
|
||||
p = u.u_procp;
|
||||
if (++p->p_cpu == 0)
|
||||
p->p_cpu--;
|
||||
if ((u.u_ru.ru_utime+u.u_ru.ru_stime+1) >
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_cur) {
|
||||
psignal(p, SIGXCPU);
|
||||
if (u.u_rlimit[RLIMIT_CPU].rlim_cur <
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_max)
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_cur += 5 * hz;
|
||||
}
|
||||
if (u.u_timer[ITIMER_PROF - 1].it_value &&
|
||||
!--u.u_timer[ITIMER_PROF - 1].it_value) {
|
||||
psignal(p, SIGPROF);
|
||||
u.u_timer[ITIMER_PROF - 1].it_value =
|
||||
u.u_timer[ITIMER_PROF - 1].it_interval;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the cpu is currently scheduled to a process, then
|
||||
* charge it with resource utilization for a tick, updating
|
||||
* statistics which run in (user+system) virtual time,
|
||||
* such as the cpu time limit and profiling timers.
|
||||
* This assumes that the current process has been running
|
||||
* the entire last tick.
|
||||
*/
|
||||
if (noproc == 0) {
|
||||
p = u.u_procp;
|
||||
if (++p->p_cpu == 0)
|
||||
p->p_cpu--;
|
||||
if ((u.u_ru.ru_utime+u.u_ru.ru_stime+1) >
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_cur) {
|
||||
psignal(p, SIGXCPU);
|
||||
if (u.u_rlimit[RLIMIT_CPU].rlim_cur <
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_max)
|
||||
u.u_rlimit[RLIMIT_CPU].rlim_cur += 5 * hz;
|
||||
}
|
||||
if (u.u_timer[ITIMER_PROF - 1].it_value &&
|
||||
!--u.u_timer[ITIMER_PROF - 1].it_value) {
|
||||
psignal(p, SIGPROF);
|
||||
u.u_timer[ITIMER_PROF - 1].it_value =
|
||||
u.u_timer[ITIMER_PROF - 1].it_interval;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UCB_METER
|
||||
gatherstats (pc, ps);
|
||||
gatherstats (pc, ps);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Increment the time-of-day, process callouts at a very
|
||||
* low cpu priority, so we don't keep the relatively high
|
||||
* clock interrupt priority any longer than necessary.
|
||||
*/
|
||||
if (adjdelta) {
|
||||
if (adjdelta > 0) {
|
||||
++lbolt;
|
||||
--adjdelta;
|
||||
} else {
|
||||
--lbolt;
|
||||
++adjdelta;
|
||||
}
|
||||
}
|
||||
if (++lbolt >= hz) {
|
||||
lbolt -= hz;
|
||||
++time.tv_sec;
|
||||
}
|
||||
/*
|
||||
* Increment the time-of-day, process callouts at a very
|
||||
* low cpu priority, so we don't keep the relatively high
|
||||
* clock interrupt priority any longer than necessary.
|
||||
*/
|
||||
if (adjdelta) {
|
||||
if (adjdelta > 0) {
|
||||
++lbolt;
|
||||
--adjdelta;
|
||||
} else {
|
||||
--lbolt;
|
||||
++adjdelta;
|
||||
}
|
||||
}
|
||||
if (++lbolt >= hz) {
|
||||
lbolt -= hz;
|
||||
++time.tv_sec;
|
||||
}
|
||||
|
||||
if (needsoft && BASEPRI(ps)) { /* if ps is high, just return */
|
||||
// (void) splsoftclock();
|
||||
softclock (pc, ps);
|
||||
}
|
||||
if (needsoft && BASEPRI(ps)) { /* if ps is high, just return */
|
||||
// (void) splsoftclock();
|
||||
softclock (pc, ps);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -251,30 +251,30 @@ hardclock(pc, ps)
|
||||
*/
|
||||
void
|
||||
timeout (fun, arg, t)
|
||||
void (*fun) (caddr_t);
|
||||
caddr_t arg;
|
||||
register int t;
|
||||
void (*fun) (caddr_t);
|
||||
caddr_t arg;
|
||||
register int t;
|
||||
{
|
||||
register struct callout *p1, *p2, *pnew;
|
||||
register int s = splclock();
|
||||
register struct callout *p1, *p2, *pnew;
|
||||
register int s = splclock();
|
||||
|
||||
if (t <= 0)
|
||||
t = 1;
|
||||
pnew = callfree;
|
||||
if (pnew == NULL)
|
||||
panic("timeout table overflow");
|
||||
callfree = pnew->c_next;
|
||||
pnew->c_arg = arg;
|
||||
pnew->c_func = fun;
|
||||
for (p1 = &calltodo; (p2 = p1->c_next) && p2->c_time < t; p1 = p2)
|
||||
if (p2->c_time > 0)
|
||||
t -= p2->c_time;
|
||||
p1->c_next = pnew;
|
||||
pnew->c_next = p2;
|
||||
pnew->c_time = t;
|
||||
if (p2)
|
||||
p2->c_time -= t;
|
||||
splx(s);
|
||||
if (t <= 0)
|
||||
t = 1;
|
||||
pnew = callfree;
|
||||
if (pnew == NULL)
|
||||
panic("timeout table overflow");
|
||||
callfree = pnew->c_next;
|
||||
pnew->c_arg = arg;
|
||||
pnew->c_func = fun;
|
||||
for (p1 = &calltodo; (p2 = p1->c_next) && p2->c_time < t; p1 = p2)
|
||||
if (p2->c_time > 0)
|
||||
t -= p2->c_time;
|
||||
p1->c_next = pnew;
|
||||
pnew->c_next = p2;
|
||||
pnew->c_time = t;
|
||||
if (p2)
|
||||
p2->c_time -= t;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -283,41 +283,41 @@ timeout (fun, arg, t)
|
||||
*/
|
||||
void
|
||||
untimeout (fun, arg)
|
||||
void (*fun) (caddr_t);
|
||||
caddr_t arg;
|
||||
void (*fun) (caddr_t);
|
||||
caddr_t arg;
|
||||
{
|
||||
register struct callout *p1, *p2;
|
||||
register int s;
|
||||
register struct callout *p1, *p2;
|
||||
register int s;
|
||||
|
||||
s = splclock();
|
||||
for (p1 = &calltodo; (p2 = p1->c_next) != 0; p1 = p2) {
|
||||
if (p2->c_func == fun && p2->c_arg == arg) {
|
||||
if (p2->c_next && p2->c_time > 0)
|
||||
p2->c_next->c_time += p2->c_time;
|
||||
p1->c_next = p2->c_next;
|
||||
p2->c_next = callfree;
|
||||
callfree = p2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
s = splclock();
|
||||
for (p1 = &calltodo; (p2 = p1->c_next) != 0; p1 = p2) {
|
||||
if (p2->c_func == fun && p2->c_arg == arg) {
|
||||
if (p2->c_next && p2->c_time > 0)
|
||||
p2->c_next->c_time += p2->c_time;
|
||||
p1->c_next = p2->c_next;
|
||||
p2->c_next = callfree;
|
||||
callfree = p2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
profil()
|
||||
{
|
||||
register struct a {
|
||||
unsigned *bufbase;
|
||||
unsigned bufsize;
|
||||
unsigned pcoffset;
|
||||
unsigned pcscale;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
register struct uprof *upp = &u.u_prof;
|
||||
register struct a {
|
||||
unsigned *bufbase;
|
||||
unsigned bufsize;
|
||||
unsigned pcoffset;
|
||||
unsigned pcscale;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
register struct uprof *upp = &u.u_prof;
|
||||
|
||||
upp->pr_base = uap->bufbase;
|
||||
upp->pr_size = uap->bufsize;
|
||||
upp->pr_off = uap->pcoffset;
|
||||
upp->pr_scale = uap->pcscale;
|
||||
upp->pr_base = uap->bufbase;
|
||||
upp->pr_size = uap->bufsize;
|
||||
upp->pr_off = uap->pcoffset;
|
||||
upp->pr_scale = uap->pcscale;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -327,36 +327,36 @@ profil()
|
||||
*/
|
||||
int
|
||||
hzto(tv)
|
||||
register struct timeval *tv;
|
||||
register struct timeval *tv;
|
||||
{
|
||||
register long ticks;
|
||||
register long sec;
|
||||
register int s = splhigh();
|
||||
register long ticks;
|
||||
register long sec;
|
||||
register int s = splhigh();
|
||||
|
||||
/*
|
||||
* If number of milliseconds will fit in 32 bit arithmetic,
|
||||
* then compute number of milliseconds to time and scale to
|
||||
* ticks. Otherwise just compute number of hz in time, rounding
|
||||
* times greater than representible to maximum value.
|
||||
*
|
||||
* Delta times less than 25 days can be computed ``exactly''.
|
||||
* Maximum value for any timeout in 10ms ticks is 250 days.
|
||||
*/
|
||||
sec = tv->tv_sec - time.tv_sec;
|
||||
if (sec <= 0x7fffffff / 1000 - 1000)
|
||||
ticks = ((tv->tv_sec - time.tv_sec) * 1000 +
|
||||
(tv->tv_usec - time.tv_usec) / 1000) / (1000/hz);
|
||||
else if (sec <= 0x7fffffff / hz)
|
||||
ticks = sec * hz;
|
||||
else
|
||||
ticks = 0x7fffffff;
|
||||
splx(s);
|
||||
/*
|
||||
* If number of milliseconds will fit in 32 bit arithmetic,
|
||||
* then compute number of milliseconds to time and scale to
|
||||
* ticks. Otherwise just compute number of hz in time, rounding
|
||||
* times greater than representible to maximum value.
|
||||
*
|
||||
* Delta times less than 25 days can be computed ``exactly''.
|
||||
* Maximum value for any timeout in 10ms ticks is 250 days.
|
||||
*/
|
||||
sec = tv->tv_sec - time.tv_sec;
|
||||
if (sec <= 0x7fffffff / 1000 - 1000)
|
||||
ticks = ((tv->tv_sec - time.tv_sec) * 1000 +
|
||||
(tv->tv_usec - time.tv_usec) / 1000) / (1000/hz);
|
||||
else if (sec <= 0x7fffffff / hz)
|
||||
ticks = sec * hz;
|
||||
else
|
||||
ticks = 0x7fffffff;
|
||||
splx(s);
|
||||
#ifdef pdp11
|
||||
/* stored in an "int", so 16-bit max */
|
||||
if (ticks > 0x7fff)
|
||||
ticks = 0x7fff;
|
||||
/* stored in an "int", so 16-bit max */
|
||||
if (ticks > 0x7fff)
|
||||
ticks = 0x7fff;
|
||||
#endif
|
||||
return ((int)ticks);
|
||||
return ((int)ticks);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -365,9 +365,9 @@ hzto(tv)
|
||||
void
|
||||
coutinit()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
callfree = callout;
|
||||
for (i=1; i<NCALL; i++)
|
||||
callout[i-1].c_next = &callout[i];
|
||||
callfree = callout;
|
||||
for (i=1; i<NCALL; i++)
|
||||
callout[i-1].c_next = &callout[i];
|
||||
}
|
||||
|
||||
@@ -34,18 +34,18 @@ const struct devspec fddevs[] = {
|
||||
*/
|
||||
static int
|
||||
ufalloc(i)
|
||||
register int i;
|
||||
register int i;
|
||||
{
|
||||
for (; i < NOFILE; i++)
|
||||
if (u.u_ofile[i] == NULL) {
|
||||
u.u_rval = i;
|
||||
u.u_pofile[i] = 0;
|
||||
if (i > u.u_lastfile)
|
||||
u.u_lastfile = i;
|
||||
return (i);
|
||||
}
|
||||
u.u_error = EMFILE;
|
||||
return (-1);
|
||||
for (; i < NOFILE; i++)
|
||||
if (u.u_ofile[i] == NULL) {
|
||||
u.u_rval = i;
|
||||
u.u_pofile[i] = 0;
|
||||
if (i > u.u_lastfile)
|
||||
u.u_lastfile = i;
|
||||
return (i);
|
||||
}
|
||||
u.u_error = EMFILE;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -54,62 +54,62 @@ ufalloc(i)
|
||||
void
|
||||
getdtablesize()
|
||||
{
|
||||
u.u_rval = NOFILE;
|
||||
u.u_rval = NOFILE;
|
||||
}
|
||||
|
||||
static void
|
||||
dupit(fd, fp, flags)
|
||||
register int fd;
|
||||
register struct file *fp;
|
||||
int flags;
|
||||
register int fd;
|
||||
register struct file *fp;
|
||||
int flags;
|
||||
{
|
||||
u.u_ofile[fd] = fp;
|
||||
u.u_pofile[fd] = flags;
|
||||
fp->f_count++;
|
||||
if (fd > u.u_lastfile)
|
||||
u.u_lastfile = fd;
|
||||
u.u_ofile[fd] = fp;
|
||||
u.u_pofile[fd] = flags;
|
||||
fp->f_count++;
|
||||
if (fd > u.u_lastfile)
|
||||
u.u_lastfile = fd;
|
||||
}
|
||||
|
||||
void
|
||||
dup()
|
||||
{
|
||||
register struct a {
|
||||
int i;
|
||||
} *uap = (struct a *) u.u_arg;
|
||||
register struct file *fp;
|
||||
register int j;
|
||||
register struct a {
|
||||
int i;
|
||||
} *uap = (struct a *) u.u_arg;
|
||||
register struct file *fp;
|
||||
register int j;
|
||||
|
||||
if (uap->i &~ 077) { uap->i &= 077; dup2(); return; } /* XXX */
|
||||
if (uap->i &~ 077) { uap->i &= 077; dup2(); return; } /* XXX */
|
||||
|
||||
GETF(fp, uap->i);
|
||||
j = ufalloc(0);
|
||||
if (j < 0)
|
||||
return;
|
||||
dupit(j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
|
||||
GETF(fp, uap->i);
|
||||
j = ufalloc(0);
|
||||
if (j < 0)
|
||||
return;
|
||||
dupit(j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
|
||||
}
|
||||
|
||||
void
|
||||
dup2()
|
||||
{
|
||||
register struct a {
|
||||
int i, j;
|
||||
} *uap = (struct a *) u.u_arg;
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int i, j;
|
||||
} *uap = (struct a *) u.u_arg;
|
||||
register struct file *fp;
|
||||
|
||||
GETF(fp, uap->i);
|
||||
if (uap->j < 0 || uap->j >= NOFILE) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
u.u_rval = uap->j;
|
||||
if (uap->i == uap->j)
|
||||
return;
|
||||
if (u.u_ofile[uap->j])
|
||||
/*
|
||||
* dup2 must succeed even if the close has an error.
|
||||
*/
|
||||
(void) closef(u.u_ofile[uap->j]);
|
||||
dupit(uap->j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
|
||||
GETF(fp, uap->i);
|
||||
if (uap->j < 0 || uap->j >= NOFILE) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
u.u_rval = uap->j;
|
||||
if (uap->i == uap->j)
|
||||
return;
|
||||
if (u.u_ofile[uap->j])
|
||||
/*
|
||||
* dup2 must succeed even if the close has an error.
|
||||
*/
|
||||
(void) closef(u.u_ofile[uap->j]);
|
||||
dupit(uap->j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -118,75 +118,75 @@ dup2()
|
||||
void
|
||||
fcntl()
|
||||
{
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
int cmd;
|
||||
int arg;
|
||||
} *uap;
|
||||
register int i;
|
||||
register char *pop;
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
int cmd;
|
||||
int arg;
|
||||
} *uap;
|
||||
register int i;
|
||||
register char *pop;
|
||||
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (fp == NULL)
|
||||
return;
|
||||
pop = &u.u_pofile[uap->fdes];
|
||||
switch(uap->cmd) {
|
||||
case F_DUPFD:
|
||||
i = uap->arg;
|
||||
if (i < 0 || i >= NOFILE) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if ((i = ufalloc(i)) < 0)
|
||||
return;
|
||||
dupit(i, fp, *pop &~ UF_EXCLOSE);
|
||||
break;
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (fp == NULL)
|
||||
return;
|
||||
pop = &u.u_pofile[uap->fdes];
|
||||
switch(uap->cmd) {
|
||||
case F_DUPFD:
|
||||
i = uap->arg;
|
||||
if (i < 0 || i >= NOFILE) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if ((i = ufalloc(i)) < 0)
|
||||
return;
|
||||
dupit(i, fp, *pop &~ UF_EXCLOSE);
|
||||
break;
|
||||
|
||||
case F_GETFD:
|
||||
u.u_rval = *pop & 1;
|
||||
break;
|
||||
case F_GETFD:
|
||||
u.u_rval = *pop & 1;
|
||||
break;
|
||||
|
||||
case F_SETFD:
|
||||
*pop = (*pop &~ 1) | (uap->arg & 1);
|
||||
break;
|
||||
case F_SETFD:
|
||||
*pop = (*pop &~ 1) | (uap->arg & 1);
|
||||
break;
|
||||
|
||||
case F_GETFL:
|
||||
u.u_rval = OFLAGS(fp->f_flag);
|
||||
break;
|
||||
case F_GETFL:
|
||||
u.u_rval = OFLAGS(fp->f_flag);
|
||||
break;
|
||||
|
||||
case F_SETFL:
|
||||
fp->f_flag &= ~FCNTLFLAGS;
|
||||
fp->f_flag |= (FFLAGS(uap->arg)) & FCNTLFLAGS;
|
||||
u.u_error = fset (fp, FNONBLOCK, fp->f_flag & FNONBLOCK);
|
||||
if (u.u_error)
|
||||
break;
|
||||
u.u_error = fset (fp, FASYNC, fp->f_flag & FASYNC);
|
||||
if (u.u_error)
|
||||
(void) fset (fp, FNONBLOCK, 0);
|
||||
break;
|
||||
case F_SETFL:
|
||||
fp->f_flag &= ~FCNTLFLAGS;
|
||||
fp->f_flag |= (FFLAGS(uap->arg)) & FCNTLFLAGS;
|
||||
u.u_error = fset (fp, FNONBLOCK, fp->f_flag & FNONBLOCK);
|
||||
if (u.u_error)
|
||||
break;
|
||||
u.u_error = fset (fp, FASYNC, fp->f_flag & FASYNC);
|
||||
if (u.u_error)
|
||||
(void) fset (fp, FNONBLOCK, 0);
|
||||
break;
|
||||
|
||||
case F_GETOWN:
|
||||
u.u_error = fgetown (fp, &u.u_rval);
|
||||
break;
|
||||
case F_GETOWN:
|
||||
u.u_error = fgetown (fp, &u.u_rval);
|
||||
break;
|
||||
|
||||
case F_SETOWN:
|
||||
u.u_error = fsetown (fp, uap->arg);
|
||||
break;
|
||||
case F_SETOWN:
|
||||
u.u_error = fsetown (fp, uap->arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
}
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
fioctl(fp, cmd, value)
|
||||
register struct file *fp;
|
||||
u_int cmd;
|
||||
caddr_t value;
|
||||
register struct file *fp;
|
||||
u_int cmd;
|
||||
caddr_t value;
|
||||
{
|
||||
return ((*Fops[fp->f_type]->fo_ioctl)(fp, cmd, value));
|
||||
return ((*Fops[fp->f_type]->fo_ioctl)(fp, cmd, value));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -194,15 +194,15 @@ fioctl(fp, cmd, value)
|
||||
*/
|
||||
int
|
||||
fset (fp, bit, value)
|
||||
register struct file *fp;
|
||||
int bit, value;
|
||||
register struct file *fp;
|
||||
int bit, value;
|
||||
{
|
||||
if (value)
|
||||
fp->f_flag |= bit;
|
||||
else
|
||||
fp->f_flag &= ~bit;
|
||||
return (fioctl(fp, (u_int)(bit == FNONBLOCK ? FIONBIO : FIOASYNC),
|
||||
(caddr_t)&value));
|
||||
if (value)
|
||||
fp->f_flag |= bit;
|
||||
else
|
||||
fp->f_flag &= ~bit;
|
||||
return (fioctl(fp, (u_int)(bit == FNONBLOCK ? FIONBIO : FIOASYNC),
|
||||
(caddr_t)&value));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -210,20 +210,20 @@ fset (fp, bit, value)
|
||||
*/
|
||||
int
|
||||
fgetown(fp, valuep)
|
||||
register struct file *fp;
|
||||
register int *valuep;
|
||||
register struct file *fp;
|
||||
register int *valuep;
|
||||
{
|
||||
register int error;
|
||||
register int error;
|
||||
|
||||
#ifdef INET
|
||||
if (fp->f_type == DTYPE_SOCKET) {
|
||||
*valuep = mfsd(&fp->f_socket->so_pgrp);
|
||||
return (0);
|
||||
}
|
||||
if (fp->f_type == DTYPE_SOCKET) {
|
||||
*valuep = mfsd(&fp->f_socket->so_pgrp);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
error = fioctl(fp, (u_int)TIOCGPGRP, (caddr_t)valuep);
|
||||
*valuep = -*valuep;
|
||||
return (error);
|
||||
error = fioctl(fp, (u_int)TIOCGPGRP, (caddr_t)valuep);
|
||||
*valuep = -*valuep;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -231,79 +231,79 @@ fgetown(fp, valuep)
|
||||
*/
|
||||
int
|
||||
fsetown(fp, value)
|
||||
register struct file *fp;
|
||||
int value;
|
||||
register struct file *fp;
|
||||
int value;
|
||||
{
|
||||
#ifdef INET
|
||||
if (fp->f_type == DTYPE_SOCKET) {
|
||||
mtsd(&fp->f_socket->so_pgrp, value);
|
||||
return (0);
|
||||
}
|
||||
if (fp->f_type == DTYPE_SOCKET) {
|
||||
mtsd(&fp->f_socket->so_pgrp, value);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
if (value > 0) {
|
||||
register struct proc *p = pfind(value);
|
||||
if (p == 0)
|
||||
return (ESRCH);
|
||||
value = p->p_pgrp;
|
||||
} else
|
||||
value = -value;
|
||||
return (fioctl(fp, (u_int)TIOCSPGRP, (caddr_t)&value));
|
||||
if (value > 0) {
|
||||
register struct proc *p = pfind(value);
|
||||
if (p == 0)
|
||||
return (ESRCH);
|
||||
value = p->p_pgrp;
|
||||
} else
|
||||
value = -value;
|
||||
return (fioctl(fp, (u_int)TIOCSPGRP, (caddr_t)&value));
|
||||
}
|
||||
|
||||
void
|
||||
close()
|
||||
{
|
||||
register struct a {
|
||||
int i;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int i;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct file *fp;
|
||||
|
||||
GETF(fp, uap->i);
|
||||
u.u_ofile[uap->i] = NULL;
|
||||
while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
|
||||
u.u_lastfile--;
|
||||
u.u_error = closef(fp);
|
||||
/* WHAT IF u.u_error ? */
|
||||
GETF(fp, uap->i);
|
||||
u.u_ofile[uap->i] = NULL;
|
||||
while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
|
||||
u.u_lastfile--;
|
||||
u.u_error = closef(fp);
|
||||
/* WHAT IF u.u_error ? */
|
||||
}
|
||||
|
||||
void
|
||||
fstat()
|
||||
{
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct stat *sb;
|
||||
} *uap;
|
||||
struct stat ub;
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct stat *sb;
|
||||
} *uap;
|
||||
struct stat ub;
|
||||
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (fp == NULL)
|
||||
return;
|
||||
switch (fp->f_type) {
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (fp == NULL)
|
||||
return;
|
||||
switch (fp->f_type) {
|
||||
|
||||
case DTYPE_PIPE:
|
||||
case DTYPE_INODE:
|
||||
u.u_error = ino_stat((struct inode *)fp->f_data, &ub);
|
||||
if (fp->f_type == DTYPE_PIPE)
|
||||
ub.st_size -= fp->f_offset;
|
||||
break;
|
||||
case DTYPE_PIPE:
|
||||
case DTYPE_INODE:
|
||||
u.u_error = ino_stat((struct inode *)fp->f_data, &ub);
|
||||
if (fp->f_type == DTYPE_PIPE)
|
||||
ub.st_size -= fp->f_offset;
|
||||
break;
|
||||
|
||||
#ifdef INET
|
||||
case DTYPE_SOCKET:
|
||||
u.u_error = SOO_STAT(fp->f_socket, &ub);
|
||||
break;
|
||||
case DTYPE_SOCKET:
|
||||
u.u_error = SOO_STAT(fp->f_socket, &ub);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
break;
|
||||
}
|
||||
if (u.u_error == 0)
|
||||
u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb,
|
||||
sizeof (ub));
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
break;
|
||||
}
|
||||
if (u.u_error == 0)
|
||||
u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb,
|
||||
sizeof (ub));
|
||||
}
|
||||
|
||||
struct file *lastf;
|
||||
struct file *lastf;
|
||||
|
||||
/*
|
||||
* Allocate a user file descriptor
|
||||
@@ -314,30 +314,30 @@ struct file *lastf;
|
||||
struct file *
|
||||
falloc()
|
||||
{
|
||||
register struct file *fp;
|
||||
register int i;
|
||||
register struct file *fp;
|
||||
register int i;
|
||||
|
||||
i = ufalloc(0);
|
||||
if (i < 0)
|
||||
return (NULL);
|
||||
if (lastf == 0)
|
||||
lastf = file;
|
||||
for (fp = lastf; fp < file+NFILE; fp++)
|
||||
if (fp->f_count == 0)
|
||||
goto slot;
|
||||
for (fp = file; fp < lastf; fp++)
|
||||
if (fp->f_count == 0)
|
||||
goto slot;
|
||||
log(LOG_ERR, "file: table full\n");
|
||||
u.u_error = ENFILE;
|
||||
return (NULL);
|
||||
i = ufalloc(0);
|
||||
if (i < 0)
|
||||
return (NULL);
|
||||
if (lastf == 0)
|
||||
lastf = file;
|
||||
for (fp = lastf; fp < file+NFILE; fp++)
|
||||
if (fp->f_count == 0)
|
||||
goto slot;
|
||||
for (fp = file; fp < lastf; fp++)
|
||||
if (fp->f_count == 0)
|
||||
goto slot;
|
||||
log(LOG_ERR, "file: table full\n");
|
||||
u.u_error = ENFILE;
|
||||
return (NULL);
|
||||
slot:
|
||||
u.u_ofile[i] = fp;
|
||||
fp->f_count = 1;
|
||||
fp->f_data = 0;
|
||||
fp->f_offset = 0;
|
||||
lastf = fp + 1;
|
||||
return (fp);
|
||||
u.u_ofile[i] = fp;
|
||||
fp->f_count = 1;
|
||||
fp->f_data = 0;
|
||||
fp->f_offset = 0;
|
||||
lastf = fp + 1;
|
||||
return (fp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -348,15 +348,15 @@ slot:
|
||||
*/
|
||||
struct file *
|
||||
getf(f)
|
||||
register int f;
|
||||
register int f;
|
||||
{
|
||||
register struct file *fp;
|
||||
register struct file *fp;
|
||||
|
||||
if ((unsigned)f >= NOFILE || (fp = u.u_ofile[f]) == NULL) {
|
||||
u.u_error = EBADF;
|
||||
return (NULL);
|
||||
}
|
||||
return (fp);
|
||||
if ((unsigned)f >= NOFILE || (fp = u.u_ofile[f]) == NULL) {
|
||||
u.u_error = EBADF;
|
||||
return (NULL);
|
||||
}
|
||||
return (fp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -365,23 +365,23 @@ getf(f)
|
||||
*/
|
||||
int
|
||||
closef(fp)
|
||||
register struct file *fp;
|
||||
register struct file *fp;
|
||||
{
|
||||
int error;
|
||||
int error;
|
||||
|
||||
if (fp == NULL)
|
||||
return(0);
|
||||
if (fp->f_count > 1) {
|
||||
fp->f_count--;
|
||||
return(0);
|
||||
}
|
||||
if (fp == NULL)
|
||||
return(0);
|
||||
if (fp->f_count > 1) {
|
||||
fp->f_count--;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if ((fp->f_flag & (FSHLOCK|FEXLOCK)) && fp->f_type == DTYPE_INODE)
|
||||
ino_unlock(fp, FSHLOCK|FEXLOCK);
|
||||
if ((fp->f_flag & (FSHLOCK|FEXLOCK)) && fp->f_type == DTYPE_INODE)
|
||||
ino_unlock(fp, FSHLOCK|FEXLOCK);
|
||||
|
||||
error = (*Fops[fp->f_type]->fo_close)(fp);
|
||||
fp->f_count = 0;
|
||||
return(error);
|
||||
error = (*Fops[fp->f_type]->fo_close)(fp);
|
||||
fp->f_count = 0;
|
||||
return(error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -390,34 +390,34 @@ closef(fp)
|
||||
void
|
||||
flock()
|
||||
{
|
||||
register struct a {
|
||||
int fd;
|
||||
int how;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct file *fp;
|
||||
int error;
|
||||
register struct a {
|
||||
int fd;
|
||||
int how;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct file *fp;
|
||||
int error;
|
||||
|
||||
if ((fp = getf(uap->fd)) == NULL)
|
||||
return;
|
||||
if (fp->f_type != DTYPE_INODE) {
|
||||
u.u_error = EOPNOTSUPP;
|
||||
return;
|
||||
}
|
||||
if (uap->how & LOCK_UN) {
|
||||
ino_unlock(fp, FSHLOCK | FEXLOCK);
|
||||
return;
|
||||
}
|
||||
if ((uap->how & (LOCK_SH | LOCK_EX)) == 0)
|
||||
return; /* error? */
|
||||
if (uap->how & LOCK_EX)
|
||||
uap->how &= ~LOCK_SH;
|
||||
/* avoid work... */
|
||||
if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX))
|
||||
return;
|
||||
if ((fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH))
|
||||
return;
|
||||
error = ino_lock(fp, uap->how);
|
||||
u.u_error = error;
|
||||
if ((fp = getf(uap->fd)) == NULL)
|
||||
return;
|
||||
if (fp->f_type != DTYPE_INODE) {
|
||||
u.u_error = EOPNOTSUPP;
|
||||
return;
|
||||
}
|
||||
if (uap->how & LOCK_UN) {
|
||||
ino_unlock(fp, FSHLOCK | FEXLOCK);
|
||||
return;
|
||||
}
|
||||
if ((uap->how & (LOCK_SH | LOCK_EX)) == 0)
|
||||
return; /* error? */
|
||||
if (uap->how & LOCK_EX)
|
||||
uap->how &= ~LOCK_SH;
|
||||
/* avoid work... */
|
||||
if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX))
|
||||
return;
|
||||
if ((fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH))
|
||||
return;
|
||||
error = ino_lock(fp, uap->how);
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -431,19 +431,19 @@ flock()
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fdopen(dev, mode, type)
|
||||
dev_t dev;
|
||||
int mode, type;
|
||||
dev_t dev;
|
||||
int mode, type;
|
||||
{
|
||||
/*
|
||||
* XXX Kludge: set u.u_dupfd to contain the value of the
|
||||
* the file descriptor being sought for duplication. The error
|
||||
* return ensures that the vnode for this device will be released
|
||||
* by vn_open. Open will detect this special error and take the
|
||||
* actions in dupfdopen below. Other callers of vn_open will
|
||||
* simply report the error.
|
||||
*/
|
||||
u.u_dupfd = minor(dev);
|
||||
return(ENODEV);
|
||||
/*
|
||||
* XXX Kludge: set u.u_dupfd to contain the value of the
|
||||
* the file descriptor being sought for duplication. The error
|
||||
* return ensures that the vnode for this device will be released
|
||||
* by vn_open. Open will detect this special error and take the
|
||||
* actions in dupfdopen below. Other callers of vn_open will
|
||||
* simply report the error.
|
||||
*/
|
||||
u.u_dupfd = minor(dev);
|
||||
return(ENODEV);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -451,82 +451,82 @@ fdopen(dev, mode, type)
|
||||
*/
|
||||
int
|
||||
dupfdopen (indx, dfd, mode, error)
|
||||
register int indx, dfd;
|
||||
int mode;
|
||||
int error;
|
||||
register int indx, dfd;
|
||||
int mode;
|
||||
int error;
|
||||
{
|
||||
register struct file *wfp;
|
||||
struct file *fp;
|
||||
register struct file *wfp;
|
||||
struct file *fp;
|
||||
|
||||
/*
|
||||
* If the to-be-dup'd fd number is greater than the allowed number
|
||||
* of file descriptors, or the fd to be dup'd has already been
|
||||
* closed, reject. Note, check for new == old is necessary as
|
||||
* falloc could allocate an already closed to-be-dup'd descriptor
|
||||
* as the new descriptor.
|
||||
*/
|
||||
fp = u.u_ofile[indx];
|
||||
if (dfd >= NOFILE || (wfp = u.u_ofile[dfd]) == NULL || fp == wfp)
|
||||
return(EBADF);
|
||||
/*
|
||||
* If the to-be-dup'd fd number is greater than the allowed number
|
||||
* of file descriptors, or the fd to be dup'd has already been
|
||||
* closed, reject. Note, check for new == old is necessary as
|
||||
* falloc could allocate an already closed to-be-dup'd descriptor
|
||||
* as the new descriptor.
|
||||
*/
|
||||
fp = u.u_ofile[indx];
|
||||
if (dfd >= NOFILE || (wfp = u.u_ofile[dfd]) == NULL || fp == wfp)
|
||||
return(EBADF);
|
||||
|
||||
/*
|
||||
* There are two cases of interest here.
|
||||
*
|
||||
* For ENODEV simply dup (dfd) to file descriptor
|
||||
* (indx) and return.
|
||||
*
|
||||
* For ENXIO steal away the file structure from (dfd) and
|
||||
* store it in (indx). (dfd) is effectively closed by
|
||||
* this operation.
|
||||
*
|
||||
* NOTE: ENXIO only comes out of the 'portal fs' code of 4.4 - since
|
||||
* 2.11BSD does not implement the portal fs the code is ifdef'd out
|
||||
* and a short message output.
|
||||
*
|
||||
* Any other error code is just returned.
|
||||
*/
|
||||
switch (error) {
|
||||
case ENODEV:
|
||||
/*
|
||||
* Check that the mode the file is being opened for is a
|
||||
* subset of the mode of the existing descriptor.
|
||||
*/
|
||||
if (((mode & (FREAD|FWRITE)) | wfp->f_flag) != wfp->f_flag)
|
||||
return(EACCES);
|
||||
u.u_ofile[indx] = wfp;
|
||||
u.u_pofile[indx] = u.u_pofile[dfd];
|
||||
wfp->f_count++;
|
||||
if (indx > u.u_lastfile)
|
||||
u.u_lastfile = indx;
|
||||
return(0);
|
||||
#ifdef haveportalfs
|
||||
case ENXIO:
|
||||
/*
|
||||
* Steal away the file pointer from dfd, and stuff it into indx.
|
||||
*/
|
||||
fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd];
|
||||
fdp->fd_ofiles[dfd] = NULL;
|
||||
fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd];
|
||||
fdp->fd_ofileflags[dfd] = 0;
|
||||
/*
|
||||
* Complete the clean up of the filedesc structure by
|
||||
* recomputing the various hints.
|
||||
*/
|
||||
if (indx > fdp->fd_lastfile)
|
||||
fdp->fd_lastfile = indx;
|
||||
else
|
||||
while (fdp->fd_lastfile > 0 &&
|
||||
fdp->fd_ofiles[fdp->fd_lastfile] == NULL)
|
||||
fdp->fd_lastfile--;
|
||||
if (dfd < fdp->fd_freefile)
|
||||
fdp->fd_freefile = dfd;
|
||||
return (0);
|
||||
/*
|
||||
* There are two cases of interest here.
|
||||
*
|
||||
* For ENODEV simply dup (dfd) to file descriptor
|
||||
* (indx) and return.
|
||||
*
|
||||
* For ENXIO steal away the file structure from (dfd) and
|
||||
* store it in (indx). (dfd) is effectively closed by
|
||||
* this operation.
|
||||
*
|
||||
* NOTE: ENXIO only comes out of the 'portal fs' code of 4.4 - since
|
||||
* 2.11BSD does not implement the portal fs the code is ifdef'd out
|
||||
* and a short message output.
|
||||
*
|
||||
* Any other error code is just returned.
|
||||
*/
|
||||
switch (error) {
|
||||
case ENODEV:
|
||||
/*
|
||||
* Check that the mode the file is being opened for is a
|
||||
* subset of the mode of the existing descriptor.
|
||||
*/
|
||||
if (((mode & (FREAD|FWRITE)) | wfp->f_flag) != wfp->f_flag)
|
||||
return(EACCES);
|
||||
u.u_ofile[indx] = wfp;
|
||||
u.u_pofile[indx] = u.u_pofile[dfd];
|
||||
wfp->f_count++;
|
||||
if (indx > u.u_lastfile)
|
||||
u.u_lastfile = indx;
|
||||
return(0);
|
||||
#ifdef haveportalfs
|
||||
case ENXIO:
|
||||
/*
|
||||
* Steal away the file pointer from dfd, and stuff it into indx.
|
||||
*/
|
||||
fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd];
|
||||
fdp->fd_ofiles[dfd] = NULL;
|
||||
fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd];
|
||||
fdp->fd_ofileflags[dfd] = 0;
|
||||
/*
|
||||
* Complete the clean up of the filedesc structure by
|
||||
* recomputing the various hints.
|
||||
*/
|
||||
if (indx > fdp->fd_lastfile)
|
||||
fdp->fd_lastfile = indx;
|
||||
else
|
||||
while (fdp->fd_lastfile > 0 &&
|
||||
fdp->fd_ofiles[fdp->fd_lastfile] == NULL)
|
||||
fdp->fd_lastfile--;
|
||||
if (dfd < fdp->fd_freefile)
|
||||
fdp->fd_freefile = dfd;
|
||||
return (0);
|
||||
#else
|
||||
log(LOG_NOTICE, "dupfdopen");
|
||||
/* FALLTHROUGH */
|
||||
log(LOG_NOTICE, "dupfdopen");
|
||||
/* FALLTHROUGH */
|
||||
#endif
|
||||
default:
|
||||
return(error);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
default:
|
||||
return(error);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
* exec system call, with and without environments.
|
||||
*/
|
||||
struct execa {
|
||||
char *fname;
|
||||
char **argp;
|
||||
char **envp;
|
||||
char *fname;
|
||||
char **argp;
|
||||
char **envp;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -38,119 +38,119 @@ struct execa {
|
||||
*/
|
||||
int exec_check(struct exec_params *epp)
|
||||
{
|
||||
int error, i, r;
|
||||
int error, i, r;
|
||||
|
||||
DEBUG("Entering exec_check\n");
|
||||
if (access (epp->ip, IEXEC))
|
||||
return ENOEXEC;
|
||||
if ((u.u_procp->p_flag & P_TRACED) && access (epp->ip, IREAD))
|
||||
return ENOEXEC;
|
||||
if ((epp->ip->i_mode & IFMT) != IFREG ||
|
||||
(epp->ip->i_mode & (IEXEC | (IEXEC>>3) | (IEXEC>>6))) == 0)
|
||||
return EACCES;
|
||||
DEBUG("Entering exec_check\n");
|
||||
if (access (epp->ip, IEXEC))
|
||||
return ENOEXEC;
|
||||
if ((u.u_procp->p_flag & P_TRACED) && access (epp->ip, IREAD))
|
||||
return ENOEXEC;
|
||||
if ((epp->ip->i_mode & IFMT) != IFREG ||
|
||||
(epp->ip->i_mode & (IEXEC | (IEXEC>>3) | (IEXEC>>6))) == 0)
|
||||
return EACCES;
|
||||
|
||||
/*
|
||||
* Read in first few bytes of file for segment sizes, magic number:
|
||||
* 407 = plain executable
|
||||
* Also an ASCII line beginning with #! is
|
||||
* the file name of a ``interpreter'' and arguments may be prepended
|
||||
* to the argument list if given here.
|
||||
*
|
||||
* INTERPRETER NAMES ARE LIMITED IN LENGTH.
|
||||
*
|
||||
* ONLY ONE ARGUMENT MAY BE PASSED TO THE INTERPRETER FROM
|
||||
* THE ASCII LINE.
|
||||
*/
|
||||
/*
|
||||
* Read in first few bytes of file for segment sizes, magic number:
|
||||
* 407 = plain executable
|
||||
* Also an ASCII line beginning with #! is
|
||||
* the file name of a ``interpreter'' and arguments may be prepended
|
||||
* to the argument list if given here.
|
||||
*
|
||||
* INTERPRETER NAMES ARE LIMITED IN LENGTH.
|
||||
*
|
||||
* ONLY ONE ARGUMENT MAY BE PASSED TO THE INTERPRETER FROM
|
||||
* THE ASCII LINE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Read the first 'SHSIZE' bytes from the file to execute
|
||||
*/
|
||||
DEBUG("Read header %d bytes from %d\n", sizeof(epp->hdr), 0);
|
||||
/*
|
||||
* Read the first 'SHSIZE' bytes from the file to execute
|
||||
*/
|
||||
DEBUG("Read header %d bytes from %d\n", sizeof(epp->hdr), 0);
|
||||
#ifdef EXEC_SCRIPT
|
||||
epp->hdr.sh[0] = '\0'; /* for zero length files */
|
||||
epp->hdr.sh[0] = '\0'; /* for zero length files */
|
||||
#endif
|
||||
error = rdwri (UIO_READ, epp->ip,
|
||||
(caddr_t) &epp->hdr, sizeof(epp->hdr),
|
||||
(off_t)0, IO_UNIT, &r);
|
||||
if (error)
|
||||
return error;
|
||||
epp->hdr_len = sizeof(epp->hdr) - r;
|
||||
error = rdwri (UIO_READ, epp->ip,
|
||||
(caddr_t) &epp->hdr, sizeof(epp->hdr),
|
||||
(off_t)0, IO_UNIT, &r);
|
||||
if (error)
|
||||
return error;
|
||||
epp->hdr_len = sizeof(epp->hdr) - r;
|
||||
|
||||
/*
|
||||
* Given the first part of the image
|
||||
* loop through the exec file handlers to find
|
||||
* someone who can handle this file format.
|
||||
*/
|
||||
error = ENOEXEC;
|
||||
DEBUG("Trying %d exec formats\n", nexecs);
|
||||
for (i = 0; i < nexecs && error != 0; i++) {
|
||||
DEBUG("Trying exec format %d : %s\n", i, execsw[i].es_name);
|
||||
if (execsw[i].es_check == NULL)
|
||||
continue;
|
||||
error = (*execsw[i].es_check)(epp);
|
||||
if (error == 0)
|
||||
break;
|
||||
}
|
||||
return error;
|
||||
/*
|
||||
* Given the first part of the image
|
||||
* loop through the exec file handlers to find
|
||||
* someone who can handle this file format.
|
||||
*/
|
||||
error = ENOEXEC;
|
||||
DEBUG("Trying %d exec formats\n", nexecs);
|
||||
for (i = 0; i < nexecs && error != 0; i++) {
|
||||
DEBUG("Trying exec format %d : %s\n", i, execsw[i].es_name);
|
||||
if (execsw[i].es_check == NULL)
|
||||
continue;
|
||||
error = (*execsw[i].es_check)(epp);
|
||||
if (error == 0)
|
||||
break;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
execv()
|
||||
{
|
||||
struct execa *arg = (struct execa *)u.u_arg;
|
||||
struct execa *arg = (struct execa *)u.u_arg;
|
||||
|
||||
arg->envp = NULL;
|
||||
execve();
|
||||
arg->envp = NULL;
|
||||
execve();
|
||||
}
|
||||
|
||||
void
|
||||
execve()
|
||||
{
|
||||
struct execa *uap = (struct execa *)u.u_arg;
|
||||
int error;
|
||||
struct inode *ip;
|
||||
struct nameidata nd;
|
||||
register struct nameidata *ndp = &nd;
|
||||
struct exec_params eparam;
|
||||
struct execa *uap = (struct execa *)u.u_arg;
|
||||
int error;
|
||||
struct inode *ip;
|
||||
struct nameidata nd;
|
||||
register struct nameidata *ndp = &nd;
|
||||
struct exec_params eparam;
|
||||
|
||||
DEBUG("execve ('%s', ['%s', '%s', ...])\n", uap->fname, uap->argp[0], uap->argp[1]);
|
||||
NDINIT (ndp, LOOKUP, FOLLOW, uap->fname);
|
||||
ip = namei (ndp);
|
||||
if (ip == NULL) {
|
||||
DEBUG("execve: file '%s' not found\n", uap->fname);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* The exec_param structure is used to
|
||||
* keep information about the executable during exec's processing
|
||||
*/
|
||||
bzero(&eparam, sizeof eparam);
|
||||
eparam.userfname = uap->fname;
|
||||
eparam.userargp = uap->argp;
|
||||
eparam.userenvp = uap->envp;
|
||||
eparam.uid = u.u_uid;
|
||||
eparam.gid = u.u_groups[0];
|
||||
DEBUG("execve ('%s', ['%s', '%s', ...])\n", uap->fname, uap->argp[0], uap->argp[1]);
|
||||
NDINIT (ndp, LOOKUP, FOLLOW, uap->fname);
|
||||
ip = namei (ndp);
|
||||
if (ip == NULL) {
|
||||
DEBUG("execve: file '%s' not found\n", uap->fname);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* The exec_param structure is used to
|
||||
* keep information about the executable during exec's processing
|
||||
*/
|
||||
bzero(&eparam, sizeof eparam);
|
||||
eparam.userfname = uap->fname;
|
||||
eparam.userargp = uap->argp;
|
||||
eparam.userenvp = uap->envp;
|
||||
eparam.uid = u.u_uid;
|
||||
eparam.gid = u.u_groups[0];
|
||||
|
||||
if (ip->i_fs->fs_flags & MNT_NOEXEC) {
|
||||
u.u_error = EACCES;
|
||||
DEBUG("EACCES\n");
|
||||
goto done;
|
||||
}
|
||||
if ((ip->i_fs->fs_flags & MNT_NOSUID) == 0) {
|
||||
if (ip->i_mode & ISUID)
|
||||
eparam.uid = ip->i_uid;
|
||||
if (ip->i_mode & ISGID)
|
||||
eparam.gid = ip->i_gid;
|
||||
}
|
||||
if (ip->i_fs->fs_flags & MNT_NOEXEC) {
|
||||
u.u_error = EACCES;
|
||||
DEBUG("EACCES\n");
|
||||
goto done;
|
||||
}
|
||||
if ((ip->i_fs->fs_flags & MNT_NOSUID) == 0) {
|
||||
if (ip->i_mode & ISUID)
|
||||
eparam.uid = ip->i_uid;
|
||||
if (ip->i_mode & ISGID)
|
||||
eparam.gid = ip->i_gid;
|
||||
}
|
||||
|
||||
eparam.ip = ip;
|
||||
DEBUG("calling exec_check()\n");
|
||||
if ((error = exec_check(&eparam)))
|
||||
u.u_error = error;
|
||||
DEBUG("back from exec_check()\n");
|
||||
eparam.ip = ip;
|
||||
DEBUG("calling exec_check()\n");
|
||||
if ((error = exec_check(&eparam)))
|
||||
u.u_error = error;
|
||||
DEBUG("back from exec_check()\n");
|
||||
done:
|
||||
exec_alloc_freeall(&eparam);
|
||||
if (ip)
|
||||
iput(ip);
|
||||
exec_alloc_freeall(&eparam);
|
||||
if (ip)
|
||||
iput(ip);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,21 +22,21 @@
|
||||
void
|
||||
endvfork()
|
||||
{
|
||||
register struct proc *rip, *rpp;
|
||||
register struct proc *rip, *rpp;
|
||||
|
||||
rpp = u.u_procp;
|
||||
rip = rpp->p_pptr;
|
||||
rpp->p_flag &= ~SVFORK;
|
||||
rpp->p_flag |= SLOCK;
|
||||
wakeup ((caddr_t) rpp);
|
||||
while (! (rpp->p_flag & SVFDONE))
|
||||
sleep ((caddr_t) rip, PZERO-1);
|
||||
/*
|
||||
* The parent has taken back our data+stack, set our sizes to 0.
|
||||
*/
|
||||
u.u_dsize = rpp->p_dsize = 0;
|
||||
u.u_ssize = rpp->p_ssize = 0;
|
||||
rpp->p_flag &= ~(SVFDONE | SLOCK);
|
||||
rpp = u.u_procp;
|
||||
rip = rpp->p_pptr;
|
||||
rpp->p_flag &= ~SVFORK;
|
||||
rpp->p_flag |= SLOCK;
|
||||
wakeup ((caddr_t) rpp);
|
||||
while (! (rpp->p_flag & SVFDONE))
|
||||
sleep ((caddr_t) rip, PZERO-1);
|
||||
/*
|
||||
* The parent has taken back our data+stack, set our sizes to 0.
|
||||
*/
|
||||
u.u_dsize = rpp->p_dsize = 0;
|
||||
u.u_ssize = rpp->p_ssize = 0;
|
||||
rpp->p_flag &= ~(SVFDONE | SLOCK);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -47,95 +47,95 @@ endvfork()
|
||||
*/
|
||||
void
|
||||
exit (rv)
|
||||
int rv;
|
||||
int rv;
|
||||
{
|
||||
register int i;
|
||||
register struct proc *p;
|
||||
struct proc **pp;
|
||||
register int i;
|
||||
register struct proc *p;
|
||||
struct proc **pp;
|
||||
|
||||
p = u.u_procp;
|
||||
p->p_flag &= ~P_TRACED;
|
||||
p->p_sigignore = ~0;
|
||||
p->p_sig = 0;
|
||||
/*
|
||||
* 2.11 doesn't need to do this and it gets overwritten anyway.
|
||||
* p->p_realtimer.it_value = 0;
|
||||
*/
|
||||
for (i = 0; i <= u.u_lastfile; i++) {
|
||||
register struct file *f;
|
||||
p = u.u_procp;
|
||||
p->p_flag &= ~P_TRACED;
|
||||
p->p_sigignore = ~0;
|
||||
p->p_sig = 0;
|
||||
/*
|
||||
* 2.11 doesn't need to do this and it gets overwritten anyway.
|
||||
* p->p_realtimer.it_value = 0;
|
||||
*/
|
||||
for (i = 0; i <= u.u_lastfile; i++) {
|
||||
register struct file *f;
|
||||
|
||||
f = u.u_ofile[i];
|
||||
u.u_ofile[i] = NULL;
|
||||
u.u_pofile[i] = 0;
|
||||
(void) closef(f);
|
||||
}
|
||||
ilock(u.u_cdir);
|
||||
iput(u.u_cdir);
|
||||
if (u.u_rdir) {
|
||||
ilock(u.u_rdir);
|
||||
iput(u.u_rdir);
|
||||
}
|
||||
u.u_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
|
||||
f = u.u_ofile[i];
|
||||
u.u_ofile[i] = NULL;
|
||||
u.u_pofile[i] = 0;
|
||||
(void) closef(f);
|
||||
}
|
||||
ilock(u.u_cdir);
|
||||
iput(u.u_cdir);
|
||||
if (u.u_rdir) {
|
||||
ilock(u.u_rdir);
|
||||
iput(u.u_rdir);
|
||||
}
|
||||
u.u_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
|
||||
|
||||
if (p->p_flag & SVFORK)
|
||||
endvfork();
|
||||
if (p->p_flag & SVFORK)
|
||||
endvfork();
|
||||
|
||||
if (p->p_pid == 1)
|
||||
panic("init died");
|
||||
if ((*p->p_prev = p->p_nxt) != NULL) /* off allproc queue */
|
||||
p->p_nxt->p_prev = p->p_prev;
|
||||
p->p_nxt = zombproc; /* onto zombproc */
|
||||
if (p->p_nxt != NULL)
|
||||
p->p_nxt->p_prev = &p->p_nxt;
|
||||
p->p_prev = &zombproc;
|
||||
zombproc = p;
|
||||
p->p_stat = SZOMB;
|
||||
if (p->p_pid == 1)
|
||||
panic("init died");
|
||||
if ((*p->p_prev = p->p_nxt) != NULL) /* off allproc queue */
|
||||
p->p_nxt->p_prev = p->p_prev;
|
||||
p->p_nxt = zombproc; /* onto zombproc */
|
||||
if (p->p_nxt != NULL)
|
||||
p->p_nxt->p_prev = &p->p_nxt;
|
||||
p->p_prev = &zombproc;
|
||||
zombproc = p;
|
||||
p->p_stat = SZOMB;
|
||||
|
||||
noproc = 1;
|
||||
for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash)
|
||||
if (*pp == p) {
|
||||
*pp = p->p_hash;
|
||||
goto done;
|
||||
}
|
||||
panic("exit");
|
||||
noproc = 1;
|
||||
for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash)
|
||||
if (*pp == p) {
|
||||
*pp = p->p_hash;
|
||||
goto done;
|
||||
}
|
||||
panic("exit");
|
||||
done:
|
||||
/*
|
||||
* Overwrite p_alive substructure of proc - better not be anything
|
||||
* important left!
|
||||
*/
|
||||
p->p_xstat = rv;
|
||||
p->p_ru = u.u_ru;
|
||||
ruadd(&p->p_ru, &u.u_cru);
|
||||
{
|
||||
register struct proc *q;
|
||||
int doingzomb = 0;
|
||||
/*
|
||||
* Overwrite p_alive substructure of proc - better not be anything
|
||||
* important left!
|
||||
*/
|
||||
p->p_xstat = rv;
|
||||
p->p_ru = u.u_ru;
|
||||
ruadd(&p->p_ru, &u.u_cru);
|
||||
{
|
||||
register struct proc *q;
|
||||
int doingzomb = 0;
|
||||
|
||||
q = allproc;
|
||||
q = allproc;
|
||||
again:
|
||||
for(; q; q = q->p_nxt)
|
||||
if (q->p_pptr == p) {
|
||||
q->p_pptr = &proc[1];
|
||||
q->p_ppid = 1;
|
||||
wakeup((caddr_t)&proc[1]);
|
||||
if (q->p_flag& P_TRACED) {
|
||||
q->p_flag &= ~P_TRACED;
|
||||
psignal(q, SIGKILL);
|
||||
} else if (q->p_stat == SSTOP) {
|
||||
psignal(q, SIGHUP);
|
||||
psignal(q, SIGCONT);
|
||||
}
|
||||
}
|
||||
if (!doingzomb) {
|
||||
doingzomb = 1;
|
||||
q = zombproc;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
psignal(p->p_pptr, SIGCHLD);
|
||||
wakeup((caddr_t) p->p_pptr);
|
||||
wakeup((caddr_t) &runin);
|
||||
swtch();
|
||||
/* NOTREACHED */
|
||||
for(; q; q = q->p_nxt)
|
||||
if (q->p_pptr == p) {
|
||||
q->p_pptr = &proc[1];
|
||||
q->p_ppid = 1;
|
||||
wakeup((caddr_t)&proc[1]);
|
||||
if (q->p_flag& P_TRACED) {
|
||||
q->p_flag &= ~P_TRACED;
|
||||
psignal(q, SIGKILL);
|
||||
} else if (q->p_stat == SSTOP) {
|
||||
psignal(q, SIGHUP);
|
||||
psignal(q, SIGCONT);
|
||||
}
|
||||
}
|
||||
if (!doingzomb) {
|
||||
doingzomb = 1;
|
||||
q = zombproc;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
psignal(p->p_pptr, SIGCHLD);
|
||||
wakeup((caddr_t) p->p_pptr);
|
||||
wakeup((caddr_t) &runin);
|
||||
swtch();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -144,19 +144,19 @@ again:
|
||||
void
|
||||
rexit()
|
||||
{
|
||||
register struct a {
|
||||
int rval;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
register struct a {
|
||||
int rval;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
|
||||
exit (W_EXITCODE (uap->rval, 0));
|
||||
/* NOTREACHED */
|
||||
exit (W_EXITCODE (uap->rval, 0));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
struct args {
|
||||
int pid;
|
||||
int *status;
|
||||
int options;
|
||||
struct rusage *rusage;
|
||||
int pid;
|
||||
int *status;
|
||||
int options;
|
||||
struct rusage *rusage;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -167,114 +167,114 @@ struct args {
|
||||
*/
|
||||
static int
|
||||
wait1 (q, uap, retval)
|
||||
struct proc *q;
|
||||
register struct args *uap;
|
||||
int retval[];
|
||||
struct proc *q;
|
||||
register struct args *uap;
|
||||
int retval[];
|
||||
{
|
||||
int nfound, status;
|
||||
struct rusage ru; /* used for local conversion */
|
||||
register struct proc *p;
|
||||
register int error;
|
||||
int nfound, status;
|
||||
struct rusage ru; /* used for local conversion */
|
||||
register struct proc *p;
|
||||
register int error;
|
||||
|
||||
if (uap->pid == WAIT_MYPGRP) /* == 0 */
|
||||
uap->pid = -q->p_pgrp;
|
||||
if (uap->pid == WAIT_MYPGRP) /* == 0 */
|
||||
uap->pid = -q->p_pgrp;
|
||||
loop:
|
||||
nfound = 0;
|
||||
/*
|
||||
* 4.X has child links in the proc structure, so they consolidate
|
||||
* these two tests into one loop. We only have the zombie chain
|
||||
* and the allproc chain, so we check for ZOMBIES first, then for
|
||||
* children that have changed state. We check for ZOMBIES first
|
||||
* because they are more common, and, as the list is typically small,
|
||||
* a faster check.
|
||||
*/
|
||||
for (p = zombproc; p; p = p->p_nxt) {
|
||||
if (p->p_pptr != q) /* are we the parent of this process? */
|
||||
continue;
|
||||
if (uap->pid != WAIT_ANY &&
|
||||
p->p_pid != uap->pid && p->p_pgrp != -uap->pid)
|
||||
continue;
|
||||
retval[0] = p->p_pid;
|
||||
retval[1] = p->p_xstat;
|
||||
if (uap->status && (error = copyout ((caddr_t) &p->p_xstat,
|
||||
(caddr_t) uap->status, sizeof (uap->status))))
|
||||
return(error);
|
||||
if (uap->rusage) {
|
||||
rucvt(&ru, &p->p_ru);
|
||||
error = copyout ((caddr_t) &ru, (caddr_t) uap->rusage, sizeof (ru));
|
||||
if (error)
|
||||
return(error);
|
||||
}
|
||||
ruadd(&u.u_cru, &p->p_ru);
|
||||
p->p_xstat = 0;
|
||||
p->p_stat = NULL;
|
||||
p->p_pid = 0;
|
||||
p->p_ppid = 0;
|
||||
if ((*p->p_prev = p->p_nxt) != NULL) /* off zombproc */
|
||||
p->p_nxt->p_prev = p->p_prev;
|
||||
p->p_nxt = freeproc; /* onto freeproc */
|
||||
freeproc = p;
|
||||
p->p_pptr = 0;
|
||||
p->p_sig = 0;
|
||||
p->p_sigcatch = 0;
|
||||
p->p_sigignore = 0;
|
||||
p->p_sigmask = 0;
|
||||
p->p_pgrp = 0;
|
||||
p->p_flag = 0;
|
||||
p->p_wchan = 0;
|
||||
return (0);
|
||||
}
|
||||
for (p = allproc; p;p = p->p_nxt) {
|
||||
if (p->p_pptr != q)
|
||||
continue;
|
||||
if (uap->pid != WAIT_ANY &&
|
||||
p->p_pid != uap->pid && p->p_pgrp != -uap->pid)
|
||||
continue;
|
||||
++nfound;
|
||||
if (p->p_stat == SSTOP && ! (p->p_flag & P_WAITED) &&
|
||||
(p->p_flag & P_TRACED || uap->options & WUNTRACED)) {
|
||||
p->p_flag |= P_WAITED;
|
||||
retval[0] = p->p_pid;
|
||||
error = 0;
|
||||
if (uap->status) {
|
||||
status = W_STOPCODE(p->p_ptracesig);
|
||||
error = copyout ((caddr_t) &status,
|
||||
(caddr_t) uap->status, sizeof (status));
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
if (nfound == 0)
|
||||
return (ECHILD);
|
||||
if (uap->options&WNOHANG) {
|
||||
retval[0] = 0;
|
||||
return (0);
|
||||
}
|
||||
error = tsleep ((caddr_t) q, PWAIT|PCATCH, 0);
|
||||
if (error == 0)
|
||||
goto loop;
|
||||
return(error);
|
||||
nfound = 0;
|
||||
/*
|
||||
* 4.X has child links in the proc structure, so they consolidate
|
||||
* these two tests into one loop. We only have the zombie chain
|
||||
* and the allproc chain, so we check for ZOMBIES first, then for
|
||||
* children that have changed state. We check for ZOMBIES first
|
||||
* because they are more common, and, as the list is typically small,
|
||||
* a faster check.
|
||||
*/
|
||||
for (p = zombproc; p; p = p->p_nxt) {
|
||||
if (p->p_pptr != q) /* are we the parent of this process? */
|
||||
continue;
|
||||
if (uap->pid != WAIT_ANY &&
|
||||
p->p_pid != uap->pid && p->p_pgrp != -uap->pid)
|
||||
continue;
|
||||
retval[0] = p->p_pid;
|
||||
retval[1] = p->p_xstat;
|
||||
if (uap->status && (error = copyout ((caddr_t) &p->p_xstat,
|
||||
(caddr_t) uap->status, sizeof (uap->status))))
|
||||
return(error);
|
||||
if (uap->rusage) {
|
||||
rucvt(&ru, &p->p_ru);
|
||||
error = copyout ((caddr_t) &ru, (caddr_t) uap->rusage, sizeof (ru));
|
||||
if (error)
|
||||
return(error);
|
||||
}
|
||||
ruadd(&u.u_cru, &p->p_ru);
|
||||
p->p_xstat = 0;
|
||||
p->p_stat = NULL;
|
||||
p->p_pid = 0;
|
||||
p->p_ppid = 0;
|
||||
if ((*p->p_prev = p->p_nxt) != NULL) /* off zombproc */
|
||||
p->p_nxt->p_prev = p->p_prev;
|
||||
p->p_nxt = freeproc; /* onto freeproc */
|
||||
freeproc = p;
|
||||
p->p_pptr = 0;
|
||||
p->p_sig = 0;
|
||||
p->p_sigcatch = 0;
|
||||
p->p_sigignore = 0;
|
||||
p->p_sigmask = 0;
|
||||
p->p_pgrp = 0;
|
||||
p->p_flag = 0;
|
||||
p->p_wchan = 0;
|
||||
return (0);
|
||||
}
|
||||
for (p = allproc; p;p = p->p_nxt) {
|
||||
if (p->p_pptr != q)
|
||||
continue;
|
||||
if (uap->pid != WAIT_ANY &&
|
||||
p->p_pid != uap->pid && p->p_pgrp != -uap->pid)
|
||||
continue;
|
||||
++nfound;
|
||||
if (p->p_stat == SSTOP && ! (p->p_flag & P_WAITED) &&
|
||||
(p->p_flag & P_TRACED || uap->options & WUNTRACED)) {
|
||||
p->p_flag |= P_WAITED;
|
||||
retval[0] = p->p_pid;
|
||||
error = 0;
|
||||
if (uap->status) {
|
||||
status = W_STOPCODE(p->p_ptracesig);
|
||||
error = copyout ((caddr_t) &status,
|
||||
(caddr_t) uap->status, sizeof (status));
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
if (nfound == 0)
|
||||
return (ECHILD);
|
||||
if (uap->options&WNOHANG) {
|
||||
retval[0] = 0;
|
||||
return (0);
|
||||
}
|
||||
error = tsleep ((caddr_t) q, PWAIT|PCATCH, 0);
|
||||
if (error == 0)
|
||||
goto loop;
|
||||
return(error);
|
||||
}
|
||||
|
||||
void
|
||||
wait4()
|
||||
{
|
||||
int retval[2];
|
||||
register struct args *uap = (struct args*) u.u_arg;
|
||||
int retval[2];
|
||||
register struct args *uap = (struct args*) u.u_arg;
|
||||
|
||||
retval[0] = 0;
|
||||
u.u_error = wait1 (u.u_procp, uap, retval);
|
||||
if (! u.u_error)
|
||||
u.u_rval = retval[0];
|
||||
retval[0] = 0;
|
||||
u.u_error = wait1 (u.u_procp, uap, retval);
|
||||
if (! u.u_error)
|
||||
u.u_rval = retval[0];
|
||||
}
|
||||
|
||||
void
|
||||
reboot()
|
||||
{
|
||||
struct a {
|
||||
int opt;
|
||||
};
|
||||
struct a {
|
||||
int opt;
|
||||
};
|
||||
|
||||
if (suser ())
|
||||
boot (rootdev, ((struct a*)u.u_arg)->opt);
|
||||
if (suser ())
|
||||
boot (rootdev, ((struct a*)u.u_arg)->opt);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "kernel.h"
|
||||
#include "syslog.h"
|
||||
|
||||
int mpid; /* generic for unique process id's */
|
||||
int mpid; /* generic for unique process id's */
|
||||
|
||||
/*
|
||||
* Create a new process -- the internal version of system call fork.
|
||||
@@ -22,217 +22,217 @@ int mpid; /* generic for unique process id's */
|
||||
*/
|
||||
int
|
||||
newproc (isvfork)
|
||||
int isvfork;
|
||||
int isvfork;
|
||||
{
|
||||
register struct proc *child, *parent;
|
||||
register int n;
|
||||
static int pidchecked = 0;
|
||||
struct file *fp;
|
||||
register struct proc *child, *parent;
|
||||
register int n;
|
||||
static int pidchecked = 0;
|
||||
struct file *fp;
|
||||
|
||||
/*
|
||||
* First, just locate a slot for a process
|
||||
* and copy the useful info from this process into it.
|
||||
* The panic "cannot happen" because fork has already
|
||||
* checked for the existence of a slot.
|
||||
*/
|
||||
mpid++;
|
||||
/*
|
||||
* First, just locate a slot for a process
|
||||
* and copy the useful info from this process into it.
|
||||
* The panic "cannot happen" because fork has already
|
||||
* checked for the existence of a slot.
|
||||
*/
|
||||
mpid++;
|
||||
retry:
|
||||
if (mpid >= 30000) {
|
||||
mpid = 100;
|
||||
pidchecked = 0;
|
||||
}
|
||||
if (mpid >= pidchecked) {
|
||||
int doingzomb = 0;
|
||||
if (mpid >= 30000) {
|
||||
mpid = 100;
|
||||
pidchecked = 0;
|
||||
}
|
||||
if (mpid >= pidchecked) {
|
||||
int doingzomb = 0;
|
||||
|
||||
pidchecked = 30000;
|
||||
/*
|
||||
* Scan the proc table to check whether this pid
|
||||
* is in use. Remember the lowest pid that's greater
|
||||
* than mpid, so we can avoid checking for a while.
|
||||
*/
|
||||
child = allproc;
|
||||
pidchecked = 30000;
|
||||
/*
|
||||
* Scan the proc table to check whether this pid
|
||||
* is in use. Remember the lowest pid that's greater
|
||||
* than mpid, so we can avoid checking for a while.
|
||||
*/
|
||||
child = allproc;
|
||||
again:
|
||||
for (; child != NULL; child = child->p_nxt) {
|
||||
if (child->p_pid == mpid || child->p_pgrp == mpid) {
|
||||
mpid++;
|
||||
if (mpid >= pidchecked)
|
||||
goto retry;
|
||||
}
|
||||
if (child->p_pid > mpid && pidchecked > child->p_pid)
|
||||
pidchecked = child->p_pid;
|
||||
if (child->p_pgrp > mpid && pidchecked > child->p_pgrp)
|
||||
pidchecked = child->p_pgrp;
|
||||
}
|
||||
if (!doingzomb) {
|
||||
doingzomb = 1;
|
||||
child = zombproc;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
child = freeproc;
|
||||
if (child == NULL)
|
||||
panic("no procs");
|
||||
for (; child != NULL; child = child->p_nxt) {
|
||||
if (child->p_pid == mpid || child->p_pgrp == mpid) {
|
||||
mpid++;
|
||||
if (mpid >= pidchecked)
|
||||
goto retry;
|
||||
}
|
||||
if (child->p_pid > mpid && pidchecked > child->p_pid)
|
||||
pidchecked = child->p_pid;
|
||||
if (child->p_pgrp > mpid && pidchecked > child->p_pgrp)
|
||||
pidchecked = child->p_pgrp;
|
||||
}
|
||||
if (!doingzomb) {
|
||||
doingzomb = 1;
|
||||
child = zombproc;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
child = freeproc;
|
||||
if (child == NULL)
|
||||
panic("no procs");
|
||||
|
||||
freeproc = child->p_nxt; /* off freeproc */
|
||||
freeproc = child->p_nxt; /* off freeproc */
|
||||
|
||||
/*
|
||||
* Make a proc table entry for the new process.
|
||||
*/
|
||||
parent = u.u_procp;
|
||||
child->p_stat = SIDL;
|
||||
child->p_realtimer.it_value = 0;
|
||||
child->p_flag = SLOAD;
|
||||
child->p_uid = parent->p_uid;
|
||||
child->p_pgrp = parent->p_pgrp;
|
||||
child->p_nice = parent->p_nice;
|
||||
child->p_pid = mpid;
|
||||
child->p_ppid = parent->p_pid;
|
||||
child->p_pptr = parent;
|
||||
child->p_time = 0;
|
||||
child->p_cpu = 0;
|
||||
child->p_sigmask = parent->p_sigmask;
|
||||
child->p_sigcatch = parent->p_sigcatch;
|
||||
child->p_sigignore = parent->p_sigignore;
|
||||
/* take along any pending signals like stops? */
|
||||
/*
|
||||
* Make a proc table entry for the new process.
|
||||
*/
|
||||
parent = u.u_procp;
|
||||
child->p_stat = SIDL;
|
||||
child->p_realtimer.it_value = 0;
|
||||
child->p_flag = SLOAD;
|
||||
child->p_uid = parent->p_uid;
|
||||
child->p_pgrp = parent->p_pgrp;
|
||||
child->p_nice = parent->p_nice;
|
||||
child->p_pid = mpid;
|
||||
child->p_ppid = parent->p_pid;
|
||||
child->p_pptr = parent;
|
||||
child->p_time = 0;
|
||||
child->p_cpu = 0;
|
||||
child->p_sigmask = parent->p_sigmask;
|
||||
child->p_sigcatch = parent->p_sigcatch;
|
||||
child->p_sigignore = parent->p_sigignore;
|
||||
/* take along any pending signals like stops? */
|
||||
#ifdef UCB_METER
|
||||
if (isvfork) {
|
||||
forkstat.cntvfork++;
|
||||
forkstat.sizvfork += (parent->p_dsize + parent->p_ssize) >> 10;
|
||||
} else {
|
||||
forkstat.cntfork++;
|
||||
forkstat.sizfork += (parent->p_dsize + parent->p_ssize) >> 10;
|
||||
}
|
||||
if (isvfork) {
|
||||
forkstat.cntvfork++;
|
||||
forkstat.sizvfork += (parent->p_dsize + parent->p_ssize) >> 10;
|
||||
} else {
|
||||
forkstat.cntfork++;
|
||||
forkstat.sizfork += (parent->p_dsize + parent->p_ssize) >> 10;
|
||||
}
|
||||
#endif
|
||||
child->p_wchan = 0;
|
||||
child->p_slptime = 0;
|
||||
{
|
||||
struct proc **hash = &pidhash [PIDHASH (child->p_pid)];
|
||||
child->p_wchan = 0;
|
||||
child->p_slptime = 0;
|
||||
{
|
||||
struct proc **hash = &pidhash [PIDHASH (child->p_pid)];
|
||||
|
||||
child->p_hash = *hash;
|
||||
*hash = child;
|
||||
}
|
||||
/*
|
||||
* some shuffling here -- in most UNIX kernels, the allproc assign
|
||||
* is done after grabbing the struct off of the freeproc list. We
|
||||
* wait so that if the clock interrupts us and vmtotal walks allproc
|
||||
* the text pointer isn't garbage.
|
||||
*/
|
||||
child->p_nxt = allproc; /* onto allproc */
|
||||
child->p_nxt->p_prev = &child->p_nxt; /* (allproc is never NULL) */
|
||||
child->p_prev = &allproc;
|
||||
allproc = child;
|
||||
child->p_hash = *hash;
|
||||
*hash = child;
|
||||
}
|
||||
/*
|
||||
* some shuffling here -- in most UNIX kernels, the allproc assign
|
||||
* is done after grabbing the struct off of the freeproc list. We
|
||||
* wait so that if the clock interrupts us and vmtotal walks allproc
|
||||
* the text pointer isn't garbage.
|
||||
*/
|
||||
child->p_nxt = allproc; /* onto allproc */
|
||||
child->p_nxt->p_prev = &child->p_nxt; /* (allproc is never NULL) */
|
||||
child->p_prev = &allproc;
|
||||
allproc = child;
|
||||
|
||||
/*
|
||||
* Increase reference counts on shared objects.
|
||||
*/
|
||||
for (n = 0; n <= u.u_lastfile; n++) {
|
||||
fp = u.u_ofile[n];
|
||||
if (fp == NULL)
|
||||
continue;
|
||||
fp->f_count++;
|
||||
}
|
||||
u.u_cdir->i_count++;
|
||||
if (u.u_rdir)
|
||||
u.u_rdir->i_count++;
|
||||
/*
|
||||
* Increase reference counts on shared objects.
|
||||
*/
|
||||
for (n = 0; n <= u.u_lastfile; n++) {
|
||||
fp = u.u_ofile[n];
|
||||
if (fp == NULL)
|
||||
continue;
|
||||
fp->f_count++;
|
||||
}
|
||||
u.u_cdir->i_count++;
|
||||
if (u.u_rdir)
|
||||
u.u_rdir->i_count++;
|
||||
|
||||
/*
|
||||
* When the longjmp is executed for the new process,
|
||||
* here's where it will resume.
|
||||
*/
|
||||
if (setjmp (&u.u_ssave)) {
|
||||
return(1);
|
||||
}
|
||||
/*
|
||||
* When the longjmp is executed for the new process,
|
||||
* here's where it will resume.
|
||||
*/
|
||||
if (setjmp (&u.u_ssave)) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
child->p_dsize = parent->p_dsize;
|
||||
child->p_ssize = parent->p_ssize;
|
||||
child->p_daddr = parent->p_daddr;
|
||||
child->p_saddr = parent->p_saddr;
|
||||
child->p_dsize = parent->p_dsize;
|
||||
child->p_ssize = parent->p_ssize;
|
||||
child->p_daddr = parent->p_daddr;
|
||||
child->p_saddr = parent->p_saddr;
|
||||
|
||||
/*
|
||||
* Partially simulate the environment of the new process so that
|
||||
* when it is actually created (by copying) it will look right.
|
||||
*/
|
||||
u.u_procp = child;
|
||||
/*
|
||||
* Partially simulate the environment of the new process so that
|
||||
* when it is actually created (by copying) it will look right.
|
||||
*/
|
||||
u.u_procp = child;
|
||||
|
||||
/*
|
||||
* Swap out the current process to generate the copy.
|
||||
*/
|
||||
parent->p_stat = SIDL;
|
||||
child->p_addr = parent->p_addr;
|
||||
child->p_stat = SRUN;
|
||||
swapout (child, X_DONTFREE, X_OLDSIZE, X_OLDSIZE);
|
||||
child->p_flag |= SSWAP;
|
||||
parent->p_stat = SRUN;
|
||||
u.u_procp = parent;
|
||||
/*
|
||||
* Swap out the current process to generate the copy.
|
||||
*/
|
||||
parent->p_stat = SIDL;
|
||||
child->p_addr = parent->p_addr;
|
||||
child->p_stat = SRUN;
|
||||
swapout (child, X_DONTFREE, X_OLDSIZE, X_OLDSIZE);
|
||||
child->p_flag |= SSWAP;
|
||||
parent->p_stat = SRUN;
|
||||
u.u_procp = parent;
|
||||
|
||||
if (isvfork) {
|
||||
/*
|
||||
* Wait for the child to finish with it.
|
||||
* RetroBSD: to make this work, significant
|
||||
* changes in scheduler are required.
|
||||
*/
|
||||
parent->p_dsize = 0;
|
||||
parent->p_ssize = 0;
|
||||
child->p_flag |= SVFORK;
|
||||
parent->p_flag |= SVFPRNT;
|
||||
while (child->p_flag & SVFORK)
|
||||
sleep ((caddr_t)child, PSWP+1);
|
||||
if ((child->p_flag & SLOAD) == 0)
|
||||
panic ("newproc vfork");
|
||||
u.u_dsize = parent->p_dsize = child->p_dsize;
|
||||
parent->p_daddr = child->p_daddr;
|
||||
child->p_dsize = 0;
|
||||
u.u_ssize = parent->p_ssize = child->p_ssize;
|
||||
parent->p_saddr = child->p_saddr;
|
||||
child->p_ssize = 0;
|
||||
child->p_flag |= SVFDONE;
|
||||
wakeup ((caddr_t) parent);
|
||||
parent->p_flag &= ~SVFPRNT;
|
||||
}
|
||||
return(0);
|
||||
if (isvfork) {
|
||||
/*
|
||||
* Wait for the child to finish with it.
|
||||
* RetroBSD: to make this work, significant
|
||||
* changes in scheduler are required.
|
||||
*/
|
||||
parent->p_dsize = 0;
|
||||
parent->p_ssize = 0;
|
||||
child->p_flag |= SVFORK;
|
||||
parent->p_flag |= SVFPRNT;
|
||||
while (child->p_flag & SVFORK)
|
||||
sleep ((caddr_t)child, PSWP+1);
|
||||
if ((child->p_flag & SLOAD) == 0)
|
||||
panic ("newproc vfork");
|
||||
u.u_dsize = parent->p_dsize = child->p_dsize;
|
||||
parent->p_daddr = child->p_daddr;
|
||||
child->p_dsize = 0;
|
||||
u.u_ssize = parent->p_ssize = child->p_ssize;
|
||||
parent->p_saddr = child->p_saddr;
|
||||
child->p_ssize = 0;
|
||||
child->p_flag |= SVFDONE;
|
||||
wakeup ((caddr_t) parent);
|
||||
parent->p_flag &= ~SVFPRNT;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
fork1 (isvfork)
|
||||
int isvfork;
|
||||
int isvfork;
|
||||
{
|
||||
register int a;
|
||||
register struct proc *p1, *p2;
|
||||
register int a;
|
||||
register struct proc *p1, *p2;
|
||||
|
||||
a = 0;
|
||||
if (u.u_uid != 0) {
|
||||
for (p1 = allproc; p1; p1 = p1->p_nxt)
|
||||
if (p1->p_uid == u.u_uid)
|
||||
a++;
|
||||
for (p1 = zombproc; p1; p1 = p1->p_nxt)
|
||||
if (p1->p_uid == u.u_uid)
|
||||
a++;
|
||||
}
|
||||
/*
|
||||
* Disallow if
|
||||
* No processes at all;
|
||||
* not su and too many procs owned; or
|
||||
* not su and would take last slot.
|
||||
*/
|
||||
p2 = freeproc;
|
||||
if (p2==NULL)
|
||||
log(LOG_ERR, "proc: table full\n");
|
||||
a = 0;
|
||||
if (u.u_uid != 0) {
|
||||
for (p1 = allproc; p1; p1 = p1->p_nxt)
|
||||
if (p1->p_uid == u.u_uid)
|
||||
a++;
|
||||
for (p1 = zombproc; p1; p1 = p1->p_nxt)
|
||||
if (p1->p_uid == u.u_uid)
|
||||
a++;
|
||||
}
|
||||
/*
|
||||
* Disallow if
|
||||
* No processes at all;
|
||||
* not su and too many procs owned; or
|
||||
* not su and would take last slot.
|
||||
*/
|
||||
p2 = freeproc;
|
||||
if (p2==NULL)
|
||||
log(LOG_ERR, "proc: table full\n");
|
||||
|
||||
if (p2==NULL || (u.u_uid!=0 && (p2->p_nxt == NULL || a>MAXUPRC))) {
|
||||
u.u_error = EAGAIN;
|
||||
return;
|
||||
}
|
||||
p1 = u.u_procp;
|
||||
if (newproc (isvfork)) {
|
||||
/* Child */
|
||||
u.u_rval = 0;
|
||||
u.u_start = time.tv_sec;
|
||||
bzero(&u.u_ru, sizeof(u.u_ru));
|
||||
bzero(&u.u_cru, sizeof(u.u_cru));
|
||||
return;
|
||||
}
|
||||
/* Parent */
|
||||
u.u_rval = p2->p_pid;
|
||||
if (p2==NULL || (u.u_uid!=0 && (p2->p_nxt == NULL || a>MAXUPRC))) {
|
||||
u.u_error = EAGAIN;
|
||||
return;
|
||||
}
|
||||
p1 = u.u_procp;
|
||||
if (newproc (isvfork)) {
|
||||
/* Child */
|
||||
u.u_rval = 0;
|
||||
u.u_start = time.tv_sec;
|
||||
bzero(&u.u_ru, sizeof(u.u_ru));
|
||||
bzero(&u.u_cru, sizeof(u.u_cru));
|
||||
return;
|
||||
}
|
||||
/* Parent */
|
||||
u.u_rval = p2->p_pid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -241,7 +241,7 @@ fork1 (isvfork)
|
||||
void
|
||||
fork()
|
||||
{
|
||||
fork1 (0);
|
||||
fork1 (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -250,5 +250,5 @@ fork()
|
||||
void
|
||||
vfork()
|
||||
{
|
||||
fork1 (1);
|
||||
fork1 (1);
|
||||
}
|
||||
|
||||
@@ -18,44 +18,44 @@ unsigned char global_segment[GLOBSZ];
|
||||
|
||||
void rdglob()
|
||||
{
|
||||
struct a {
|
||||
int addr;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct a {
|
||||
int addr;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
|
||||
// Only root should have access to the shared memory block
|
||||
if(u.u_uid!=0)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
// Only root should have access to the shared memory block
|
||||
if(u.u_uid!=0)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if(uap->addr>=GLOBSZ)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
u.u_rval = global_segment[uap->addr];
|
||||
if(uap->addr>=GLOBSZ)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
u.u_rval = global_segment[uap->addr];
|
||||
}
|
||||
|
||||
void wrglob()
|
||||
{
|
||||
struct a {
|
||||
int addr;
|
||||
unsigned char value;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct a {
|
||||
int addr;
|
||||
unsigned char value;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
|
||||
// Only root should have access to the shared memory block
|
||||
if(u.u_uid!=0)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
// Only root should have access to the shared memory block
|
||||
if(u.u_uid!=0)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if(uap->addr>=GLOBSZ)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
u.u_rval = 0;
|
||||
global_segment[uap->addr] = uap->value;
|
||||
if(uap->addr>=GLOBSZ)
|
||||
{
|
||||
u.u_rval = -1;
|
||||
return;
|
||||
}
|
||||
u.u_rval = 0;
|
||||
global_segment[uap->addr] = uap->value;
|
||||
}
|
||||
|
||||
@@ -12,27 +12,27 @@
|
||||
void
|
||||
brk()
|
||||
{
|
||||
struct a {
|
||||
int naddr;
|
||||
};
|
||||
register int newsize, d;
|
||||
struct a {
|
||||
int naddr;
|
||||
};
|
||||
register int newsize, d;
|
||||
|
||||
/* set newsize to new data size */
|
||||
newsize = ((struct a*)u.u_arg)->naddr - u.u_procp->p_daddr;
|
||||
if (newsize < 0)
|
||||
newsize = 0;
|
||||
if (u.u_tsize + newsize + u.u_ssize > MAXMEM) {
|
||||
u.u_error = ENOMEM;
|
||||
return;
|
||||
}
|
||||
/* set newsize to new data size */
|
||||
newsize = ((struct a*)u.u_arg)->naddr - u.u_procp->p_daddr;
|
||||
if (newsize < 0)
|
||||
newsize = 0;
|
||||
if (u.u_tsize + newsize + u.u_ssize > MAXMEM) {
|
||||
u.u_error = ENOMEM;
|
||||
return;
|
||||
}
|
||||
|
||||
u.u_procp->p_dsize = newsize;
|
||||
u.u_procp->p_dsize = newsize;
|
||||
|
||||
/* set d to (new - old) */
|
||||
d = newsize - u.u_dsize;
|
||||
/* set d to (new - old) */
|
||||
d = newsize - u.u_dsize;
|
||||
//printf ("brk: new size %u bytes, incremented by %d\n", newsize, d);
|
||||
if (d > 0)
|
||||
bzero ((void*) (u.u_procp->p_daddr + u.u_dsize), d);
|
||||
u.u_dsize = newsize;
|
||||
u.u_rval = u.u_procp->p_daddr + u.u_dsize;
|
||||
if (d > 0)
|
||||
bzero ((void*) (u.u_procp->p_daddr + u.u_dsize), d);
|
||||
u.u_dsize = newsize;
|
||||
u.u_rval = u.u_procp->p_daddr + u.u_dsize;
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
*/
|
||||
int
|
||||
inferior(p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
for (; p != u.u_procp; p = p->p_pptr)
|
||||
if (p->p_ppid == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
for (; p != u.u_procp; p = p->p_pptr)
|
||||
if (p->p_ppid == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -26,14 +26,14 @@ inferior(p)
|
||||
*/
|
||||
struct proc *
|
||||
pfind (pid)
|
||||
register int pid;
|
||||
register int pid;
|
||||
{
|
||||
register struct proc *p = pidhash [PIDHASH(pid)];
|
||||
register struct proc *p = pidhash [PIDHASH(pid)];
|
||||
|
||||
for (; p; p = p->p_hash)
|
||||
if (p->p_pid == pid)
|
||||
return (p);
|
||||
return ((struct proc *)0);
|
||||
for (; p; p = p->p_hash)
|
||||
if (p->p_pid == pid)
|
||||
return (p);
|
||||
return ((struct proc *)0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -42,24 +42,24 @@ pfind (pid)
|
||||
void
|
||||
pqinit()
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
|
||||
/*
|
||||
* most procs are initially on freequeue
|
||||
* nb: we place them there in their "natural" order.
|
||||
*/
|
||||
/*
|
||||
* most procs are initially on freequeue
|
||||
* nb: we place them there in their "natural" order.
|
||||
*/
|
||||
|
||||
freeproc = NULL;
|
||||
for (p = proc+NPROC; --p > proc; freeproc = p)
|
||||
p->p_nxt = freeproc;
|
||||
freeproc = NULL;
|
||||
for (p = proc+NPROC; --p > proc; freeproc = p)
|
||||
p->p_nxt = freeproc;
|
||||
|
||||
/*
|
||||
* but proc[0] is special ...
|
||||
*/
|
||||
/*
|
||||
* but proc[0] is special ...
|
||||
*/
|
||||
|
||||
allproc = p;
|
||||
p->p_nxt = NULL;
|
||||
p->p_prev = &allproc;
|
||||
allproc = p;
|
||||
p->p_nxt = NULL;
|
||||
p->p_prev = &allproc;
|
||||
|
||||
zombproc = NULL;
|
||||
zombproc = NULL;
|
||||
}
|
||||
|
||||
@@ -13,55 +13,55 @@
|
||||
void
|
||||
getpid()
|
||||
{
|
||||
u.u_rval = u.u_procp->p_pid;
|
||||
u.u_rval = u.u_procp->p_pid;
|
||||
}
|
||||
|
||||
void
|
||||
getppid()
|
||||
{
|
||||
u.u_rval = u.u_procp->p_ppid;
|
||||
u.u_rval = u.u_procp->p_ppid;
|
||||
}
|
||||
|
||||
void
|
||||
getpgrp()
|
||||
{
|
||||
register struct a {
|
||||
int pid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int pid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
|
||||
if (uap->pid == 0) /* silly... */
|
||||
uap->pid = u.u_procp->p_pid;
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
u.u_rval = p->p_pgrp;
|
||||
if (uap->pid == 0) /* silly... */
|
||||
uap->pid = u.u_procp->p_pid;
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
u.u_rval = p->p_pgrp;
|
||||
}
|
||||
|
||||
void
|
||||
getuid()
|
||||
{
|
||||
u.u_rval = u.u_ruid;
|
||||
u.u_rval = u.u_ruid;
|
||||
}
|
||||
|
||||
void
|
||||
geteuid()
|
||||
{
|
||||
u.u_rval = u.u_uid;
|
||||
u.u_rval = u.u_uid;
|
||||
}
|
||||
|
||||
void
|
||||
getgid()
|
||||
{
|
||||
u.u_rval = u.u_rgid;
|
||||
u.u_rval = u.u_rgid;
|
||||
}
|
||||
|
||||
void
|
||||
getegid()
|
||||
{
|
||||
u.u_rval = u.u_groups[0];
|
||||
u.u_rval = u.u_groups[0];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -71,72 +71,72 @@ getegid()
|
||||
void
|
||||
getgroups()
|
||||
{
|
||||
register struct a {
|
||||
u_int gidsetsize;
|
||||
int *gidset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t *gp;
|
||||
register struct a {
|
||||
u_int gidsetsize;
|
||||
int *gidset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t *gp;
|
||||
|
||||
for (gp = &u.u_groups[NGROUPS]; gp > u.u_groups; gp--)
|
||||
if (gp[-1] != NOGROUP)
|
||||
break;
|
||||
if (uap->gidsetsize < gp - u.u_groups) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
uap->gidsetsize = gp - u.u_groups;
|
||||
u.u_error = copyout((caddr_t)u.u_groups, (caddr_t)uap->gidset,
|
||||
uap->gidsetsize * sizeof(u.u_groups[0]));
|
||||
if (u.u_error)
|
||||
return;
|
||||
u.u_rval = uap->gidsetsize;
|
||||
for (gp = &u.u_groups[NGROUPS]; gp > u.u_groups; gp--)
|
||||
if (gp[-1] != NOGROUP)
|
||||
break;
|
||||
if (uap->gidsetsize < gp - u.u_groups) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
uap->gidsetsize = gp - u.u_groups;
|
||||
u.u_error = copyout((caddr_t)u.u_groups, (caddr_t)uap->gidset,
|
||||
uap->gidsetsize * sizeof(u.u_groups[0]));
|
||||
if (u.u_error)
|
||||
return;
|
||||
u.u_rval = uap->gidsetsize;
|
||||
}
|
||||
|
||||
void
|
||||
setpgrp()
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int pid;
|
||||
int pgrp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int pid;
|
||||
int pgrp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
|
||||
if (uap->pid == 0) /* silly... */
|
||||
uap->pid = u.u_procp->p_pid;
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
/* need better control mechanisms for process groups */
|
||||
if (p->p_uid != u.u_uid && u.u_uid && !inferior(p)) {
|
||||
u.u_error = EPERM;
|
||||
return;
|
||||
}
|
||||
p->p_pgrp = uap->pgrp;
|
||||
if (uap->pid == 0) /* silly... */
|
||||
uap->pid = u.u_procp->p_pid;
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
/* need better control mechanisms for process groups */
|
||||
if (p->p_uid != u.u_uid && u.u_uid && !inferior(p)) {
|
||||
u.u_error = EPERM;
|
||||
return;
|
||||
}
|
||||
p->p_pgrp = uap->pgrp;
|
||||
}
|
||||
|
||||
void
|
||||
setgroups()
|
||||
{
|
||||
register struct a {
|
||||
u_int gidsetsize;
|
||||
int *gidset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t *gp;
|
||||
register struct a {
|
||||
u_int gidsetsize;
|
||||
int *gidset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t *gp;
|
||||
|
||||
if (!suser())
|
||||
return;
|
||||
if (uap->gidsetsize > sizeof (u.u_groups) / sizeof (u.u_groups[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
u.u_error = copyin((caddr_t)uap->gidset, (caddr_t)u.u_groups,
|
||||
uap->gidsetsize * sizeof (u.u_groups[0]));
|
||||
if (u.u_error)
|
||||
return;
|
||||
for (gp = &u.u_groups[uap->gidsetsize]; gp < &u.u_groups[NGROUPS]; gp++)
|
||||
*gp = NOGROUP;
|
||||
if (!suser())
|
||||
return;
|
||||
if (uap->gidsetsize > sizeof (u.u_groups) / sizeof (u.u_groups[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
u.u_error = copyin((caddr_t)uap->gidset, (caddr_t)u.u_groups,
|
||||
uap->gidsetsize * sizeof (u.u_groups[0]));
|
||||
if (u.u_error)
|
||||
return;
|
||||
for (gp = &u.u_groups[uap->gidsetsize]; gp < &u.u_groups[NGROUPS]; gp++)
|
||||
*gp = NOGROUP;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -144,12 +144,12 @@ setgroups()
|
||||
*/
|
||||
int
|
||||
groupmember(gid)
|
||||
gid_t gid;
|
||||
gid_t gid;
|
||||
{
|
||||
register gid_t *gp;
|
||||
register gid_t *gp;
|
||||
|
||||
for (gp = u.u_groups; gp < &u.u_groups[NGROUPS] && *gp != NOGROUP; gp++)
|
||||
if (*gp == gid)
|
||||
return (1);
|
||||
return (0);
|
||||
for (gp = u.u_groups; gp < &u.u_groups[NGROUPS] && *gp != NOGROUP; gp++)
|
||||
if (*gp == gid)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
@@ -17,8 +17,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -43,72 +43,72 @@
|
||||
void
|
||||
setuid()
|
||||
{
|
||||
struct a {
|
||||
uid_t uid;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
register uid_t uid;
|
||||
struct a {
|
||||
uid_t uid;
|
||||
} *uap = (struct a*) u.u_arg;
|
||||
register uid_t uid;
|
||||
|
||||
uid = uap->uid;
|
||||
if (uid != u.u_ruid && ! suser())
|
||||
return;
|
||||
/*
|
||||
* Everything's okay, do it.
|
||||
*/
|
||||
u.u_procp->p_uid = uid;
|
||||
u.u_uid = uid;
|
||||
u.u_ruid = uid;
|
||||
u.u_svuid = uid;
|
||||
u.u_error = 0;
|
||||
uid = uap->uid;
|
||||
if (uid != u.u_ruid && ! suser())
|
||||
return;
|
||||
/*
|
||||
* Everything's okay, do it.
|
||||
*/
|
||||
u.u_procp->p_uid = uid;
|
||||
u.u_uid = uid;
|
||||
u.u_ruid = uid;
|
||||
u.u_svuid = uid;
|
||||
u.u_error = 0;
|
||||
}
|
||||
|
||||
void
|
||||
seteuid()
|
||||
{
|
||||
struct a {
|
||||
uid_t euid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register uid_t euid;
|
||||
struct a {
|
||||
uid_t euid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register uid_t euid;
|
||||
|
||||
euid = uap->euid;
|
||||
if (euid != u.u_ruid && euid != u.u_svuid && ! suser())
|
||||
return;
|
||||
/*
|
||||
* Everything's okay, do it.
|
||||
*/
|
||||
u.u_uid = euid;
|
||||
u.u_error = 0;
|
||||
euid = uap->euid;
|
||||
if (euid != u.u_ruid && euid != u.u_svuid && ! suser())
|
||||
return;
|
||||
/*
|
||||
* Everything's okay, do it.
|
||||
*/
|
||||
u.u_uid = euid;
|
||||
u.u_error = 0;
|
||||
}
|
||||
|
||||
void
|
||||
setgid()
|
||||
{
|
||||
struct a {
|
||||
gid_t gid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t gid;
|
||||
struct a {
|
||||
gid_t gid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t gid;
|
||||
|
||||
gid = uap->gid;
|
||||
if (gid != u.u_rgid && ! suser())
|
||||
return;
|
||||
gid = uap->gid;
|
||||
if (gid != u.u_rgid && ! suser())
|
||||
return;
|
||||
|
||||
u.u_groups[0] = gid; /* effective gid is u_groups[0] */
|
||||
u.u_rgid = gid;
|
||||
u.u_svgid = gid;
|
||||
u.u_error = 0;
|
||||
u.u_groups[0] = gid; /* effective gid is u_groups[0] */
|
||||
u.u_rgid = gid;
|
||||
u.u_svgid = gid;
|
||||
u.u_error = 0;
|
||||
}
|
||||
|
||||
void
|
||||
setegid()
|
||||
{
|
||||
struct a {
|
||||
gid_t egid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t egid;
|
||||
struct a {
|
||||
gid_t egid;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register gid_t egid;
|
||||
|
||||
egid = uap->egid;
|
||||
if (egid != u.u_rgid && egid != u.u_svgid && ! suser())
|
||||
return;
|
||||
egid = uap->egid;
|
||||
if (egid != u.u_rgid && egid != u.u_svgid && ! suser())
|
||||
return;
|
||||
|
||||
u.u_groups[0] = egid;
|
||||
u.u_error = 0;
|
||||
u.u_groups[0] = egid;
|
||||
u.u_error = 0;
|
||||
}
|
||||
|
||||
@@ -16,214 +16,214 @@
|
||||
void
|
||||
getpriority()
|
||||
{
|
||||
register struct a {
|
||||
int which;
|
||||
int who;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register int low = PRIO_MAX + 1;
|
||||
register struct a {
|
||||
int which;
|
||||
int who;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register int low = PRIO_MAX + 1;
|
||||
|
||||
switch (uap->which) {
|
||||
case PRIO_PROCESS:
|
||||
if (uap->who == 0)
|
||||
p = u.u_procp;
|
||||
else
|
||||
p = pfind(uap->who);
|
||||
if (p == 0)
|
||||
break;
|
||||
low = p->p_nice;
|
||||
break;
|
||||
case PRIO_PGRP:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_procp->p_pgrp;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_pgrp == uap->who &&
|
||||
p->p_nice < low)
|
||||
low = p->p_nice;
|
||||
}
|
||||
break;
|
||||
case PRIO_USER:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_uid;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_uid == uap->who &&
|
||||
p->p_nice < low)
|
||||
low = p->p_nice;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (low == PRIO_MAX + 1) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
u.u_rval = low;
|
||||
switch (uap->which) {
|
||||
case PRIO_PROCESS:
|
||||
if (uap->who == 0)
|
||||
p = u.u_procp;
|
||||
else
|
||||
p = pfind(uap->who);
|
||||
if (p == 0)
|
||||
break;
|
||||
low = p->p_nice;
|
||||
break;
|
||||
case PRIO_PGRP:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_procp->p_pgrp;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_pgrp == uap->who &&
|
||||
p->p_nice < low)
|
||||
low = p->p_nice;
|
||||
}
|
||||
break;
|
||||
case PRIO_USER:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_uid;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_uid == uap->who &&
|
||||
p->p_nice < low)
|
||||
low = p->p_nice;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (low == PRIO_MAX + 1) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
u.u_rval = low;
|
||||
}
|
||||
|
||||
static void
|
||||
donice(p, n)
|
||||
register struct proc *p;
|
||||
register int n;
|
||||
register struct proc *p;
|
||||
register int n;
|
||||
{
|
||||
if (u.u_uid && u.u_ruid &&
|
||||
u.u_uid != p->p_uid && u.u_ruid != p->p_uid) {
|
||||
u.u_error = EPERM;
|
||||
return;
|
||||
}
|
||||
if (n > PRIO_MAX)
|
||||
n = PRIO_MAX;
|
||||
if (n < PRIO_MIN)
|
||||
n = PRIO_MIN;
|
||||
if (n < p->p_nice && !suser()) {
|
||||
u.u_error = EACCES;
|
||||
return;
|
||||
}
|
||||
p->p_nice = n;
|
||||
if (u.u_uid && u.u_ruid &&
|
||||
u.u_uid != p->p_uid && u.u_ruid != p->p_uid) {
|
||||
u.u_error = EPERM;
|
||||
return;
|
||||
}
|
||||
if (n > PRIO_MAX)
|
||||
n = PRIO_MAX;
|
||||
if (n < PRIO_MIN)
|
||||
n = PRIO_MIN;
|
||||
if (n < p->p_nice && !suser()) {
|
||||
u.u_error = EACCES;
|
||||
return;
|
||||
}
|
||||
p->p_nice = n;
|
||||
}
|
||||
|
||||
void
|
||||
setpriority()
|
||||
{
|
||||
register struct a {
|
||||
int which;
|
||||
int who;
|
||||
int prio;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register int found = 0;
|
||||
register struct a {
|
||||
int which;
|
||||
int who;
|
||||
int prio;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct proc *p;
|
||||
register int found = 0;
|
||||
|
||||
switch (uap->which) {
|
||||
case PRIO_PROCESS:
|
||||
if (uap->who == 0)
|
||||
p = u.u_procp;
|
||||
else
|
||||
p = pfind(uap->who);
|
||||
if (p == 0)
|
||||
break;
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
break;
|
||||
case PRIO_PGRP:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_procp->p_pgrp;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt)
|
||||
if (p->p_pgrp == uap->who) {
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
}
|
||||
break;
|
||||
case PRIO_USER:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_uid;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt)
|
||||
if (p->p_uid == uap->who) {
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (found == 0)
|
||||
u.u_error = ESRCH;
|
||||
switch (uap->which) {
|
||||
case PRIO_PROCESS:
|
||||
if (uap->who == 0)
|
||||
p = u.u_procp;
|
||||
else
|
||||
p = pfind(uap->who);
|
||||
if (p == 0)
|
||||
break;
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
break;
|
||||
case PRIO_PGRP:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_procp->p_pgrp;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt)
|
||||
if (p->p_pgrp == uap->who) {
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
}
|
||||
break;
|
||||
case PRIO_USER:
|
||||
if (uap->who == 0)
|
||||
uap->who = u.u_uid;
|
||||
for (p = allproc; p != NULL; p = p->p_nxt)
|
||||
if (p->p_uid == uap->who) {
|
||||
donice(p, uap->prio);
|
||||
found++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (found == 0)
|
||||
u.u_error = ESRCH;
|
||||
}
|
||||
|
||||
void
|
||||
setrlimit()
|
||||
{
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct rlimit *lim;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct rlimit alim;
|
||||
register struct rlimit *alimp;
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct rlimit *lim;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct rlimit alim;
|
||||
register struct rlimit *alimp;
|
||||
|
||||
if (uap->which >= RLIM_NLIMITS) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
alimp = &u.u_rlimit[uap->which];
|
||||
u.u_error = copyin((caddr_t)uap->lim, (caddr_t)&alim,
|
||||
sizeof (struct rlimit));
|
||||
if (u.u_error)
|
||||
return;
|
||||
if (uap->which == RLIMIT_CPU) {
|
||||
/*
|
||||
* 2.11 stores RLIMIT_CPU as ticks to keep from making
|
||||
* hardclock() do long multiplication/division.
|
||||
*/
|
||||
if (alim.rlim_cur >= RLIM_INFINITY / hz)
|
||||
alim.rlim_cur = RLIM_INFINITY;
|
||||
else
|
||||
alim.rlim_cur = alim.rlim_cur * hz;
|
||||
if (alim.rlim_max >= RLIM_INFINITY / hz)
|
||||
alim.rlim_max = RLIM_INFINITY;
|
||||
else
|
||||
alim.rlim_max = alim.rlim_max * hz;
|
||||
}
|
||||
if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max)
|
||||
if (!suser())
|
||||
return;
|
||||
*alimp = alim;
|
||||
if (uap->which >= RLIM_NLIMITS) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
alimp = &u.u_rlimit[uap->which];
|
||||
u.u_error = copyin((caddr_t)uap->lim, (caddr_t)&alim,
|
||||
sizeof (struct rlimit));
|
||||
if (u.u_error)
|
||||
return;
|
||||
if (uap->which == RLIMIT_CPU) {
|
||||
/*
|
||||
* 2.11 stores RLIMIT_CPU as ticks to keep from making
|
||||
* hardclock() do long multiplication/division.
|
||||
*/
|
||||
if (alim.rlim_cur >= RLIM_INFINITY / hz)
|
||||
alim.rlim_cur = RLIM_INFINITY;
|
||||
else
|
||||
alim.rlim_cur = alim.rlim_cur * hz;
|
||||
if (alim.rlim_max >= RLIM_INFINITY / hz)
|
||||
alim.rlim_max = RLIM_INFINITY;
|
||||
else
|
||||
alim.rlim_max = alim.rlim_max * hz;
|
||||
}
|
||||
if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max)
|
||||
if (!suser())
|
||||
return;
|
||||
*alimp = alim;
|
||||
}
|
||||
|
||||
void
|
||||
getrlimit()
|
||||
{
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct rlimit *rlp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct rlimit *rlp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
|
||||
if (uap->which >= RLIM_NLIMITS) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (uap->which == RLIMIT_CPU) {
|
||||
struct rlimit alim;
|
||||
if (uap->which >= RLIM_NLIMITS) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
if (uap->which == RLIMIT_CPU) {
|
||||
struct rlimit alim;
|
||||
|
||||
alim = u.u_rlimit[uap->which];
|
||||
if (alim.rlim_cur != RLIM_INFINITY)
|
||||
alim.rlim_cur = alim.rlim_cur / hz;
|
||||
if (alim.rlim_max != RLIM_INFINITY)
|
||||
alim.rlim_max = alim.rlim_max / hz;
|
||||
u.u_error = copyout((caddr_t)&alim,
|
||||
(caddr_t)uap->rlp,sizeof (struct rlimit));
|
||||
}
|
||||
else u.u_error = copyout((caddr_t)&u.u_rlimit[uap->which],
|
||||
(caddr_t)uap->rlp,sizeof (struct rlimit));
|
||||
alim = u.u_rlimit[uap->which];
|
||||
if (alim.rlim_cur != RLIM_INFINITY)
|
||||
alim.rlim_cur = alim.rlim_cur / hz;
|
||||
if (alim.rlim_max != RLIM_INFINITY)
|
||||
alim.rlim_max = alim.rlim_max / hz;
|
||||
u.u_error = copyout((caddr_t)&alim,
|
||||
(caddr_t)uap->rlp,sizeof (struct rlimit));
|
||||
}
|
||||
else u.u_error = copyout((caddr_t)&u.u_rlimit[uap->which],
|
||||
(caddr_t)uap->rlp,sizeof (struct rlimit));
|
||||
}
|
||||
|
||||
void
|
||||
getrusage()
|
||||
{
|
||||
register struct a {
|
||||
int who;
|
||||
struct rusage *rusage;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct k_rusage *rup;
|
||||
struct rusage ru;
|
||||
register struct a {
|
||||
int who;
|
||||
struct rusage *rusage;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register struct k_rusage *rup;
|
||||
struct rusage ru;
|
||||
|
||||
switch (uap->who) {
|
||||
switch (uap->who) {
|
||||
|
||||
case RUSAGE_SELF:
|
||||
rup = &u.u_ru;
|
||||
break;
|
||||
case RUSAGE_SELF:
|
||||
rup = &u.u_ru;
|
||||
break;
|
||||
|
||||
case RUSAGE_CHILDREN:
|
||||
rup = &u.u_cru;
|
||||
break;
|
||||
case RUSAGE_CHILDREN:
|
||||
rup = &u.u_cru;
|
||||
break;
|
||||
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
rucvt(&ru,rup);
|
||||
u.u_error = copyout((caddr_t)&ru, (caddr_t)uap->rusage,
|
||||
sizeof (struct rusage));
|
||||
default:
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
rucvt(&ru,rup);
|
||||
u.u_error = copyout((caddr_t)&ru, (caddr_t)uap->rusage,
|
||||
sizeof (struct rusage));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -231,19 +231,19 @@ getrusage()
|
||||
*/
|
||||
void
|
||||
ruadd(ru, ru2)
|
||||
struct k_rusage *ru, *ru2;
|
||||
struct k_rusage *ru, *ru2;
|
||||
{
|
||||
register long *ip, *ip2;
|
||||
register int i;
|
||||
register long *ip, *ip2;
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* since the kernel timeval structures are single longs,
|
||||
* fold them into the loop.
|
||||
*/
|
||||
ip = &ru->k_ru_first;
|
||||
ip2 = &ru2->k_ru_first;
|
||||
for (i = &ru->k_ru_last - &ru->k_ru_first; i >= 0; i--)
|
||||
*ip++ += *ip2++;
|
||||
/*
|
||||
* since the kernel timeval structures are single longs,
|
||||
* fold them into the loop.
|
||||
*/
|
||||
ip = &ru->k_ru_first;
|
||||
ip2 = &ru2->k_ru_first;
|
||||
for (i = &ru->k_ru_last - &ru->k_ru_first; i >= 0; i--)
|
||||
*ip++ += *ip2++;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -251,20 +251,20 @@ ruadd(ru, ru2)
|
||||
*/
|
||||
void
|
||||
rucvt (rup, krup)
|
||||
register struct rusage *rup;
|
||||
register struct k_rusage *krup;
|
||||
register struct rusage *rup;
|
||||
register struct k_rusage *krup;
|
||||
{
|
||||
bzero((caddr_t)rup, sizeof(*rup));
|
||||
rup->ru_utime.tv_sec = krup->ru_utime / hz;
|
||||
rup->ru_utime.tv_usec = (krup->ru_utime % hz) * usechz;
|
||||
rup->ru_stime.tv_sec = krup->ru_stime / hz;
|
||||
rup->ru_stime.tv_usec = (krup->ru_stime % hz) * usechz;
|
||||
rup->ru_nswap = krup->ru_nswap;
|
||||
rup->ru_inblock = krup->ru_inblock;
|
||||
rup->ru_oublock = krup->ru_oublock;
|
||||
rup->ru_msgsnd = krup->ru_msgsnd;
|
||||
rup->ru_msgrcv = krup->ru_msgrcv;
|
||||
rup->ru_nsignals = krup->ru_nsignals;
|
||||
rup->ru_nvcsw = krup->ru_nvcsw;
|
||||
rup->ru_nivcsw = krup->ru_nivcsw;
|
||||
bzero((caddr_t)rup, sizeof(*rup));
|
||||
rup->ru_utime.tv_sec = krup->ru_utime / hz;
|
||||
rup->ru_utime.tv_usec = (krup->ru_utime % hz) * usechz;
|
||||
rup->ru_stime.tv_sec = krup->ru_stime / hz;
|
||||
rup->ru_stime.tv_usec = (krup->ru_stime % hz) * usechz;
|
||||
rup->ru_nswap = krup->ru_nswap;
|
||||
rup->ru_inblock = krup->ru_inblock;
|
||||
rup->ru_oublock = krup->ru_oublock;
|
||||
rup->ru_msgsnd = krup->ru_msgsnd;
|
||||
rup->ru_msgrcv = krup->ru_msgrcv;
|
||||
rup->ru_nsignals = krup->ru_nsignals;
|
||||
rup->ru_nvcsw = krup->ru_nvcsw;
|
||||
rup->ru_nivcsw = krup->ru_nivcsw;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
@@ -17,8 +17,8 @@
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@@ -43,7 +43,7 @@
|
||||
* overlay structure. A smaller kern_sig2.c fits more easily into an overlaid
|
||||
* kernel.
|
||||
*/
|
||||
#define SIGPROP /* include signal properties table */
|
||||
#define SIGPROP /* include signal properties table */
|
||||
#include <sys/param.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/signalvar.h>
|
||||
@@ -54,109 +54,109 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/user.h> /* for coredump */
|
||||
#include <sys/user.h> /* for coredump */
|
||||
|
||||
static void
|
||||
setsigvec(signum, sa)
|
||||
int signum;
|
||||
register struct sigaction *sa;
|
||||
int signum;
|
||||
register struct sigaction *sa;
|
||||
{
|
||||
unsigned long bit;
|
||||
register struct proc *p = u.u_procp;
|
||||
unsigned long bit;
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
bit = sigmask(signum);
|
||||
/*
|
||||
* Change setting atomically.
|
||||
*/
|
||||
(void) splhigh();
|
||||
u.u_signal[signum] = sa->sa_handler;
|
||||
u.u_sigmask[signum] = sa->sa_mask &~ sigcantmask;
|
||||
if ((sa->sa_flags & SA_RESTART) == 0)
|
||||
u.u_sigintr |= bit;
|
||||
else
|
||||
u.u_sigintr &= ~bit;
|
||||
if (sa->sa_flags & SA_ONSTACK)
|
||||
u.u_sigonstack |= bit;
|
||||
else
|
||||
u.u_sigonstack &= ~bit;
|
||||
if (signum == SIGCHLD) {
|
||||
if (sa->sa_flags & SA_NOCLDSTOP)
|
||||
p->p_flag |= P_NOCLDSTOP;
|
||||
else
|
||||
p->p_flag &= ~P_NOCLDSTOP;
|
||||
}
|
||||
/*
|
||||
* Set bit in p_sigignore for signals that are set to SIG_IGN,
|
||||
* and for signals set to SIG_DFL where the default is to ignore.
|
||||
* However, don't put SIGCONT in p_sigignore,
|
||||
* as we have to restart the process.
|
||||
*/
|
||||
if (sa->sa_handler == SIG_IGN ||
|
||||
(sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
|
||||
p->p_sig &= ~bit; /* never to be seen again */
|
||||
if (signum != SIGCONT)
|
||||
p->p_sigignore |= bit; /* easier in psignal */
|
||||
p->p_sigcatch &= ~bit;
|
||||
} else {
|
||||
p->p_sigignore &= ~bit;
|
||||
if (sa->sa_handler == SIG_DFL)
|
||||
p->p_sigcatch &= ~bit;
|
||||
else
|
||||
p->p_sigcatch |= bit;
|
||||
}
|
||||
(void) spl0();
|
||||
bit = sigmask(signum);
|
||||
/*
|
||||
* Change setting atomically.
|
||||
*/
|
||||
(void) splhigh();
|
||||
u.u_signal[signum] = sa->sa_handler;
|
||||
u.u_sigmask[signum] = sa->sa_mask &~ sigcantmask;
|
||||
if ((sa->sa_flags & SA_RESTART) == 0)
|
||||
u.u_sigintr |= bit;
|
||||
else
|
||||
u.u_sigintr &= ~bit;
|
||||
if (sa->sa_flags & SA_ONSTACK)
|
||||
u.u_sigonstack |= bit;
|
||||
else
|
||||
u.u_sigonstack &= ~bit;
|
||||
if (signum == SIGCHLD) {
|
||||
if (sa->sa_flags & SA_NOCLDSTOP)
|
||||
p->p_flag |= P_NOCLDSTOP;
|
||||
else
|
||||
p->p_flag &= ~P_NOCLDSTOP;
|
||||
}
|
||||
/*
|
||||
* Set bit in p_sigignore for signals that are set to SIG_IGN,
|
||||
* and for signals set to SIG_DFL where the default is to ignore.
|
||||
* However, don't put SIGCONT in p_sigignore,
|
||||
* as we have to restart the process.
|
||||
*/
|
||||
if (sa->sa_handler == SIG_IGN ||
|
||||
(sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
|
||||
p->p_sig &= ~bit; /* never to be seen again */
|
||||
if (signum != SIGCONT)
|
||||
p->p_sigignore |= bit; /* easier in psignal */
|
||||
p->p_sigcatch &= ~bit;
|
||||
} else {
|
||||
p->p_sigignore &= ~bit;
|
||||
if (sa->sa_handler == SIG_DFL)
|
||||
p->p_sigcatch &= ~bit;
|
||||
else
|
||||
p->p_sigcatch |= bit;
|
||||
}
|
||||
(void) spl0();
|
||||
}
|
||||
|
||||
void
|
||||
sigaction()
|
||||
{
|
||||
register struct a {
|
||||
int signum;
|
||||
struct sigaction *nsa;
|
||||
struct sigaction *osa;
|
||||
u_int sigtramp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct sigaction vec;
|
||||
register struct sigaction *sa;
|
||||
register int signum;
|
||||
u_long bit;
|
||||
int error = 0;
|
||||
register struct a {
|
||||
int signum;
|
||||
struct sigaction *nsa;
|
||||
struct sigaction *osa;
|
||||
u_int sigtramp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct sigaction vec;
|
||||
register struct sigaction *sa;
|
||||
register int signum;
|
||||
u_long bit;
|
||||
int error = 0;
|
||||
|
||||
u.u_sigtramp = uap->sigtramp; /* save trampoline address */
|
||||
u.u_sigtramp = uap->sigtramp; /* save trampoline address */
|
||||
|
||||
signum = uap->signum;
|
||||
if (signum <= 0 || signum >= NSIG) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (uap->nsa && (signum == SIGKILL || signum == SIGSTOP)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
sa = &vec;
|
||||
if (uap->osa) {
|
||||
sa->sa_handler = u.u_signal[signum];
|
||||
sa->sa_mask = u.u_sigmask[signum];
|
||||
bit = sigmask(signum);
|
||||
sa->sa_flags = 0;
|
||||
if ((u.u_sigonstack & bit) != 0)
|
||||
sa->sa_flags |= SA_ONSTACK;
|
||||
if ((u.u_sigintr & bit) == 0)
|
||||
sa->sa_flags |= SA_RESTART;
|
||||
if (u.u_procp->p_flag & P_NOCLDSTOP)
|
||||
sa->sa_flags |= SA_NOCLDSTOP;
|
||||
error = copyout ((caddr_t) sa, (caddr_t) uap->osa, sizeof(vec));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
}
|
||||
if (uap->nsa) {
|
||||
error = copyin ((caddr_t) uap->nsa, (caddr_t) sa, sizeof(vec));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
setsigvec(signum, sa);
|
||||
}
|
||||
signum = uap->signum;
|
||||
if (signum <= 0 || signum >= NSIG) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (uap->nsa && (signum == SIGKILL || signum == SIGSTOP)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
sa = &vec;
|
||||
if (uap->osa) {
|
||||
sa->sa_handler = u.u_signal[signum];
|
||||
sa->sa_mask = u.u_sigmask[signum];
|
||||
bit = sigmask(signum);
|
||||
sa->sa_flags = 0;
|
||||
if ((u.u_sigonstack & bit) != 0)
|
||||
sa->sa_flags |= SA_ONSTACK;
|
||||
if ((u.u_sigintr & bit) == 0)
|
||||
sa->sa_flags |= SA_RESTART;
|
||||
if (u.u_procp->p_flag & P_NOCLDSTOP)
|
||||
sa->sa_flags |= SA_NOCLDSTOP;
|
||||
error = copyout ((caddr_t) sa, (caddr_t) uap->osa, sizeof(vec));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
}
|
||||
if (uap->nsa) {
|
||||
error = copyin ((caddr_t) uap->nsa, (caddr_t) sa, sizeof(vec));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
setsigvec(signum, sa);
|
||||
}
|
||||
out:
|
||||
u.u_error = error;
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -166,17 +166,17 @@ out:
|
||||
*/
|
||||
void
|
||||
fatalsig(signum)
|
||||
int signum;
|
||||
int signum;
|
||||
{
|
||||
unsigned long mask;
|
||||
register struct proc *p = u.u_procp;
|
||||
unsigned long mask;
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
u.u_signal[signum] = SIG_DFL;
|
||||
mask = sigmask(signum);
|
||||
p->p_sigignore &= ~mask;
|
||||
p->p_sigcatch &= ~mask;
|
||||
p->p_sigmask &= ~mask;
|
||||
psignal(p, signum);
|
||||
u.u_signal[signum] = SIG_DFL;
|
||||
mask = sigmask(signum);
|
||||
p->p_sigignore &= ~mask;
|
||||
p->p_sigcatch &= ~mask;
|
||||
p->p_sigmask &= ~mask;
|
||||
psignal(p, signum);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -185,13 +185,13 @@ fatalsig(signum)
|
||||
*/
|
||||
void
|
||||
siginit(p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register int i;
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < NSIG; i++)
|
||||
if (sigprop[i] & SA_IGNORE && i != SIGCONT)
|
||||
p->p_sigignore |= sigmask(i);
|
||||
for (i = 0; i < NSIG; i++)
|
||||
if (sigprop[i] & SA_IGNORE && i != SIGCONT)
|
||||
p->p_sigignore |= sigmask(i);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -205,42 +205,42 @@ siginit(p)
|
||||
void
|
||||
sigprocmask()
|
||||
{
|
||||
register struct a {
|
||||
int how;
|
||||
sigset_t *set;
|
||||
sigset_t *oset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
int error = 0;
|
||||
sigset_t oldmask, newmask;
|
||||
register struct proc *p = u.u_procp;
|
||||
register struct a {
|
||||
int how;
|
||||
sigset_t *set;
|
||||
sigset_t *oset;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
int error = 0;
|
||||
sigset_t oldmask, newmask;
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
oldmask = p->p_sigmask;
|
||||
if (! uap->set) /* No new mask, go possibly return old mask */
|
||||
goto out;
|
||||
error = copyin ((caddr_t) uap->set, (caddr_t) &newmask, sizeof (newmask));
|
||||
if (error)
|
||||
goto out;
|
||||
(void) splhigh();
|
||||
oldmask = p->p_sigmask;
|
||||
if (! uap->set) /* No new mask, go possibly return old mask */
|
||||
goto out;
|
||||
error = copyin ((caddr_t) uap->set, (caddr_t) &newmask, sizeof (newmask));
|
||||
if (error)
|
||||
goto out;
|
||||
(void) splhigh();
|
||||
|
||||
switch (uap->how) {
|
||||
case SIG_BLOCK:
|
||||
p->p_sigmask |= (newmask &~ sigcantmask);
|
||||
break;
|
||||
case SIG_UNBLOCK:
|
||||
p->p_sigmask &= ~newmask;
|
||||
break;
|
||||
case SIG_SETMASK:
|
||||
p->p_sigmask = newmask &~ sigcantmask;
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
(void) spl0();
|
||||
switch (uap->how) {
|
||||
case SIG_BLOCK:
|
||||
p->p_sigmask |= (newmask &~ sigcantmask);
|
||||
break;
|
||||
case SIG_UNBLOCK:
|
||||
p->p_sigmask &= ~newmask;
|
||||
break;
|
||||
case SIG_SETMASK:
|
||||
p->p_sigmask = newmask &~ sigcantmask;
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
(void) spl0();
|
||||
out:
|
||||
if (error == 0 && uap->oset)
|
||||
error = copyout ((caddr_t) &oldmask, (caddr_t) uap->oset, sizeof (oldmask));
|
||||
u.u_error = error;
|
||||
if (error == 0 && uap->oset)
|
||||
error = copyout ((caddr_t) &oldmask, (caddr_t) uap->oset, sizeof (oldmask));
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -250,18 +250,18 @@ out:
|
||||
void
|
||||
sigpending()
|
||||
{
|
||||
register struct a {
|
||||
struct sigset_t *set;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register int error = 0;
|
||||
struct proc *p = u.u_procp;
|
||||
register struct a {
|
||||
struct sigset_t *set;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
register int error = 0;
|
||||
struct proc *p = u.u_procp;
|
||||
|
||||
if (uap->set)
|
||||
error = copyout((caddr_t)&p->p_sig, (caddr_t)uap->set,
|
||||
sizeof (p->p_sig));
|
||||
else
|
||||
error = EINVAL;
|
||||
u.u_error = error;
|
||||
if (uap->set)
|
||||
error = copyout((caddr_t)&p->p_sig, (caddr_t)uap->set,
|
||||
sizeof (p->p_sig));
|
||||
else
|
||||
error = EINVAL;
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -271,101 +271,101 @@ sigpending()
|
||||
void
|
||||
sigsuspend()
|
||||
{
|
||||
register struct a {
|
||||
struct sigset_t *set;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
sigset_t nmask = 0;
|
||||
struct proc *p = u.u_procp;
|
||||
int error;
|
||||
register struct a {
|
||||
struct sigset_t *set;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
sigset_t nmask = 0;
|
||||
struct proc *p = u.u_procp;
|
||||
int error;
|
||||
|
||||
if (uap->set && (error = copyin ((caddr_t) uap->set, (caddr_t) &nmask, sizeof (nmask))))
|
||||
nmask = 0;
|
||||
/*
|
||||
* When returning from sigsuspend, we want the old mask to be restored
|
||||
* after the signal handler has finished. Thus, we save it here and set
|
||||
* a flag to indicate this.
|
||||
*/
|
||||
u.u_oldmask = p->p_sigmask;
|
||||
u.u_psflags |= SAS_OLDMASK;
|
||||
p->p_sigmask = nmask &~ sigcantmask;
|
||||
while (tsleep((caddr_t)&u, PPAUSE|PCATCH, 0) == 0)
|
||||
;
|
||||
/* always return EINTR rather than ERESTART */
|
||||
u.u_error = EINTR;
|
||||
if (uap->set && (error = copyin ((caddr_t) uap->set, (caddr_t) &nmask, sizeof (nmask))))
|
||||
nmask = 0;
|
||||
/*
|
||||
* When returning from sigsuspend, we want the old mask to be restored
|
||||
* after the signal handler has finished. Thus, we save it here and set
|
||||
* a flag to indicate this.
|
||||
*/
|
||||
u.u_oldmask = p->p_sigmask;
|
||||
u.u_psflags |= SAS_OLDMASK;
|
||||
p->p_sigmask = nmask &~ sigcantmask;
|
||||
while (tsleep((caddr_t)&u, PPAUSE|PCATCH, 0) == 0)
|
||||
;
|
||||
/* always return EINTR rather than ERESTART */
|
||||
u.u_error = EINTR;
|
||||
}
|
||||
|
||||
void
|
||||
sigaltstack()
|
||||
{
|
||||
register struct a {
|
||||
struct sigaltstack * nss;
|
||||
struct sigaltstack * oss;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct sigaltstack ss;
|
||||
int error = 0;
|
||||
register struct a {
|
||||
struct sigaltstack * nss;
|
||||
struct sigaltstack * oss;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct sigaltstack ss;
|
||||
int error = 0;
|
||||
|
||||
if ((u.u_psflags & SAS_ALTSTACK) == 0)
|
||||
u.u_sigstk.ss_flags |= SA_DISABLE;
|
||||
if (uap->oss && (error = copyout((caddr_t)&u.u_sigstk,
|
||||
(caddr_t)uap->oss, sizeof (struct sigaltstack))))
|
||||
goto out;
|
||||
if (uap->nss == 0)
|
||||
goto out;
|
||||
error = copyin ((caddr_t) uap->nss, (caddr_t) &ss, sizeof(ss));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
if (ss.ss_flags & SA_DISABLE) {
|
||||
if (u.u_sigstk.ss_flags & SA_ONSTACK)
|
||||
{
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
u.u_psflags &= ~SAS_ALTSTACK;
|
||||
u.u_sigstk.ss_flags = ss.ss_flags;
|
||||
goto out;
|
||||
}
|
||||
if (ss.ss_size < MINSIGSTKSZ)
|
||||
{
|
||||
error = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
u.u_psflags |= SAS_ALTSTACK;
|
||||
u.u_sigstk = ss;
|
||||
if ((u.u_psflags & SAS_ALTSTACK) == 0)
|
||||
u.u_sigstk.ss_flags |= SA_DISABLE;
|
||||
if (uap->oss && (error = copyout((caddr_t)&u.u_sigstk,
|
||||
(caddr_t)uap->oss, sizeof (struct sigaltstack))))
|
||||
goto out;
|
||||
if (uap->nss == 0)
|
||||
goto out;
|
||||
error = copyin ((caddr_t) uap->nss, (caddr_t) &ss, sizeof(ss));
|
||||
if (error != 0)
|
||||
goto out;
|
||||
if (ss.ss_flags & SA_DISABLE) {
|
||||
if (u.u_sigstk.ss_flags & SA_ONSTACK)
|
||||
{
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
u.u_psflags &= ~SAS_ALTSTACK;
|
||||
u.u_sigstk.ss_flags = ss.ss_flags;
|
||||
goto out;
|
||||
}
|
||||
if (ss.ss_size < MINSIGSTKSZ)
|
||||
{
|
||||
error = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
u.u_psflags |= SAS_ALTSTACK;
|
||||
u.u_sigstk = ss;
|
||||
out:
|
||||
u.u_error = error;
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
void
|
||||
sigwait()
|
||||
{
|
||||
register struct a {
|
||||
sigset_t *set;
|
||||
int *sig;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
sigset_t wanted, sigsavail;
|
||||
register struct proc *p = u.u_procp;
|
||||
int signo, error;
|
||||
register struct a {
|
||||
sigset_t *set;
|
||||
int *sig;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
sigset_t wanted, sigsavail;
|
||||
register struct proc *p = u.u_procp;
|
||||
int signo, error;
|
||||
|
||||
if (uap->set == 0 || uap->sig == 0) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
error = copyin ((caddr_t) uap->set, (caddr_t) &wanted, sizeof (sigset_t));
|
||||
if (error)
|
||||
goto out;
|
||||
if (uap->set == 0 || uap->sig == 0) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
error = copyin ((caddr_t) uap->set, (caddr_t) &wanted, sizeof (sigset_t));
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
wanted |= sigcantmask;
|
||||
while ((sigsavail = (wanted & p->p_sig)) == 0)
|
||||
tsleep ((caddr_t) &u.u_signal[0], PPAUSE | PCATCH, 0);
|
||||
wanted |= sigcantmask;
|
||||
while ((sigsavail = (wanted & p->p_sig)) == 0)
|
||||
tsleep ((caddr_t) &u.u_signal[0], PPAUSE | PCATCH, 0);
|
||||
|
||||
if (sigsavail & sigcantmask) {
|
||||
error = EINTR;
|
||||
goto out;
|
||||
}
|
||||
if (sigsavail & sigcantmask) {
|
||||
error = EINTR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
signo = ffs(sigsavail);
|
||||
p->p_sig &= ~sigmask(signo);
|
||||
error = copyout ((caddr_t) &signo, (caddr_t) uap->sig, sizeof (int));
|
||||
signo = ffs(sigsavail);
|
||||
p->p_sig &= ~sigmask(signo);
|
||||
error = copyout ((caddr_t) &signo, (caddr_t) uap->sig, sizeof (int));
|
||||
out:
|
||||
u.u_error = error;
|
||||
u.u_error = error;
|
||||
}
|
||||
|
||||
@@ -14,36 +14,36 @@
|
||||
*/
|
||||
int
|
||||
uiomove (cp, n, uio)
|
||||
caddr_t cp;
|
||||
u_int n;
|
||||
register struct uio *uio;
|
||||
caddr_t cp;
|
||||
u_int n;
|
||||
register struct uio *uio;
|
||||
{
|
||||
register struct iovec *iov;
|
||||
int error = 0;
|
||||
register u_int cnt;
|
||||
register struct iovec *iov;
|
||||
int error = 0;
|
||||
register u_int cnt;
|
||||
|
||||
while (n > 0 && uio->uio_resid) {
|
||||
iov = uio->uio_iov;
|
||||
cnt = iov->iov_len;
|
||||
if (cnt == 0) {
|
||||
uio->uio_iov++;
|
||||
uio->uio_iovcnt--;
|
||||
continue;
|
||||
}
|
||||
if (cnt > n)
|
||||
cnt = n;
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
bcopy ((caddr_t) cp, iov->iov_base, cnt);
|
||||
else
|
||||
bcopy (iov->iov_base, (caddr_t) cp, cnt);
|
||||
iov->iov_base += cnt;
|
||||
iov->iov_len -= cnt;
|
||||
uio->uio_resid -= cnt;
|
||||
uio->uio_offset += cnt;
|
||||
cp += cnt;
|
||||
n -= cnt;
|
||||
}
|
||||
return (error);
|
||||
while (n > 0 && uio->uio_resid) {
|
||||
iov = uio->uio_iov;
|
||||
cnt = iov->iov_len;
|
||||
if (cnt == 0) {
|
||||
uio->uio_iov++;
|
||||
uio->uio_iovcnt--;
|
||||
continue;
|
||||
}
|
||||
if (cnt > n)
|
||||
cnt = n;
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
bcopy ((caddr_t) cp, iov->iov_base, cnt);
|
||||
else
|
||||
bcopy (iov->iov_base, (caddr_t) cp, cnt);
|
||||
iov->iov_base += cnt;
|
||||
iov->iov_len -= cnt;
|
||||
uio->uio_resid -= cnt;
|
||||
uio->uio_offset += cnt;
|
||||
cp += cnt;
|
||||
n -= cnt;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -51,27 +51,27 @@ uiomove (cp, n, uio)
|
||||
*/
|
||||
int
|
||||
ureadc (c, uio)
|
||||
register int c;
|
||||
register struct uio *uio;
|
||||
register int c;
|
||||
register struct uio *uio;
|
||||
{
|
||||
register struct iovec *iov;
|
||||
register struct iovec *iov;
|
||||
|
||||
again:
|
||||
if (uio->uio_iovcnt == 0)
|
||||
panic("ureadc");
|
||||
iov = uio->uio_iov;
|
||||
if (iov->iov_len == 0 || uio->uio_resid == 0) {
|
||||
uio->uio_iovcnt--;
|
||||
uio->uio_iov++;
|
||||
goto again;
|
||||
}
|
||||
*iov->iov_base = c;
|
||||
if (uio->uio_iovcnt == 0)
|
||||
panic("ureadc");
|
||||
iov = uio->uio_iov;
|
||||
if (iov->iov_len == 0 || uio->uio_resid == 0) {
|
||||
uio->uio_iovcnt--;
|
||||
uio->uio_iov++;
|
||||
goto again;
|
||||
}
|
||||
*iov->iov_base = c;
|
||||
|
||||
iov->iov_base++;
|
||||
iov->iov_len--;
|
||||
uio->uio_resid--;
|
||||
uio->uio_offset++;
|
||||
return (0);
|
||||
iov->iov_base++;
|
||||
iov->iov_len--;
|
||||
uio->uio_resid--;
|
||||
uio->uio_offset++;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -79,30 +79,30 @@ again:
|
||||
*/
|
||||
int
|
||||
uwritec(uio)
|
||||
register struct uio *uio;
|
||||
register struct uio *uio;
|
||||
{
|
||||
register struct iovec *iov;
|
||||
register int c;
|
||||
register struct iovec *iov;
|
||||
register int c;
|
||||
|
||||
if (uio->uio_resid == 0)
|
||||
return (-1);
|
||||
if (uio->uio_resid == 0)
|
||||
return (-1);
|
||||
again:
|
||||
if (uio->uio_iovcnt <= 0)
|
||||
panic("uwritec");
|
||||
iov = uio->uio_iov;
|
||||
if (iov->iov_len == 0) {
|
||||
uio->uio_iov++;
|
||||
if (--uio->uio_iovcnt == 0)
|
||||
return (-1);
|
||||
goto again;
|
||||
}
|
||||
c = (u_char) *iov->iov_base;
|
||||
if (uio->uio_iovcnt <= 0)
|
||||
panic("uwritec");
|
||||
iov = uio->uio_iov;
|
||||
if (iov->iov_len == 0) {
|
||||
uio->uio_iov++;
|
||||
if (--uio->uio_iovcnt == 0)
|
||||
return (-1);
|
||||
goto again;
|
||||
}
|
||||
c = (u_char) *iov->iov_base;
|
||||
|
||||
iov->iov_base++;
|
||||
iov->iov_len--;
|
||||
uio->uio_resid--;
|
||||
uio->uio_offset++;
|
||||
return (c & 0377);
|
||||
iov->iov_base++;
|
||||
iov->iov_len--;
|
||||
uio->uio_resid--;
|
||||
uio->uio_offset++;
|
||||
return (c & 0377);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -110,17 +110,17 @@ again:
|
||||
*/
|
||||
int
|
||||
uiofmove(cp, n, uio, iov)
|
||||
caddr_t cp;
|
||||
register int n;
|
||||
struct uio *uio;
|
||||
struct iovec *iov;
|
||||
caddr_t cp;
|
||||
register int n;
|
||||
struct uio *uio;
|
||||
struct iovec *iov;
|
||||
{
|
||||
if (uio->uio_rw == UIO_READ) {
|
||||
/* From kernel to user. */
|
||||
bcopy(cp, iov->iov_base, n);
|
||||
} else {
|
||||
/* From user to kernel. */
|
||||
bcopy(iov->iov_base, cp, n);
|
||||
}
|
||||
return(0);
|
||||
if (uio->uio_rw == UIO_READ) {
|
||||
/* From kernel to user. */
|
||||
bcopy(cp, iov->iov_base, n);
|
||||
} else {
|
||||
/* From user to kernel. */
|
||||
bcopy(iov->iov_base, cp, n);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
#include "kernel.h"
|
||||
#include "systm.h"
|
||||
|
||||
#define SQSIZE 16 /* Must be power of 2 */
|
||||
#define SQSIZE 16 /* Must be power of 2 */
|
||||
|
||||
#define HASH(x) (((int)x >> 5) & (SQSIZE - 1))
|
||||
#define SCHMAG 8/10
|
||||
#define HASH(x) (((int)x >> 5) & (SQSIZE - 1))
|
||||
#define SCHMAG 8/10
|
||||
|
||||
struct proc *slpque[SQSIZE];
|
||||
struct proc *slpque[SQSIZE];
|
||||
|
||||
int runrun; /* scheduling flag */
|
||||
char curpri; /* more scheduling */
|
||||
int runrun; /* scheduling flag */
|
||||
char curpri; /* more scheduling */
|
||||
|
||||
/*
|
||||
* Recompute process priorities, once a second
|
||||
@@ -29,46 +29,46 @@ char curpri; /* more scheduling */
|
||||
void
|
||||
schedcpu (caddr_t arg)
|
||||
{
|
||||
register struct proc *p;
|
||||
register int a;
|
||||
register struct proc *p;
|
||||
register int a;
|
||||
|
||||
wakeup((caddr_t)&lbolt);
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_time != 127)
|
||||
p->p_time++;
|
||||
/*
|
||||
* this is where 2.11 does its real time alarms. 4.X uses
|
||||
* timeouts, since it offers better than second resolution.
|
||||
* Putting it here allows us to continue using use an int
|
||||
* to store the number of ticks in the callout structure,
|
||||
* since the kernel never has a timeout of greater than
|
||||
* around 9 minutes.
|
||||
*/
|
||||
if (p->p_realtimer.it_value && !--p->p_realtimer.it_value) {
|
||||
psignal(p, SIGALRM);
|
||||
p->p_realtimer.it_value = p->p_realtimer.it_interval;
|
||||
}
|
||||
if (p->p_stat == SSLEEP || p->p_stat == SSTOP)
|
||||
if (p->p_slptime != 127)
|
||||
p->p_slptime++;
|
||||
if (p->p_slptime > 1)
|
||||
continue;
|
||||
a = (p->p_cpu & 0377) * SCHMAG + p->p_nice;
|
||||
if (a < 0)
|
||||
a = 0;
|
||||
if (a > 255)
|
||||
a = 255;
|
||||
p->p_cpu = a;
|
||||
if (p->p_pri >= PUSER)
|
||||
setpri(p);
|
||||
}
|
||||
vmmeter();
|
||||
if (runin != 0) {
|
||||
runin = 0;
|
||||
wakeup((caddr_t)&runin);
|
||||
}
|
||||
++runrun; /* swtch at least once a second */
|
||||
timeout (schedcpu, (caddr_t) 0, hz);
|
||||
wakeup((caddr_t)&lbolt);
|
||||
for (p = allproc; p != NULL; p = p->p_nxt) {
|
||||
if (p->p_time != 127)
|
||||
p->p_time++;
|
||||
/*
|
||||
* this is where 2.11 does its real time alarms. 4.X uses
|
||||
* timeouts, since it offers better than second resolution.
|
||||
* Putting it here allows us to continue using use an int
|
||||
* to store the number of ticks in the callout structure,
|
||||
* since the kernel never has a timeout of greater than
|
||||
* around 9 minutes.
|
||||
*/
|
||||
if (p->p_realtimer.it_value && !--p->p_realtimer.it_value) {
|
||||
psignal(p, SIGALRM);
|
||||
p->p_realtimer.it_value = p->p_realtimer.it_interval;
|
||||
}
|
||||
if (p->p_stat == SSLEEP || p->p_stat == SSTOP)
|
||||
if (p->p_slptime != 127)
|
||||
p->p_slptime++;
|
||||
if (p->p_slptime > 1)
|
||||
continue;
|
||||
a = (p->p_cpu & 0377) * SCHMAG + p->p_nice;
|
||||
if (a < 0)
|
||||
a = 0;
|
||||
if (a > 255)
|
||||
a = 255;
|
||||
p->p_cpu = a;
|
||||
if (p->p_pri >= PUSER)
|
||||
setpri(p);
|
||||
}
|
||||
vmmeter();
|
||||
if (runin != 0) {
|
||||
runin = 0;
|
||||
wakeup((caddr_t)&runin);
|
||||
}
|
||||
++runrun; /* swtch at least once a second */
|
||||
timeout (schedcpu, (caddr_t) 0, hz);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -76,19 +76,19 @@ schedcpu (caddr_t arg)
|
||||
*/
|
||||
void
|
||||
updatepri(p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register int a = p->p_cpu & 0377;
|
||||
register int a = p->p_cpu & 0377;
|
||||
|
||||
p->p_slptime--; /* the first time was done in schedcpu */
|
||||
while (a && --p->p_slptime)
|
||||
a = (SCHMAG * a) /* + p->p_nice */;
|
||||
if (a < 0)
|
||||
a = 0;
|
||||
if (a > 255)
|
||||
a = 255;
|
||||
p->p_cpu = a;
|
||||
(void) setpri(p);
|
||||
p->p_slptime--; /* the first time was done in schedcpu */
|
||||
while (a && --p->p_slptime)
|
||||
a = (SCHMAG * a) /* + p->p_nice */;
|
||||
if (a < 0)
|
||||
a = 0;
|
||||
if (a > 255)
|
||||
a = 255;
|
||||
p->p_cpu = a;
|
||||
(void) setpri(p);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -98,19 +98,19 @@ updatepri(p)
|
||||
*/
|
||||
static void
|
||||
endtsleep (p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register int s;
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
if (p->p_wchan) {
|
||||
if (p->p_stat == SSLEEP)
|
||||
setrun(p);
|
||||
else
|
||||
unsleep(p);
|
||||
p->p_flag |= P_TIMEOUT;
|
||||
}
|
||||
splx(s);
|
||||
s = splhigh();
|
||||
if (p->p_wchan) {
|
||||
if (p->p_stat == SSLEEP)
|
||||
setrun(p);
|
||||
else
|
||||
unsleep(p);
|
||||
p->p_flag |= P_TIMEOUT;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -128,85 +128,85 @@ endtsleep (p)
|
||||
*/
|
||||
int
|
||||
tsleep (ident, priority, timo)
|
||||
caddr_t ident;
|
||||
int priority;
|
||||
u_int timo;
|
||||
caddr_t ident;
|
||||
int priority;
|
||||
u_int timo;
|
||||
{
|
||||
register struct proc *p = u.u_procp;
|
||||
register struct proc **qp;
|
||||
int s;
|
||||
int sig, catch = priority & PCATCH;
|
||||
register struct proc *p = u.u_procp;
|
||||
register struct proc **qp;
|
||||
int s;
|
||||
int sig, catch = priority & PCATCH;
|
||||
|
||||
s = splhigh();
|
||||
if (panicstr) {
|
||||
/*
|
||||
* After a panic just give interrupts a chance then just return. Don't
|
||||
* run any other procs (or panic again below) in case this is the idle
|
||||
* process and already asleep. The splnet should be spl0 if the network
|
||||
* was being used but for now avoid network interrupts that might cause
|
||||
* another panic.
|
||||
*/
|
||||
(void) splnet();
|
||||
noop();
|
||||
splx(s);
|
||||
return(0);
|
||||
}
|
||||
#ifdef DIAGNOSTIC
|
||||
if (ident == NULL || p->p_stat != SRUN)
|
||||
panic("tsleep");
|
||||
s = splhigh();
|
||||
if (panicstr) {
|
||||
/*
|
||||
* After a panic just give interrupts a chance then just return. Don't
|
||||
* run any other procs (or panic again below) in case this is the idle
|
||||
* process and already asleep. The splnet should be spl0 if the network
|
||||
* was being used but for now avoid network interrupts that might cause
|
||||
* another panic.
|
||||
*/
|
||||
(void) splnet();
|
||||
noop();
|
||||
splx(s);
|
||||
return(0);
|
||||
}
|
||||
#ifdef DIAGNOSTIC
|
||||
if (ident == NULL || p->p_stat != SRUN)
|
||||
panic("tsleep");
|
||||
#endif
|
||||
p->p_wchan = ident;
|
||||
p->p_slptime = 0;
|
||||
p->p_pri = priority & PRIMASK;
|
||||
qp = &slpque[HASH(ident)];
|
||||
p->p_link = *qp;
|
||||
*qp = p;
|
||||
if (timo)
|
||||
timeout (endtsleep, (caddr_t)p, timo);
|
||||
/*
|
||||
* We put outselves on the sleep queue and start the timeout before calling
|
||||
* CURSIG as we could stop there and a wakeup or a SIGCONT (or both) could
|
||||
* occur while we were stopped. A SIGCONT would cause us to be marked SSLEEP
|
||||
* without resuming us thus we must be ready for sleep when CURSIG is called.
|
||||
* If the wakeup happens while we're stopped p->p_wchan will be 0 upon
|
||||
* return from CURSIG.
|
||||
*/
|
||||
if (catch) {
|
||||
p->p_flag |= P_SINTR;
|
||||
sig = CURSIG(p);
|
||||
if (sig) {
|
||||
if (p->p_wchan)
|
||||
unsleep(p);
|
||||
p->p_stat = SRUN;
|
||||
goto resume;
|
||||
}
|
||||
if (p->p_wchan == 0) {
|
||||
catch = 0;
|
||||
goto resume;
|
||||
}
|
||||
} else
|
||||
sig = 0;
|
||||
p->p_wchan = ident;
|
||||
p->p_slptime = 0;
|
||||
p->p_pri = priority & PRIMASK;
|
||||
qp = &slpque[HASH(ident)];
|
||||
p->p_link = *qp;
|
||||
*qp = p;
|
||||
if (timo)
|
||||
timeout (endtsleep, (caddr_t)p, timo);
|
||||
/*
|
||||
* We put outselves on the sleep queue and start the timeout before calling
|
||||
* CURSIG as we could stop there and a wakeup or a SIGCONT (or both) could
|
||||
* occur while we were stopped. A SIGCONT would cause us to be marked SSLEEP
|
||||
* without resuming us thus we must be ready for sleep when CURSIG is called.
|
||||
* If the wakeup happens while we're stopped p->p_wchan will be 0 upon
|
||||
* return from CURSIG.
|
||||
*/
|
||||
if (catch) {
|
||||
p->p_flag |= P_SINTR;
|
||||
sig = CURSIG(p);
|
||||
if (sig) {
|
||||
if (p->p_wchan)
|
||||
unsleep(p);
|
||||
p->p_stat = SRUN;
|
||||
goto resume;
|
||||
}
|
||||
if (p->p_wchan == 0) {
|
||||
catch = 0;
|
||||
goto resume;
|
||||
}
|
||||
} else
|
||||
sig = 0;
|
||||
|
||||
p->p_stat = SSLEEP;
|
||||
if (p != &proc[0])
|
||||
wakeup((caddr_t) &runin);
|
||||
u.u_ru.ru_nvcsw++;
|
||||
swtch();
|
||||
p->p_stat = SSLEEP;
|
||||
if (p != &proc[0])
|
||||
wakeup((caddr_t) &runin);
|
||||
u.u_ru.ru_nvcsw++;
|
||||
swtch();
|
||||
resume:
|
||||
splx(s);
|
||||
p->p_flag &= ~P_SINTR;
|
||||
if (p->p_flag & P_TIMEOUT) {
|
||||
p->p_flag &= ~P_TIMEOUT;
|
||||
if (sig == 0)
|
||||
return(EWOULDBLOCK);
|
||||
} else if (timo)
|
||||
untimeout (endtsleep, (caddr_t)p);
|
||||
if (catch && (sig != 0 || (sig = CURSIG(p)))) {
|
||||
if (u.u_sigintr & sigmask(sig))
|
||||
return(EINTR);
|
||||
return(ERESTART);
|
||||
}
|
||||
return(0);
|
||||
splx(s);
|
||||
p->p_flag &= ~P_SINTR;
|
||||
if (p->p_flag & P_TIMEOUT) {
|
||||
p->p_flag &= ~P_TIMEOUT;
|
||||
if (sig == 0)
|
||||
return(EWOULDBLOCK);
|
||||
} else if (timo)
|
||||
untimeout (endtsleep, (caddr_t)p);
|
||||
if (catch && (sig != 0 || (sig = CURSIG(p)))) {
|
||||
if (u.u_sigintr & sigmask(sig))
|
||||
return(EINTR);
|
||||
return(ERESTART);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -223,33 +223,33 @@ resume:
|
||||
*/
|
||||
void
|
||||
sleep (chan, pri)
|
||||
caddr_t chan;
|
||||
int pri;
|
||||
caddr_t chan;
|
||||
int pri;
|
||||
{
|
||||
register int priority = pri;
|
||||
register int priority = pri;
|
||||
|
||||
if (pri > PZERO)
|
||||
priority |= PCATCH;
|
||||
if (pri > PZERO)
|
||||
priority |= PCATCH;
|
||||
|
||||
u.u_error = tsleep (chan, priority, 0);
|
||||
/*
|
||||
* sleep does not return anything. If it was a non-interruptible sleep _or_
|
||||
* a successful/normal sleep (one for which a wakeup was done) then return.
|
||||
*/
|
||||
if ((priority & PCATCH) == 0 || (u.u_error == 0))
|
||||
return;
|
||||
/*
|
||||
* XXX - compatibility uglyness.
|
||||
*
|
||||
* The tsleep() above will leave one of the following in u_error:
|
||||
*
|
||||
* 0 - a wakeup was done, this is handled above
|
||||
* EWOULDBLOCK - since no timeout was passed to tsleep we will not see this
|
||||
* EINTR - put into u_error for trap.c to find (interrupted syscall)
|
||||
* ERESTART - system call to be restared
|
||||
*/
|
||||
longjmp (u.u_procp->p_addr, &u.u_qsave);
|
||||
/*NOTREACHED*/
|
||||
u.u_error = tsleep (chan, priority, 0);
|
||||
/*
|
||||
* sleep does not return anything. If it was a non-interruptible sleep _or_
|
||||
* a successful/normal sleep (one for which a wakeup was done) then return.
|
||||
*/
|
||||
if ((priority & PCATCH) == 0 || (u.u_error == 0))
|
||||
return;
|
||||
/*
|
||||
* XXX - compatibility uglyness.
|
||||
*
|
||||
* The tsleep() above will leave one of the following in u_error:
|
||||
*
|
||||
* 0 - a wakeup was done, this is handled above
|
||||
* EWOULDBLOCK - since no timeout was passed to tsleep we will not see this
|
||||
* EINTR - put into u_error for trap.c to find (interrupted syscall)
|
||||
* ERESTART - system call to be restared
|
||||
*/
|
||||
longjmp (u.u_procp->p_addr, &u.u_qsave);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -257,20 +257,20 @@ sleep (chan, pri)
|
||||
*/
|
||||
void
|
||||
unsleep (p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register struct proc **hp;
|
||||
register int s;
|
||||
register struct proc **hp;
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
if (p->p_wchan) {
|
||||
hp = &slpque[HASH(p->p_wchan)];
|
||||
while (*hp != p)
|
||||
hp = &(*hp)->p_link;
|
||||
*hp = p->p_link;
|
||||
p->p_wchan = 0;
|
||||
}
|
||||
splx(s);
|
||||
s = splhigh();
|
||||
if (p->p_wchan) {
|
||||
hp = &slpque[HASH(p->p_wchan)];
|
||||
while (*hp != p)
|
||||
hp = &(*hp)->p_link;
|
||||
*hp = p->p_link;
|
||||
p->p_wchan = 0;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -278,52 +278,52 @@ unsleep (p)
|
||||
*/
|
||||
void
|
||||
wakeup (chan)
|
||||
register caddr_t chan;
|
||||
register caddr_t chan;
|
||||
{
|
||||
register struct proc *p, **q;
|
||||
struct proc **qp;
|
||||
int s;
|
||||
register struct proc *p, **q;
|
||||
struct proc **qp;
|
||||
int s;
|
||||
|
||||
/*
|
||||
* Since we are called at interrupt time, must insure normal
|
||||
* kernel mapping to access proc.
|
||||
*/
|
||||
s = splclock();
|
||||
qp = &slpque[HASH(chan)];
|
||||
/*
|
||||
* Since we are called at interrupt time, must insure normal
|
||||
* kernel mapping to access proc.
|
||||
*/
|
||||
s = splclock();
|
||||
qp = &slpque[HASH(chan)];
|
||||
restart:
|
||||
for (q = qp; (p = *q); ) {
|
||||
if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
|
||||
panic("wakeup");
|
||||
if (p->p_wchan==chan) {
|
||||
p->p_wchan = 0;
|
||||
*q = p->p_link;
|
||||
if (p->p_stat == SSLEEP) {
|
||||
/* OPTIMIZED INLINE EXPANSION OF setrun(p) */
|
||||
if (p->p_slptime > 1)
|
||||
updatepri(p);
|
||||
p->p_slptime = 0;
|
||||
p->p_stat = SRUN;
|
||||
if (p->p_flag & SLOAD)
|
||||
setrq(p);
|
||||
/*
|
||||
* Since curpri is a usrpri,
|
||||
* p->p_pri is always better than curpri.
|
||||
*/
|
||||
runrun++;
|
||||
if (! (p->p_flag & SLOAD)) {
|
||||
if (runout != 0) {
|
||||
runout = 0;
|
||||
wakeup((caddr_t)&runout);
|
||||
}
|
||||
}
|
||||
/* END INLINE EXPANSION */
|
||||
goto restart;
|
||||
}
|
||||
p->p_slptime = 0;
|
||||
} else
|
||||
q = &p->p_link;
|
||||
}
|
||||
splx(s);
|
||||
for (q = qp; (p = *q); ) {
|
||||
if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
|
||||
panic("wakeup");
|
||||
if (p->p_wchan==chan) {
|
||||
p->p_wchan = 0;
|
||||
*q = p->p_link;
|
||||
if (p->p_stat == SSLEEP) {
|
||||
/* OPTIMIZED INLINE EXPANSION OF setrun(p) */
|
||||
if (p->p_slptime > 1)
|
||||
updatepri(p);
|
||||
p->p_slptime = 0;
|
||||
p->p_stat = SRUN;
|
||||
if (p->p_flag & SLOAD)
|
||||
setrq(p);
|
||||
/*
|
||||
* Since curpri is a usrpri,
|
||||
* p->p_pri is always better than curpri.
|
||||
*/
|
||||
runrun++;
|
||||
if (! (p->p_flag & SLOAD)) {
|
||||
if (runout != 0) {
|
||||
runout = 0;
|
||||
wakeup((caddr_t)&runout);
|
||||
}
|
||||
}
|
||||
/* END INLINE EXPANSION */
|
||||
goto restart;
|
||||
}
|
||||
p->p_slptime = 0;
|
||||
} else
|
||||
q = &p->p_link;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -332,41 +332,41 @@ restart:
|
||||
*/
|
||||
void
|
||||
setrun (p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register int s;
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
switch (p->p_stat) {
|
||||
case 0:
|
||||
case SWAIT:
|
||||
case SRUN:
|
||||
case SZOMB:
|
||||
default:
|
||||
panic("setrun");
|
||||
s = splhigh();
|
||||
switch (p->p_stat) {
|
||||
case 0:
|
||||
case SWAIT:
|
||||
case SRUN:
|
||||
case SZOMB:
|
||||
default:
|
||||
panic("setrun");
|
||||
|
||||
case SSTOP:
|
||||
case SSLEEP:
|
||||
unsleep(p); /* e.g. when sending signals */
|
||||
break;
|
||||
case SSTOP:
|
||||
case SSLEEP:
|
||||
unsleep(p); /* e.g. when sending signals */
|
||||
break;
|
||||
|
||||
case SIDL:
|
||||
break;
|
||||
}
|
||||
if (p->p_slptime > 1)
|
||||
updatepri(p);
|
||||
p->p_stat = SRUN;
|
||||
if (p->p_flag & SLOAD)
|
||||
setrq(p);
|
||||
splx(s);
|
||||
if (p->p_pri < curpri)
|
||||
runrun++;
|
||||
if (! (p->p_flag & SLOAD)) {
|
||||
if (runout != 0) {
|
||||
runout = 0;
|
||||
wakeup((caddr_t)&runout);
|
||||
}
|
||||
}
|
||||
case SIDL:
|
||||
break;
|
||||
}
|
||||
if (p->p_slptime > 1)
|
||||
updatepri(p);
|
||||
p->p_stat = SRUN;
|
||||
if (p->p_flag & SLOAD)
|
||||
setrq(p);
|
||||
splx(s);
|
||||
if (p->p_pri < curpri)
|
||||
runrun++;
|
||||
if (! (p->p_flag & SLOAD)) {
|
||||
if (runout != 0) {
|
||||
runout = 0;
|
||||
wakeup((caddr_t)&runout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -377,18 +377,18 @@ setrun (p)
|
||||
*/
|
||||
int
|
||||
setpri (pp)
|
||||
register struct proc *pp;
|
||||
register struct proc *pp;
|
||||
{
|
||||
register int p;
|
||||
register int p;
|
||||
|
||||
p = (pp->p_cpu & 0377)/16;
|
||||
p += PUSER + pp->p_nice;
|
||||
if (p > 127)
|
||||
p = 127;
|
||||
if (p < curpri)
|
||||
runrun++;
|
||||
pp->p_pri = p;
|
||||
return (p);
|
||||
p = (pp->p_cpu & 0377)/16;
|
||||
p += PUSER + pp->p_nice;
|
||||
if (p > 127)
|
||||
p = 127;
|
||||
if (p < curpri)
|
||||
runrun++;
|
||||
pp->p_pri = p;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,88 +402,88 @@ setpri (pp)
|
||||
void
|
||||
swtch()
|
||||
{
|
||||
register struct proc *p, *q;
|
||||
register int n;
|
||||
struct proc *pp, *pq;
|
||||
int s;
|
||||
register struct proc *p, *q;
|
||||
register int n;
|
||||
struct proc *pp, *pq;
|
||||
int s;
|
||||
|
||||
#ifdef UCB_METER
|
||||
cnt.v_swtch++;
|
||||
cnt.v_swtch++;
|
||||
#endif
|
||||
/* If not the idle process, resume the idle process. */
|
||||
if (u.u_procp != &proc[0]) {
|
||||
if (setjmp (&u.u_rsave)) {
|
||||
/* Returned from swapper to user process. */
|
||||
return;
|
||||
}
|
||||
/* Switch from user process to swapper. */
|
||||
longjmp (proc[0].p_addr, &u.u_qsave);
|
||||
}
|
||||
/*
|
||||
* The first save returns nonzero when proc 0 is resumed
|
||||
* by another process (above); then the second is not done
|
||||
* and the process-search loop is entered.
|
||||
*/
|
||||
if (setjmp (&u.u_qsave)) {
|
||||
/* Returned from user process. */
|
||||
goto loop;
|
||||
}
|
||||
/*
|
||||
* The first save returns 0 when swtch is called in proc 0
|
||||
* from sched(). The second save returns 0 immediately, so
|
||||
* in this case too the process-search loop is entered.
|
||||
* Thus when proc 0 is awakened by being made runnable, it will
|
||||
* find itself and resume itself at rsave, and return to sched().
|
||||
*/
|
||||
if (setjmp (&u.u_rsave)) {
|
||||
/* Swapper resumed by itself. */
|
||||
return;
|
||||
}
|
||||
/* If not the idle process, resume the idle process. */
|
||||
if (u.u_procp != &proc[0]) {
|
||||
if (setjmp (&u.u_rsave)) {
|
||||
/* Returned from swapper to user process. */
|
||||
return;
|
||||
}
|
||||
/* Switch from user process to swapper. */
|
||||
longjmp (proc[0].p_addr, &u.u_qsave);
|
||||
}
|
||||
/*
|
||||
* The first save returns nonzero when proc 0 is resumed
|
||||
* by another process (above); then the second is not done
|
||||
* and the process-search loop is entered.
|
||||
*/
|
||||
if (setjmp (&u.u_qsave)) {
|
||||
/* Returned from user process. */
|
||||
goto loop;
|
||||
}
|
||||
/*
|
||||
* The first save returns 0 when swtch is called in proc 0
|
||||
* from sched(). The second save returns 0 immediately, so
|
||||
* in this case too the process-search loop is entered.
|
||||
* Thus when proc 0 is awakened by being made runnable, it will
|
||||
* find itself and resume itself at rsave, and return to sched().
|
||||
*/
|
||||
if (setjmp (&u.u_rsave)) {
|
||||
/* Swapper resumed by itself. */
|
||||
return;
|
||||
}
|
||||
loop:
|
||||
s = splhigh();
|
||||
noproc = 0;
|
||||
runrun = 0;
|
||||
s = splhigh();
|
||||
noproc = 0;
|
||||
runrun = 0;
|
||||
#ifdef DIAGNOSTIC
|
||||
for (p = qs; p; p = p->p_link)
|
||||
if (p->p_stat != SRUN)
|
||||
panic ("swtch SRUN");
|
||||
for (p = qs; p; p = p->p_link)
|
||||
if (p->p_stat != SRUN)
|
||||
panic ("swtch SRUN");
|
||||
#endif
|
||||
pp = NULL;
|
||||
q = NULL;
|
||||
n = 128;
|
||||
/*
|
||||
* search for highest-priority runnable process
|
||||
*/
|
||||
pq = 0;
|
||||
for (p = qs; p; p = p->p_link) {
|
||||
if (p->p_flag & SLOAD && p->p_pri < n) {
|
||||
pp = p;
|
||||
pq = q;
|
||||
n = p->p_pri;
|
||||
}
|
||||
q = p;
|
||||
}
|
||||
/*
|
||||
* if no process is runnable, idle.
|
||||
*/
|
||||
p = pp;
|
||||
if (p == NULL) {
|
||||
idle();
|
||||
goto loop;
|
||||
}
|
||||
if (pq)
|
||||
pq->p_link = p->p_link;
|
||||
else
|
||||
qs = p->p_link;
|
||||
curpri = n;
|
||||
splx(s);
|
||||
/*
|
||||
* the rsave (ssave) contents are interpreted
|
||||
* in the new address space
|
||||
*/
|
||||
n = p->p_flag & SSWAP;
|
||||
p->p_flag &= ~SSWAP;
|
||||
longjmp (p->p_addr, n ? &u.u_ssave : &u.u_rsave);
|
||||
pp = NULL;
|
||||
q = NULL;
|
||||
n = 128;
|
||||
/*
|
||||
* search for highest-priority runnable process
|
||||
*/
|
||||
pq = 0;
|
||||
for (p = qs; p; p = p->p_link) {
|
||||
if (p->p_flag & SLOAD && p->p_pri < n) {
|
||||
pp = p;
|
||||
pq = q;
|
||||
n = p->p_pri;
|
||||
}
|
||||
q = p;
|
||||
}
|
||||
/*
|
||||
* if no process is runnable, idle.
|
||||
*/
|
||||
p = pp;
|
||||
if (p == NULL) {
|
||||
idle();
|
||||
goto loop;
|
||||
}
|
||||
if (pq)
|
||||
pq->p_link = p->p_link;
|
||||
else
|
||||
qs = p->p_link;
|
||||
curpri = n;
|
||||
splx(s);
|
||||
/*
|
||||
* the rsave (ssave) contents are interpreted
|
||||
* in the new address space
|
||||
*/
|
||||
n = p->p_flag & SSWAP;
|
||||
p->p_flag &= ~SSWAP;
|
||||
longjmp (p->p_addr, n ? &u.u_ssave : &u.u_rsave);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -491,23 +491,23 @@ loop:
|
||||
*/
|
||||
void
|
||||
setrq (p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register int s;
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
s = splhigh();
|
||||
#ifdef DIAGNOSTIC
|
||||
{ /* see if already on the run queue */
|
||||
register struct proc *q;
|
||||
{ /* see if already on the run queue */
|
||||
register struct proc *q;
|
||||
|
||||
for (q = qs;q != NULL;q = q->p_link)
|
||||
if (q == p)
|
||||
panic("setrq");
|
||||
}
|
||||
for (q = qs;q != NULL;q = q->p_link)
|
||||
if (q == p)
|
||||
panic("setrq");
|
||||
}
|
||||
#endif
|
||||
p->p_link = qs;
|
||||
qs = p;
|
||||
splx(s);
|
||||
p->p_link = qs;
|
||||
qs = p;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -517,22 +517,22 @@ setrq (p)
|
||||
*/
|
||||
void
|
||||
remrq (p)
|
||||
register struct proc *p;
|
||||
register struct proc *p;
|
||||
{
|
||||
register struct proc *q;
|
||||
register int s;
|
||||
register struct proc *q;
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
if (p == qs)
|
||||
qs = p->p_link;
|
||||
else {
|
||||
for (q = qs; q; q = q->p_link)
|
||||
if (q->p_link == p) {
|
||||
q->p_link = p->p_link;
|
||||
goto done;
|
||||
}
|
||||
panic("remrq");
|
||||
}
|
||||
s = splhigh();
|
||||
if (p == qs)
|
||||
qs = p->p_link;
|
||||
else {
|
||||
for (q = qs; q; q = q->p_link)
|
||||
if (q->p_link == p) {
|
||||
q->p_link = p->p_link;
|
||||
goto done;
|
||||
}
|
||||
panic("remrq");
|
||||
}
|
||||
done:
|
||||
splx(s);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,40 +11,40 @@
|
||||
|
||||
static void
|
||||
setthetime (tv)
|
||||
register struct timeval *tv;
|
||||
register struct timeval *tv;
|
||||
{
|
||||
int s;
|
||||
int s;
|
||||
|
||||
if (! suser())
|
||||
return;
|
||||
#ifdef NOTNOW
|
||||
if (! suser())
|
||||
return;
|
||||
#ifdef NOTNOW
|
||||
/*
|
||||
* If the system is secure, we do not allow the time to be set to an
|
||||
* earlier value. The time may be slowed (using adjtime) but not set back.
|
||||
*
|
||||
* NOTE: Can not do this until ntpd is updated to deal with the coarse (50, 60
|
||||
* hz) clocks. Ntpd wants to adjust time system clock a few microseconds
|
||||
* at a time (which gets rounded to 0 in adjtime below). If that fails
|
||||
* ntpd uses settimeofday to step the time backwards which obviously
|
||||
* will fail if the next 'if' is enabled - all that does is fill up the
|
||||
* logfiles with "can't set time" messages and the time keeps drifting.
|
||||
* hz) clocks. Ntpd wants to adjust time system clock a few microseconds
|
||||
* at a time (which gets rounded to 0 in adjtime below). If that fails
|
||||
* ntpd uses settimeofday to step the time backwards which obviously
|
||||
* will fail if the next 'if' is enabled - all that does is fill up the
|
||||
* logfiles with "can't set time" messages and the time keeps drifting.
|
||||
*/
|
||||
if (securelevel > 0 && timercmp(tv, &time, <)) {
|
||||
u.u_error = EPERM; /* XXX */
|
||||
return;
|
||||
}
|
||||
if (securelevel > 0 && timercmp(tv, &time, <)) {
|
||||
u.u_error = EPERM; /* XXX */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
|
||||
boottime.tv_sec += tv->tv_sec - time.tv_sec;
|
||||
s = splhigh();
|
||||
time = *tv;
|
||||
lbolt = time.tv_usec / usechz;
|
||||
splx(s);
|
||||
#ifdef notyet
|
||||
/*
|
||||
* if you have a time of day board, use it here
|
||||
*/
|
||||
resettodr();
|
||||
boottime.tv_sec += tv->tv_sec - time.tv_sec;
|
||||
s = splhigh();
|
||||
time = *tv;
|
||||
lbolt = time.tv_usec / usechz;
|
||||
splx(s);
|
||||
#ifdef notyet
|
||||
/*
|
||||
* if you have a time of day board, use it here
|
||||
*/
|
||||
resettodr();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -57,185 +57,185 @@ setthetime (tv)
|
||||
void
|
||||
gettimeofday()
|
||||
{
|
||||
register struct a {
|
||||
struct timeval *tp;
|
||||
struct timezone *tzp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
int s;
|
||||
register u_int ms;
|
||||
register struct a {
|
||||
struct timeval *tp;
|
||||
struct timezone *tzp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
int s;
|
||||
register u_int ms;
|
||||
|
||||
if (uap->tp) {
|
||||
/*
|
||||
* We don't resolve the milliseconds on every clock tick; it's
|
||||
* easier to do it here. Long casts are out of paranoia.
|
||||
*/
|
||||
s = splhigh();
|
||||
atv = time;
|
||||
ms = lbolt;
|
||||
splx(s);
|
||||
atv.tv_usec = (long)ms * usechz;
|
||||
u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->tp,
|
||||
sizeof(atv));
|
||||
if (u.u_error)
|
||||
return;
|
||||
}
|
||||
if (uap->tzp)
|
||||
u.u_error = copyout ((caddr_t) &tz, (caddr_t) uap->tzp,
|
||||
sizeof (tz));
|
||||
if (uap->tp) {
|
||||
/*
|
||||
* We don't resolve the milliseconds on every clock tick; it's
|
||||
* easier to do it here. Long casts are out of paranoia.
|
||||
*/
|
||||
s = splhigh();
|
||||
atv = time;
|
||||
ms = lbolt;
|
||||
splx(s);
|
||||
atv.tv_usec = (long)ms * usechz;
|
||||
u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->tp,
|
||||
sizeof(atv));
|
||||
if (u.u_error)
|
||||
return;
|
||||
}
|
||||
if (uap->tzp)
|
||||
u.u_error = copyout ((caddr_t) &tz, (caddr_t) uap->tzp,
|
||||
sizeof (tz));
|
||||
}
|
||||
|
||||
void
|
||||
settimeofday()
|
||||
{
|
||||
register struct a {
|
||||
struct timeval *tv;
|
||||
struct timezone *tzp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
struct timezone atz;
|
||||
register struct a {
|
||||
struct timeval *tv;
|
||||
struct timezone *tzp;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
struct timezone atz;
|
||||
|
||||
if (uap->tv) {
|
||||
u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
|
||||
sizeof (struct timeval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
setthetime(&atv);
|
||||
if (u.u_error)
|
||||
return;
|
||||
}
|
||||
if (uap->tzp && suser()) {
|
||||
u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz,
|
||||
sizeof (atz));
|
||||
if (u.u_error == 0)
|
||||
tz = atz;
|
||||
}
|
||||
if (uap->tv) {
|
||||
u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
|
||||
sizeof (struct timeval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
setthetime(&atv);
|
||||
if (u.u_error)
|
||||
return;
|
||||
}
|
||||
if (uap->tzp && suser()) {
|
||||
u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz,
|
||||
sizeof (atz));
|
||||
if (u.u_error == 0)
|
||||
tz = atz;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
adjtime()
|
||||
{
|
||||
register struct a {
|
||||
struct timeval *delta;
|
||||
struct timeval *olddelta;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
register int s;
|
||||
long adjust;
|
||||
register struct a {
|
||||
struct timeval *delta;
|
||||
struct timeval *olddelta;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct timeval atv;
|
||||
register int s;
|
||||
long adjust;
|
||||
|
||||
if (!suser())
|
||||
return;
|
||||
u.u_error = copyin((caddr_t)uap->delta, (caddr_t)&atv,
|
||||
sizeof (struct timeval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
adjust = (atv.tv_sec * hz) + (atv.tv_usec / usechz);
|
||||
/* if unstoreable values, just set the clock */
|
||||
if (adjust > 0x7fff || adjust < 0x8000) {
|
||||
s = splclock();
|
||||
time.tv_sec += atv.tv_sec;
|
||||
lbolt += atv.tv_usec / usechz;
|
||||
while (lbolt >= hz) {
|
||||
lbolt -= hz;
|
||||
++time.tv_sec;
|
||||
}
|
||||
splx(s);
|
||||
if (!uap->olddelta)
|
||||
return;
|
||||
atv.tv_sec = atv.tv_usec = 0;
|
||||
} else {
|
||||
if (!uap->olddelta) {
|
||||
adjdelta = adjust;
|
||||
return;
|
||||
}
|
||||
atv.tv_sec = adjdelta / hz;
|
||||
atv.tv_usec = (adjdelta % hz) * usechz;
|
||||
adjdelta = adjust;
|
||||
}
|
||||
u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->olddelta,
|
||||
sizeof (struct timeval));
|
||||
if (!suser())
|
||||
return;
|
||||
u.u_error = copyin((caddr_t)uap->delta, (caddr_t)&atv,
|
||||
sizeof (struct timeval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
adjust = (atv.tv_sec * hz) + (atv.tv_usec / usechz);
|
||||
/* if unstoreable values, just set the clock */
|
||||
if (adjust > 0x7fff || adjust < 0x8000) {
|
||||
s = splclock();
|
||||
time.tv_sec += atv.tv_sec;
|
||||
lbolt += atv.tv_usec / usechz;
|
||||
while (lbolt >= hz) {
|
||||
lbolt -= hz;
|
||||
++time.tv_sec;
|
||||
}
|
||||
splx(s);
|
||||
if (!uap->olddelta)
|
||||
return;
|
||||
atv.tv_sec = atv.tv_usec = 0;
|
||||
} else {
|
||||
if (!uap->olddelta) {
|
||||
adjdelta = adjust;
|
||||
return;
|
||||
}
|
||||
atv.tv_sec = adjdelta / hz;
|
||||
atv.tv_usec = (adjdelta % hz) * usechz;
|
||||
adjdelta = adjust;
|
||||
}
|
||||
u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->olddelta,
|
||||
sizeof (struct timeval));
|
||||
}
|
||||
|
||||
void
|
||||
getitimer()
|
||||
{
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct itimerval *itv;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct itimerval aitv;
|
||||
register int s;
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct itimerval *itv;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct itimerval aitv;
|
||||
register int s;
|
||||
|
||||
if (uap->which > ITIMER_PROF) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
aitv.it_interval.tv_usec = 0;
|
||||
aitv.it_value.tv_usec = 0;
|
||||
s = splclock();
|
||||
if (uap->which == ITIMER_REAL) {
|
||||
register struct proc *p = u.u_procp;
|
||||
if (uap->which > ITIMER_PROF) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
aitv.it_interval.tv_usec = 0;
|
||||
aitv.it_value.tv_usec = 0;
|
||||
s = splclock();
|
||||
if (uap->which == ITIMER_REAL) {
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
aitv.it_interval.tv_sec = p->p_realtimer.it_interval;
|
||||
aitv.it_value.tv_sec = p->p_realtimer.it_value;
|
||||
} else {
|
||||
register struct k_itimerval *t = &u.u_timer[uap->which - 1];
|
||||
aitv.it_interval.tv_sec = p->p_realtimer.it_interval;
|
||||
aitv.it_value.tv_sec = p->p_realtimer.it_value;
|
||||
} else {
|
||||
register struct k_itimerval *t = &u.u_timer[uap->which - 1];
|
||||
|
||||
aitv.it_interval.tv_sec = t->it_interval / hz;
|
||||
aitv.it_value.tv_sec = t->it_value / hz;
|
||||
}
|
||||
splx(s);
|
||||
u.u_error = copyout ((caddr_t)&aitv, (caddr_t)uap->itv,
|
||||
sizeof (struct itimerval));
|
||||
aitv.it_interval.tv_sec = t->it_interval / hz;
|
||||
aitv.it_value.tv_sec = t->it_value / hz;
|
||||
}
|
||||
splx(s);
|
||||
u.u_error = copyout ((caddr_t)&aitv, (caddr_t)uap->itv,
|
||||
sizeof (struct itimerval));
|
||||
}
|
||||
|
||||
void
|
||||
setitimer()
|
||||
{
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct itimerval *itv, *oitv;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct itimerval aitv;
|
||||
register struct itimerval *aitvp;
|
||||
int s;
|
||||
register struct a {
|
||||
u_int which;
|
||||
struct itimerval *itv, *oitv;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct itimerval aitv;
|
||||
register struct itimerval *aitvp;
|
||||
int s;
|
||||
|
||||
if (uap->which > ITIMER_PROF) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
aitvp = uap->itv;
|
||||
if (uap->oitv) {
|
||||
uap->itv = uap->oitv;
|
||||
getitimer();
|
||||
}
|
||||
if (aitvp == 0)
|
||||
return;
|
||||
u.u_error = copyin((caddr_t)aitvp, (caddr_t)&aitv,
|
||||
sizeof (struct itimerval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
s = splclock();
|
||||
if (uap->which == ITIMER_REAL) {
|
||||
register struct proc *p = u.u_procp;
|
||||
if (uap->which > ITIMER_PROF) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
aitvp = uap->itv;
|
||||
if (uap->oitv) {
|
||||
uap->itv = uap->oitv;
|
||||
getitimer();
|
||||
}
|
||||
if (aitvp == 0)
|
||||
return;
|
||||
u.u_error = copyin((caddr_t)aitvp, (caddr_t)&aitv,
|
||||
sizeof (struct itimerval));
|
||||
if (u.u_error)
|
||||
return;
|
||||
s = splclock();
|
||||
if (uap->which == ITIMER_REAL) {
|
||||
register struct proc *p = u.u_procp;
|
||||
|
||||
p->p_realtimer.it_value = aitv.it_value.tv_sec;
|
||||
if (aitv.it_value.tv_usec)
|
||||
++p->p_realtimer.it_value;
|
||||
p->p_realtimer.it_interval = aitv.it_interval.tv_sec;
|
||||
if (aitv.it_interval.tv_usec)
|
||||
++p->p_realtimer.it_interval;
|
||||
} else {
|
||||
register struct k_itimerval *t = &u.u_timer[uap->which - 1];
|
||||
p->p_realtimer.it_value = aitv.it_value.tv_sec;
|
||||
if (aitv.it_value.tv_usec)
|
||||
++p->p_realtimer.it_value;
|
||||
p->p_realtimer.it_interval = aitv.it_interval.tv_sec;
|
||||
if (aitv.it_interval.tv_usec)
|
||||
++p->p_realtimer.it_interval;
|
||||
} else {
|
||||
register struct k_itimerval *t = &u.u_timer[uap->which - 1];
|
||||
|
||||
t->it_value = aitv.it_value.tv_sec * hz;
|
||||
if (aitv.it_value.tv_usec)
|
||||
t->it_value += hz;
|
||||
t->it_interval = aitv.it_interval.tv_sec * hz;
|
||||
if (aitv.it_interval.tv_usec)
|
||||
t->it_interval += hz;
|
||||
}
|
||||
splx(s);
|
||||
t->it_value = aitv.it_value.tv_sec * hz;
|
||||
if (aitv.it_value.tv_usec)
|
||||
t->it_value += hz;
|
||||
t->it_interval = aitv.it_interval.tv_sec * hz;
|
||||
if (aitv.it_interval.tv_usec)
|
||||
t->it_interval += hz;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -246,14 +246,14 @@ setitimer()
|
||||
*/
|
||||
int
|
||||
itimerfix(tv)
|
||||
struct timeval *tv;
|
||||
struct timeval *tv;
|
||||
{
|
||||
if (tv->tv_sec < 0 || tv->tv_sec > 100000000L ||
|
||||
tv->tv_usec < 0 || tv->tv_usec >= 1000000L)
|
||||
return (EINVAL);
|
||||
if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < (1000/hz))
|
||||
tv->tv_usec = 1000/hz;
|
||||
return (0);
|
||||
if (tv->tv_sec < 0 || tv->tv_sec > 100000000L ||
|
||||
tv->tv_usec < 0 || tv->tv_usec >= 1000000L)
|
||||
return (EINVAL);
|
||||
if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < (1000/hz))
|
||||
tv->tv_usec = 1000/hz;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef NOT_CURRENTLY_IN_USE
|
||||
@@ -268,50 +268,50 @@ itimerfix(tv)
|
||||
* on which it is operating cannot change in value.
|
||||
*/
|
||||
itimerdecr(itp, usec)
|
||||
register struct itimerval *itp;
|
||||
int usec;
|
||||
register struct itimerval *itp;
|
||||
int usec;
|
||||
{
|
||||
|
||||
if (itp->it_value.tv_usec < usec) {
|
||||
if (itp->it_value.tv_sec == 0) {
|
||||
/* expired, and already in next interval */
|
||||
usec -= itp->it_value.tv_usec;
|
||||
goto expire;
|
||||
}
|
||||
itp->it_value.tv_usec += 1000000L;
|
||||
itp->it_value.tv_sec--;
|
||||
}
|
||||
itp->it_value.tv_usec -= usec;
|
||||
usec = 0;
|
||||
if (timerisset(&itp->it_value))
|
||||
return (1);
|
||||
/* expired, exactly at end of interval */
|
||||
if (itp->it_value.tv_usec < usec) {
|
||||
if (itp->it_value.tv_sec == 0) {
|
||||
/* expired, and already in next interval */
|
||||
usec -= itp->it_value.tv_usec;
|
||||
goto expire;
|
||||
}
|
||||
itp->it_value.tv_usec += 1000000L;
|
||||
itp->it_value.tv_sec--;
|
||||
}
|
||||
itp->it_value.tv_usec -= usec;
|
||||
usec = 0;
|
||||
if (timerisset(&itp->it_value))
|
||||
return (1);
|
||||
/* expired, exactly at end of interval */
|
||||
expire:
|
||||
if (timerisset(&itp->it_interval)) {
|
||||
itp->it_value = itp->it_interval;
|
||||
itp->it_value.tv_usec -= usec;
|
||||
if (itp->it_value.tv_usec < 0) {
|
||||
itp->it_value.tv_usec += 1000000L;
|
||||
itp->it_value.tv_sec--;
|
||||
}
|
||||
} else
|
||||
itp->it_value.tv_usec = 0; /* sec is already 0 */
|
||||
return (0);
|
||||
if (timerisset(&itp->it_interval)) {
|
||||
itp->it_value = itp->it_interval;
|
||||
itp->it_value.tv_usec -= usec;
|
||||
if (itp->it_value.tv_usec < 0) {
|
||||
itp->it_value.tv_usec += 1000000L;
|
||||
itp->it_value.tv_sec--;
|
||||
}
|
||||
} else
|
||||
itp->it_value.tv_usec = 0; /* sec is already 0 */
|
||||
return (0);
|
||||
}
|
||||
#endif /* NOT_CURRENTLY_IN_USE */
|
||||
|
||||
static void
|
||||
tvfix(t1)
|
||||
struct timeval *t1;
|
||||
struct timeval *t1;
|
||||
{
|
||||
if (t1->tv_usec < 0) {
|
||||
t1->tv_sec--;
|
||||
t1->tv_usec += 1000000L;
|
||||
}
|
||||
if (t1->tv_usec >= 1000000L) {
|
||||
t1->tv_sec++;
|
||||
t1->tv_usec -= 1000000L;
|
||||
}
|
||||
if (t1->tv_usec < 0) {
|
||||
t1->tv_sec--;
|
||||
t1->tv_usec += 1000000L;
|
||||
}
|
||||
if (t1->tv_usec >= 1000000L) {
|
||||
t1->tv_sec++;
|
||||
t1->tv_usec -= 1000000L;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -323,20 +323,20 @@ tvfix(t1)
|
||||
*/
|
||||
void
|
||||
timevaladd(t1, t2)
|
||||
struct timeval *t1, *t2;
|
||||
struct timeval *t1, *t2;
|
||||
{
|
||||
t1->tv_sec += t2->tv_sec;
|
||||
t1->tv_usec += t2->tv_usec;
|
||||
tvfix(t1);
|
||||
t1->tv_sec += t2->tv_sec;
|
||||
t1->tv_usec += t2->tv_usec;
|
||||
tvfix(t1);
|
||||
}
|
||||
|
||||
#ifdef NOT_CURRENTLY_IN_USE
|
||||
void
|
||||
timevalsub(t1, t2)
|
||||
struct timeval *t1, *t2;
|
||||
struct timeval *t1, *t2;
|
||||
{
|
||||
t1->tv_sec -= t2->tv_sec;
|
||||
t1->tv_usec -= t2->tv_usec;
|
||||
tvfix(t1);
|
||||
t1->tv_sec -= t2->tv_sec;
|
||||
t1->tv_usec -= t2->tv_usec;
|
||||
tvfix(t1);
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
||||
* error logging daemon.
|
||||
*/
|
||||
|
||||
#define NLOG 1
|
||||
int nlog = 1;
|
||||
#define NLOG 1
|
||||
int nlog = 1;
|
||||
|
||||
#include "param.h"
|
||||
#include "user.h"
|
||||
@@ -37,51 +37,51 @@ const struct devspec logdevs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#define LOG_RDPRI (PZERO + 1)
|
||||
#define LOG_RDPRI (PZERO + 1)
|
||||
|
||||
#define LOG_OPEN 0x01
|
||||
#define LOG_ASYNC 0x04
|
||||
#define LOG_RDWAIT 0x08
|
||||
#define LOG_OPEN 0x01
|
||||
#define LOG_ASYNC 0x04
|
||||
#define LOG_RDWAIT 0x08
|
||||
|
||||
struct msgbuf msgbuf[NLOG];
|
||||
struct msgbuf msgbuf[NLOG];
|
||||
|
||||
static struct logsoftc {
|
||||
int sc_state; /* see above for possibilities */
|
||||
struct proc *sc_selp; /* process waiting on select call */
|
||||
int sc_pgid; /* process/group for async I/O */
|
||||
int sc_overrun; /* full buffer count */
|
||||
int sc_state; /* see above for possibilities */
|
||||
struct proc *sc_selp; /* process waiting on select call */
|
||||
int sc_pgid; /* process/group for async I/O */
|
||||
int sc_overrun; /* full buffer count */
|
||||
} logsoftc[NLOG];
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
logopen(dev, mode, unused)
|
||||
dev_t dev;
|
||||
int mode;
|
||||
dev_t dev;
|
||||
int mode;
|
||||
{
|
||||
register int unit = minor(dev);
|
||||
register int unit = minor(dev);
|
||||
|
||||
if (unit >= NLOG)
|
||||
return(ENODEV);
|
||||
if (logisopen(unit))
|
||||
return(EBUSY);
|
||||
if (msgbuf[unit].msg_bufc == 0) /* no buffer allocated */
|
||||
return(ENOMEM);
|
||||
logsoftc[unit].sc_state |= LOG_OPEN;
|
||||
logsoftc[unit].sc_pgid = u.u_procp->p_pid; /* signal process only */
|
||||
logsoftc[unit].sc_overrun = 0;
|
||||
return(0);
|
||||
if (unit >= NLOG)
|
||||
return(ENODEV);
|
||||
if (logisopen(unit))
|
||||
return(EBUSY);
|
||||
if (msgbuf[unit].msg_bufc == 0) /* no buffer allocated */
|
||||
return(ENOMEM);
|
||||
logsoftc[unit].sc_state |= LOG_OPEN;
|
||||
logsoftc[unit].sc_pgid = u.u_procp->p_pid; /* signal process only */
|
||||
logsoftc[unit].sc_overrun = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
logclose(dev, flag, unused)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
int flag;
|
||||
{
|
||||
register int unit = minor(dev);
|
||||
register int unit = minor(dev);
|
||||
|
||||
logsoftc[unit].sc_state = 0;
|
||||
return(0);
|
||||
logsoftc[unit].sc_state = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -90,172 +90,172 @@ logclose(dev, flag, unused)
|
||||
*/
|
||||
int
|
||||
logisopen(unit)
|
||||
int unit;
|
||||
int unit;
|
||||
{
|
||||
if (logsoftc[unit].sc_state & LOG_OPEN)
|
||||
return(1);
|
||||
return(0);
|
||||
if (logsoftc[unit].sc_state & LOG_OPEN)
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
logread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
register int l;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
int s, error = 0;
|
||||
char buf [128];
|
||||
register int l;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
int s, error = 0;
|
||||
char buf [128];
|
||||
|
||||
l = minor(dev);
|
||||
lp = &logsoftc[l];
|
||||
mp = &msgbuf[l];
|
||||
s = splhigh();
|
||||
while (mp->msg_bufr == mp->msg_bufx) {
|
||||
if (flag & IO_NDELAY) {
|
||||
splx(s);
|
||||
return(EWOULDBLOCK);
|
||||
}
|
||||
lp->sc_state |= LOG_RDWAIT;
|
||||
sleep((caddr_t)mp, LOG_RDPRI);
|
||||
}
|
||||
lp->sc_state &= ~LOG_RDWAIT;
|
||||
l = minor(dev);
|
||||
lp = &logsoftc[l];
|
||||
mp = &msgbuf[l];
|
||||
s = splhigh();
|
||||
while (mp->msg_bufr == mp->msg_bufx) {
|
||||
if (flag & IO_NDELAY) {
|
||||
splx(s);
|
||||
return(EWOULDBLOCK);
|
||||
}
|
||||
lp->sc_state |= LOG_RDWAIT;
|
||||
sleep((caddr_t)mp, LOG_RDPRI);
|
||||
}
|
||||
lp->sc_state &= ~LOG_RDWAIT;
|
||||
|
||||
while (uio->uio_resid) {
|
||||
l = mp->msg_bufx - mp->msg_bufr;
|
||||
/*
|
||||
* If the reader and writer are equal then we have caught up and there
|
||||
* is nothing more to transfer.
|
||||
*/
|
||||
if (l == 0)
|
||||
break;
|
||||
/*
|
||||
* If the write pointer is behind the reader then only consider as
|
||||
* available for now the bytes from the read pointer thru the end of
|
||||
* the buffer.
|
||||
*/
|
||||
if (l < 0) {
|
||||
l = MSG_BSIZE - mp->msg_bufr;
|
||||
/*
|
||||
* If the reader is exactly at the end of the buffer it is
|
||||
* time to wrap it around to the beginning and recalculate the
|
||||
* amount of data to transfer.
|
||||
*/
|
||||
if (l == 0) {
|
||||
mp->msg_bufr = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
l = MIN (l, uio->uio_resid);
|
||||
l = MIN (l, sizeof buf);
|
||||
bcopy (&mp->msg_bufc[mp->msg_bufr], buf, l);
|
||||
error = uiomove (buf, l, uio);
|
||||
if (error)
|
||||
break;
|
||||
mp->msg_bufr += l;
|
||||
}
|
||||
splx(s);
|
||||
return(error);
|
||||
while (uio->uio_resid) {
|
||||
l = mp->msg_bufx - mp->msg_bufr;
|
||||
/*
|
||||
* If the reader and writer are equal then we have caught up and there
|
||||
* is nothing more to transfer.
|
||||
*/
|
||||
if (l == 0)
|
||||
break;
|
||||
/*
|
||||
* If the write pointer is behind the reader then only consider as
|
||||
* available for now the bytes from the read pointer thru the end of
|
||||
* the buffer.
|
||||
*/
|
||||
if (l < 0) {
|
||||
l = MSG_BSIZE - mp->msg_bufr;
|
||||
/*
|
||||
* If the reader is exactly at the end of the buffer it is
|
||||
* time to wrap it around to the beginning and recalculate the
|
||||
* amount of data to transfer.
|
||||
*/
|
||||
if (l == 0) {
|
||||
mp->msg_bufr = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
l = MIN (l, uio->uio_resid);
|
||||
l = MIN (l, sizeof buf);
|
||||
bcopy (&mp->msg_bufc[mp->msg_bufr], buf, l);
|
||||
error = uiomove (buf, l, uio);
|
||||
if (error)
|
||||
break;
|
||||
mp->msg_bufr += l;
|
||||
}
|
||||
splx(s);
|
||||
return(error);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
logselect(dev, rw)
|
||||
dev_t dev;
|
||||
int rw;
|
||||
dev_t dev;
|
||||
int rw;
|
||||
{
|
||||
register int s = splhigh();
|
||||
int unit = minor(dev);
|
||||
register int s = splhigh();
|
||||
int unit = minor(dev);
|
||||
|
||||
switch (rw) {
|
||||
case FREAD:
|
||||
if (msgbuf[unit].msg_bufr != msgbuf[unit].msg_bufx) {
|
||||
splx(s);
|
||||
return(1);
|
||||
}
|
||||
logsoftc[unit].sc_selp = u.u_procp;
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
return(0);
|
||||
switch (rw) {
|
||||
case FREAD:
|
||||
if (msgbuf[unit].msg_bufr != msgbuf[unit].msg_bufx) {
|
||||
splx(s);
|
||||
return(1);
|
||||
}
|
||||
logsoftc[unit].sc_selp = u.u_procp;
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
logwakeup(unit)
|
||||
int unit;
|
||||
int unit;
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
register struct proc *p;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
|
||||
if (! logisopen(unit))
|
||||
return;
|
||||
lp = &logsoftc[unit];
|
||||
mp = &msgbuf[unit];
|
||||
if (lp->sc_selp) {
|
||||
selwakeup(lp->sc_selp, (long) 0);
|
||||
lp->sc_selp = 0;
|
||||
}
|
||||
if (lp->sc_state & LOG_ASYNC && (mp->msg_bufx != mp->msg_bufr)) {
|
||||
if (lp->sc_pgid < 0)
|
||||
gsignal(-lp->sc_pgid, SIGIO);
|
||||
else if ((p = pfind(lp->sc_pgid)))
|
||||
psignal(p, SIGIO);
|
||||
}
|
||||
if (lp->sc_state & LOG_RDWAIT) {
|
||||
wakeup((caddr_t)mp);
|
||||
lp->sc_state &= ~LOG_RDWAIT;
|
||||
}
|
||||
if (! logisopen(unit))
|
||||
return;
|
||||
lp = &logsoftc[unit];
|
||||
mp = &msgbuf[unit];
|
||||
if (lp->sc_selp) {
|
||||
selwakeup(lp->sc_selp, (long) 0);
|
||||
lp->sc_selp = 0;
|
||||
}
|
||||
if (lp->sc_state & LOG_ASYNC && (mp->msg_bufx != mp->msg_bufr)) {
|
||||
if (lp->sc_pgid < 0)
|
||||
gsignal(-lp->sc_pgid, SIGIO);
|
||||
else if ((p = pfind(lp->sc_pgid)))
|
||||
psignal(p, SIGIO);
|
||||
}
|
||||
if (lp->sc_state & LOG_RDWAIT) {
|
||||
wakeup((caddr_t)mp);
|
||||
lp->sc_state &= ~LOG_RDWAIT;
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
logioctl(dev, com, data, flag)
|
||||
dev_t dev;
|
||||
u_int com;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
u_int com;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
{
|
||||
long l;
|
||||
register int s;
|
||||
int unit;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
long l;
|
||||
register int s;
|
||||
int unit;
|
||||
register struct logsoftc *lp;
|
||||
register struct msgbuf *mp;
|
||||
|
||||
unit = minor(dev);
|
||||
lp = &logsoftc[unit];
|
||||
mp = &msgbuf[unit];
|
||||
unit = minor(dev);
|
||||
lp = &logsoftc[unit];
|
||||
mp = &msgbuf[unit];
|
||||
|
||||
switch (com) {
|
||||
case FIONREAD:
|
||||
s = splhigh();
|
||||
l = mp->msg_bufx - mp->msg_bufr;
|
||||
splx(s);
|
||||
if (l < 0)
|
||||
l += MSG_BSIZE;
|
||||
*(off_t *)data = l;
|
||||
break;
|
||||
case FIONBIO:
|
||||
break;
|
||||
case FIOASYNC:
|
||||
if (*(int *)data)
|
||||
lp->sc_state |= LOG_ASYNC;
|
||||
else
|
||||
lp->sc_state &= ~LOG_ASYNC;
|
||||
break;
|
||||
case TIOCSPGRP:
|
||||
lp->sc_pgid = *(int *)data;
|
||||
break;
|
||||
case TIOCGPGRP:
|
||||
*(int *)data = lp->sc_pgid;
|
||||
break;
|
||||
default:
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
switch (com) {
|
||||
case FIONREAD:
|
||||
s = splhigh();
|
||||
l = mp->msg_bufx - mp->msg_bufr;
|
||||
splx(s);
|
||||
if (l < 0)
|
||||
l += MSG_BSIZE;
|
||||
*(off_t *)data = l;
|
||||
break;
|
||||
case FIONBIO:
|
||||
break;
|
||||
case FIOASYNC:
|
||||
if (*(int *)data)
|
||||
lp->sc_state |= LOG_ASYNC;
|
||||
else
|
||||
lp->sc_state &= ~LOG_ASYNC;
|
||||
break;
|
||||
case TIOCSPGRP:
|
||||
lp->sc_pgid = *(int *)data;
|
||||
break;
|
||||
case TIOCGPGRP:
|
||||
*(int *)data = lp->sc_pgid;
|
||||
break;
|
||||
default:
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -264,59 +264,59 @@ logioctl(dev, com, data, flag)
|
||||
*/
|
||||
int
|
||||
logwrt (buf, len, log)
|
||||
char *buf;
|
||||
int len;
|
||||
int log;
|
||||
char *buf;
|
||||
int len;
|
||||
int log;
|
||||
{
|
||||
register struct msgbuf *mp = &msgbuf[log];
|
||||
struct logsoftc *lp = &logsoftc[log];
|
||||
register int infront;
|
||||
int s, n, writer, err = 0;
|
||||
register struct msgbuf *mp = &msgbuf[log];
|
||||
struct logsoftc *lp = &logsoftc[log];
|
||||
register int infront;
|
||||
int s, n, writer, err = 0;
|
||||
|
||||
if (mp->msg_magic != MSG_MAGIC || (len > MSG_BSIZE))
|
||||
return(-1);
|
||||
/*
|
||||
* Hate to do this but since this can be called from anywhere in the kernel
|
||||
* we have to hold off any interrupt service routines so they don't change
|
||||
* things. This looks like a lot of code but it isn't really.
|
||||
*/
|
||||
s = splhigh();
|
||||
while (len) {
|
||||
again: infront = MSG_BSIZE - mp->msg_bufx;
|
||||
if (infront <= 0) {
|
||||
mp->msg_bufx = 0;
|
||||
infront = MSG_BSIZE - mp->msg_bufr;
|
||||
}
|
||||
n = mp->msg_bufr - mp->msg_bufx;
|
||||
if (n < 0) /* bufr < bufx */
|
||||
writer = (MSG_BSIZE - mp->msg_bufx) + mp->msg_bufr;
|
||||
else if (n == 0)
|
||||
writer = MSG_BSIZE;
|
||||
else {
|
||||
writer = n;
|
||||
infront = n;
|
||||
}
|
||||
if (len > writer) {
|
||||
/*
|
||||
* won't fit. the total number of bytes to be written is
|
||||
* greater than the number available. the buffer is full.
|
||||
* throw away the old data and keep the current data by resetting
|
||||
* the 'writer' pointer to the current 'reader' position. Bump the
|
||||
* overrun counter in case anyone wants to look at it for debugging.
|
||||
*/
|
||||
lp->sc_overrun++;
|
||||
mp->msg_bufx = mp->msg_bufr;
|
||||
goto again;
|
||||
}
|
||||
if (infront > len)
|
||||
infront = len;
|
||||
bcopy(buf, &mp->msg_bufc[mp->msg_bufx], infront);
|
||||
mp->msg_bufx += infront;
|
||||
len -= infront;
|
||||
buf += infront;
|
||||
}
|
||||
splx(s);
|
||||
return(err);
|
||||
if (mp->msg_magic != MSG_MAGIC || (len > MSG_BSIZE))
|
||||
return(-1);
|
||||
/*
|
||||
* Hate to do this but since this can be called from anywhere in the kernel
|
||||
* we have to hold off any interrupt service routines so they don't change
|
||||
* things. This looks like a lot of code but it isn't really.
|
||||
*/
|
||||
s = splhigh();
|
||||
while (len) {
|
||||
again: infront = MSG_BSIZE - mp->msg_bufx;
|
||||
if (infront <= 0) {
|
||||
mp->msg_bufx = 0;
|
||||
infront = MSG_BSIZE - mp->msg_bufr;
|
||||
}
|
||||
n = mp->msg_bufr - mp->msg_bufx;
|
||||
if (n < 0) /* bufr < bufx */
|
||||
writer = (MSG_BSIZE - mp->msg_bufx) + mp->msg_bufr;
|
||||
else if (n == 0)
|
||||
writer = MSG_BSIZE;
|
||||
else {
|
||||
writer = n;
|
||||
infront = n;
|
||||
}
|
||||
if (len > writer) {
|
||||
/*
|
||||
* won't fit. the total number of bytes to be written is
|
||||
* greater than the number available. the buffer is full.
|
||||
* throw away the old data and keep the current data by resetting
|
||||
* the 'writer' pointer to the current 'reader' position. Bump the
|
||||
* overrun counter in case anyone wants to look at it for debugging.
|
||||
*/
|
||||
lp->sc_overrun++;
|
||||
mp->msg_bufx = mp->msg_bufr;
|
||||
goto again;
|
||||
}
|
||||
if (infront > len)
|
||||
infront = len;
|
||||
bcopy(buf, &mp->msg_bufc[mp->msg_bufx], infront);
|
||||
mp->msg_bufx += infront;
|
||||
len -= infront;
|
||||
buf += infront;
|
||||
}
|
||||
splx(s);
|
||||
return(err);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -326,11 +326,11 @@ again: infront = MSG_BSIZE - mp->msg_bufx;
|
||||
int
|
||||
loginit()
|
||||
{
|
||||
register struct msgbuf *mp;
|
||||
register struct msgbuf *mp;
|
||||
|
||||
for (mp = &msgbuf[0]; mp < &msgbuf[NLOG]; mp++) {
|
||||
mp->msg_magic = MSG_MAGIC;
|
||||
mp->msg_bufx = mp->msg_bufr = 0;
|
||||
}
|
||||
return(0);
|
||||
for (mp = &msgbuf[0]; mp < &msgbuf[NLOG]; mp++) {
|
||||
mp->msg_magic = MSG_MAGIC;
|
||||
mp->msg_bufx = mp->msg_bufr = 0;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#include "systm.h"
|
||||
#include "syslog.h"
|
||||
|
||||
#define TOCONS 0x1
|
||||
#define TOTTY 0x2
|
||||
#define TOLOG 0x4
|
||||
#define TOCONS 0x1
|
||||
#define TOTTY 0x2
|
||||
#define TOLOG 0x4
|
||||
|
||||
/*
|
||||
* In case console is off,
|
||||
* panicstr contains argument to last
|
||||
* call to panic.
|
||||
*/
|
||||
char *panicstr;
|
||||
char *panicstr;
|
||||
|
||||
/*
|
||||
* Print a character on console or users terminal.
|
||||
@@ -32,38 +32,38 @@ char *panicstr;
|
||||
*/
|
||||
static void
|
||||
putchar (c, flags, tp)
|
||||
int c, flags;
|
||||
register struct tty *tp;
|
||||
int c, flags;
|
||||
register struct tty *tp;
|
||||
{
|
||||
if (flags & TOTTY) {
|
||||
register int s = spltty();
|
||||
if (flags & TOTTY) {
|
||||
register int s = spltty();
|
||||
|
||||
if (tp && (tp->t_state & (TS_CARR_ON | TS_ISOPEN)) ==
|
||||
(TS_CARR_ON | TS_ISOPEN)) {
|
||||
if (c == '\n')
|
||||
(void) ttyoutput('\r', tp);
|
||||
(void) ttyoutput(c, tp);
|
||||
ttstart(tp);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
if (tp && (tp->t_state & (TS_CARR_ON | TS_ISOPEN)) ==
|
||||
(TS_CARR_ON | TS_ISOPEN)) {
|
||||
if (c == '\n')
|
||||
(void) ttyoutput('\r', tp);
|
||||
(void) ttyoutput(c, tp);
|
||||
ttstart(tp);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
#ifdef LOG_ENABLED
|
||||
if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177) {
|
||||
char sym = c;
|
||||
logwrt (&sym, 1, logMSG);
|
||||
}
|
||||
if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177) {
|
||||
char sym = c;
|
||||
logwrt (&sym, 1, logMSG);
|
||||
}
|
||||
#endif
|
||||
if ((flags & TOCONS) && c != '\0')
|
||||
cnputc(c);
|
||||
if ((flags & TOCONS) && c != '\0')
|
||||
cnputc(c);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
mkhex (unsigned ch)
|
||||
{
|
||||
ch &= 15;
|
||||
if (ch > 9)
|
||||
return ch + 'a' - 10;
|
||||
return ch + '0';
|
||||
ch &= 15;
|
||||
if (ch > 9)
|
||||
return ch + 'a' - 10;
|
||||
return ch + '0';
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -75,27 +75,27 @@ mkhex (unsigned ch)
|
||||
static char *
|
||||
ksprintn (char *nbuf, unsigned long ul, int base, int width, int *lenp)
|
||||
{
|
||||
char *p;
|
||||
char *p;
|
||||
|
||||
p = nbuf;
|
||||
*p = 0;
|
||||
for (;;) {
|
||||
*++p = mkhex (ul % base);
|
||||
ul /= base;
|
||||
if (--width > 0)
|
||||
continue;
|
||||
if (! ul)
|
||||
break;
|
||||
}
|
||||
if (lenp)
|
||||
*lenp = p - nbuf;
|
||||
return (p);
|
||||
p = nbuf;
|
||||
*p = 0;
|
||||
for (;;) {
|
||||
*++p = mkhex (ul % base);
|
||||
ul /= base;
|
||||
if (--width > 0)
|
||||
continue;
|
||||
if (! ul)
|
||||
break;
|
||||
}
|
||||
if (lenp)
|
||||
*lenp = p - nbuf;
|
||||
return (p);
|
||||
}
|
||||
|
||||
void puts(char *s, int flags, struct tty *ttyp)
|
||||
{
|
||||
while(*s)
|
||||
putchar(*(s++), flags, ttyp);
|
||||
putchar(*(s++), flags, ttyp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -107,7 +107,7 @@ void puts(char *s, int flags, struct tty *ttyp)
|
||||
* The format %b is supported to decode error registers.
|
||||
* Its usage is:
|
||||
*
|
||||
* printf("reg=%b\n", regval, "<base><arg>*");
|
||||
* printf("reg=%b\n", regval, "<base><arg>*");
|
||||
*
|
||||
* where <base> is the output base expressed as a control character, e.g.
|
||||
* \10 gives octal; \20 gives hex. Each arg is a sequence of characters,
|
||||
@@ -115,17 +115,17 @@ void puts(char *s, int flags, struct tty *ttyp)
|
||||
* the next characters (up to a control character, i.e. a character <= 32),
|
||||
* give the name of the register. Thus:
|
||||
*
|
||||
* kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
|
||||
* kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
|
||||
*
|
||||
* would produce output:
|
||||
*
|
||||
* reg=3<BITTWO,BITONE>
|
||||
* reg=3<BITTWO,BITONE>
|
||||
*
|
||||
* The format %D -- Hexdump, takes a pointer. Sharp flag - use `:' as
|
||||
* a separator, instead of a space. For example:
|
||||
*
|
||||
* ("%6D", ptr) -> XX XX XX XX XX XX
|
||||
* ("%#*D", len, ptr) -> XX:XX:XX:XX ...
|
||||
* ("%6D", ptr) -> XX XX XX XX XX XX
|
||||
* ("%#*D", len, ptr) -> XX:XX:XX:XX ...
|
||||
*/
|
||||
|
||||
#define PUTC(C) putchar(C,flags,ttyp)
|
||||
@@ -134,296 +134,307 @@ void puts(char *s, int flags, struct tty *ttyp)
|
||||
#define HIOFF "\e[0m"
|
||||
static void
|
||||
prf (fmt, ap, flags, ttyp)
|
||||
register char *fmt;
|
||||
register u_int *ap;
|
||||
int flags;
|
||||
struct tty *ttyp;
|
||||
register char *fmt;
|
||||
register u_int *ap;
|
||||
int flags;
|
||||
struct tty *ttyp;
|
||||
{
|
||||
#define va_arg(ap,type) *(type*) (void*) (ap++)
|
||||
#define va_arg(ap,type) *(type*) (void*) (ap++)
|
||||
|
||||
char *q, nbuf [sizeof(long) * 8 + 1];
|
||||
const char *s;
|
||||
int c, padding, base, lflag, ladjust, sharpflag, neg, dot, size;
|
||||
int n, width, dwidth, uppercase, extrazeros, sign;
|
||||
unsigned long ul;
|
||||
char *q, nbuf [sizeof(long) * 8 + 1];
|
||||
const char *s;
|
||||
int c, padding, base, lflag, ladjust, sharpflag, neg, dot, size;
|
||||
int n, width, dwidth, uppercase, extrazeros, sign;
|
||||
unsigned long ul;
|
||||
|
||||
#ifdef KERNEL_HIGHLIGHT
|
||||
puts(HION,flags,ttyp);
|
||||
puts(HION, flags, ttyp);
|
||||
#endif
|
||||
|
||||
if (! fmt)
|
||||
fmt = "(null)\n";
|
||||
if (! fmt)
|
||||
fmt = "(null)\n";
|
||||
|
||||
for (;;) {
|
||||
while ((c = *fmt++) != '%') {
|
||||
if (! c) {
|
||||
for (;;) {
|
||||
while ((c = *fmt++) != '%') {
|
||||
if (! c) {
|
||||
#ifdef KERNEL_HIGHLIGHT
|
||||
puts(HIOFF,flags,ttyp);
|
||||
puts(HIOFF, flags, ttyp);
|
||||
#endif
|
||||
return;
|
||||
return;
|
||||
}
|
||||
PUTC (c);
|
||||
}
|
||||
padding = ' ';
|
||||
width = 0; extrazeros = 0;
|
||||
lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
|
||||
sign = 0; dot = 0; uppercase = 0; dwidth = -1;
|
||||
reswitch: c = *fmt++;
|
||||
switch (c) {
|
||||
case '.':
|
||||
dot = 1;
|
||||
padding = ' ';
|
||||
dwidth = 0;
|
||||
goto reswitch;
|
||||
PUTC (c);
|
||||
}
|
||||
padding = ' ';
|
||||
width = 0; extrazeros = 0;
|
||||
lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
|
||||
sign = 0; dot = 0; uppercase = 0; dwidth = -1;
|
||||
reswitch:
|
||||
c = *fmt++;
|
||||
switch (c) {
|
||||
case '.':
|
||||
dot = 1;
|
||||
padding = ' ';
|
||||
dwidth = 0;
|
||||
goto reswitch;
|
||||
|
||||
case '#':
|
||||
sharpflag = 1;
|
||||
goto reswitch;
|
||||
case '#':
|
||||
sharpflag = 1;
|
||||
goto reswitch;
|
||||
|
||||
case '+':
|
||||
sign = -1;
|
||||
goto reswitch;
|
||||
case '+':
|
||||
sign = -1;
|
||||
goto reswitch;
|
||||
|
||||
case '-':
|
||||
ladjust = 1;
|
||||
goto reswitch;
|
||||
case '-':
|
||||
ladjust = 1;
|
||||
goto reswitch;
|
||||
|
||||
case '%':
|
||||
PUTC (c);
|
||||
break;
|
||||
case '%':
|
||||
PUTC (c);
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if (! dot) {
|
||||
width = va_arg (ap, int);
|
||||
if (width < 0) {
|
||||
ladjust = !ladjust;
|
||||
width = -width;
|
||||
}
|
||||
} else {
|
||||
dwidth = va_arg (ap, int);
|
||||
}
|
||||
goto reswitch;
|
||||
case '*':
|
||||
if (! dot) {
|
||||
width = va_arg (ap, int);
|
||||
if (width < 0) {
|
||||
ladjust = !ladjust;
|
||||
width = -width;
|
||||
}
|
||||
} else {
|
||||
dwidth = va_arg (ap, int);
|
||||
}
|
||||
goto reswitch;
|
||||
|
||||
case '0':
|
||||
if (! dot) {
|
||||
padding = '0';
|
||||
goto reswitch;
|
||||
}
|
||||
case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
for (n=0; ; ++fmt) {
|
||||
n = n * 10 + c - '0';
|
||||
c = *fmt;
|
||||
if (c < '0' || c > '9')
|
||||
break;
|
||||
}
|
||||
if (dot)
|
||||
dwidth = n;
|
||||
else
|
||||
width = n;
|
||||
goto reswitch;
|
||||
case '0':
|
||||
if (! dot) {
|
||||
padding = '0';
|
||||
goto reswitch;
|
||||
}
|
||||
case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
for (n=0; ; ++fmt) {
|
||||
n = n * 10 + c - '0';
|
||||
c = *fmt;
|
||||
if (c < '0' || c > '9')
|
||||
break;
|
||||
}
|
||||
if (dot)
|
||||
dwidth = n;
|
||||
else
|
||||
width = n;
|
||||
goto reswitch;
|
||||
|
||||
case 'b':
|
||||
ul = va_arg (ap, int);
|
||||
s = va_arg (ap, const char*);
|
||||
q = ksprintn (nbuf, ul, *s++, -1, 0);
|
||||
while (*q)
|
||||
PUTC (*q--);
|
||||
case 'b':
|
||||
ul = va_arg (ap, int);
|
||||
s = va_arg (ap, const char*);
|
||||
q = ksprintn (nbuf, ul, *s++, -1, 0);
|
||||
while (*q)
|
||||
PUTC (*q--);
|
||||
|
||||
if (! ul)
|
||||
break;
|
||||
size = 0;
|
||||
while (*s) {
|
||||
n = *s++;
|
||||
if ((char) (ul >> (n-1)) & 1) {
|
||||
PUTC (size ? ',' : '<');
|
||||
for (; (n = *s) > ' '; ++s)
|
||||
PUTC (n);
|
||||
size = 1;
|
||||
} else
|
||||
while (*s > ' ')
|
||||
++s;
|
||||
}
|
||||
if (size)
|
||||
PUTC ('>');
|
||||
break;
|
||||
if (! ul)
|
||||
break;
|
||||
size = 0;
|
||||
while (*s) {
|
||||
n = *s++;
|
||||
if ((char) (ul >> (n-1)) & 1) {
|
||||
PUTC (size ? ',' : '<');
|
||||
for (; (n = *s) > ' '; ++s)
|
||||
PUTC (n);
|
||||
size = 1;
|
||||
} else {
|
||||
while (*s > ' ')
|
||||
++s;
|
||||
}
|
||||
}
|
||||
if (size)
|
||||
PUTC ('>');
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (! ladjust && width > 0)
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
case 'c':
|
||||
if (! ladjust && width > 0) {
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
}
|
||||
|
||||
PUTC (va_arg (ap, int));
|
||||
PUTC (va_arg (ap, int));
|
||||
|
||||
if (ladjust && width > 0)
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
break;
|
||||
if (ladjust && width > 0) {
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
s = va_arg (ap, const char*);
|
||||
if (! width)
|
||||
width = 16;
|
||||
if (sharpflag)
|
||||
padding = ':';
|
||||
while (width--) {
|
||||
c = *s++;
|
||||
PUTC (mkhex (c >> 4));
|
||||
PUTC (mkhex (c));
|
||||
if (width)
|
||||
PUTC (padding);
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
s = va_arg (ap, const char*);
|
||||
if (! width)
|
||||
width = 16;
|
||||
if (sharpflag)
|
||||
padding = ':';
|
||||
while (width--) {
|
||||
c = *s++;
|
||||
PUTC (mkhex (c >> 4));
|
||||
PUTC (mkhex (c));
|
||||
if (width)
|
||||
PUTC (padding);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
ul = lflag ? va_arg (ap, long) : va_arg (ap, int);
|
||||
if (! sign) sign = 1;
|
||||
base = 10;
|
||||
goto number;
|
||||
case 'd':
|
||||
ul = lflag ? va_arg (ap, long) : va_arg (ap, int);
|
||||
if (! sign) sign = 1;
|
||||
base = 10;
|
||||
goto number;
|
||||
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
goto reswitch;
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
goto reswitch;
|
||||
|
||||
case 'o':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 8;
|
||||
goto nosign;
|
||||
case 'o':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 8;
|
||||
goto nosign;
|
||||
|
||||
case 'p':
|
||||
ul = (size_t) va_arg (ap, void*);
|
||||
if (! ul) {
|
||||
s = "(nil)";
|
||||
goto const_string;
|
||||
}
|
||||
base = 16;
|
||||
sharpflag = (width == 0);
|
||||
goto nosign;
|
||||
case 'p':
|
||||
ul = (size_t) va_arg (ap, void*);
|
||||
if (! ul) {
|
||||
s = "(nil)";
|
||||
goto const_string;
|
||||
}
|
||||
base = 16;
|
||||
sharpflag = (width == 0);
|
||||
goto nosign;
|
||||
|
||||
case 'n':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
sign ? (unsigned long) va_arg (ap, int) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 10;
|
||||
goto number;
|
||||
case 'n':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
sign ? (unsigned long) va_arg (ap, int) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 10;
|
||||
goto number;
|
||||
|
||||
case 's':
|
||||
s = va_arg (ap, char*);
|
||||
if (! s)
|
||||
s = (const char*) "(null)";
|
||||
case 's':
|
||||
s = va_arg (ap, char*);
|
||||
if (! s)
|
||||
s = (const char*) "(null)";
|
||||
const_string:
|
||||
if (! dot)
|
||||
n = strlen (s);
|
||||
else
|
||||
for (n=0; n<dwidth && s[n]; n++)
|
||||
continue;
|
||||
if (! dot)
|
||||
n = strlen (s);
|
||||
else
|
||||
for (n=0; n<dwidth && s[n]; n++)
|
||||
continue;
|
||||
|
||||
width -= n;
|
||||
width -= n;
|
||||
|
||||
if (! ladjust && width > 0)
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
while (n--)
|
||||
PUTC (*s++);
|
||||
if (ladjust && width > 0)
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
break;
|
||||
if (! ladjust && width > 0) {
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
}
|
||||
while (n--)
|
||||
PUTC (*s++);
|
||||
if (ladjust && width > 0) {
|
||||
while (width--)
|
||||
PUTC (' ');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 10;
|
||||
goto nosign;
|
||||
case 'u':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 10;
|
||||
goto nosign;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 16;
|
||||
uppercase = (c == 'X');
|
||||
goto nosign;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
sign ? (unsigned long) va_arg (ap, int) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 16;
|
||||
uppercase = (c == 'Z');
|
||||
goto number;
|
||||
case 'x':
|
||||
case 'X':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 16;
|
||||
uppercase = (c == 'X');
|
||||
goto nosign;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
ul = lflag ? va_arg (ap, unsigned long) :
|
||||
sign ? (unsigned long) va_arg (ap, int) :
|
||||
va_arg (ap, unsigned int);
|
||||
base = 16;
|
||||
uppercase = (c == 'Z');
|
||||
goto number;
|
||||
nosign:
|
||||
sign = 0;
|
||||
number:
|
||||
if (sign && ((long) ul != 0L)) {
|
||||
if ((long) ul < 0L) {
|
||||
neg = '-';
|
||||
ul = -(long) ul;
|
||||
} else if (sign < 0)
|
||||
neg = '+';
|
||||
}
|
||||
if (dwidth >= (int) sizeof(nbuf)) {
|
||||
extrazeros = dwidth - sizeof(nbuf) + 1;
|
||||
dwidth = sizeof(nbuf) - 1;
|
||||
}
|
||||
s = ksprintn (nbuf, ul, base, dwidth, &size);
|
||||
if (sharpflag && ul != 0) {
|
||||
if (base == 8)
|
||||
size++;
|
||||
else if (base == 16)
|
||||
size += 2;
|
||||
}
|
||||
if (neg)
|
||||
size++;
|
||||
|
||||
nosign: sign = 0;
|
||||
number: if (sign && ((long) ul != 0L)) {
|
||||
if ((long) ul < 0L) {
|
||||
neg = '-';
|
||||
ul = -(long) ul;
|
||||
} else if (sign < 0)
|
||||
neg = '+';
|
||||
}
|
||||
if (dwidth >= (int) sizeof(nbuf)) {
|
||||
extrazeros = dwidth - sizeof(nbuf) + 1;
|
||||
dwidth = sizeof(nbuf) - 1;
|
||||
}
|
||||
s = ksprintn (nbuf, ul, base, dwidth, &size);
|
||||
if (sharpflag && ul != 0) {
|
||||
if (base == 8)
|
||||
size++;
|
||||
else if (base == 16)
|
||||
size += 2;
|
||||
}
|
||||
if (neg)
|
||||
size++;
|
||||
if (! ladjust && width && padding == ' ' &&
|
||||
(width -= size) > 0) {
|
||||
do {
|
||||
PUTC (' ');
|
||||
} while (--width > 0);
|
||||
}
|
||||
|
||||
if (! ladjust && width && padding == ' ' &&
|
||||
(width -= size) > 0)
|
||||
do {
|
||||
PUTC (' ');
|
||||
} while (--width > 0);
|
||||
if (neg)
|
||||
PUTC (neg);
|
||||
|
||||
if (neg)
|
||||
PUTC (neg);
|
||||
if (sharpflag && ul != 0) {
|
||||
if (base == 8) {
|
||||
PUTC ('0');
|
||||
} else if (base == 16) {
|
||||
PUTC ('0');
|
||||
PUTC (uppercase ? 'X' : 'x');
|
||||
}
|
||||
}
|
||||
|
||||
if (sharpflag && ul != 0) {
|
||||
if (base == 8) {
|
||||
PUTC ('0');
|
||||
} else if (base == 16) {
|
||||
PUTC ('0');
|
||||
PUTC (uppercase ? 'X' : 'x');
|
||||
}
|
||||
}
|
||||
if (extrazeros) {
|
||||
do {
|
||||
PUTC ('0');
|
||||
} while (--extrazeros > 0);
|
||||
}
|
||||
|
||||
if (extrazeros)
|
||||
do {
|
||||
PUTC ('0');
|
||||
} while (--extrazeros > 0);
|
||||
if (! ladjust && width && (width -= size) > 0) {
|
||||
do {
|
||||
PUTC (padding);
|
||||
} while (--width > 0);
|
||||
}
|
||||
|
||||
if (! ladjust && width && (width -= size) > 0)
|
||||
do {
|
||||
PUTC (padding);
|
||||
} while (--width > 0);
|
||||
for (; *s; --s) {
|
||||
if (uppercase && *s>='a' && *s<='z') {
|
||||
PUTC (*s + 'A' - 'a');
|
||||
} else {
|
||||
PUTC (*s);
|
||||
}
|
||||
}
|
||||
|
||||
for (; *s; --s) {
|
||||
if (uppercase && *s>='a' && *s<='z') {
|
||||
PUTC (*s + 'A' - 'a');
|
||||
} else {
|
||||
PUTC (*s);
|
||||
}
|
||||
}
|
||||
|
||||
if (ladjust && width && (width -= size) > 0)
|
||||
do {
|
||||
PUTC (' ');
|
||||
} while (--width > 0);
|
||||
break;
|
||||
default:
|
||||
PUTC ('%');
|
||||
if (lflag)
|
||||
PUTC ('l');
|
||||
PUTC (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ladjust && width && (width -= size) > 0) {
|
||||
do {
|
||||
PUTC (' ');
|
||||
} while (--width > 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PUTC ('%');
|
||||
if (lflag)
|
||||
PUTC ('l');
|
||||
PUTC (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef KERNEL_HIGHLIGHT
|
||||
puts(HIOFF,flags,ttyp);
|
||||
#endif
|
||||
@@ -431,11 +442,11 @@ number: if (sign && ((long) ul != 0L)) {
|
||||
|
||||
static void
|
||||
logpri (level)
|
||||
int level;
|
||||
int level;
|
||||
{
|
||||
putchar ('<', TOLOG, (struct tty*) 0);
|
||||
prf ("%u", &level, TOLOG, (struct tty*) 0);
|
||||
putchar ('>', TOLOG, (struct tty*) 0);
|
||||
putchar ('<', TOLOG, (struct tty*) 0);
|
||||
prf ("%u", &level, TOLOG, (struct tty*) 0);
|
||||
putchar ('>', TOLOG, (struct tty*) 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -446,20 +457,20 @@ logpri (level)
|
||||
*
|
||||
* One additional format: %b is supported to decode error registers.
|
||||
* Usage is:
|
||||
* printf("reg=%b\n", regval, "<base><arg>*");
|
||||
* printf("reg=%b\n", regval, "<base><arg>*");
|
||||
* Where <base> is the output base expressed as a control character,
|
||||
* e.g. \10 gives octal; \20 gives hex. Each arg is a sequence of
|
||||
* characters, the first of which gives the bit number to be inspected
|
||||
* (origin 1), and the next characters (up to a control character, i.e.
|
||||
* a character <= 32), give the name of the register. Thus
|
||||
* printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
|
||||
* printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
|
||||
* would produce output:
|
||||
* reg=3<BITTWO,BITONE>
|
||||
* reg=3<BITTWO,BITONE>
|
||||
*/
|
||||
void
|
||||
printf(char *fmt, ...)
|
||||
{
|
||||
prf(fmt, &fmt + 1, TOCONS | TOLOG, (struct tty *)0);
|
||||
prf(fmt, &fmt + 1, TOCONS | TOLOG, (struct tty *)0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -488,14 +499,14 @@ void _printf_cdnopsuxX(char *fmt, ...)
|
||||
void
|
||||
uprintf (char *fmt, ...)
|
||||
{
|
||||
register struct tty *tp;
|
||||
register struct tty *tp;
|
||||
|
||||
tp = u.u_ttyp;
|
||||
if (tp == NULL)
|
||||
return;
|
||||
tp = u.u_ttyp;
|
||||
if (tp == NULL)
|
||||
return;
|
||||
|
||||
if (ttycheckoutq (tp, 1))
|
||||
prf (fmt, &fmt+1, TOTTY, tp);
|
||||
if (ttycheckoutq (tp, 1))
|
||||
prf (fmt, &fmt+1, TOTTY, tp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -507,16 +518,16 @@ uprintf (char *fmt, ...)
|
||||
void
|
||||
tprintf (register struct tty *tp, char *fmt, ...)
|
||||
{
|
||||
int flags = TOTTY | TOLOG;
|
||||
int flags = TOTTY | TOLOG;
|
||||
|
||||
logpri (LOG_INFO);
|
||||
if (tp == (struct tty*) NULL)
|
||||
tp = &cnttys[0];
|
||||
if (ttycheckoutq (tp, 0) == 0)
|
||||
flags = TOLOG;
|
||||
prf (fmt, &fmt + 1, flags, tp);
|
||||
logpri (LOG_INFO);
|
||||
if (tp == (struct tty*) NULL)
|
||||
tp = &cnttys[0];
|
||||
if (ttycheckoutq (tp, 0) == 0)
|
||||
flags = TOLOG;
|
||||
prf (fmt, &fmt + 1, flags, tp);
|
||||
#ifdef LOG_ENABLED
|
||||
logwakeup (logMSG);
|
||||
logwakeup (logMSG);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -529,17 +540,17 @@ tprintf (register struct tty *tp, char *fmt, ...)
|
||||
void
|
||||
log (int level, char *fmt, ...)
|
||||
{
|
||||
register int s = splhigh();
|
||||
register int s = splhigh();
|
||||
|
||||
logpri(level);
|
||||
prf(fmt, &fmt + 1, TOLOG, (struct tty *)0);
|
||||
splx(s);
|
||||
logpri(level);
|
||||
prf(fmt, &fmt + 1, TOLOG, (struct tty *)0);
|
||||
splx(s);
|
||||
#ifdef LOG_ENABLED
|
||||
if (! logisopen(logMSG))
|
||||
if (! logisopen(logMSG))
|
||||
#endif
|
||||
prf(fmt, &fmt + 1, TOCONS, (struct tty *)0);
|
||||
prf(fmt, &fmt + 1, TOCONS, (struct tty *)0);
|
||||
#ifdef LOG_ENABLED
|
||||
logwakeup(logMSG);
|
||||
logwakeup(logMSG);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -551,15 +562,15 @@ log (int level, char *fmt, ...)
|
||||
*/
|
||||
void
|
||||
panic(s)
|
||||
char *s;
|
||||
char *s;
|
||||
{
|
||||
int bootopt = RB_HALT | RB_DUMP;
|
||||
int bootopt = RB_HALT | RB_DUMP;
|
||||
|
||||
if (panicstr) {
|
||||
bootopt |= RB_NOSYNC;
|
||||
} else {
|
||||
panicstr = s;
|
||||
}
|
||||
printf ("panic: %s\n", s);
|
||||
boot (rootdev, bootopt);
|
||||
if (panicstr) {
|
||||
bootopt |= RB_NOSYNC;
|
||||
} else {
|
||||
panicstr = s;
|
||||
}
|
||||
printf ("panic: %s\n", s);
|
||||
boot (rootdev, bootopt);
|
||||
}
|
||||
|
||||
@@ -43,37 +43,37 @@
|
||||
*/
|
||||
size_t
|
||||
malloc (mp, size)
|
||||
struct map *mp;
|
||||
register size_t size;
|
||||
struct map *mp;
|
||||
register size_t size;
|
||||
{
|
||||
register struct mapent *bp, *ep;
|
||||
size_t addr;
|
||||
register struct mapent *bp, *ep;
|
||||
size_t addr;
|
||||
|
||||
if (! size)
|
||||
panic ("malloc: size = 0");
|
||||
/*
|
||||
* Search for a piece of the resource map which has enough
|
||||
* free space to accomodate the request.
|
||||
*/
|
||||
for (bp = mp->m_map; bp->m_size; ++bp)
|
||||
if (bp->m_size >= size) {
|
||||
/*
|
||||
* Allocate from the map. If we allocated the entire
|
||||
* piece, move the rest of the map to the left.
|
||||
*/
|
||||
addr = bp->m_addr;
|
||||
bp->m_size -= size;
|
||||
if (bp->m_size)
|
||||
bp->m_addr += size;
|
||||
else for (ep = bp;; ++ep) {
|
||||
*ep = *++bp;
|
||||
if (!bp->m_size)
|
||||
break;
|
||||
}
|
||||
return(addr);
|
||||
}
|
||||
/* no entries big enough */
|
||||
return 0;
|
||||
if (! size)
|
||||
panic ("malloc: size = 0");
|
||||
/*
|
||||
* Search for a piece of the resource map which has enough
|
||||
* free space to accomodate the request.
|
||||
*/
|
||||
for (bp = mp->m_map; bp->m_size; ++bp)
|
||||
if (bp->m_size >= size) {
|
||||
/*
|
||||
* Allocate from the map. If we allocated the entire
|
||||
* piece, move the rest of the map to the left.
|
||||
*/
|
||||
addr = bp->m_addr;
|
||||
bp->m_size -= size;
|
||||
if (bp->m_size)
|
||||
bp->m_addr += size;
|
||||
else for (ep = bp;; ++ep) {
|
||||
*ep = *++bp;
|
||||
if (!bp->m_size)
|
||||
break;
|
||||
}
|
||||
return(addr);
|
||||
}
|
||||
/* no entries big enough */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -82,88 +82,88 @@ malloc (mp, size)
|
||||
*/
|
||||
void
|
||||
mfree (mp, size, addr)
|
||||
struct map *mp;
|
||||
size_t size;
|
||||
register size_t addr;
|
||||
struct map *mp;
|
||||
size_t size;
|
||||
register size_t addr;
|
||||
{
|
||||
register struct mapent *bp, *ep;
|
||||
struct mapent *start;
|
||||
register struct mapent *bp, *ep;
|
||||
struct mapent *start;
|
||||
|
||||
if (! size)
|
||||
return;
|
||||
/* the address must not be 0, or the protocol has broken down. */
|
||||
if (! addr)
|
||||
panic ("mfree: addr = 0");
|
||||
if (! size)
|
||||
return;
|
||||
/* the address must not be 0, or the protocol has broken down. */
|
||||
if (! addr)
|
||||
panic ("mfree: addr = 0");
|
||||
|
||||
/*
|
||||
* locate the piece of the map which starts after the
|
||||
* returned space (or the end of the map).
|
||||
*/
|
||||
bp = mp->m_map;
|
||||
/* printf ("mfree (size=%u, addr=%u) m_map = %08x\n", size, addr, bp); */
|
||||
/*
|
||||
* locate the piece of the map which starts after the
|
||||
* returned space (or the end of the map).
|
||||
*/
|
||||
bp = mp->m_map;
|
||||
/* printf ("mfree (size=%u, addr=%u) m_map = %08x\n", size, addr, bp); */
|
||||
|
||||
while (bp->m_size && bp->m_addr <= addr) {
|
||||
/*printf ("skip m_map[%d]: m_addr %u <= addr %u\n", bp - mp->m_map, bp->m_addr, addr);*/
|
||||
++bp;
|
||||
}
|
||||
while (bp->m_size && bp->m_addr <= addr) {
|
||||
/*printf ("skip m_map[%d]: m_addr %u <= addr %u\n", bp - mp->m_map, bp->m_addr, addr);*/
|
||||
++bp;
|
||||
}
|
||||
|
||||
/* if there is a piece on the left abutting us, combine with it. */
|
||||
ep = bp - 1;
|
||||
if (bp != mp->m_map && ep->m_addr + ep->m_size >= addr) {
|
||||
/* if there is a piece on the left abutting us, combine with it. */
|
||||
ep = bp - 1;
|
||||
if (bp != mp->m_map && ep->m_addr + ep->m_size >= addr) {
|
||||
#ifdef DIAGNOSTIC
|
||||
/* any overlap is an internal error */
|
||||
if (ep->m_addr + ep->m_size > addr)
|
||||
panic("mfree overlap #1");
|
||||
/* any overlap is an internal error */
|
||||
if (ep->m_addr + ep->m_size > addr)
|
||||
panic("mfree overlap #1");
|
||||
#endif
|
||||
/* add into piece on the left by increasing its size. */
|
||||
ep->m_size += size;
|
||||
/* add into piece on the left by increasing its size. */
|
||||
ep->m_size += size;
|
||||
|
||||
/*
|
||||
* if the combined piece abuts the piece on the right now,
|
||||
* compress it in also, by shifting the remaining pieces
|
||||
* of the map over.
|
||||
*/
|
||||
if (bp->m_size && addr + size >= bp->m_addr) {
|
||||
/*
|
||||
* if the combined piece abuts the piece on the right now,
|
||||
* compress it in also, by shifting the remaining pieces
|
||||
* of the map over.
|
||||
*/
|
||||
if (bp->m_size && addr + size >= bp->m_addr) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (addr + size > bp->m_addr)
|
||||
panic("mfree overlap #2");
|
||||
if (addr + size > bp->m_addr)
|
||||
panic("mfree overlap #2");
|
||||
#endif
|
||||
ep->m_size += bp->m_size;
|
||||
do {
|
||||
*++ep = *++bp;
|
||||
} while (bp->m_size);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ep->m_size += bp->m_size;
|
||||
do {
|
||||
*++ep = *++bp;
|
||||
} while (bp->m_size);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* if doesn't abut on the left, check for abutting on the right. */
|
||||
if (bp->m_size && addr + size >= bp->m_addr) {
|
||||
/* if doesn't abut on the left, check for abutting on the right. */
|
||||
if (bp->m_size && addr + size >= bp->m_addr) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (addr + size > bp->m_addr)
|
||||
panic("mfree overlap #3");
|
||||
if (addr + size > bp->m_addr)
|
||||
panic("mfree overlap #3");
|
||||
#endif
|
||||
bp->m_addr = addr;
|
||||
bp->m_size += size;
|
||||
return;
|
||||
}
|
||||
bp->m_addr = addr;
|
||||
bp->m_size += size;
|
||||
return;
|
||||
}
|
||||
|
||||
/* doesn't abut. Make a new entry and check for map overflow. */
|
||||
for (start = bp; bp->m_size; ++bp);
|
||||
if (++bp > mp->m_limit)
|
||||
/*
|
||||
* too many segments; if this happens, the correct fix
|
||||
* is to make the map bigger; you can't afford to lose
|
||||
* chunks of the map. If you need to implement recovery,
|
||||
* use the above "for" loop to find the smallest entry
|
||||
* and toss it.
|
||||
*/
|
||||
printf("%s: overflow, lost %u clicks at 0%o\n",
|
||||
mp->m_name, size, addr);
|
||||
else {
|
||||
for (ep = bp - 1; ep >= start; *bp-- = *ep--);
|
||||
start->m_addr = addr;
|
||||
start->m_size = size;
|
||||
}
|
||||
/* doesn't abut. Make a new entry and check for map overflow. */
|
||||
for (start = bp; bp->m_size; ++bp);
|
||||
if (++bp > mp->m_limit)
|
||||
/*
|
||||
* too many segments; if this happens, the correct fix
|
||||
* is to make the map bigger; you can't afford to lose
|
||||
* chunks of the map. If you need to implement recovery,
|
||||
* use the above "for" loop to find the smallest entry
|
||||
* and toss it.
|
||||
*/
|
||||
printf("%s: overflow, lost %u clicks at 0%o\n",
|
||||
mp->m_name, size, addr);
|
||||
else {
|
||||
for (ep = bp - 1; ep >= start; *bp-- = *ep--);
|
||||
start->m_addr = addr;
|
||||
start->m_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -175,56 +175,58 @@ mfree (mp, size, addr)
|
||||
*/
|
||||
size_t
|
||||
malloc3 (mp, d_size, s_size, u_size, a)
|
||||
struct map *mp;
|
||||
size_t d_size, s_size, u_size;
|
||||
size_t a[3];
|
||||
struct map *mp;
|
||||
size_t d_size, s_size, u_size;
|
||||
size_t a[3];
|
||||
{
|
||||
register struct mapent *bp, *remap;
|
||||
register int next;
|
||||
struct mapent *madd[3];
|
||||
size_t sizes[3];
|
||||
int found;
|
||||
register struct mapent *bp, *remap;
|
||||
register int next;
|
||||
struct mapent *madd[3];
|
||||
size_t sizes[3];
|
||||
int found;
|
||||
|
||||
sizes[0] = d_size;
|
||||
sizes[1] = s_size;
|
||||
sizes[2] = u_size;
|
||||
/*
|
||||
* note, this has to work for d_size and s_size of zero,
|
||||
* since init() comes in that way.
|
||||
*/
|
||||
madd[0] = madd[1] = madd[2] = remap = NULL;
|
||||
for (found = 0, bp = mp->m_map; bp->m_size; ++bp)
|
||||
for (next = 0; next < 3; ++next)
|
||||
if (!madd[next] && sizes[next] <= bp->m_size) {
|
||||
madd[next] = bp;
|
||||
bp->m_size -= sizes[next];
|
||||
if (!bp->m_size && !remap)
|
||||
remap = bp;
|
||||
if (++found == 3)
|
||||
goto resolve;
|
||||
}
|
||||
sizes[0] = d_size;
|
||||
sizes[1] = s_size;
|
||||
sizes[2] = u_size;
|
||||
/*
|
||||
* note, this has to work for d_size and s_size of zero,
|
||||
* since init() comes in that way.
|
||||
*/
|
||||
madd[0] = madd[1] = madd[2] = remap = NULL;
|
||||
for (found = 0, bp = mp->m_map; bp->m_size; ++bp)
|
||||
for (next = 0; next < 3; ++next)
|
||||
if (!madd[next] && sizes[next] <= bp->m_size) {
|
||||
madd[next] = bp;
|
||||
bp->m_size -= sizes[next];
|
||||
if (!bp->m_size && !remap)
|
||||
remap = bp;
|
||||
if (++found == 3)
|
||||
goto resolve;
|
||||
}
|
||||
|
||||
/* couldn't get it all; restore the old sizes, try again */
|
||||
for (next = 0; next < 3; ++next)
|
||||
if (madd[next])
|
||||
madd[next]->m_size += sizes[next];
|
||||
return 0;
|
||||
/* couldn't get it all; restore the old sizes, try again */
|
||||
for (next = 0; next < 3; ++next)
|
||||
if (madd[next])
|
||||
madd[next]->m_size += sizes[next];
|
||||
return 0;
|
||||
|
||||
resolve:
|
||||
/* got it all, update the addresses. */
|
||||
for (next = 0; next < 3; ++next) {
|
||||
bp = madd[next];
|
||||
a[next] = bp->m_addr;
|
||||
bp->m_addr += sizes[next];
|
||||
}
|
||||
/* got it all, update the addresses. */
|
||||
for (next = 0; next < 3; ++next) {
|
||||
bp = madd[next];
|
||||
a[next] = bp->m_addr;
|
||||
bp->m_addr += sizes[next];
|
||||
}
|
||||
|
||||
/* remove any entries of size 0; addr of 0 terminates */
|
||||
if (remap)
|
||||
for (bp = remap + 1;; ++bp)
|
||||
if (bp->m_size || !bp->m_addr) {
|
||||
*remap++ = *bp;
|
||||
if (!bp->m_addr)
|
||||
break;
|
||||
}
|
||||
return(a[2]);
|
||||
/* remove any entries of size 0; addr of 0 terminates */
|
||||
if (remap) {
|
||||
for (bp = remap + 1;; ++bp) {
|
||||
if (bp->m_size || !bp->m_addr) {
|
||||
*remap++ = *bp;
|
||||
if (!bp->m_addr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(a[2]);
|
||||
}
|
||||
|
||||
@@ -15,51 +15,51 @@
|
||||
#include "kernel.h"
|
||||
#include "systm.h"
|
||||
|
||||
int selwait;
|
||||
int selwait;
|
||||
|
||||
static void
|
||||
rwuio (uio)
|
||||
register struct uio *uio;
|
||||
register struct uio *uio;
|
||||
{
|
||||
struct a {
|
||||
int fdes;
|
||||
};
|
||||
register struct file *fp;
|
||||
register struct iovec *iov;
|
||||
u_int i, count;
|
||||
off_t total;
|
||||
struct a {
|
||||
int fdes;
|
||||
};
|
||||
register struct file *fp;
|
||||
register struct iovec *iov;
|
||||
u_int i, count;
|
||||
off_t total;
|
||||
|
||||
GETF(fp, ((struct a *)u.u_arg)->fdes);
|
||||
if ((fp->f_flag & (uio->uio_rw == UIO_READ ? FREAD : FWRITE)) == 0) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
total = 0;
|
||||
uio->uio_resid = 0;
|
||||
for (iov = uio->uio_iov, i = 0; i < uio->uio_iovcnt; i++, iov++)
|
||||
total += iov->iov_len;
|
||||
GETF(fp, ((struct a *)u.u_arg)->fdes);
|
||||
if ((fp->f_flag & (uio->uio_rw == UIO_READ ? FREAD : FWRITE)) == 0) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
total = 0;
|
||||
uio->uio_resid = 0;
|
||||
for (iov = uio->uio_iov, i = 0; i < uio->uio_iovcnt; i++, iov++)
|
||||
total += iov->iov_len;
|
||||
|
||||
uio->uio_resid = total;
|
||||
if (uio->uio_resid != total) { /* check wraparound */
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
count = uio->uio_resid;
|
||||
if (setjmp (&u.u_qsave)) {
|
||||
/*
|
||||
* The ONLY way we can get here is via the longjump in sleep. Thus signals
|
||||
* have been checked and u_error set accordingly. If no bytes have been
|
||||
* transferred then all that needs to be done now is 'return'; the system
|
||||
* call will either be restarted or reported as interrupted. If bytes have
|
||||
* been transferred then we need to calculate the number of bytes transferred.
|
||||
*/
|
||||
if (uio->uio_resid == count)
|
||||
return;
|
||||
u.u_error = 0;
|
||||
} else
|
||||
u.u_error = (*Fops[fp->f_type]->fo_rw) (fp, uio);
|
||||
uio->uio_resid = total;
|
||||
if (uio->uio_resid != total) { /* check wraparound */
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
count = uio->uio_resid;
|
||||
if (setjmp (&u.u_qsave)) {
|
||||
/*
|
||||
* The ONLY way we can get here is via the longjump in sleep. Thus signals
|
||||
* have been checked and u_error set accordingly. If no bytes have been
|
||||
* transferred then all that needs to be done now is 'return'; the system
|
||||
* call will either be restarted or reported as interrupted. If bytes have
|
||||
* been transferred then we need to calculate the number of bytes transferred.
|
||||
*/
|
||||
if (uio->uio_resid == count)
|
||||
return;
|
||||
u.u_error = 0;
|
||||
} else
|
||||
u.u_error = (*Fops[fp->f_type]->fo_rw) (fp, uio);
|
||||
|
||||
u.u_rval = count - uio->uio_resid;
|
||||
u.u_rval = count - uio->uio_resid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -68,45 +68,45 @@ rwuio (uio)
|
||||
void
|
||||
read()
|
||||
{
|
||||
register struct a {
|
||||
int fdes;
|
||||
char *cbuf;
|
||||
unsigned count;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
register struct a {
|
||||
int fdes;
|
||||
char *cbuf;
|
||||
unsigned count;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
|
||||
aiov.iov_base = (caddr_t)uap->cbuf;
|
||||
aiov.iov_len = uap->count;
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_rw = UIO_READ;
|
||||
rwuio (&auio);
|
||||
aiov.iov_base = (caddr_t)uap->cbuf;
|
||||
aiov.iov_len = uap->count;
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_rw = UIO_READ;
|
||||
rwuio (&auio);
|
||||
}
|
||||
|
||||
void
|
||||
readv()
|
||||
{
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct iovec *iovp;
|
||||
unsigned iovcnt;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov[16]; /* XXX */
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct iovec *iovp;
|
||||
unsigned iovcnt;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov[16]; /* XXX */
|
||||
|
||||
if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
auio.uio_iov = aiov;
|
||||
auio.uio_iovcnt = uap->iovcnt;
|
||||
auio.uio_rw = UIO_READ;
|
||||
u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov,
|
||||
uap->iovcnt * sizeof (struct iovec));
|
||||
if (u.u_error)
|
||||
return;
|
||||
rwuio (&auio);
|
||||
if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
auio.uio_iov = aiov;
|
||||
auio.uio_iovcnt = uap->iovcnt;
|
||||
auio.uio_rw = UIO_READ;
|
||||
u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov,
|
||||
uap->iovcnt * sizeof (struct iovec));
|
||||
if (u.u_error)
|
||||
return;
|
||||
rwuio (&auio);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,45 +115,45 @@ readv()
|
||||
void
|
||||
write()
|
||||
{
|
||||
register struct a {
|
||||
int fdes;
|
||||
char *cbuf;
|
||||
unsigned count;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
register struct a {
|
||||
int fdes;
|
||||
char *cbuf;
|
||||
unsigned count;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
aiov.iov_base = uap->cbuf;
|
||||
aiov.iov_len = uap->count;
|
||||
rwuio (&auio);
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
aiov.iov_base = uap->cbuf;
|
||||
aiov.iov_len = uap->count;
|
||||
rwuio (&auio);
|
||||
}
|
||||
|
||||
void
|
||||
writev()
|
||||
{
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct iovec *iovp;
|
||||
unsigned iovcnt;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov[16]; /* XXX */
|
||||
register struct a {
|
||||
int fdes;
|
||||
struct iovec *iovp;
|
||||
unsigned iovcnt;
|
||||
} *uap = (struct a *)u.u_arg;
|
||||
struct uio auio;
|
||||
struct iovec aiov[16]; /* XXX */
|
||||
|
||||
if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
auio.uio_iov = aiov;
|
||||
auio.uio_iovcnt = uap->iovcnt;
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov,
|
||||
uap->iovcnt * sizeof (struct iovec));
|
||||
if (u.u_error)
|
||||
return;
|
||||
rwuio (&auio);
|
||||
if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) {
|
||||
u.u_error = EINVAL;
|
||||
return;
|
||||
}
|
||||
auio.uio_iov = aiov;
|
||||
auio.uio_iovcnt = uap->iovcnt;
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov,
|
||||
uap->iovcnt * sizeof (struct iovec));
|
||||
if (u.u_error)
|
||||
return;
|
||||
rwuio (&auio);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -162,102 +162,102 @@ writev()
|
||||
void
|
||||
ioctl()
|
||||
{
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
long cmd;
|
||||
caddr_t cmarg;
|
||||
} *uap;
|
||||
u_int com;
|
||||
register struct file *fp;
|
||||
register struct a {
|
||||
int fdes;
|
||||
long cmd;
|
||||
caddr_t cmarg;
|
||||
} *uap;
|
||||
u_int com;
|
||||
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (! fp)
|
||||
return;
|
||||
if (! (fp->f_flag & (FREAD | FWRITE))) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
com = (u_int) uap->cmd;
|
||||
if (com & (IOC_IN | IOC_OUT)) {
|
||||
/* Check user address. */
|
||||
u_int nbytes = (com & ~(IOC_INOUT | IOC_VOID)) >> 16;
|
||||
if (baduaddr (uap->cmarg) ||
|
||||
baduaddr (uap->cmarg + nbytes - 1)) {
|
||||
u.u_error = EFAULT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
uap = (struct a *)u.u_arg;
|
||||
fp = getf(uap->fdes);
|
||||
if (! fp)
|
||||
return;
|
||||
if (! (fp->f_flag & (FREAD | FWRITE))) {
|
||||
u.u_error = EBADF;
|
||||
return;
|
||||
}
|
||||
com = (u_int) uap->cmd;
|
||||
if (com & (IOC_IN | IOC_OUT)) {
|
||||
/* Check user address. */
|
||||
u_int nbytes = (com & ~(IOC_INOUT | IOC_VOID)) >> 16;
|
||||
if (baduaddr (uap->cmarg) ||
|
||||
baduaddr (uap->cmarg + nbytes - 1)) {
|
||||
u.u_error = EFAULT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (com) {
|
||||
case FIOCLEX:
|
||||
u.u_pofile[uap->fdes] |= UF_EXCLOSE;
|
||||
return;
|
||||
case FIONCLEX:
|
||||
u.u_pofile[uap->fdes] &= ~UF_EXCLOSE;
|
||||
return;
|
||||
case FIONBIO:
|
||||
u.u_error = fset (fp, FNONBLOCK, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOASYNC:
|
||||
u.u_error = fset (fp, FASYNC, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOSETOWN:
|
||||
u.u_error = fsetown (fp, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOGETOWN:
|
||||
u.u_error = fgetown (fp, (int*) uap->cmarg);
|
||||
return;
|
||||
}
|
||||
u.u_error = (*Fops[fp->f_type]->fo_ioctl) (fp, com, uap->cmarg);
|
||||
switch (com) {
|
||||
case FIOCLEX:
|
||||
u.u_pofile[uap->fdes] |= UF_EXCLOSE;
|
||||
return;
|
||||
case FIONCLEX:
|
||||
u.u_pofile[uap->fdes] &= ~UF_EXCLOSE;
|
||||
return;
|
||||
case FIONBIO:
|
||||
u.u_error = fset (fp, FNONBLOCK, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOASYNC:
|
||||
u.u_error = fset (fp, FASYNC, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOSETOWN:
|
||||
u.u_error = fsetown (fp, *(int*) uap->cmarg);
|
||||
return;
|
||||
case FIOGETOWN:
|
||||
u.u_error = fgetown (fp, (int*) uap->cmarg);
|
||||
return;
|
||||
}
|
||||
u.u_error = (*Fops[fp->f_type]->fo_ioctl) (fp, com, uap->cmarg);
|
||||
}
|
||||
|
||||
int nselcoll;
|
||||
int nselcoll;
|
||||
|
||||
struct pselect_args {
|
||||
int nd;
|
||||
fd_set *in;
|
||||
fd_set *ou;
|
||||
fd_set *ex;
|
||||
struct timespec *ts;
|
||||
sigset_t *maskp;
|
||||
int nd;
|
||||
fd_set *in;
|
||||
fd_set *ou;
|
||||
fd_set *ex;
|
||||
struct timespec *ts;
|
||||
sigset_t *maskp;
|
||||
};
|
||||
|
||||
int
|
||||
selscan(ibits, obits, nfd, retval)
|
||||
fd_set *ibits, *obits;
|
||||
int nfd, *retval;
|
||||
fd_set *ibits, *obits;
|
||||
int nfd, *retval;
|
||||
{
|
||||
register int i, j, flag;
|
||||
fd_mask bits;
|
||||
struct file *fp;
|
||||
int which, n = 0;
|
||||
register int i, j, flag;
|
||||
fd_mask bits;
|
||||
struct file *fp;
|
||||
int which, n = 0;
|
||||
|
||||
for (which = 0; which < 3; which++) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
flag = FREAD; break;
|
||||
case 1:
|
||||
flag = FWRITE; break;
|
||||
case 2:
|
||||
flag = 0; break;
|
||||
}
|
||||
for (i = 0; i < nfd; i += NFDBITS) {
|
||||
bits = ibits[which].fds_bits[i/NFDBITS];
|
||||
while ((j = ffs(bits)) && i + --j < nfd) {
|
||||
bits &= ~(1L << j);
|
||||
fp = u.u_ofile[i + j];
|
||||
if (fp == NULL)
|
||||
return(EBADF);
|
||||
if ((*Fops[fp->f_type]->fo_select) (fp, flag)) {
|
||||
FD_SET(i + j, &obits[which]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*retval = n;
|
||||
return(0);
|
||||
for (which = 0; which < 3; which++) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
flag = FREAD; break;
|
||||
case 1:
|
||||
flag = FWRITE; break;
|
||||
case 2:
|
||||
flag = 0; break;
|
||||
}
|
||||
for (i = 0; i < nfd; i += NFDBITS) {
|
||||
bits = ibits[which].fds_bits[i/NFDBITS];
|
||||
while ((j = ffs(bits)) && i + --j < nfd) {
|
||||
bits &= ~(1L << j);
|
||||
fp = u.u_ofile[i + j];
|
||||
if (fp == NULL)
|
||||
return(EBADF);
|
||||
if ((*Fops[fp->f_type]->fo_select) (fp, flag)) {
|
||||
FD_SET(i + j, &obits[which]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*retval = n;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -265,127 +265,127 @@ selscan(ibits, obits, nfd, retval)
|
||||
*/
|
||||
static int
|
||||
select1(uap, is_pselect)
|
||||
register struct pselect_args *uap;
|
||||
int is_pselect;
|
||||
register struct pselect_args *uap;
|
||||
int is_pselect;
|
||||
{
|
||||
fd_set ibits[3], obits[3];
|
||||
struct timeval atv;
|
||||
sigset_t sigmsk;
|
||||
unsigned int timo = 0;
|
||||
register int error, ni;
|
||||
int ncoll, s;
|
||||
fd_set ibits[3], obits[3];
|
||||
struct timeval atv;
|
||||
sigset_t sigmsk;
|
||||
unsigned int timo = 0;
|
||||
register int error, ni;
|
||||
int ncoll, s;
|
||||
|
||||
bzero((caddr_t)ibits, sizeof(ibits));
|
||||
bzero((caddr_t)obits, sizeof(obits));
|
||||
if (uap->nd > NOFILE)
|
||||
uap->nd = NOFILE; /* forgiving, if slightly wrong */
|
||||
ni = howmany(uap->nd, NFDBITS);
|
||||
bzero((caddr_t)ibits, sizeof(ibits));
|
||||
bzero((caddr_t)obits, sizeof(obits));
|
||||
if (uap->nd > NOFILE)
|
||||
uap->nd = NOFILE; /* forgiving, if slightly wrong */
|
||||
ni = howmany(uap->nd, NFDBITS);
|
||||
|
||||
#define getbits(name, x) \
|
||||
if (uap->name) { \
|
||||
error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
|
||||
(unsigned)(ni * sizeof(fd_mask))); \
|
||||
if (error) \
|
||||
goto done; \
|
||||
}
|
||||
getbits(in, 0);
|
||||
getbits(ou, 1);
|
||||
getbits(ex, 2);
|
||||
#undef getbits
|
||||
#define getbits(name, x) \
|
||||
if (uap->name) { \
|
||||
error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
|
||||
(unsigned)(ni * sizeof(fd_mask))); \
|
||||
if (error) \
|
||||
goto done; \
|
||||
}
|
||||
getbits(in, 0);
|
||||
getbits(ou, 1);
|
||||
getbits(ex, 2);
|
||||
#undef getbits
|
||||
|
||||
if (uap->maskp) {
|
||||
error = copyin ((caddr_t) uap->maskp, (caddr_t) &sigmsk, sizeof(sigmsk));
|
||||
sigmsk &= ~sigcantmask;
|
||||
if (error)
|
||||
goto done;
|
||||
}
|
||||
if (uap->ts) {
|
||||
error = copyin ((caddr_t) uap->ts, (caddr_t) &atv, sizeof (atv));
|
||||
if (error)
|
||||
goto done;
|
||||
/*
|
||||
* nanoseconds ('struct timespec') on a PDP-11 are stupid since a 50 or 60 hz
|
||||
* clock is all we have. Keeping the names and logic made porting easier
|
||||
* though.
|
||||
*/
|
||||
if (is_pselect) {
|
||||
struct timespec *ts = (struct timespec *)&atv;
|
||||
if (uap->maskp) {
|
||||
error = copyin ((caddr_t) uap->maskp, (caddr_t) &sigmsk, sizeof(sigmsk));
|
||||
sigmsk &= ~sigcantmask;
|
||||
if (error)
|
||||
goto done;
|
||||
}
|
||||
if (uap->ts) {
|
||||
error = copyin ((caddr_t) uap->ts, (caddr_t) &atv, sizeof (atv));
|
||||
if (error)
|
||||
goto done;
|
||||
/*
|
||||
* nanoseconds ('struct timespec') on a PDP-11 are stupid since a 50 or 60 hz
|
||||
* clock is all we have. Keeping the names and logic made porting easier
|
||||
* though.
|
||||
*/
|
||||
if (is_pselect) {
|
||||
struct timespec *ts = (struct timespec *)&atv;
|
||||
|
||||
if (ts->tv_sec == 0 && ts->tv_nsec < 1000)
|
||||
atv.tv_usec = 1;
|
||||
else
|
||||
atv.tv_usec = ts->tv_nsec / 1000;
|
||||
}
|
||||
if (itimerfix(&atv)) {
|
||||
error = EINVAL;
|
||||
goto done;
|
||||
}
|
||||
s = splhigh();
|
||||
time.tv_usec = lbolt * usechz;
|
||||
timevaladd(&atv, &time);
|
||||
splx(s);
|
||||
}
|
||||
if (ts->tv_sec == 0 && ts->tv_nsec < 1000)
|
||||
atv.tv_usec = 1;
|
||||
else
|
||||
atv.tv_usec = ts->tv_nsec / 1000;
|
||||
}
|
||||
if (itimerfix(&atv)) {
|
||||
error = EINVAL;
|
||||
goto done;
|
||||
}
|
||||
s = splhigh();
|
||||
time.tv_usec = lbolt * usechz;
|
||||
timevaladd(&atv, &time);
|
||||
splx(s);
|
||||
}
|
||||
retry:
|
||||
ncoll = nselcoll;
|
||||
u.u_procp->p_flag |= P_SELECT;
|
||||
error = selscan(ibits, obits, uap->nd, &u.u_rval);
|
||||
if (error || u.u_rval)
|
||||
goto done;
|
||||
s = splhigh();
|
||||
if (uap->ts) {
|
||||
/* this should be timercmp(&time, &atv, >=) */
|
||||
if ((time.tv_sec > atv.tv_sec || (time.tv_sec == atv.tv_sec
|
||||
&& lbolt * usechz >= atv.tv_usec))) {
|
||||
splx(s);
|
||||
goto done;
|
||||
}
|
||||
timo = hzto(&atv);
|
||||
if (timo == 0)
|
||||
timo = 1;
|
||||
}
|
||||
if ((u.u_procp->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
splx(s);
|
||||
goto retry;
|
||||
}
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
/*
|
||||
* If doing a pselect() need to set a temporary mask while in tsleep.
|
||||
* Returning from pselect after catching a signal the old mask has to be
|
||||
* restored. Save it here and set the appropriate flag.
|
||||
*/
|
||||
if (uap->maskp) {
|
||||
u.u_oldmask = u.u_procp->p_sigmask;
|
||||
u.u_psflags |= SAS_OLDMASK;
|
||||
u.u_procp->p_sigmask = sigmsk;
|
||||
}
|
||||
error = tsleep ((caddr_t) &selwait, PSOCK | PCATCH, timo);
|
||||
if (uap->maskp)
|
||||
u.u_procp->p_sigmask = u.u_oldmask;
|
||||
splx(s);
|
||||
if (error == 0)
|
||||
goto retry;
|
||||
ncoll = nselcoll;
|
||||
u.u_procp->p_flag |= P_SELECT;
|
||||
error = selscan(ibits, obits, uap->nd, &u.u_rval);
|
||||
if (error || u.u_rval)
|
||||
goto done;
|
||||
s = splhigh();
|
||||
if (uap->ts) {
|
||||
/* this should be timercmp(&time, &atv, >=) */
|
||||
if ((time.tv_sec > atv.tv_sec || (time.tv_sec == atv.tv_sec
|
||||
&& lbolt * usechz >= atv.tv_usec))) {
|
||||
splx(s);
|
||||
goto done;
|
||||
}
|
||||
timo = hzto(&atv);
|
||||
if (timo == 0)
|
||||
timo = 1;
|
||||
}
|
||||
if ((u.u_procp->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
splx(s);
|
||||
goto retry;
|
||||
}
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
/*
|
||||
* If doing a pselect() need to set a temporary mask while in tsleep.
|
||||
* Returning from pselect after catching a signal the old mask has to be
|
||||
* restored. Save it here and set the appropriate flag.
|
||||
*/
|
||||
if (uap->maskp) {
|
||||
u.u_oldmask = u.u_procp->p_sigmask;
|
||||
u.u_psflags |= SAS_OLDMASK;
|
||||
u.u_procp->p_sigmask = sigmsk;
|
||||
}
|
||||
error = tsleep ((caddr_t) &selwait, PSOCK | PCATCH, timo);
|
||||
if (uap->maskp)
|
||||
u.u_procp->p_sigmask = u.u_oldmask;
|
||||
splx(s);
|
||||
if (error == 0)
|
||||
goto retry;
|
||||
done:
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
/* select is not restarted after signals... */
|
||||
if (error == ERESTART)
|
||||
error = EINTR;
|
||||
if (error == EWOULDBLOCK)
|
||||
error = 0;
|
||||
#define putbits(name, x) \
|
||||
if (uap->name && \
|
||||
(error2 = copyout ((caddr_t) &obits[x], (caddr_t) uap->name, ni*sizeof(fd_mask)))) \
|
||||
error = error2;
|
||||
u.u_procp->p_flag &= ~P_SELECT;
|
||||
/* select is not restarted after signals... */
|
||||
if (error == ERESTART)
|
||||
error = EINTR;
|
||||
if (error == EWOULDBLOCK)
|
||||
error = 0;
|
||||
#define putbits(name, x) \
|
||||
if (uap->name && \
|
||||
(error2 = copyout ((caddr_t) &obits[x], (caddr_t) uap->name, ni*sizeof(fd_mask)))) \
|
||||
error = error2;
|
||||
|
||||
if (error == 0) {
|
||||
int error2;
|
||||
if (error == 0) {
|
||||
int error2;
|
||||
|
||||
putbits(in, 0);
|
||||
putbits(ou, 1);
|
||||
putbits(ex, 2);
|
||||
putbits(in, 0);
|
||||
putbits(ou, 1);
|
||||
putbits(ex, 2);
|
||||
#undef putbits
|
||||
}
|
||||
return(error);
|
||||
}
|
||||
return(error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -394,19 +394,19 @@ done:
|
||||
void
|
||||
select()
|
||||
{
|
||||
struct uap {
|
||||
int nd;
|
||||
fd_set *in, *ou, *ex;
|
||||
struct timeval *tv;
|
||||
} *uap = (struct uap *)u.u_arg;
|
||||
register struct pselect_args *pselargs = (struct pselect_args *)uap;
|
||||
struct uap {
|
||||
int nd;
|
||||
fd_set *in, *ou, *ex;
|
||||
struct timeval *tv;
|
||||
} *uap = (struct uap *)u.u_arg;
|
||||
register struct pselect_args *pselargs = (struct pselect_args *)uap;
|
||||
|
||||
/*
|
||||
* Fake the 6th parameter of pselect. See the comment below about the
|
||||
* number of parameters!
|
||||
*/
|
||||
pselargs->maskp = 0;
|
||||
u.u_error = select1 (pselargs, 0);
|
||||
/*
|
||||
* Fake the 6th parameter of pselect. See the comment below about the
|
||||
* number of parameters!
|
||||
*/
|
||||
pselargs->maskp = 0;
|
||||
u.u_error = select1 (pselargs, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -418,95 +418,95 @@ select()
|
||||
void
|
||||
pselect()
|
||||
{
|
||||
register struct pselect_args *uap = (struct pselect_args *)u.u_arg;
|
||||
register struct pselect_args *uap = (struct pselect_args *)u.u_arg;
|
||||
|
||||
u.u_error = select1(uap, 1);
|
||||
u.u_error = select1(uap, 1);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
seltrue(dev, flag)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
int flag;
|
||||
{
|
||||
return (1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
selwakeup (p, coll)
|
||||
register struct proc *p;
|
||||
long coll;
|
||||
register struct proc *p;
|
||||
long coll;
|
||||
{
|
||||
if (coll) {
|
||||
nselcoll++;
|
||||
wakeup ((caddr_t)&selwait);
|
||||
}
|
||||
if (p) {
|
||||
register int s = splhigh();
|
||||
if (p->p_wchan == (caddr_t)&selwait) {
|
||||
if (p->p_stat == SSLEEP)
|
||||
setrun(p);
|
||||
else
|
||||
unsleep(p);
|
||||
} else if (p->p_flag & P_SELECT)
|
||||
p->p_flag &= ~P_SELECT;
|
||||
splx(s);
|
||||
}
|
||||
if (coll) {
|
||||
nselcoll++;
|
||||
wakeup ((caddr_t)&selwait);
|
||||
}
|
||||
if (p) {
|
||||
register int s = splhigh();
|
||||
if (p->p_wchan == (caddr_t)&selwait) {
|
||||
if (p->p_stat == SSLEEP)
|
||||
setrun(p);
|
||||
else
|
||||
unsleep(p);
|
||||
} else if (p->p_flag & P_SELECT)
|
||||
p->p_flag &= ~P_SELECT;
|
||||
splx(s);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
sorw(fp, uio)
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
{
|
||||
#ifdef INET
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
return(SORECEIVE((struct socket *)fp->f_socket, 0, uio, 0, 0));
|
||||
return(SOSEND((struct socket *)fp->f_socket, 0, uio, 0, 0));
|
||||
#ifdef INET
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
return(SORECEIVE((struct socket *)fp->f_socket, 0, uio, 0, 0));
|
||||
return(SOSEND((struct socket *)fp->f_socket, 0, uio, 0, 0));
|
||||
#else
|
||||
return (EOPNOTSUPP);
|
||||
return (EOPNOTSUPP);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
soctl(fp, com, data)
|
||||
struct file *fp;
|
||||
u_int com;
|
||||
char *data;
|
||||
struct file *fp;
|
||||
u_int com;
|
||||
char *data;
|
||||
{
|
||||
#ifdef INET
|
||||
return (SOO_IOCTL(fp, com, data));
|
||||
#ifdef INET
|
||||
return (SOO_IOCTL(fp, com, data));
|
||||
#else
|
||||
return (EOPNOTSUPP);
|
||||
return (EOPNOTSUPP);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
sosel(fp, flag)
|
||||
struct file *fp;
|
||||
int flag;
|
||||
struct file *fp;
|
||||
int flag;
|
||||
{
|
||||
#ifdef INET
|
||||
return (SOO_SELECT(fp, flag));
|
||||
#ifdef INET
|
||||
return (SOO_SELECT(fp, flag));
|
||||
#else
|
||||
return (EOPNOTSUPP);
|
||||
return (EOPNOTSUPP);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
socls(fp)
|
||||
register struct file *fp;
|
||||
register struct file *fp;
|
||||
{
|
||||
register int error = 0;
|
||||
register int error = 0;
|
||||
|
||||
#ifdef INET
|
||||
if (fp->f_data)
|
||||
error = SOCLOSE((struct socket *)fp->f_data);
|
||||
fp->f_data = 0;
|
||||
#ifdef INET
|
||||
if (fp->f_data)
|
||||
error = SOCLOSE((struct socket *)fp->f_data);
|
||||
fp->f_data = 0;
|
||||
#else
|
||||
error = EOPNOTSUPP;
|
||||
error = EOPNOTSUPP;
|
||||
#endif
|
||||
return(error);
|
||||
return(error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -515,11 +515,11 @@ socls(fp)
|
||||
* networking might not be defined an appropriate error has to be set
|
||||
*/
|
||||
const struct fileops socketops = {
|
||||
sorw, soctl, sosel, socls
|
||||
sorw, soctl, sosel, socls
|
||||
};
|
||||
|
||||
const struct fileops *const Fops[] = {
|
||||
NULL, &inodeops, &socketops, &pipeops
|
||||
NULL, &inodeops, &socketops, &pipeops
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -527,9 +527,9 @@ const struct fileops *const Fops[] = {
|
||||
*/
|
||||
void
|
||||
nostrategy (bp)
|
||||
struct buf *bp;
|
||||
struct buf *bp;
|
||||
{
|
||||
/* Empty. */
|
||||
/* Empty. */
|
||||
}
|
||||
|
||||
#ifndef INET
|
||||
@@ -539,6 +539,6 @@ nostrategy (bp)
|
||||
void
|
||||
nonet()
|
||||
{
|
||||
u.u_error = EPROTONOSUPPORT;
|
||||
u.u_error = EPROTONOSUPPORT;
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,178 +15,178 @@
|
||||
|
||||
int
|
||||
readp (fp, uio, flag)
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
register struct inode *ip;
|
||||
int error;
|
||||
register struct inode *ip;
|
||||
int error;
|
||||
|
||||
ip = (struct inode *)fp->f_data;
|
||||
ip = (struct inode *)fp->f_data;
|
||||
loop:
|
||||
/* Very conservative locking. */
|
||||
ILOCK(ip);
|
||||
/* Very conservative locking. */
|
||||
ILOCK(ip);
|
||||
|
||||
/* If nothing in the pipe, wait (unless FNONBLOCK is set). */
|
||||
if (ip->i_size == 0) {
|
||||
/*
|
||||
* If there are not both reader and writer active,
|
||||
* return without satisfying read.
|
||||
*/
|
||||
IUNLOCK(ip);
|
||||
if (ip->i_count != 2)
|
||||
return (0);
|
||||
if (fp->f_flag & FNONBLOCK)
|
||||
return (EWOULDBLOCK);
|
||||
ip->i_mode |= IREAD;
|
||||
sleep((caddr_t)ip+4, PPIPE);
|
||||
goto loop;
|
||||
}
|
||||
/* If nothing in the pipe, wait (unless FNONBLOCK is set). */
|
||||
if (ip->i_size == 0) {
|
||||
/*
|
||||
* If there are not both reader and writer active,
|
||||
* return without satisfying read.
|
||||
*/
|
||||
IUNLOCK(ip);
|
||||
if (ip->i_count != 2)
|
||||
return (0);
|
||||
if (fp->f_flag & FNONBLOCK)
|
||||
return (EWOULDBLOCK);
|
||||
ip->i_mode |= IREAD;
|
||||
sleep((caddr_t)ip+4, PPIPE);
|
||||
goto loop;
|
||||
}
|
||||
|
||||
uio->uio_offset = fp->f_offset;
|
||||
error = rwip(ip, uio, flag);
|
||||
fp->f_offset = uio->uio_offset;
|
||||
uio->uio_offset = fp->f_offset;
|
||||
error = rwip(ip, uio, flag);
|
||||
fp->f_offset = uio->uio_offset;
|
||||
|
||||
/*
|
||||
* If reader has caught up with writer, reset
|
||||
* offset and size to 0.
|
||||
*/
|
||||
if (fp->f_offset == ip->i_size) {
|
||||
fp->f_offset = 0;
|
||||
ip->i_size = 0;
|
||||
if (ip->i_mode & IWRITE) {
|
||||
ip->i_mode &= ~IWRITE;
|
||||
wakeup((caddr_t)ip+2);
|
||||
}
|
||||
if (ip->i_wsel) {
|
||||
selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL));
|
||||
ip->i_wsel = 0;
|
||||
ip->i_flag &= ~IWCOLL;
|
||||
}
|
||||
}
|
||||
IUNLOCK(ip);
|
||||
return (error);
|
||||
/*
|
||||
* If reader has caught up with writer, reset
|
||||
* offset and size to 0.
|
||||
*/
|
||||
if (fp->f_offset == ip->i_size) {
|
||||
fp->f_offset = 0;
|
||||
ip->i_size = 0;
|
||||
if (ip->i_mode & IWRITE) {
|
||||
ip->i_mode &= ~IWRITE;
|
||||
wakeup((caddr_t)ip+2);
|
||||
}
|
||||
if (ip->i_wsel) {
|
||||
selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL));
|
||||
ip->i_wsel = 0;
|
||||
ip->i_flag &= ~IWCOLL;
|
||||
}
|
||||
}
|
||||
IUNLOCK(ip);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
writep (fp, uio, flag)
|
||||
struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
register struct inode *ip;
|
||||
register int c;
|
||||
int error = 0;
|
||||
register struct inode *ip;
|
||||
register int c;
|
||||
int error = 0;
|
||||
|
||||
ip = (struct inode *)fp->f_data;
|
||||
c = uio->uio_resid;
|
||||
ILOCK(ip);
|
||||
if ((fp->f_flag & FNONBLOCK) && ip->i_size + c >= MAXPIPSIZ) {
|
||||
error = EWOULDBLOCK;
|
||||
goto done;
|
||||
}
|
||||
ip = (struct inode *)fp->f_data;
|
||||
c = uio->uio_resid;
|
||||
ILOCK(ip);
|
||||
if ((fp->f_flag & FNONBLOCK) && ip->i_size + c >= MAXPIPSIZ) {
|
||||
error = EWOULDBLOCK;
|
||||
goto done;
|
||||
}
|
||||
loop:
|
||||
/* If all done, return. */
|
||||
if (c == 0) {
|
||||
uio->uio_resid = 0;
|
||||
goto done;
|
||||
}
|
||||
/* If all done, return. */
|
||||
if (c == 0) {
|
||||
uio->uio_resid = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are not both read and write sides of the pipe active,
|
||||
* return error and signal too.
|
||||
*/
|
||||
if (ip->i_count != 2) {
|
||||
psignal(u.u_procp, SIGPIPE);
|
||||
error = EPIPE;
|
||||
done: IUNLOCK(ip);
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* If there are not both read and write sides of the pipe active,
|
||||
* return error and signal too.
|
||||
*/
|
||||
if (ip->i_count != 2) {
|
||||
psignal(u.u_procp, SIGPIPE);
|
||||
error = EPIPE;
|
||||
done: IUNLOCK(ip);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the pipe is full, wait for reads to deplete
|
||||
* and truncate it.
|
||||
*/
|
||||
if (ip->i_size >= MAXPIPSIZ) {
|
||||
ip->i_mode |= IWRITE;
|
||||
IUNLOCK(ip);
|
||||
sleep((caddr_t)ip+2, PPIPE);
|
||||
ILOCK(ip);
|
||||
goto loop;
|
||||
}
|
||||
/*
|
||||
* If the pipe is full, wait for reads to deplete
|
||||
* and truncate it.
|
||||
*/
|
||||
if (ip->i_size >= MAXPIPSIZ) {
|
||||
ip->i_mode |= IWRITE;
|
||||
IUNLOCK(ip);
|
||||
sleep((caddr_t)ip+2, PPIPE);
|
||||
ILOCK(ip);
|
||||
goto loop;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write what is possible and loop back.
|
||||
* If writing less than MAXPIPSIZ, it always goes.
|
||||
* One can therefore get a file > MAXPIPSIZ if write
|
||||
* sizes do not divide MAXPIPSIZ.
|
||||
*/
|
||||
uio->uio_offset = ip->i_size;
|
||||
uio->uio_resid = MIN((u_int)c, (u_int)MAXPIPSIZ);
|
||||
c -= uio->uio_resid;
|
||||
error = rwip(ip, uio, flag);
|
||||
if (ip->i_mode&IREAD) {
|
||||
ip->i_mode &= ~IREAD;
|
||||
wakeup((caddr_t)ip+4);
|
||||
}
|
||||
if (ip->i_rsel) {
|
||||
selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL));
|
||||
ip->i_rsel = 0;
|
||||
ip->i_flag &= ~IRCOLL;
|
||||
}
|
||||
goto loop;
|
||||
/*
|
||||
* Write what is possible and loop back.
|
||||
* If writing less than MAXPIPSIZ, it always goes.
|
||||
* One can therefore get a file > MAXPIPSIZ if write
|
||||
* sizes do not divide MAXPIPSIZ.
|
||||
*/
|
||||
uio->uio_offset = ip->i_size;
|
||||
uio->uio_resid = MIN((u_int)c, (u_int)MAXPIPSIZ);
|
||||
c -= uio->uio_resid;
|
||||
error = rwip(ip, uio, flag);
|
||||
if (ip->i_mode&IREAD) {
|
||||
ip->i_mode &= ~IREAD;
|
||||
wakeup((caddr_t)ip+4);
|
||||
}
|
||||
if (ip->i_rsel) {
|
||||
selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL));
|
||||
ip->i_rsel = 0;
|
||||
ip->i_flag &= ~IRCOLL;
|
||||
}
|
||||
goto loop;
|
||||
}
|
||||
|
||||
int
|
||||
pipe_rw (fp, uio, flag)
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
register struct file *fp;
|
||||
register struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
return (readp(fp, uio, flag));
|
||||
return (writep(fp, uio, flag));
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
return (readp(fp, uio, flag));
|
||||
return (writep(fp, uio, flag));
|
||||
}
|
||||
|
||||
int
|
||||
pipe_select (fp, which)
|
||||
struct file *fp;
|
||||
int which;
|
||||
struct file *fp;
|
||||
int which;
|
||||
{
|
||||
register struct inode *ip = (struct inode *)fp->f_data;
|
||||
register struct proc *p;
|
||||
register int retval = 0;
|
||||
extern int selwait;
|
||||
register struct inode *ip = (struct inode *)fp->f_data;
|
||||
register struct proc *p;
|
||||
register int retval = 0;
|
||||
extern int selwait;
|
||||
|
||||
ILOCK(ip);
|
||||
if (ip->i_count != 2)
|
||||
retval = 1;
|
||||
ILOCK(ip);
|
||||
if (ip->i_count != 2)
|
||||
retval = 1;
|
||||
|
||||
else switch (which) {
|
||||
case FREAD:
|
||||
if (ip->i_size) {
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
if ((p = ip->i_rsel) && p->p_wchan == (caddr_t)&selwait)
|
||||
ip->i_flag |= IRCOLL;
|
||||
else
|
||||
ip->i_rsel = u.u_procp;
|
||||
break;
|
||||
else switch (which) {
|
||||
case FREAD:
|
||||
if (ip->i_size) {
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
if ((p = ip->i_rsel) && p->p_wchan == (caddr_t)&selwait)
|
||||
ip->i_flag |= IRCOLL;
|
||||
else
|
||||
ip->i_rsel = u.u_procp;
|
||||
break;
|
||||
|
||||
case FWRITE:
|
||||
if (ip->i_size < MAXPIPSIZ) {
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
if ((p = ip->i_wsel) && p->p_wchan == (caddr_t)&selwait)
|
||||
ip->i_flag |= IWCOLL;
|
||||
else
|
||||
ip->i_wsel = u.u_procp;
|
||||
break;
|
||||
}
|
||||
IUNLOCK(ip);
|
||||
return(retval);
|
||||
case FWRITE:
|
||||
if (ip->i_size < MAXPIPSIZ) {
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
if ((p = ip->i_wsel) && p->p_wchan == (caddr_t)&selwait)
|
||||
ip->i_flag |= IWCOLL;
|
||||
else
|
||||
ip->i_wsel = u.u_procp;
|
||||
break;
|
||||
}
|
||||
IUNLOCK(ip);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -201,38 +201,38 @@ pipe_select (fp, which)
|
||||
*/
|
||||
int
|
||||
pipe_close(fp)
|
||||
struct file *fp;
|
||||
struct file *fp;
|
||||
{
|
||||
register struct inode *ip = (struct inode *)fp->f_data;
|
||||
register struct inode *ip = (struct inode *)fp->f_data;
|
||||
|
||||
ilock(ip);
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((ip->i_flag & IPIPE) == 0)
|
||||
panic("pipe_close !IPIPE");
|
||||
ilock(ip);
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((ip->i_flag & IPIPE) == 0)
|
||||
panic("pipe_close !IPIPE");
|
||||
#endif
|
||||
if (ip->i_rsel) {
|
||||
selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL));
|
||||
ip->i_rsel = 0;
|
||||
ip->i_flag &= ~IRCOLL;
|
||||
}
|
||||
if (ip->i_wsel) {
|
||||
selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL));
|
||||
ip->i_wsel = 0;
|
||||
ip->i_flag &= ~IWCOLL;
|
||||
}
|
||||
ip->i_mode &= ~(IREAD|IWRITE);
|
||||
wakeup((caddr_t)ip+2);
|
||||
wakeup((caddr_t)ip+4);
|
||||
if (ip->i_rsel) {
|
||||
selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL));
|
||||
ip->i_rsel = 0;
|
||||
ip->i_flag &= ~IRCOLL;
|
||||
}
|
||||
if (ip->i_wsel) {
|
||||
selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL));
|
||||
ip->i_wsel = 0;
|
||||
ip->i_flag &= ~IWCOLL;
|
||||
}
|
||||
ip->i_mode &= ~(IREAD|IWRITE);
|
||||
wakeup((caddr_t)ip+2);
|
||||
wakeup((caddr_t)ip+4);
|
||||
|
||||
/*
|
||||
* And finally decrement the reference count and (likely) release the inode.
|
||||
*/
|
||||
iput(ip);
|
||||
return(0);
|
||||
/*
|
||||
* And finally decrement the reference count and (likely) release the inode.
|
||||
*/
|
||||
iput(ip);
|
||||
return(0);
|
||||
}
|
||||
|
||||
const struct fileops pipeops = {
|
||||
pipe_rw, ino_ioctl, pipe_select, pipe_close
|
||||
pipe_rw, ino_ioctl, pipe_select, pipe_close
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -243,65 +243,65 @@ const struct fileops pipeops = {
|
||||
void
|
||||
pipe()
|
||||
{
|
||||
register struct inode *ip;
|
||||
register struct file *rf, *wf;
|
||||
static struct mount *mp;
|
||||
struct inode itmp;
|
||||
int r;
|
||||
register struct inode *ip;
|
||||
register struct file *rf, *wf;
|
||||
static struct mount *mp;
|
||||
struct inode itmp;
|
||||
int r;
|
||||
|
||||
/*
|
||||
* if pipedev not yet found, or not available, get it; if can't
|
||||
* find it, use rootdev. It would be cleaner to wander around
|
||||
* and fix it so that this and getfs() only check m_dev OR
|
||||
* m_inodp, but hopefully the mount table isn't scanned enough
|
||||
* to make it a problem. Besides, 4.3's is just as bad. Basic
|
||||
* fantasy is that if m_inodp is set, m_dev *will* be okay.
|
||||
*/
|
||||
if (! mp || ! mp->m_inodp || mp->m_dev != pipedev) {
|
||||
for (mp = &mount[0]; ; ++mp) {
|
||||
if (mp == &mount[NMOUNT]) {
|
||||
mp = &mount[0]; /* use root */
|
||||
break;
|
||||
}
|
||||
if (mp->m_inodp == NULL || mp->m_dev != pipedev)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (mp->m_filsys.fs_ronly) {
|
||||
u.u_error = EROFS;
|
||||
return;
|
||||
}
|
||||
}
|
||||
itmp.i_fs = &mp->m_filsys;
|
||||
itmp.i_dev = mp->m_dev;
|
||||
ip = ialloc (&itmp);
|
||||
if (ip == NULL)
|
||||
return;
|
||||
rf = falloc();
|
||||
if (rf == NULL) {
|
||||
iput (ip);
|
||||
return;
|
||||
}
|
||||
r = u.u_rval;
|
||||
wf = falloc();
|
||||
if (wf == NULL) {
|
||||
rf->f_count = 0;
|
||||
u.u_ofile[r] = NULL;
|
||||
iput (ip);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* if pipedev not yet found, or not available, get it; if can't
|
||||
* find it, use rootdev. It would be cleaner to wander around
|
||||
* and fix it so that this and getfs() only check m_dev OR
|
||||
* m_inodp, but hopefully the mount table isn't scanned enough
|
||||
* to make it a problem. Besides, 4.3's is just as bad. Basic
|
||||
* fantasy is that if m_inodp is set, m_dev *will* be okay.
|
||||
*/
|
||||
if (! mp || ! mp->m_inodp || mp->m_dev != pipedev) {
|
||||
for (mp = &mount[0]; ; ++mp) {
|
||||
if (mp == &mount[NMOUNT]) {
|
||||
mp = &mount[0]; /* use root */
|
||||
break;
|
||||
}
|
||||
if (mp->m_inodp == NULL || mp->m_dev != pipedev)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (mp->m_filsys.fs_ronly) {
|
||||
u.u_error = EROFS;
|
||||
return;
|
||||
}
|
||||
}
|
||||
itmp.i_fs = &mp->m_filsys;
|
||||
itmp.i_dev = mp->m_dev;
|
||||
ip = ialloc (&itmp);
|
||||
if (ip == NULL)
|
||||
return;
|
||||
rf = falloc();
|
||||
if (rf == NULL) {
|
||||
iput (ip);
|
||||
return;
|
||||
}
|
||||
r = u.u_rval;
|
||||
wf = falloc();
|
||||
if (wf == NULL) {
|
||||
rf->f_count = 0;
|
||||
u.u_ofile[r] = NULL;
|
||||
iput (ip);
|
||||
return;
|
||||
}
|
||||
#ifdef __mips__
|
||||
/* Move a secondary return value to register $v1. */
|
||||
u.u_frame [FRAME_R3] = u.u_rval;
|
||||
/* Move a secondary return value to register $v1. */
|
||||
u.u_frame [FRAME_R3] = u.u_rval;
|
||||
#else
|
||||
#error "pipe return value for unknown architecture"
|
||||
#endif
|
||||
u.u_rval = r;
|
||||
wf->f_flag = FWRITE;
|
||||
rf->f_flag = FREAD;
|
||||
rf->f_type = wf->f_type = DTYPE_PIPE;
|
||||
rf->f_data = wf->f_data = (caddr_t) ip;
|
||||
ip->i_count = 2;
|
||||
ip->i_mode = IFREG;
|
||||
ip->i_flag = IACC | IUPD | ICHG | IPIPE;
|
||||
u.u_rval = r;
|
||||
wf->f_flag = FWRITE;
|
||||
rf->f_flag = FREAD;
|
||||
rf->f_type = wf->f_type = DTYPE_PIPE;
|
||||
rf->f_data = wf->f_data = (caddr_t) ip;
|
||||
ip->i_count = 2;
|
||||
ip->i_mode = IFREG;
|
||||
ip->i_flag = IACC | IUPD | ICHG | IPIPE;
|
||||
}
|
||||
|
||||
@@ -17,40 +17,40 @@
|
||||
void
|
||||
ptrace()
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int req;
|
||||
int pid;
|
||||
int *addr;
|
||||
int data;
|
||||
} *uap;
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int req;
|
||||
int pid;
|
||||
int *addr;
|
||||
int data;
|
||||
} *uap;
|
||||
|
||||
uap = (struct a *)u.u_arg;
|
||||
if (uap->req <= 0) {
|
||||
u.u_procp->p_flag |= P_TRACED;
|
||||
return;
|
||||
}
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid ||
|
||||
!(p->p_flag & P_TRACED)) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
while (ipc.ip_lock)
|
||||
sleep((caddr_t)&ipc, PZERO);
|
||||
ipc.ip_lock = p->p_pid;
|
||||
ipc.ip_data = uap->data;
|
||||
ipc.ip_addr = uap->addr;
|
||||
ipc.ip_req = uap->req;
|
||||
p->p_flag &= ~P_WAITED;
|
||||
setrun(p);
|
||||
while (ipc.ip_req > 0)
|
||||
sleep((caddr_t)&ipc, PZERO);
|
||||
u.u_rval = ipc.ip_data;
|
||||
if (ipc.ip_req < 0)
|
||||
u.u_error = EIO;
|
||||
ipc.ip_lock = 0;
|
||||
wakeup((caddr_t)&ipc);
|
||||
uap = (struct a *)u.u_arg;
|
||||
if (uap->req <= 0) {
|
||||
u.u_procp->p_flag |= P_TRACED;
|
||||
return;
|
||||
}
|
||||
p = pfind(uap->pid);
|
||||
if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid ||
|
||||
!(p->p_flag & P_TRACED)) {
|
||||
u.u_error = ESRCH;
|
||||
return;
|
||||
}
|
||||
while (ipc.ip_lock)
|
||||
sleep((caddr_t)&ipc, PZERO);
|
||||
ipc.ip_lock = p->p_pid;
|
||||
ipc.ip_data = uap->data;
|
||||
ipc.ip_addr = uap->addr;
|
||||
ipc.ip_req = uap->req;
|
||||
p->p_flag &= ~P_WAITED;
|
||||
setrun(p);
|
||||
while (ipc.ip_req > 0)
|
||||
sleep((caddr_t)&ipc, PZERO);
|
||||
u.u_rval = ipc.ip_data;
|
||||
if (ipc.ip_req < 0)
|
||||
u.u_error = EIO;
|
||||
ipc.ip_lock = 0;
|
||||
wakeup((caddr_t)&ipc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -61,77 +61,77 @@ ptrace()
|
||||
int
|
||||
procxmt()
|
||||
{
|
||||
register int i, *p;
|
||||
register int i, *p;
|
||||
|
||||
if (ipc.ip_lock != u.u_procp->p_pid)
|
||||
return(0);
|
||||
u.u_procp->p_slptime = 0;
|
||||
i = ipc.ip_req;
|
||||
ipc.ip_req = 0;
|
||||
wakeup ((caddr_t)&ipc);
|
||||
switch (i) {
|
||||
if (ipc.ip_lock != u.u_procp->p_pid)
|
||||
return(0);
|
||||
u.u_procp->p_slptime = 0;
|
||||
i = ipc.ip_req;
|
||||
ipc.ip_req = 0;
|
||||
wakeup ((caddr_t)&ipc);
|
||||
switch (i) {
|
||||
|
||||
/* read user I */
|
||||
case PT_READ_I:
|
||||
/* read user I */
|
||||
case PT_READ_I:
|
||||
|
||||
/* read user D */
|
||||
case PT_READ_D:
|
||||
if (baduaddr ((caddr_t) ipc.ip_addr))
|
||||
goto error;
|
||||
ipc.ip_data = *(int*) ipc.ip_addr;
|
||||
break;
|
||||
/* read user D */
|
||||
case PT_READ_D:
|
||||
if (baduaddr ((caddr_t) ipc.ip_addr))
|
||||
goto error;
|
||||
ipc.ip_data = *(int*) ipc.ip_addr;
|
||||
break;
|
||||
|
||||
/* read u */
|
||||
case PT_READ_U:
|
||||
i = (int) ipc.ip_addr;
|
||||
if (i < 0 || i >= USIZE)
|
||||
goto error;
|
||||
ipc.ip_data = ((unsigned*)&u) [i/sizeof(int)];
|
||||
break;
|
||||
/* read u */
|
||||
case PT_READ_U:
|
||||
i = (int) ipc.ip_addr;
|
||||
if (i < 0 || i >= USIZE)
|
||||
goto error;
|
||||
ipc.ip_data = ((unsigned*)&u) [i/sizeof(int)];
|
||||
break;
|
||||
|
||||
/* write user I */
|
||||
case PT_WRITE_I:
|
||||
/* write user D */
|
||||
case PT_WRITE_D:
|
||||
if (baduaddr ((caddr_t) ipc.ip_addr))
|
||||
goto error;
|
||||
*(int*) ipc.ip_addr = ipc.ip_data;
|
||||
break;
|
||||
/* write user I */
|
||||
case PT_WRITE_I:
|
||||
/* write user D */
|
||||
case PT_WRITE_D:
|
||||
if (baduaddr ((caddr_t) ipc.ip_addr))
|
||||
goto error;
|
||||
*(int*) ipc.ip_addr = ipc.ip_data;
|
||||
break;
|
||||
|
||||
/* write u */
|
||||
case PT_WRITE_U:
|
||||
i = (int)ipc.ip_addr;
|
||||
p = (int*)&u + i/sizeof(int);
|
||||
for (i=0; i<FRAME_WORDS; i++)
|
||||
if (p == &u.u_frame[i])
|
||||
goto ok;
|
||||
goto error;
|
||||
/* write u */
|
||||
case PT_WRITE_U:
|
||||
i = (int)ipc.ip_addr;
|
||||
p = (int*)&u + i/sizeof(int);
|
||||
for (i=0; i<FRAME_WORDS; i++)
|
||||
if (p == &u.u_frame[i])
|
||||
goto ok;
|
||||
goto error;
|
||||
ok:
|
||||
*p = ipc.ip_data;
|
||||
break;
|
||||
*p = ipc.ip_data;
|
||||
break;
|
||||
|
||||
/* set signal and continue */
|
||||
/* one version causes a trace-trap */
|
||||
case PT_STEP:
|
||||
/* Use Status.RP bit to indicate a single-step request. */
|
||||
u.u_frame [FRAME_STATUS] |= ST_RP;
|
||||
/* FALL THROUGH TO ... */
|
||||
case PT_CONTINUE:
|
||||
if ((int)ipc.ip_addr != 1)
|
||||
u.u_frame [FRAME_PC] = (int)ipc.ip_addr;
|
||||
if (ipc.ip_data > NSIG)
|
||||
goto error;
|
||||
u.u_procp->p_ptracesig = ipc.ip_data;
|
||||
return(1);
|
||||
/* set signal and continue */
|
||||
/* one version causes a trace-trap */
|
||||
case PT_STEP:
|
||||
/* Use Status.RP bit to indicate a single-step request. */
|
||||
u.u_frame [FRAME_STATUS] |= ST_RP;
|
||||
/* FALL THROUGH TO ... */
|
||||
case PT_CONTINUE:
|
||||
if ((int)ipc.ip_addr != 1)
|
||||
u.u_frame [FRAME_PC] = (int)ipc.ip_addr;
|
||||
if (ipc.ip_data > NSIG)
|
||||
goto error;
|
||||
u.u_procp->p_ptracesig = ipc.ip_data;
|
||||
return(1);
|
||||
|
||||
/* force exit */
|
||||
case PT_KILL:
|
||||
exit(u.u_procp->p_ptracesig);
|
||||
/*NOTREACHED*/
|
||||
/* force exit */
|
||||
case PT_KILL:
|
||||
exit(u.u_procp->p_ptracesig);
|
||||
/*NOTREACHED*/
|
||||
|
||||
default:
|
||||
default:
|
||||
error:
|
||||
ipc.ip_req = -1;
|
||||
}
|
||||
return(0);
|
||||
ipc.ip_req = -1;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -9,161 +9,161 @@
|
||||
*/
|
||||
#ifndef pdp11
|
||||
const char *const syscallnames[] = {
|
||||
"indir", /* 0 = indir */
|
||||
"exit", /* 1 = exit */
|
||||
"fork", /* 2 = fork */
|
||||
"read", /* 3 = read */
|
||||
"write", /* 4 = write */
|
||||
"open", /* 5 = open */
|
||||
"close", /* 6 = close */
|
||||
"wait4", /* 7 = wait4 */
|
||||
"#8", /* 8 = (old creat) */
|
||||
"link", /* 9 = link */
|
||||
"unlink", /* 10 = unlink */
|
||||
"execv", /* 11 = execv */
|
||||
"chdir", /* 12 = chdir */
|
||||
"fchdir", /* 13 = fchdir */
|
||||
"mknod", /* 14 = mknod */
|
||||
"chmod", /* 15 = chmod */
|
||||
"chown", /* 16 = chown; now 3 args */
|
||||
"chflags", /* 17 = chflags */
|
||||
"fchflags", /* 18 = fchflags */
|
||||
"lseek", /* 19 = lseek */
|
||||
"getpid", /* 20 = getpid */
|
||||
"mount", /* 21 = mount */
|
||||
"umount", /* 22 = umount */
|
||||
"__sysctl", /* 23 = __sysctl */
|
||||
"getuid", /* 24 = getuid */
|
||||
"geteuid", /* 25 = geteuid */
|
||||
"ptrace", /* 26 = ptrace */
|
||||
"getppid", /* 27 = getppid */
|
||||
"statfs", /* 28 = statfs */
|
||||
"fstatfs", /* 29 = fstatfs */
|
||||
"getfsstat", /* 30 = getfsstat */
|
||||
"sigaction", /* 31 = sigaction */
|
||||
"sigprocmask", /* 32 = sigprocmask */
|
||||
"access", /* 33 = access */
|
||||
"sigpending", /* 34 = sigpending */
|
||||
"sigaltstack", /* 35 = sigaltstack */
|
||||
"sync", /* 36 = sync */
|
||||
"kill", /* 37 = kill */
|
||||
"stat", /* 38 = stat */
|
||||
"getlogin", /* 39 = getlogin */
|
||||
"lstat", /* 40 = lstat */
|
||||
"dup", /* 41 = dup */
|
||||
"pipe", /* 42 = pipe */
|
||||
"setlogin", /* 43 = setlogin */
|
||||
"profil", /* 44 = profil */
|
||||
"setuid", /* 45 = setuid */
|
||||
"seteuid", /* 46 = seteuid */
|
||||
"getgid", /* 47 = getgid */
|
||||
"getegid", /* 48 = getegid */
|
||||
"setgid", /* 49 = setgid */
|
||||
"setegid", /* 50 = setegid */
|
||||
"kmemdev", /* 51 = kmemdev */
|
||||
"phys", /* 52 = (2.9) set phys addr */
|
||||
"lock", /* 53 = (2.9) lock in core */
|
||||
"ioctl", /* 54 = ioctl */
|
||||
"reboot", /* 55 = reboot */
|
||||
"sigwait", /* 56 = sigwait */
|
||||
"symlink", /* 57 = symlink */
|
||||
"readlink", /* 58 = readlink */
|
||||
"execve", /* 59 = execve */
|
||||
"umask", /* 60 = umask */
|
||||
"chroot", /* 61 = chroot */
|
||||
"fstat", /* 62 = fstat */
|
||||
"#63", /* 63 = unused */
|
||||
"#64", /* 64 = (old getpagesize) */
|
||||
"pselect", /* 65 = pselect */
|
||||
"vfork", /* 66 = vfork */
|
||||
"#67", /* 67 = unused */
|
||||
"#68", /* 68 = unused */
|
||||
"brk", /* 69 = brk */
|
||||
"rdglob", /* 70 = read from global space */
|
||||
"wrglob", /* 71 = write to global space */
|
||||
"msec", /* 72 = kticks */
|
||||
"#73", /* 73 = unused */
|
||||
"#74", /* 74 = unused */
|
||||
"#75", /* 75 = unused */
|
||||
"vhangup", /* 76 = vhangup */
|
||||
"#77", /* 77 = unused */
|
||||
"#78", /* 78 = unused */
|
||||
"getgroups", /* 79 = getgroups */
|
||||
"setgroups", /* 80 = setgroups */
|
||||
"getpgrp", /* 81 = getpgrp */
|
||||
"setpgrp", /* 82 = setpgrp */
|
||||
"setitimer", /* 83 = setitimer */
|
||||
"old wait", /* 84 = wait,wait3 COMPAT*/
|
||||
"#85", /* 85 = unused */
|
||||
"getitimer", /* 86 = getitimer */
|
||||
"#87", /* 87 = (old gethostname) */
|
||||
"#88", /* 88 = (old sethostname) */
|
||||
"getdtablesize", /* 89 = getdtablesize */
|
||||
"dup2", /* 90 = dup2 */
|
||||
"#91", /* 91 = unused */
|
||||
"fcntl", /* 92 = fcntl */
|
||||
"select", /* 93 = select */
|
||||
"#94", /* 94 = unused */
|
||||
"fsync", /* 95 = fsync */
|
||||
"setpriority", /* 96 = setpriority */
|
||||
"socket", /* 97 = socket */
|
||||
"connect", /* 98 = connect */
|
||||
"accept", /* 99 = accept */
|
||||
"getpriority", /* 100 = getpriority */
|
||||
"send", /* 101 = send */
|
||||
"recv", /* 102 = recv */
|
||||
"sigreturn", /* 103 = sigreturn */
|
||||
"bind", /* 104 = bind */
|
||||
"setsockopt", /* 105 = setsockopt */
|
||||
"listen", /* 106 = listen */
|
||||
"sigsuspend", /* 107 = sigsuspend */
|
||||
"#108", /* 108 = (old sigvec) */
|
||||
"#109", /* 109 = (old sigblock) */
|
||||
"#110", /* 110 = (old sigsetmask) */
|
||||
"#111", /* 111 = (old sigpause) */
|
||||
"sigstack", /* 112 = sigstack COMPAT-43 */
|
||||
"recvmsg", /* 113 = recvmsg */
|
||||
"sendmsg", /* 114 = sendmsg */
|
||||
"#115", /* 115 = unused */
|
||||
"gettimeofday", /* 116 = gettimeofday */
|
||||
"getrusage", /* 117 = getrusage */
|
||||
"getsockopt", /* 118 = getsockopt */
|
||||
"#119", /* 119 = unused */
|
||||
"readv", /* 120 = readv */
|
||||
"writev", /* 121 = writev */
|
||||
"settimeofday", /* 122 = settimeofday */
|
||||
"fchown", /* 123 = fchown */
|
||||
"fchmod", /* 124 = fchmod */
|
||||
"recvfrom", /* 125 = recvfrom */
|
||||
"#126", /* 126 = (old setreuid) */
|
||||
"#127", /* 127 = (old setregid) */
|
||||
"rename", /* 128 = rename */
|
||||
"truncate", /* 129 = truncate */
|
||||
"ftruncate", /* 130 = ftruncate */
|
||||
"flock", /* 131 = flock */
|
||||
"#132", /* 132 = unused */
|
||||
"sendto", /* 133 = sendto */
|
||||
"shutdown", /* 134 = shutdown */
|
||||
"socketpair", /* 135 = socketpair */
|
||||
"mkdir", /* 136 = mkdir */
|
||||
"rmdir", /* 137 = rmdir */
|
||||
"utimes", /* 138 = utimes */
|
||||
"#139", /* 139 = unused */
|
||||
"adjtime", /* 140 = adjtime */
|
||||
"getpeername", /* 141 = getpeername */
|
||||
"#142", /* 142 = (old gethostid) */
|
||||
"#143", /* 143 = (old sethostid) */
|
||||
"getrlimit", /* 144 = getrlimit */
|
||||
"setrlimit", /* 145 = setrlimit */
|
||||
"killpg", /* 146 = killpg */
|
||||
"#147", /* 147 = unused */
|
||||
"setquota", /* 148 = setquota */
|
||||
"quota", /* 149 = quota */
|
||||
"getsockname", /* 150 = getsockname */
|
||||
"#151", /* 151 = unused */
|
||||
"ustore", /* 152 = ustore */
|
||||
"ufetch", /* 153 = ufetch */
|
||||
"ucall", /* 154 = ucall */
|
||||
"#155", /* 155 = unused */
|
||||
"indir", /* 0 = indir */
|
||||
"exit", /* 1 = exit */
|
||||
"fork", /* 2 = fork */
|
||||
"read", /* 3 = read */
|
||||
"write", /* 4 = write */
|
||||
"open", /* 5 = open */
|
||||
"close", /* 6 = close */
|
||||
"wait4", /* 7 = wait4 */
|
||||
"#8", /* 8 = (old creat) */
|
||||
"link", /* 9 = link */
|
||||
"unlink", /* 10 = unlink */
|
||||
"execv", /* 11 = execv */
|
||||
"chdir", /* 12 = chdir */
|
||||
"fchdir", /* 13 = fchdir */
|
||||
"mknod", /* 14 = mknod */
|
||||
"chmod", /* 15 = chmod */
|
||||
"chown", /* 16 = chown; now 3 args */
|
||||
"chflags", /* 17 = chflags */
|
||||
"fchflags", /* 18 = fchflags */
|
||||
"lseek", /* 19 = lseek */
|
||||
"getpid", /* 20 = getpid */
|
||||
"mount", /* 21 = mount */
|
||||
"umount", /* 22 = umount */
|
||||
"__sysctl", /* 23 = __sysctl */
|
||||
"getuid", /* 24 = getuid */
|
||||
"geteuid", /* 25 = geteuid */
|
||||
"ptrace", /* 26 = ptrace */
|
||||
"getppid", /* 27 = getppid */
|
||||
"statfs", /* 28 = statfs */
|
||||
"fstatfs", /* 29 = fstatfs */
|
||||
"getfsstat", /* 30 = getfsstat */
|
||||
"sigaction", /* 31 = sigaction */
|
||||
"sigprocmask", /* 32 = sigprocmask */
|
||||
"access", /* 33 = access */
|
||||
"sigpending", /* 34 = sigpending */
|
||||
"sigaltstack", /* 35 = sigaltstack */
|
||||
"sync", /* 36 = sync */
|
||||
"kill", /* 37 = kill */
|
||||
"stat", /* 38 = stat */
|
||||
"getlogin", /* 39 = getlogin */
|
||||
"lstat", /* 40 = lstat */
|
||||
"dup", /* 41 = dup */
|
||||
"pipe", /* 42 = pipe */
|
||||
"setlogin", /* 43 = setlogin */
|
||||
"profil", /* 44 = profil */
|
||||
"setuid", /* 45 = setuid */
|
||||
"seteuid", /* 46 = seteuid */
|
||||
"getgid", /* 47 = getgid */
|
||||
"getegid", /* 48 = getegid */
|
||||
"setgid", /* 49 = setgid */
|
||||
"setegid", /* 50 = setegid */
|
||||
"kmemdev", /* 51 = kmemdev */
|
||||
"phys", /* 52 = (2.9) set phys addr */
|
||||
"lock", /* 53 = (2.9) lock in core */
|
||||
"ioctl", /* 54 = ioctl */
|
||||
"reboot", /* 55 = reboot */
|
||||
"sigwait", /* 56 = sigwait */
|
||||
"symlink", /* 57 = symlink */
|
||||
"readlink", /* 58 = readlink */
|
||||
"execve", /* 59 = execve */
|
||||
"umask", /* 60 = umask */
|
||||
"chroot", /* 61 = chroot */
|
||||
"fstat", /* 62 = fstat */
|
||||
"#63", /* 63 = unused */
|
||||
"#64", /* 64 = (old getpagesize) */
|
||||
"pselect", /* 65 = pselect */
|
||||
"vfork", /* 66 = vfork */
|
||||
"#67", /* 67 = unused */
|
||||
"#68", /* 68 = unused */
|
||||
"brk", /* 69 = brk */
|
||||
"rdglob", /* 70 = read from global space */
|
||||
"wrglob", /* 71 = write to global space */
|
||||
"msec", /* 72 = kticks */
|
||||
"#73", /* 73 = unused */
|
||||
"#74", /* 74 = unused */
|
||||
"#75", /* 75 = unused */
|
||||
"vhangup", /* 76 = vhangup */
|
||||
"#77", /* 77 = unused */
|
||||
"#78", /* 78 = unused */
|
||||
"getgroups", /* 79 = getgroups */
|
||||
"setgroups", /* 80 = setgroups */
|
||||
"getpgrp", /* 81 = getpgrp */
|
||||
"setpgrp", /* 82 = setpgrp */
|
||||
"setitimer", /* 83 = setitimer */
|
||||
"old wait", /* 84 = wait,wait3 COMPAT*/
|
||||
"#85", /* 85 = unused */
|
||||
"getitimer", /* 86 = getitimer */
|
||||
"#87", /* 87 = (old gethostname) */
|
||||
"#88", /* 88 = (old sethostname) */
|
||||
"getdtablesize", /* 89 = getdtablesize */
|
||||
"dup2", /* 90 = dup2 */
|
||||
"#91", /* 91 = unused */
|
||||
"fcntl", /* 92 = fcntl */
|
||||
"select", /* 93 = select */
|
||||
"#94", /* 94 = unused */
|
||||
"fsync", /* 95 = fsync */
|
||||
"setpriority", /* 96 = setpriority */
|
||||
"socket", /* 97 = socket */
|
||||
"connect", /* 98 = connect */
|
||||
"accept", /* 99 = accept */
|
||||
"getpriority", /* 100 = getpriority */
|
||||
"send", /* 101 = send */
|
||||
"recv", /* 102 = recv */
|
||||
"sigreturn", /* 103 = sigreturn */
|
||||
"bind", /* 104 = bind */
|
||||
"setsockopt", /* 105 = setsockopt */
|
||||
"listen", /* 106 = listen */
|
||||
"sigsuspend", /* 107 = sigsuspend */
|
||||
"#108", /* 108 = (old sigvec) */
|
||||
"#109", /* 109 = (old sigblock) */
|
||||
"#110", /* 110 = (old sigsetmask) */
|
||||
"#111", /* 111 = (old sigpause) */
|
||||
"sigstack", /* 112 = sigstack COMPAT-43 */
|
||||
"recvmsg", /* 113 = recvmsg */
|
||||
"sendmsg", /* 114 = sendmsg */
|
||||
"#115", /* 115 = unused */
|
||||
"gettimeofday", /* 116 = gettimeofday */
|
||||
"getrusage", /* 117 = getrusage */
|
||||
"getsockopt", /* 118 = getsockopt */
|
||||
"#119", /* 119 = unused */
|
||||
"readv", /* 120 = readv */
|
||||
"writev", /* 121 = writev */
|
||||
"settimeofday", /* 122 = settimeofday */
|
||||
"fchown", /* 123 = fchown */
|
||||
"fchmod", /* 124 = fchmod */
|
||||
"recvfrom", /* 125 = recvfrom */
|
||||
"#126", /* 126 = (old setreuid) */
|
||||
"#127", /* 127 = (old setregid) */
|
||||
"rename", /* 128 = rename */
|
||||
"truncate", /* 129 = truncate */
|
||||
"ftruncate", /* 130 = ftruncate */
|
||||
"flock", /* 131 = flock */
|
||||
"#132", /* 132 = unused */
|
||||
"sendto", /* 133 = sendto */
|
||||
"shutdown", /* 134 = shutdown */
|
||||
"socketpair", /* 135 = socketpair */
|
||||
"mkdir", /* 136 = mkdir */
|
||||
"rmdir", /* 137 = rmdir */
|
||||
"utimes", /* 138 = utimes */
|
||||
"#139", /* 139 = unused */
|
||||
"adjtime", /* 140 = adjtime */
|
||||
"getpeername", /* 141 = getpeername */
|
||||
"#142", /* 142 = (old gethostid) */
|
||||
"#143", /* 143 = (old sethostid) */
|
||||
"getrlimit", /* 144 = getrlimit */
|
||||
"setrlimit", /* 145 = setrlimit */
|
||||
"killpg", /* 146 = killpg */
|
||||
"#147", /* 147 = unused */
|
||||
"setquota", /* 148 = setquota */
|
||||
"quota", /* 149 = quota */
|
||||
"getsockname", /* 150 = getsockname */
|
||||
"#151", /* 151 = unused */
|
||||
"ustore", /* 152 = ustore */
|
||||
"ufetch", /* 153 = ufetch */
|
||||
"ucall", /* 154 = ucall */
|
||||
"#155", /* 155 = unused */
|
||||
};
|
||||
#endif
|
||||
|
||||
2522
sys/kernel/tty.c
2522
sys/kernel/tty.c
File diff suppressed because it is too large
Load Diff
@@ -33,106 +33,108 @@ const struct devspec ptcdevs[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
extern int TTYHOG; /* see tty.c */
|
||||
extern int TTYHOG; /* see tty.c */
|
||||
|
||||
#define BUFSIZ 100 /* Chunk size iomoved to/from user */
|
||||
#define BUFSIZ 100 /* Chunk size iomoved to/from user */
|
||||
|
||||
/*
|
||||
* pts == /dev/tty[pqrs]?
|
||||
* ptc == /dev/pty[pqrs]?
|
||||
*/
|
||||
struct tty pt_tty[NPTY];
|
||||
struct pt_ioctl {
|
||||
int pt_flags;
|
||||
struct proc *pt_selr, *pt_selw;
|
||||
u_char pt_send;
|
||||
u_char pt_ucntl;
|
||||
} pt_ioctl[NPTY];
|
||||
int npty = NPTY; /* for pstat -t */
|
||||
struct tty pt_tty[NPTY];
|
||||
|
||||
#define PF_RCOLL 0x01
|
||||
#define PF_WCOLL 0x02
|
||||
#define PF_PKT 0x08 /* packet mode */
|
||||
#define PF_STOPPED 0x10 /* user told stopped */
|
||||
#define PF_REMOTE 0x20 /* remote and flow controlled input */
|
||||
#define PF_NOSTOP 0x40
|
||||
#define PF_UCNTL 0x80 /* user control mode */
|
||||
struct pt_ioctl {
|
||||
int pt_flags;
|
||||
struct proc *pt_selr, *pt_selw;
|
||||
u_char pt_send;
|
||||
u_char pt_ucntl;
|
||||
} pt_ioctl[NPTY];
|
||||
|
||||
int npty = NPTY; /* for pstat -t */
|
||||
|
||||
#define PF_RCOLL 0x01
|
||||
#define PF_WCOLL 0x02
|
||||
#define PF_PKT 0x08 /* packet mode */
|
||||
#define PF_STOPPED 0x10 /* user told stopped */
|
||||
#define PF_REMOTE 0x20 /* remote and flow controlled input */
|
||||
#define PF_NOSTOP 0x40
|
||||
#define PF_UCNTL 0x80 /* user control mode */
|
||||
|
||||
/*ARGSUSED*/
|
||||
int ptsopen(dev_t dev, int flag, int mode)
|
||||
{
|
||||
register struct tty *tp;
|
||||
int error;
|
||||
register struct tty *tp;
|
||||
int error;
|
||||
|
||||
#ifdef lint
|
||||
npty = npty;
|
||||
npty = npty;
|
||||
#endif
|
||||
if (minor(dev) >= NPTY)
|
||||
return (ENXIO);
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if ((tp->t_state & TS_ISOPEN) == 0) {
|
||||
ttychars(tp); /* Set up default chars */
|
||||
tp->t_ispeed = tp->t_ospeed = B115200;
|
||||
tp->t_flags = 0; /* No features (nor raw mode) */
|
||||
} else if (tp->t_state&TS_XCLUDE && u.u_uid != 0)
|
||||
return (EBUSY);
|
||||
if (tp->t_oproc) /* Ctrlr still around. */
|
||||
tp->t_state |= TS_CARR_ON;
|
||||
while ((tp->t_state & TS_CARR_ON) == 0) {
|
||||
tp->t_state |= TS_WOPEN;
|
||||
sleep((caddr_t)&tp->t_rawq, TTIPRI);
|
||||
}
|
||||
error = ttyopen(dev, tp);
|
||||
ptcwakeup (tp, FREAD | FWRITE);
|
||||
return (error);
|
||||
if (minor(dev) >= NPTY)
|
||||
return (ENXIO);
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if ((tp->t_state & TS_ISOPEN) == 0) {
|
||||
ttychars(tp); /* Set up default chars */
|
||||
tp->t_ispeed = tp->t_ospeed = B115200;
|
||||
tp->t_flags = 0; /* No features (nor raw mode) */
|
||||
} else if (tp->t_state&TS_XCLUDE && u.u_uid != 0)
|
||||
return (EBUSY);
|
||||
if (tp->t_oproc) /* Ctrlr still around. */
|
||||
tp->t_state |= TS_CARR_ON;
|
||||
while ((tp->t_state & TS_CARR_ON) == 0) {
|
||||
tp->t_state |= TS_WOPEN;
|
||||
sleep((caddr_t)&tp->t_rawq, TTIPRI);
|
||||
}
|
||||
error = ttyopen(dev, tp);
|
||||
ptcwakeup (tp, FREAD | FWRITE);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int ptsclose(dev_t dev, int flag, int mode)
|
||||
{
|
||||
register struct tty *tp;
|
||||
register struct tty *tp;
|
||||
|
||||
tp = &pt_tty[minor(dev)];
|
||||
ttyclose(tp);
|
||||
ptcwakeup(tp, FREAD|FWRITE);
|
||||
return 0;
|
||||
tp = &pt_tty[minor(dev)];
|
||||
ttyclose(tp);
|
||||
ptcwakeup(tp, FREAD|FWRITE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ptsread(dev_t dev, register struct uio *uio, int flag)
|
||||
{
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int error = 0;
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int error = 0;
|
||||
|
||||
again:
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
while (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) {
|
||||
if ((u.u_procp->p_sigignore & sigmask(SIGTTIN)) ||
|
||||
(u.u_procp->p_sigmask & sigmask(SIGTTIN)) ||
|
||||
u.u_procp->p_flag&SVFORK)
|
||||
return (EIO);
|
||||
gsignal(u.u_procp->p_pgrp, SIGTTIN);
|
||||
sleep((caddr_t)&lbolt, TTIPRI);
|
||||
}
|
||||
if (tp->t_canq.c_cc == 0) {
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
sleep((caddr_t)&tp->t_canq, TTIPRI);
|
||||
goto again;
|
||||
}
|
||||
while (tp->t_canq.c_cc > 1 && uio->uio_resid)
|
||||
if (ureadc(getc(&tp->t_canq), uio) < 0) {
|
||||
error = EFAULT;
|
||||
break;
|
||||
}
|
||||
if (tp->t_canq.c_cc == 1)
|
||||
(void) getc(&tp->t_canq);
|
||||
if (tp->t_canq.c_cc)
|
||||
return (error);
|
||||
} else
|
||||
if (tp->t_oproc)
|
||||
error = ttread(tp, uio, flag);
|
||||
ptcwakeup(tp, FWRITE);
|
||||
return (error);
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
while (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) {
|
||||
if ((u.u_procp->p_sigignore & sigmask(SIGTTIN)) ||
|
||||
(u.u_procp->p_sigmask & sigmask(SIGTTIN)) ||
|
||||
u.u_procp->p_flag&SVFORK)
|
||||
return (EIO);
|
||||
gsignal(u.u_procp->p_pgrp, SIGTTIN);
|
||||
sleep((caddr_t)&lbolt, TTIPRI);
|
||||
}
|
||||
if (tp->t_canq.c_cc == 0) {
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
sleep((caddr_t)&tp->t_canq, TTIPRI);
|
||||
goto again;
|
||||
}
|
||||
while (tp->t_canq.c_cc > 1 && uio->uio_resid)
|
||||
if (ureadc(getc(&tp->t_canq), uio) < 0) {
|
||||
error = EFAULT;
|
||||
break;
|
||||
}
|
||||
if (tp->t_canq.c_cc == 1)
|
||||
(void) getc(&tp->t_canq);
|
||||
if (tp->t_canq.c_cc)
|
||||
return (error);
|
||||
} else
|
||||
if (tp->t_oproc)
|
||||
error = ttread(tp, uio, flag);
|
||||
ptcwakeup(tp, FWRITE);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -142,12 +144,12 @@ again:
|
||||
*/
|
||||
int ptswrite(dev_t dev, register struct uio *uio, int flag)
|
||||
{
|
||||
register struct tty *tp;
|
||||
register struct tty *tp;
|
||||
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if (tp->t_oproc == 0)
|
||||
return (EIO);
|
||||
return ttwrite(tp, uio, flag);
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if (tp->t_oproc == 0)
|
||||
return (EIO);
|
||||
return ttwrite(tp, uio, flag);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -156,365 +158,365 @@ int ptswrite(dev_t dev, register struct uio *uio, int flag)
|
||||
*/
|
||||
void ptsstart(struct tty *tp)
|
||||
{
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
|
||||
if (tp->t_state & TS_TTSTOP)
|
||||
return;
|
||||
if (pti->pt_flags & PF_STOPPED) {
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send = TIOCPKT_START;
|
||||
}
|
||||
ptcwakeup(tp, FREAD);
|
||||
if (tp->t_state & TS_TTSTOP)
|
||||
return;
|
||||
if (pti->pt_flags & PF_STOPPED) {
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send = TIOCPKT_START;
|
||||
}
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
|
||||
void ptcwakeup(struct tty *tp, int flag)
|
||||
{
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
|
||||
if (flag & FREAD) {
|
||||
if (pti->pt_selr) {
|
||||
selwakeup(pti->pt_selr, (long)(pti->pt_flags & PF_RCOLL));
|
||||
pti->pt_selr = 0;
|
||||
pti->pt_flags &= ~PF_RCOLL;
|
||||
}
|
||||
wakeup((caddr_t)&tp->t_outq.c_cf);
|
||||
}
|
||||
if (flag & FWRITE) {
|
||||
if (pti->pt_selw) {
|
||||
selwakeup(pti->pt_selw, (long)(pti->pt_flags & PF_WCOLL));
|
||||
pti->pt_selw = 0;
|
||||
pti->pt_flags &= ~PF_WCOLL;
|
||||
}
|
||||
wakeup((caddr_t)&tp->t_rawq.c_cf);
|
||||
}
|
||||
if (flag & FREAD) {
|
||||
if (pti->pt_selr) {
|
||||
selwakeup(pti->pt_selr, (long)(pti->pt_flags & PF_RCOLL));
|
||||
pti->pt_selr = 0;
|
||||
pti->pt_flags &= ~PF_RCOLL;
|
||||
}
|
||||
wakeup((caddr_t)&tp->t_outq.c_cf);
|
||||
}
|
||||
if (flag & FWRITE) {
|
||||
if (pti->pt_selw) {
|
||||
selwakeup(pti->pt_selw, (long)(pti->pt_flags & PF_WCOLL));
|
||||
pti->pt_selw = 0;
|
||||
pti->pt_flags &= ~PF_WCOLL;
|
||||
}
|
||||
wakeup((caddr_t)&tp->t_rawq.c_cf);
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int ptcopen(dev_t dev, int flag, int mode)
|
||||
{
|
||||
register struct tty *tp;
|
||||
struct pt_ioctl *pti;
|
||||
register struct tty *tp;
|
||||
struct pt_ioctl *pti;
|
||||
|
||||
if (minor(dev) >= NPTY)
|
||||
return (ENXIO);
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if (tp->t_oproc)
|
||||
return (EIO);
|
||||
tp->t_oproc = ptsstart;
|
||||
ttymodem(tp, 1);
|
||||
pti = &pt_ioctl[minor(dev)];
|
||||
pti->pt_flags = 0;
|
||||
pti->pt_send = 0;
|
||||
pti->pt_ucntl = 0;
|
||||
return (0);
|
||||
if (minor(dev) >= NPTY)
|
||||
return (ENXIO);
|
||||
tp = &pt_tty[minor(dev)];
|
||||
if (tp->t_oproc)
|
||||
return (EIO);
|
||||
tp->t_oproc = ptsstart;
|
||||
ttymodem(tp, 1);
|
||||
pti = &pt_ioctl[minor(dev)];
|
||||
pti->pt_flags = 0;
|
||||
pti->pt_send = 0;
|
||||
pti->pt_ucntl = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptcclose(dev_t dev, int flag, int mode)
|
||||
{
|
||||
register struct tty *tp;
|
||||
register struct tty *tp;
|
||||
|
||||
tp = &pt_tty[minor(dev)];
|
||||
ttymodem(tp, 0);
|
||||
tp->t_state &= ~TS_CARR_ON;
|
||||
tp->t_oproc = 0; /* mark closed */
|
||||
return 0;
|
||||
tp = &pt_tty[minor(dev)];
|
||||
ttymodem(tp, 0);
|
||||
tp->t_state &= ~TS_CARR_ON;
|
||||
tp->t_oproc = 0; /* mark closed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ptcread(dev_t dev, register struct uio *uio, int flag)
|
||||
{
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
char buf[BUFSIZ];
|
||||
int error = 0, cc;
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
char buf[BUFSIZ];
|
||||
int error = 0, cc;
|
||||
|
||||
/*
|
||||
* We want to block until the slave
|
||||
* is open, and there's something to read;
|
||||
* but if we lost the slave or we're NBIO,
|
||||
* then return the appropriate error instead.
|
||||
*/
|
||||
for (;;) {
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags&PF_PKT && pti->pt_send) {
|
||||
error = ureadc((int)pti->pt_send, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
pti->pt_send = 0;
|
||||
return (0);
|
||||
}
|
||||
if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
|
||||
error = ureadc((int)pti->pt_ucntl, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
pti->pt_ucntl = 0;
|
||||
return (0);
|
||||
}
|
||||
if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
|
||||
break;
|
||||
}
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (0); /* EOF */
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
|
||||
}
|
||||
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
|
||||
error = ureadc(0, uio);
|
||||
while (uio->uio_resid && error == 0) {
|
||||
cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ));
|
||||
if (cc <= 0)
|
||||
break;
|
||||
error = uiomove(buf, cc, uio);
|
||||
}
|
||||
if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
|
||||
if (tp->t_state&TS_ASLEEP) {
|
||||
tp->t_state &= ~TS_ASLEEP;
|
||||
wakeup((caddr_t)&tp->t_outq);
|
||||
}
|
||||
if (tp->t_wsel) {
|
||||
selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
|
||||
tp->t_wsel = 0;
|
||||
tp->t_state &= ~TS_WCOLL;
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
/*
|
||||
* We want to block until the slave
|
||||
* is open, and there's something to read;
|
||||
* but if we lost the slave or we're NBIO,
|
||||
* then return the appropriate error instead.
|
||||
*/
|
||||
for (;;) {
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags&PF_PKT && pti->pt_send) {
|
||||
error = ureadc((int)pti->pt_send, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
pti->pt_send = 0;
|
||||
return (0);
|
||||
}
|
||||
if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
|
||||
error = ureadc((int)pti->pt_ucntl, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
pti->pt_ucntl = 0;
|
||||
return (0);
|
||||
}
|
||||
if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
|
||||
break;
|
||||
}
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (0); /* EOF */
|
||||
if (flag & IO_NDELAY)
|
||||
return (EWOULDBLOCK);
|
||||
sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
|
||||
}
|
||||
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
|
||||
error = ureadc(0, uio);
|
||||
while (uio->uio_resid && error == 0) {
|
||||
cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ));
|
||||
if (cc <= 0)
|
||||
break;
|
||||
error = uiomove(buf, cc, uio);
|
||||
}
|
||||
if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
|
||||
if (tp->t_state&TS_ASLEEP) {
|
||||
tp->t_state &= ~TS_ASLEEP;
|
||||
wakeup((caddr_t)&tp->t_outq);
|
||||
}
|
||||
if (tp->t_wsel) {
|
||||
selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
|
||||
tp->t_wsel = 0;
|
||||
tp->t_state &= ~TS_WCOLL;
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
void ptsstop(register struct tty *tp, int flush)
|
||||
{
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
int flag;
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
|
||||
int flag;
|
||||
|
||||
/* note: FLUSHREAD and FLUSHWRITE already ok */
|
||||
if (flush == 0) {
|
||||
flush = TIOCPKT_STOP;
|
||||
pti->pt_flags |= PF_STOPPED;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send |= flush;
|
||||
/* change of perspective */
|
||||
flag = 0;
|
||||
if (flush & FREAD)
|
||||
flag |= FWRITE;
|
||||
if (flush & FWRITE)
|
||||
flag |= FREAD;
|
||||
ptcwakeup(tp, flag);
|
||||
/* note: FLUSHREAD and FLUSHWRITE already ok */
|
||||
if (flush == 0) {
|
||||
flush = TIOCPKT_STOP;
|
||||
pti->pt_flags |= PF_STOPPED;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_STOPPED;
|
||||
pti->pt_send |= flush;
|
||||
/* change of perspective */
|
||||
flag = 0;
|
||||
if (flush & FREAD)
|
||||
flag |= FWRITE;
|
||||
if (flush & FWRITE)
|
||||
flag |= FREAD;
|
||||
ptcwakeup(tp, flag);
|
||||
}
|
||||
|
||||
int ptcselect(dev_t dev, int rw)
|
||||
{
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
struct proc *p;
|
||||
int s;
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
struct proc *p;
|
||||
int s;
|
||||
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (1);
|
||||
switch (rw) {
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (1);
|
||||
switch (rw) {
|
||||
|
||||
case FREAD:
|
||||
/*
|
||||
* Need to block timeouts (ttrstart).
|
||||
*/
|
||||
s = spltty();
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
splx(s);
|
||||
/* FALLTHROUGH */
|
||||
case FREAD:
|
||||
/*
|
||||
* Need to block timeouts (ttrstart).
|
||||
*/
|
||||
s = spltty();
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
splx(s);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 0: /* exceptional */
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
((pti->pt_flags&PF_PKT && pti->pt_send) ||
|
||||
(pti->pt_flags&PF_UCNTL && pti->pt_ucntl)))
|
||||
return (1);
|
||||
if ((p = pti->pt_selr) && p->p_wchan == (caddr_t)&selwait)
|
||||
pti->pt_flags |= PF_RCOLL;
|
||||
else
|
||||
pti->pt_selr = u.u_procp;
|
||||
break;
|
||||
case 0: /* exceptional */
|
||||
if ((tp->t_state&TS_ISOPEN) &&
|
||||
((pti->pt_flags&PF_PKT && pti->pt_send) ||
|
||||
(pti->pt_flags&PF_UCNTL && pti->pt_ucntl)))
|
||||
return (1);
|
||||
if ((p = pti->pt_selr) && p->p_wchan == (caddr_t)&selwait)
|
||||
pti->pt_flags |= PF_RCOLL;
|
||||
else
|
||||
pti->pt_selr = u.u_procp;
|
||||
break;
|
||||
|
||||
|
||||
case FWRITE:
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc == 0)
|
||||
return (1);
|
||||
} else {
|
||||
if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
|
||||
return (1);
|
||||
if (tp->t_canq.c_cc == 0 &&
|
||||
(tp->t_flags & (RAW|CBREAK)) == 0)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
if ((p = pti->pt_selw) && p->p_wchan == (caddr_t)&selwait)
|
||||
pti->pt_flags |= PF_WCOLL;
|
||||
else
|
||||
pti->pt_selw = u.u_procp;
|
||||
break;
|
||||
case FWRITE:
|
||||
if (tp->t_state&TS_ISOPEN) {
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc == 0)
|
||||
return (1);
|
||||
} else {
|
||||
if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
|
||||
return (1);
|
||||
if (tp->t_canq.c_cc == 0 &&
|
||||
(tp->t_flags & (RAW|CBREAK)) == 0)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
if ((p = pti->pt_selw) && p->p_wchan == (caddr_t)&selwait)
|
||||
pti->pt_flags |= PF_WCOLL;
|
||||
else
|
||||
pti->pt_selw = u.u_procp;
|
||||
break;
|
||||
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptcwrite(dev_t dev, register struct uio *uio, int flag)
|
||||
{
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register char *cp = NULL;
|
||||
register int cc = 0;
|
||||
char locbuf[BUFSIZ];
|
||||
int cnt = 0;
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int error = 0;
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register char *cp = NULL;
|
||||
register int cc = 0;
|
||||
char locbuf[BUFSIZ];
|
||||
int cnt = 0;
|
||||
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int error = 0;
|
||||
|
||||
again:
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
goto block;
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc)
|
||||
goto block;
|
||||
while (uio->uio_resid && tp->t_canq.c_cc < TTYHOG - 1) {
|
||||
if (cc == 0) {
|
||||
cc = MIN(uio->uio_resid, BUFSIZ);
|
||||
cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc);
|
||||
cp = locbuf;
|
||||
error = uiomove(cp, cc, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
/* check again for safety */
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
return (EIO);
|
||||
}
|
||||
if (cc)
|
||||
(void) b_to_q(cp, cc, &tp->t_canq);
|
||||
cc = 0;
|
||||
}
|
||||
(void) putc(0, &tp->t_canq);
|
||||
ttwakeup(tp);
|
||||
wakeup((caddr_t)&tp->t_canq);
|
||||
return (0);
|
||||
}
|
||||
while (uio->uio_resid > 0) {
|
||||
if (cc == 0) {
|
||||
cc = MIN(uio->uio_resid, BUFSIZ);
|
||||
cp = locbuf;
|
||||
error = uiomove(cp, cc, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
/* check again for safety */
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
return (EIO);
|
||||
}
|
||||
while (cc > 0) {
|
||||
if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
|
||||
(tp->t_canq.c_cc > 0 ||
|
||||
tp->t_flags & (RAW|CBREAK))) {
|
||||
wakeup((caddr_t)&tp->t_rawq);
|
||||
goto block;
|
||||
}
|
||||
ttyinput(*cp++, tp);
|
||||
cnt++;
|
||||
cc--;
|
||||
}
|
||||
cc = 0;
|
||||
}
|
||||
return (0);
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
goto block;
|
||||
if (pti->pt_flags & PF_REMOTE) {
|
||||
if (tp->t_canq.c_cc)
|
||||
goto block;
|
||||
while (uio->uio_resid && tp->t_canq.c_cc < TTYHOG - 1) {
|
||||
if (cc == 0) {
|
||||
cc = MIN(uio->uio_resid, BUFSIZ);
|
||||
cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc);
|
||||
cp = locbuf;
|
||||
error = uiomove(cp, cc, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
/* check again for safety */
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
return (EIO);
|
||||
}
|
||||
if (cc)
|
||||
(void) b_to_q(cp, cc, &tp->t_canq);
|
||||
cc = 0;
|
||||
}
|
||||
(void) putc(0, &tp->t_canq);
|
||||
ttwakeup(tp);
|
||||
wakeup((caddr_t)&tp->t_canq);
|
||||
return (0);
|
||||
}
|
||||
while (uio->uio_resid > 0) {
|
||||
if (cc == 0) {
|
||||
cc = MIN(uio->uio_resid, BUFSIZ);
|
||||
cp = locbuf;
|
||||
error = uiomove(cp, cc, uio);
|
||||
if (error)
|
||||
return (error);
|
||||
/* check again for safety */
|
||||
if ((tp->t_state&TS_ISOPEN) == 0)
|
||||
return (EIO);
|
||||
}
|
||||
while (cc > 0) {
|
||||
if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
|
||||
(tp->t_canq.c_cc > 0 ||
|
||||
tp->t_flags & (RAW|CBREAK))) {
|
||||
wakeup((caddr_t)&tp->t_rawq);
|
||||
goto block;
|
||||
}
|
||||
ttyinput(*cp++, tp);
|
||||
cnt++;
|
||||
cc--;
|
||||
}
|
||||
cc = 0;
|
||||
}
|
||||
return (0);
|
||||
block:
|
||||
/*
|
||||
* Come here to wait for slave to open, for space
|
||||
* in outq, or space in rawq.
|
||||
*/
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (EIO);
|
||||
if (flag & IO_NDELAY) {
|
||||
/* adjust for data copied in but not written */
|
||||
uio->uio_resid += cc;
|
||||
if (cnt == 0)
|
||||
return (EWOULDBLOCK);
|
||||
return (0);
|
||||
}
|
||||
sleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI);
|
||||
goto again;
|
||||
/*
|
||||
* Come here to wait for slave to open, for space
|
||||
* in outq, or space in rawq.
|
||||
*/
|
||||
if ((tp->t_state&TS_CARR_ON) == 0)
|
||||
return (EIO);
|
||||
if (flag & IO_NDELAY) {
|
||||
/* adjust for data copied in but not written */
|
||||
uio->uio_resid += cc;
|
||||
if (cnt == 0)
|
||||
return (EWOULDBLOCK);
|
||||
return (0);
|
||||
}
|
||||
sleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI);
|
||||
goto again;
|
||||
}
|
||||
|
||||
int ptyioctl(dev_t dev, u_int cmd, caddr_t data, int flag)
|
||||
{
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int stop, error;
|
||||
register struct tty *tp = &pt_tty[minor(dev)];
|
||||
register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
|
||||
int stop, error;
|
||||
|
||||
/*
|
||||
* IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
|
||||
* ttywflush(tp) will hang if there are characters in the outq.
|
||||
*/
|
||||
if (cdevsw[major(dev)].d_open == ptcopen)
|
||||
switch (cmd) {
|
||||
/*
|
||||
* IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
|
||||
* ttywflush(tp) will hang if there are characters in the outq.
|
||||
*/
|
||||
if (cdevsw[major(dev)].d_open == ptcopen)
|
||||
switch (cmd) {
|
||||
|
||||
case TIOCPKT:
|
||||
if (*(int *)data) {
|
||||
if (pti->pt_flags & PF_UCNTL)
|
||||
return (EINVAL);
|
||||
pti->pt_flags |= PF_PKT;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_PKT;
|
||||
return (0);
|
||||
case TIOCPKT:
|
||||
if (*(int *)data) {
|
||||
if (pti->pt_flags & PF_UCNTL)
|
||||
return (EINVAL);
|
||||
pti->pt_flags |= PF_PKT;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_PKT;
|
||||
return (0);
|
||||
|
||||
case TIOCUCNTL:
|
||||
if (*(int *)data) {
|
||||
if (pti->pt_flags & PF_PKT)
|
||||
return (EINVAL);
|
||||
pti->pt_flags |= PF_UCNTL;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_UCNTL;
|
||||
return (0);
|
||||
case TIOCUCNTL:
|
||||
if (*(int *)data) {
|
||||
if (pti->pt_flags & PF_PKT)
|
||||
return (EINVAL);
|
||||
pti->pt_flags |= PF_UCNTL;
|
||||
} else
|
||||
pti->pt_flags &= ~PF_UCNTL;
|
||||
return (0);
|
||||
|
||||
case TIOCREMOTE:
|
||||
if (*(int *)data)
|
||||
pti->pt_flags |= PF_REMOTE;
|
||||
else
|
||||
pti->pt_flags &= ~PF_REMOTE;
|
||||
ttyflush(tp, FREAD|FWRITE);
|
||||
return (0);
|
||||
case TIOCREMOTE:
|
||||
if (*(int *)data)
|
||||
pti->pt_flags |= PF_REMOTE;
|
||||
else
|
||||
pti->pt_flags &= ~PF_REMOTE;
|
||||
ttyflush(tp, FREAD|FWRITE);
|
||||
return (0);
|
||||
|
||||
case TIOCSETP:
|
||||
case TIOCSETN:
|
||||
case TIOCSETD:
|
||||
while (getc(&tp->t_outq) >= 0)
|
||||
;
|
||||
break;
|
||||
}
|
||||
error = ttioctl (tp, cmd, data, flag);
|
||||
if (error < 0) {
|
||||
if (pti->pt_flags & PF_UCNTL &&
|
||||
(cmd & ~0xff) == UIOCCMD(0)) {
|
||||
if (cmd & 0xff) {
|
||||
pti->pt_ucntl = (u_char)cmd;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
error = ENOTTY;
|
||||
}
|
||||
stop = (tp->t_flags & RAW) == 0 &&
|
||||
tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q');
|
||||
if (pti->pt_flags & PF_NOSTOP) {
|
||||
if (stop) {
|
||||
pti->pt_send &= ~TIOCPKT_NOSTOP;
|
||||
pti->pt_send |= TIOCPKT_DOSTOP;
|
||||
pti->pt_flags &= ~PF_NOSTOP;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
} else {
|
||||
if (!stop) {
|
||||
pti->pt_send &= ~TIOCPKT_DOSTOP;
|
||||
pti->pt_send |= TIOCPKT_NOSTOP;
|
||||
pti->pt_flags |= PF_NOSTOP;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
case TIOCSETP:
|
||||
case TIOCSETN:
|
||||
case TIOCSETD:
|
||||
while (getc(&tp->t_outq) >= 0)
|
||||
;
|
||||
break;
|
||||
}
|
||||
error = ttioctl (tp, cmd, data, flag);
|
||||
if (error < 0) {
|
||||
if (pti->pt_flags & PF_UCNTL &&
|
||||
(cmd & ~0xff) == UIOCCMD(0)) {
|
||||
if (cmd & 0xff) {
|
||||
pti->pt_ucntl = (u_char)cmd;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
error = ENOTTY;
|
||||
}
|
||||
stop = (tp->t_flags & RAW) == 0 &&
|
||||
tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q');
|
||||
if (pti->pt_flags & PF_NOSTOP) {
|
||||
if (stop) {
|
||||
pti->pt_send &= ~TIOCPKT_NOSTOP;
|
||||
pti->pt_send |= TIOCPKT_DOSTOP;
|
||||
pti->pt_flags &= ~PF_NOSTOP;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
} else {
|
||||
if (!stop) {
|
||||
pti->pt_send &= ~TIOCPKT_DOSTOP;
|
||||
pti->pt_send |= TIOCPKT_NOSTOP;
|
||||
pti->pt_flags |= PF_NOSTOP;
|
||||
ptcwakeup(tp, FREAD);
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,52 +9,52 @@
|
||||
#include "tty.h"
|
||||
#include "systm.h"
|
||||
|
||||
char cwaiting;
|
||||
char cwaiting;
|
||||
|
||||
/*
|
||||
* Character list get/put
|
||||
*/
|
||||
int
|
||||
getc(p)
|
||||
register struct clist *p;
|
||||
register struct clist *p;
|
||||
{
|
||||
register struct cblock *bp;
|
||||
register int c, s;
|
||||
register struct cblock *bp;
|
||||
register int c, s;
|
||||
|
||||
s = spltty();
|
||||
if (p->c_cc <= 0) {
|
||||
c = -1;
|
||||
p->c_cc = 0;
|
||||
p->c_cf = p->c_cl = NULL;
|
||||
} else {
|
||||
c = *p->c_cf++ & 0377;
|
||||
if (--p->c_cc<=0) {
|
||||
bp = (struct cblock *)(p->c_cf-1);
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
p->c_cf = NULL;
|
||||
p->c_cl = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
} else if (((int)p->c_cf & CROUND) == 0){
|
||||
bp = (struct cblock *)(p->c_cf);
|
||||
bp--;
|
||||
p->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (c);
|
||||
s = spltty();
|
||||
if (p->c_cc <= 0) {
|
||||
c = -1;
|
||||
p->c_cc = 0;
|
||||
p->c_cf = p->c_cl = NULL;
|
||||
} else {
|
||||
c = *p->c_cf++ & 0377;
|
||||
if (--p->c_cc<=0) {
|
||||
bp = (struct cblock *)(p->c_cf-1);
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
p->c_cf = NULL;
|
||||
p->c_cl = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
} else if (((int)p->c_cf & CROUND) == 0){
|
||||
bp = (struct cblock *)(p->c_cf);
|
||||
bp--;
|
||||
p->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -63,62 +63,62 @@ getc(p)
|
||||
*/
|
||||
int
|
||||
q_to_b (q, cp, cc)
|
||||
register struct clist *q;
|
||||
char *cp;
|
||||
register struct clist *q;
|
||||
char *cp;
|
||||
{
|
||||
register struct cblock *bp;
|
||||
register int nc;
|
||||
int s;
|
||||
char *acp;
|
||||
register struct cblock *bp;
|
||||
register int nc;
|
||||
int s;
|
||||
char *acp;
|
||||
|
||||
if (cc <= 0)
|
||||
return (0);
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0) {
|
||||
q->c_cc = 0;
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
acp = cp;
|
||||
if (cc <= 0)
|
||||
return (0);
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0) {
|
||||
q->c_cc = 0;
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
acp = cp;
|
||||
|
||||
while (cc) {
|
||||
nc = sizeof (struct cblock) - ((int)q->c_cf & CROUND);
|
||||
nc = MIN(nc, cc);
|
||||
nc = MIN(nc, q->c_cc);
|
||||
(void) bcopy(q->c_cf, cp, (unsigned)nc);
|
||||
q->c_cf += nc;
|
||||
q->c_cc -= nc;
|
||||
cc -= nc;
|
||||
cp += nc;
|
||||
if (q->c_cc <= 0) {
|
||||
bp = (struct cblock *)(q->c_cf - 1);
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (((int)q->c_cf & CROUND) == 0) {
|
||||
bp = (struct cblock *)(q->c_cf);
|
||||
bp--;
|
||||
q->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (cp - acp);
|
||||
while (cc) {
|
||||
nc = sizeof (struct cblock) - ((int)q->c_cf & CROUND);
|
||||
nc = MIN(nc, cc);
|
||||
nc = MIN(nc, q->c_cc);
|
||||
(void) bcopy(q->c_cf, cp, (unsigned)nc);
|
||||
q->c_cf += nc;
|
||||
q->c_cc -= nc;
|
||||
cc -= nc;
|
||||
cp += nc;
|
||||
if (q->c_cc <= 0) {
|
||||
bp = (struct cblock *)(q->c_cf - 1);
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (((int)q->c_cf & CROUND) == 0) {
|
||||
bp = (struct cblock *)(q->c_cf);
|
||||
bp--;
|
||||
q->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (cp - acp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -127,38 +127,38 @@ q_to_b (q, cp, cc)
|
||||
* Stop counting if flag&character is non-null.
|
||||
*/
|
||||
int ndqb (q, flag)
|
||||
register struct clist *q;
|
||||
register struct clist *q;
|
||||
{
|
||||
int cc;
|
||||
int s;
|
||||
int cc;
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0) {
|
||||
cc = -q->c_cc;
|
||||
goto out;
|
||||
}
|
||||
cc = ((int)q->c_cf + CBSIZE) & ~CROUND;
|
||||
cc -= (int)q->c_cf;
|
||||
if (q->c_cc < cc)
|
||||
cc = q->c_cc;
|
||||
if (flag) {
|
||||
register char *p, *end;
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0) {
|
||||
cc = -q->c_cc;
|
||||
goto out;
|
||||
}
|
||||
cc = ((int)q->c_cf + CBSIZE) & ~CROUND;
|
||||
cc -= (int)q->c_cf;
|
||||
if (q->c_cc < cc)
|
||||
cc = q->c_cc;
|
||||
if (flag) {
|
||||
register char *p, *end;
|
||||
|
||||
p = q->c_cf;
|
||||
end = p;
|
||||
end += cc;
|
||||
while (p < end) {
|
||||
if (*p & flag) {
|
||||
cc = (int)p;
|
||||
cc -= (int)q->c_cf;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
p = q->c_cf;
|
||||
end = p;
|
||||
end += cc;
|
||||
while (p < end) {
|
||||
if (*p & flag) {
|
||||
cc = (int)p;
|
||||
cc -= (int)q->c_cf;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
out:
|
||||
splx(s);
|
||||
return (cc);
|
||||
splx(s);
|
||||
return (cc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -166,56 +166,56 @@ out:
|
||||
*/
|
||||
void
|
||||
ndflush (q, cc)
|
||||
register struct clist *q;
|
||||
register int cc;
|
||||
register struct clist *q;
|
||||
register int cc;
|
||||
{
|
||||
register struct cblock *bp;
|
||||
char *end;
|
||||
int rem, s;
|
||||
register struct cblock *bp;
|
||||
char *end;
|
||||
int rem, s;
|
||||
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0)
|
||||
goto out;
|
||||
while (cc>0 && q->c_cc) {
|
||||
bp = (struct cblock *)((int)q->c_cf & ~CROUND);
|
||||
if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) {
|
||||
end = q->c_cl;
|
||||
} else {
|
||||
end = (char *)((int)bp + sizeof (struct cblock));
|
||||
}
|
||||
rem = end - q->c_cf;
|
||||
if (cc >= rem) {
|
||||
cc -= rem;
|
||||
q->c_cc -= rem;
|
||||
q->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
} else {
|
||||
q->c_cc -= cc;
|
||||
q->c_cf += cc;
|
||||
if (q->c_cc <= 0) {
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (q->c_cc <= 0) {
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
q->c_cc = 0;
|
||||
}
|
||||
s = spltty();
|
||||
if (q->c_cc <= 0)
|
||||
goto out;
|
||||
while (cc>0 && q->c_cc) {
|
||||
bp = (struct cblock *)((int)q->c_cf & ~CROUND);
|
||||
if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) {
|
||||
end = q->c_cl;
|
||||
} else {
|
||||
end = (char *)((int)bp + sizeof (struct cblock));
|
||||
}
|
||||
rem = end - q->c_cf;
|
||||
if (cc >= rem) {
|
||||
cc -= rem;
|
||||
q->c_cc -= rem;
|
||||
q->c_cf = bp->c_next->c_info;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
} else {
|
||||
q->c_cc -= cc;
|
||||
q->c_cf += cc;
|
||||
if (q->c_cc <= 0) {
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
if (cwaiting) {
|
||||
wakeup (&cwaiting);
|
||||
cwaiting = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (q->c_cc <= 0) {
|
||||
q->c_cf = q->c_cl = NULL;
|
||||
q->c_cc = 0;
|
||||
}
|
||||
out:
|
||||
splx(s);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -223,39 +223,39 @@ out:
|
||||
*/
|
||||
int
|
||||
putc (c, p)
|
||||
register struct clist *p;
|
||||
register struct clist *p;
|
||||
{
|
||||
register struct cblock *bp;
|
||||
register char *cp;
|
||||
register int s;
|
||||
register struct cblock *bp;
|
||||
register char *cp;
|
||||
register int s;
|
||||
|
||||
s = spltty();
|
||||
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
|
||||
if ((bp = cfreelist) == NULL) {
|
||||
splx(s);
|
||||
return (-1);
|
||||
}
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
p->c_cf = cp = bp->c_info;
|
||||
} else if (((int)cp & CROUND) == 0) {
|
||||
bp = (struct cblock *)cp - 1;
|
||||
if ((bp->c_next = cfreelist) == NULL) {
|
||||
splx(s);
|
||||
return (-1);
|
||||
}
|
||||
bp = bp->c_next;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
cp = bp->c_info;
|
||||
}
|
||||
*cp++ = c;
|
||||
p->c_cc++;
|
||||
p->c_cl = cp;
|
||||
splx(s);
|
||||
return (0);
|
||||
s = spltty();
|
||||
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
|
||||
if ((bp = cfreelist) == NULL) {
|
||||
splx(s);
|
||||
return (-1);
|
||||
}
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
p->c_cf = cp = bp->c_info;
|
||||
} else if (((int)cp & CROUND) == 0) {
|
||||
bp = (struct cblock *)cp - 1;
|
||||
if ((bp->c_next = cfreelist) == NULL) {
|
||||
splx(s);
|
||||
return (-1);
|
||||
}
|
||||
bp = bp->c_next;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
cp = bp->c_info;
|
||||
}
|
||||
*cp++ = c;
|
||||
p->c_cc++;
|
||||
p->c_cl = cp;
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -264,50 +264,50 @@ putc (c, p)
|
||||
*/
|
||||
int
|
||||
b_to_q (cp, cc, q)
|
||||
register char *cp;
|
||||
struct clist *q;
|
||||
register int cc;
|
||||
register char *cp;
|
||||
struct clist *q;
|
||||
register int cc;
|
||||
{
|
||||
register char *cq;
|
||||
register struct cblock *bp;
|
||||
register int s, nc;
|
||||
int acc;
|
||||
register char *cq;
|
||||
register struct cblock *bp;
|
||||
register int s, nc;
|
||||
int acc;
|
||||
|
||||
if (cc <= 0)
|
||||
return (0);
|
||||
acc = cc;
|
||||
s = spltty();
|
||||
if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
|
||||
if ((bp = cfreelist) == NULL)
|
||||
goto out;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
q->c_cf = cq = bp->c_info;
|
||||
}
|
||||
if (cc <= 0)
|
||||
return (0);
|
||||
acc = cc;
|
||||
s = spltty();
|
||||
if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
|
||||
if ((bp = cfreelist) == NULL)
|
||||
goto out;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
q->c_cf = cq = bp->c_info;
|
||||
}
|
||||
|
||||
while (cc) {
|
||||
if (((int)cq & CROUND) == 0) {
|
||||
bp = (struct cblock *)cq - 1;
|
||||
if ((bp->c_next = cfreelist) == NULL)
|
||||
goto out;
|
||||
bp = bp->c_next;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
cq = bp->c_info;
|
||||
}
|
||||
nc = MIN(cc, sizeof (struct cblock) - ((int)cq & CROUND));
|
||||
(void) bcopy(cp, cq, (unsigned)nc);
|
||||
cp += nc;
|
||||
cq += nc;
|
||||
cc -= nc;
|
||||
}
|
||||
while (cc) {
|
||||
if (((int)cq & CROUND) == 0) {
|
||||
bp = (struct cblock *)cq - 1;
|
||||
if ((bp->c_next = cfreelist) == NULL)
|
||||
goto out;
|
||||
bp = bp->c_next;
|
||||
cfreelist = bp->c_next;
|
||||
cfreecount -= CBSIZE;
|
||||
bp->c_next = NULL;
|
||||
cq = bp->c_info;
|
||||
}
|
||||
nc = MIN(cc, sizeof (struct cblock) - ((int)cq & CROUND));
|
||||
(void) bcopy(cp, cq, (unsigned)nc);
|
||||
cp += nc;
|
||||
cq += nc;
|
||||
cc -= nc;
|
||||
}
|
||||
out:
|
||||
q->c_cl = cq;
|
||||
q->c_cc += acc - cc;
|
||||
splx(s);
|
||||
return (cc);
|
||||
q->c_cl = cq;
|
||||
q->c_cc += acc - cc;
|
||||
splx(s);
|
||||
return (cc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -320,19 +320,19 @@ out:
|
||||
*/
|
||||
char *
|
||||
nextc (p, cp)
|
||||
register struct clist *p;
|
||||
register char *cp;
|
||||
register struct clist *p;
|
||||
register char *cp;
|
||||
{
|
||||
register char *rcp;
|
||||
register char *rcp;
|
||||
|
||||
if (p->c_cc && ++cp != p->c_cl) {
|
||||
if (((int)cp & CROUND) == 0)
|
||||
rcp = ((struct cblock *)cp)[-1].c_next->c_info;
|
||||
else
|
||||
rcp = cp;
|
||||
} else
|
||||
rcp = (char *)NULL;
|
||||
return (rcp);
|
||||
if (p->c_cc && ++cp != p->c_cl) {
|
||||
if (((int)cp & CROUND) == 0)
|
||||
rcp = ((struct cblock *)cp)[-1].c_next->c_info;
|
||||
else
|
||||
rcp = cp;
|
||||
} else
|
||||
rcp = (char *)NULL;
|
||||
return (rcp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -340,41 +340,41 @@ nextc (p, cp)
|
||||
*/
|
||||
int
|
||||
unputc (p)
|
||||
register struct clist *p;
|
||||
register struct clist *p;
|
||||
{
|
||||
register struct cblock *bp;
|
||||
register int c, s;
|
||||
struct cblock *obp;
|
||||
register struct cblock *bp;
|
||||
register int c, s;
|
||||
struct cblock *obp;
|
||||
|
||||
s = spltty();
|
||||
if (p->c_cc <= 0)
|
||||
c = -1;
|
||||
else {
|
||||
c = *--p->c_cl;
|
||||
if (--p->c_cc <= 0) {
|
||||
bp = (struct cblock *)p->c_cl;
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
p->c_cl = p->c_cf = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
} else if (((int)p->c_cl & CROUND) == sizeof(bp->c_next)) {
|
||||
p->c_cl = (char *)((int)p->c_cl & ~CROUND);
|
||||
bp = (struct cblock *)p->c_cf;
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
while (bp->c_next != (struct cblock *)p->c_cl)
|
||||
bp = bp->c_next;
|
||||
obp = bp;
|
||||
p->c_cl = (char *)(bp + 1);
|
||||
bp = bp->c_next;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
obp->c_next = NULL;
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (c);
|
||||
s = spltty();
|
||||
if (p->c_cc <= 0)
|
||||
c = -1;
|
||||
else {
|
||||
c = *--p->c_cl;
|
||||
if (--p->c_cc <= 0) {
|
||||
bp = (struct cblock *)p->c_cl;
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
p->c_cl = p->c_cf = NULL;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
} else if (((int)p->c_cl & CROUND) == sizeof(bp->c_next)) {
|
||||
p->c_cl = (char *)((int)p->c_cl & ~CROUND);
|
||||
bp = (struct cblock *)p->c_cf;
|
||||
bp = (struct cblock *)((int)bp & ~CROUND);
|
||||
while (bp->c_next != (struct cblock *)p->c_cl)
|
||||
bp = bp->c_next;
|
||||
obp = bp;
|
||||
p->c_cl = (char *)(bp + 1);
|
||||
bp = bp->c_next;
|
||||
bp->c_next = cfreelist;
|
||||
cfreelist = bp;
|
||||
cfreecount += CBSIZE;
|
||||
obp->c_next = NULL;
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -383,24 +383,24 @@ unputc (p)
|
||||
*/
|
||||
void
|
||||
catq (from, to)
|
||||
register struct clist *from, *to;
|
||||
register struct clist *from, *to;
|
||||
{
|
||||
char bbuf [CBSIZE*4];
|
||||
register int c;
|
||||
int s;
|
||||
char bbuf [CBSIZE*4];
|
||||
register int c;
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
if (to->c_cc == 0) {
|
||||
*to = *from;
|
||||
from->c_cc = 0;
|
||||
from->c_cf = NULL;
|
||||
from->c_cl = NULL;
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
splx(s);
|
||||
while (from->c_cc > 0) {
|
||||
c = q_to_b(from, bbuf, sizeof bbuf);
|
||||
(void) b_to_q(bbuf, c, to);
|
||||
}
|
||||
s = spltty();
|
||||
if (to->c_cc == 0) {
|
||||
*to = *from;
|
||||
from->c_cc = 0;
|
||||
from->c_cf = NULL;
|
||||
from->c_cl = NULL;
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
splx(s);
|
||||
while (from->c_cc > 0) {
|
||||
c = q_to_b(from, bbuf, sizeof bbuf);
|
||||
(void) b_to_q(bbuf, c, to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*
|
||||
* @(#)tty_tty.c 1.2 (2.11BSD GTE) 11/29/94
|
||||
* @(#)tty_tty.c 1.2 (2.11BSD GTE) 11/29/94
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -25,66 +25,66 @@ const struct devspec sydevs[] = {
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
syopen (dev, flag)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
int flag;
|
||||
{
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag, 0));
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag, 0));
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
syread (dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio, flag));
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio, flag));
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
sywrite (dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
{
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio, flag));
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio, flag));
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
syioctl (dev, cmd, addr, flag)
|
||||
dev_t dev;
|
||||
u_int cmd;
|
||||
caddr_t addr;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
u_int cmd;
|
||||
caddr_t addr;
|
||||
int flag;
|
||||
{
|
||||
if (cmd == TIOCNOTTY) {
|
||||
u.u_ttyp = 0;
|
||||
u.u_ttyd = 0;
|
||||
u.u_procp->p_pgrp = 0;
|
||||
return (0);
|
||||
}
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag));
|
||||
if (cmd == TIOCNOTTY) {
|
||||
u.u_ttyp = 0;
|
||||
u.u_ttyd = 0;
|
||||
u.u_procp->p_pgrp = 0;
|
||||
return (0);
|
||||
}
|
||||
if (u.u_ttyp == NULL)
|
||||
return (ENXIO);
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag));
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
syselect (dev, flag)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
dev_t dev;
|
||||
int flag;
|
||||
{
|
||||
|
||||
if (u.u_ttyp == NULL) {
|
||||
u.u_error = ENXIO;
|
||||
return (0);
|
||||
}
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag));
|
||||
if (u.u_ttyp == NULL) {
|
||||
u.u_error = ENXIO;
|
||||
return (0);
|
||||
}
|
||||
return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "proc.h"
|
||||
#include "systm.h"
|
||||
|
||||
typedef struct fblk *FBLKP;
|
||||
typedef struct fblk *FBLKP;
|
||||
|
||||
/*
|
||||
* Allocate a block in the file system.
|
||||
@@ -26,91 +26,91 @@ typedef struct fblk *FBLKP;
|
||||
*/
|
||||
struct buf *
|
||||
balloc(ip, flags)
|
||||
struct inode *ip;
|
||||
int flags;
|
||||
struct inode *ip;
|
||||
int flags;
|
||||
{
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
int async;
|
||||
daddr_t bno;
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
int async;
|
||||
daddr_t bno;
|
||||
|
||||
fs = ip->i_fs;
|
||||
async = fs->fs_flags & MNT_ASYNC;
|
||||
fs = ip->i_fs;
|
||||
async = fs->fs_flags & MNT_ASYNC;
|
||||
|
||||
while (fs->fs_flock)
|
||||
sleep((caddr_t)&fs->fs_flock, PINOD);
|
||||
do {
|
||||
if (fs->fs_nfree <= 0)
|
||||
goto nospace;
|
||||
if (fs->fs_nfree > NICFREE) {
|
||||
fserr (fs, "bad free count");
|
||||
goto nospace;
|
||||
}
|
||||
bno = fs->fs_free[--fs->fs_nfree];
|
||||
if (bno == 0)
|
||||
goto nospace;
|
||||
} while (badblock(fs, bno));
|
||||
if (fs->fs_nfree <= 0) {
|
||||
fs->fs_flock++;
|
||||
bp = bread(ip->i_dev, bno);
|
||||
if (((bp->b_flags&B_ERROR) == 0) && (bp->b_resid==0)) {
|
||||
register struct fblk *fbp;
|
||||
while (fs->fs_flock)
|
||||
sleep((caddr_t)&fs->fs_flock, PINOD);
|
||||
do {
|
||||
if (fs->fs_nfree <= 0)
|
||||
goto nospace;
|
||||
if (fs->fs_nfree > NICFREE) {
|
||||
fserr (fs, "bad free count");
|
||||
goto nospace;
|
||||
}
|
||||
bno = fs->fs_free[--fs->fs_nfree];
|
||||
if (bno == 0)
|
||||
goto nospace;
|
||||
} while (badblock(fs, bno));
|
||||
if (fs->fs_nfree <= 0) {
|
||||
fs->fs_flock++;
|
||||
bp = bread(ip->i_dev, bno);
|
||||
if (((bp->b_flags&B_ERROR) == 0) && (bp->b_resid==0)) {
|
||||
register struct fblk *fbp;
|
||||
|
||||
fbp = (FBLKP) bp->b_addr;
|
||||
*((FBLKP)&fs->fs_nfree) = *fbp;
|
||||
}
|
||||
brelse(bp);
|
||||
/*
|
||||
* Write the superblock back, synchronously if requested,
|
||||
* so that the free list pointer won't point at garbage.
|
||||
* We can still end up with dups in free if we then
|
||||
* use some of the blocks in this freeblock, then crash
|
||||
* without a sync.
|
||||
*/
|
||||
bp = getblk(ip->i_dev, SUPERB);
|
||||
fs->fs_fmod = 0;
|
||||
fs->fs_time = time.tv_sec;
|
||||
{
|
||||
register struct fs *fps;
|
||||
fbp = (FBLKP) bp->b_addr;
|
||||
*((FBLKP)&fs->fs_nfree) = *fbp;
|
||||
}
|
||||
brelse(bp);
|
||||
/*
|
||||
* Write the superblock back, synchronously if requested,
|
||||
* so that the free list pointer won't point at garbage.
|
||||
* We can still end up with dups in free if we then
|
||||
* use some of the blocks in this freeblock, then crash
|
||||
* without a sync.
|
||||
*/
|
||||
bp = getblk(ip->i_dev, SUPERB);
|
||||
fs->fs_fmod = 0;
|
||||
fs->fs_time = time.tv_sec;
|
||||
{
|
||||
register struct fs *fps;
|
||||
|
||||
fps = (struct fs*) bp->b_addr;
|
||||
*fps = *fs;
|
||||
}
|
||||
if (!async)
|
||||
bwrite(bp);
|
||||
else
|
||||
bdwrite(bp);
|
||||
fs->fs_flock = 0;
|
||||
wakeup((caddr_t)&fs->fs_flock);
|
||||
if (fs->fs_nfree <=0)
|
||||
goto nospace;
|
||||
}
|
||||
bp = getblk(ip->i_dev, bno);
|
||||
bp->b_resid = 0;
|
||||
if (flags & B_CLRBUF)
|
||||
bzero (bp->b_addr, MAXBSIZE);
|
||||
fs->fs_fmod = 1;
|
||||
fs->fs_tfree--;
|
||||
return(bp);
|
||||
fps = (struct fs*) bp->b_addr;
|
||||
*fps = *fs;
|
||||
}
|
||||
if (!async)
|
||||
bwrite(bp);
|
||||
else
|
||||
bdwrite(bp);
|
||||
fs->fs_flock = 0;
|
||||
wakeup((caddr_t)&fs->fs_flock);
|
||||
if (fs->fs_nfree <=0)
|
||||
goto nospace;
|
||||
}
|
||||
bp = getblk(ip->i_dev, bno);
|
||||
bp->b_resid = 0;
|
||||
if (flags & B_CLRBUF)
|
||||
bzero (bp->b_addr, MAXBSIZE);
|
||||
fs->fs_fmod = 1;
|
||||
fs->fs_tfree--;
|
||||
return(bp);
|
||||
|
||||
nospace:
|
||||
fs->fs_nfree = 0;
|
||||
fs->fs_tfree = 0;
|
||||
fserr (fs, "file system full");
|
||||
/*
|
||||
* THIS IS A KLUDGE...
|
||||
* SHOULD RATHER SEND A SIGNAL AND SUSPEND THE PROCESS IN A
|
||||
* STATE FROM WHICH THE SYSTEM CALL WILL RESTART
|
||||
*/
|
||||
uprintf("\n%s: write failed, file system full\n", fs->fs_fsmnt);
|
||||
{
|
||||
register int i;
|
||||
fs->fs_nfree = 0;
|
||||
fs->fs_tfree = 0;
|
||||
fserr (fs, "file system full");
|
||||
/*
|
||||
* THIS IS A KLUDGE...
|
||||
* SHOULD RATHER SEND A SIGNAL AND SUSPEND THE PROCESS IN A
|
||||
* STATE FROM WHICH THE SYSTEM CALL WILL RESTART
|
||||
*/
|
||||
uprintf("\n%s: write failed, file system full\n", fs->fs_fsmnt);
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
sleep((caddr_t)&lbolt, PRIBIO);
|
||||
}
|
||||
u.u_error = ENOSPC;
|
||||
return(NULL);
|
||||
for (i = 0; i < 5; i++)
|
||||
sleep((caddr_t)&lbolt, PRIBIO);
|
||||
}
|
||||
u.u_error = ENOSPC;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -123,98 +123,98 @@ nospace:
|
||||
*/
|
||||
struct inode *
|
||||
ialloc (pip)
|
||||
struct inode *pip;
|
||||
struct inode *pip;
|
||||
{
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
register struct inode *ip;
|
||||
int i;
|
||||
struct dinode *dp;
|
||||
ino_t ino;
|
||||
daddr_t adr;
|
||||
ino_t inobas;
|
||||
int first;
|
||||
struct inode *ifind();
|
||||
char *emsg = "no inodes free";
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
register struct inode *ip;
|
||||
int i;
|
||||
struct dinode *dp;
|
||||
ino_t ino;
|
||||
daddr_t adr;
|
||||
ino_t inobas;
|
||||
int first;
|
||||
struct inode *ifind();
|
||||
char *emsg = "no inodes free";
|
||||
|
||||
fs = pip->i_fs;
|
||||
while (fs->fs_ilock)
|
||||
sleep((caddr_t)&fs->fs_ilock, PINOD);
|
||||
fs = pip->i_fs;
|
||||
while (fs->fs_ilock)
|
||||
sleep((caddr_t)&fs->fs_ilock, PINOD);
|
||||
loop:
|
||||
if (fs->fs_ninode > 0) {
|
||||
ino = fs->fs_inode[--fs->fs_ninode];
|
||||
if (ino <= ROOTINO)
|
||||
goto loop;
|
||||
ip = iget(pip->i_dev, fs, ino);
|
||||
if (ip == NULL)
|
||||
return(NULL);
|
||||
if (ip->i_mode == 0) {
|
||||
bzero((caddr_t)ip->i_addr,sizeof(ip->i_addr));
|
||||
ip->i_flags = 0;
|
||||
fs->fs_fmod = 1;
|
||||
fs->fs_tinode--;
|
||||
return(ip);
|
||||
}
|
||||
/*
|
||||
* Inode was allocated after all.
|
||||
* Look some more.
|
||||
*/
|
||||
iput(ip);
|
||||
goto loop;
|
||||
}
|
||||
fs->fs_ilock++;
|
||||
if (fs->fs_nbehind < 4 * NICINOD) {
|
||||
first = 1;
|
||||
ino = fs->fs_lasti;
|
||||
if (fs->fs_ninode > 0) {
|
||||
ino = fs->fs_inode[--fs->fs_ninode];
|
||||
if (ino <= ROOTINO)
|
||||
goto loop;
|
||||
ip = iget(pip->i_dev, fs, ino);
|
||||
if (ip == NULL)
|
||||
return(NULL);
|
||||
if (ip->i_mode == 0) {
|
||||
bzero((caddr_t)ip->i_addr,sizeof(ip->i_addr));
|
||||
ip->i_flags = 0;
|
||||
fs->fs_fmod = 1;
|
||||
fs->fs_tinode--;
|
||||
return(ip);
|
||||
}
|
||||
/*
|
||||
* Inode was allocated after all.
|
||||
* Look some more.
|
||||
*/
|
||||
iput(ip);
|
||||
goto loop;
|
||||
}
|
||||
fs->fs_ilock++;
|
||||
if (fs->fs_nbehind < 4 * NICINOD) {
|
||||
first = 1;
|
||||
ino = fs->fs_lasti;
|
||||
#ifdef DIAGNOSTIC
|
||||
if (itoo(ino))
|
||||
panic("ialloc");
|
||||
if (itoo(ino))
|
||||
panic("ialloc");
|
||||
#endif
|
||||
adr = itod(ino);
|
||||
} else {
|
||||
adr = itod(ino);
|
||||
} else {
|
||||
fromtop:
|
||||
first = 0;
|
||||
ino = 1;
|
||||
adr = SUPERB+1;
|
||||
fs->fs_nbehind = 0;
|
||||
}
|
||||
inobas = 0;
|
||||
for (; adr < fs->fs_isize; adr++) {
|
||||
inobas = ino;
|
||||
bp = bread(pip->i_dev, adr);
|
||||
if ((bp->b_flags & B_ERROR) || bp->b_resid) {
|
||||
brelse(bp);
|
||||
ino += INOPB;
|
||||
continue;
|
||||
}
|
||||
dp = (struct dinode*) bp->b_addr;
|
||||
for (i = 0;i < INOPB;i++) {
|
||||
if (dp->di_mode != 0)
|
||||
goto cont;
|
||||
if (ifind(pip->i_dev, ino))
|
||||
goto cont;
|
||||
fs->fs_inode[fs->fs_ninode++] = ino;
|
||||
if (fs->fs_ninode >= NICINOD)
|
||||
break;
|
||||
cont:
|
||||
ino++;
|
||||
dp++;
|
||||
}
|
||||
brelse(bp);
|
||||
if (fs->fs_ninode >= NICINOD)
|
||||
break;
|
||||
}
|
||||
if (fs->fs_ninode < NICINOD && first)
|
||||
goto fromtop;
|
||||
fs->fs_lasti = inobas;
|
||||
fs->fs_ilock = 0;
|
||||
wakeup((caddr_t)&fs->fs_ilock);
|
||||
if (fs->fs_ninode > 0)
|
||||
goto loop;
|
||||
fserr (fs, emsg);
|
||||
uprintf("\n%s: %s\n", fs->fs_fsmnt, emsg);
|
||||
u.u_error = ENOSPC;
|
||||
return(NULL);
|
||||
first = 0;
|
||||
ino = 1;
|
||||
adr = SUPERB+1;
|
||||
fs->fs_nbehind = 0;
|
||||
}
|
||||
inobas = 0;
|
||||
for (; adr < fs->fs_isize; adr++) {
|
||||
inobas = ino;
|
||||
bp = bread(pip->i_dev, adr);
|
||||
if ((bp->b_flags & B_ERROR) || bp->b_resid) {
|
||||
brelse(bp);
|
||||
ino += INOPB;
|
||||
continue;
|
||||
}
|
||||
dp = (struct dinode*) bp->b_addr;
|
||||
for (i = 0;i < INOPB;i++) {
|
||||
if (dp->di_mode != 0)
|
||||
goto cont;
|
||||
if (ifind(pip->i_dev, ino))
|
||||
goto cont;
|
||||
fs->fs_inode[fs->fs_ninode++] = ino;
|
||||
if (fs->fs_ninode >= NICINOD)
|
||||
break;
|
||||
cont:
|
||||
ino++;
|
||||
dp++;
|
||||
}
|
||||
brelse(bp);
|
||||
if (fs->fs_ninode >= NICINOD)
|
||||
break;
|
||||
}
|
||||
if (fs->fs_ninode < NICINOD && first)
|
||||
goto fromtop;
|
||||
fs->fs_lasti = inobas;
|
||||
fs->fs_ilock = 0;
|
||||
wakeup((caddr_t)&fs->fs_ilock);
|
||||
if (fs->fs_ninode > 0)
|
||||
goto loop;
|
||||
fserr (fs, emsg);
|
||||
uprintf("\n%s: %s\n", fs->fs_fsmnt, emsg);
|
||||
u.u_error = ENOSPC;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -225,40 +225,40 @@ fromtop:
|
||||
*/
|
||||
void
|
||||
free (ip, bno)
|
||||
struct inode *ip;
|
||||
daddr_t bno;
|
||||
struct inode *ip;
|
||||
daddr_t bno;
|
||||
{
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
struct fblk *fbp;
|
||||
register struct fs *fs;
|
||||
register struct buf *bp;
|
||||
struct fblk *fbp;
|
||||
|
||||
fs = ip->i_fs;
|
||||
if (badblock (fs, bno)) {
|
||||
printf("bad block %D, ino %d\n", bno, ip->i_number);
|
||||
return;
|
||||
}
|
||||
while (fs->fs_flock)
|
||||
sleep((caddr_t)&fs->fs_flock, PINOD);
|
||||
if (fs->fs_nfree <= 0) {
|
||||
fs->fs_nfree = 1;
|
||||
fs->fs_free[0] = 0;
|
||||
}
|
||||
if (fs->fs_nfree >= NICFREE) {
|
||||
fs->fs_flock++;
|
||||
bp = getblk(ip->i_dev, bno);
|
||||
fbp = (FBLKP) bp->b_addr;
|
||||
*fbp = *((FBLKP)&fs->fs_nfree);
|
||||
fs->fs_nfree = 0;
|
||||
if (fs->fs_flags & MNT_ASYNC)
|
||||
bdwrite(bp);
|
||||
else
|
||||
bwrite(bp);
|
||||
fs->fs_flock = 0;
|
||||
wakeup((caddr_t)&fs->fs_flock);
|
||||
}
|
||||
fs->fs_free[fs->fs_nfree++] = bno;
|
||||
fs->fs_tfree++;
|
||||
fs->fs_fmod = 1;
|
||||
fs = ip->i_fs;
|
||||
if (badblock (fs, bno)) {
|
||||
printf("bad block %D, ino %d\n", bno, ip->i_number);
|
||||
return;
|
||||
}
|
||||
while (fs->fs_flock)
|
||||
sleep((caddr_t)&fs->fs_flock, PINOD);
|
||||
if (fs->fs_nfree <= 0) {
|
||||
fs->fs_nfree = 1;
|
||||
fs->fs_free[0] = 0;
|
||||
}
|
||||
if (fs->fs_nfree >= NICFREE) {
|
||||
fs->fs_flock++;
|
||||
bp = getblk(ip->i_dev, bno);
|
||||
fbp = (FBLKP) bp->b_addr;
|
||||
*fbp = *((FBLKP)&fs->fs_nfree);
|
||||
fs->fs_nfree = 0;
|
||||
if (fs->fs_flags & MNT_ASYNC)
|
||||
bdwrite(bp);
|
||||
else
|
||||
bwrite(bp);
|
||||
fs->fs_flock = 0;
|
||||
wakeup((caddr_t)&fs->fs_flock);
|
||||
}
|
||||
fs->fs_free[fs->fs_nfree++] = bno;
|
||||
fs->fs_tfree++;
|
||||
fs->fs_fmod = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -269,34 +269,34 @@ free (ip, bno)
|
||||
*/
|
||||
void
|
||||
ifree (ip, ino)
|
||||
struct inode *ip;
|
||||
ino_t ino;
|
||||
struct inode *ip;
|
||||
ino_t ino;
|
||||
{
|
||||
register struct fs *fs;
|
||||
register struct fs *fs;
|
||||
|
||||
fs = ip->i_fs;
|
||||
fs->fs_tinode++;
|
||||
if (fs->fs_ilock)
|
||||
return;
|
||||
if (fs->fs_ninode >= NICINOD) {
|
||||
if (fs->fs_lasti > ino)
|
||||
fs->fs_nbehind++;
|
||||
return;
|
||||
}
|
||||
fs->fs_inode[fs->fs_ninode++] = ino;
|
||||
fs->fs_fmod = 1;
|
||||
fs = ip->i_fs;
|
||||
fs->fs_tinode++;
|
||||
if (fs->fs_ilock)
|
||||
return;
|
||||
if (fs->fs_ninode >= NICINOD) {
|
||||
if (fs->fs_lasti > ino)
|
||||
fs->fs_nbehind++;
|
||||
return;
|
||||
}
|
||||
fs->fs_inode[fs->fs_ninode++] = ino;
|
||||
fs->fs_fmod = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fserr prints the name of a file system with an error diagnostic.
|
||||
*
|
||||
* The form of the error message is:
|
||||
* fs: error message
|
||||
* fs: error message
|
||||
*/
|
||||
void
|
||||
fserr (fp, cp)
|
||||
struct fs *fp;
|
||||
char *cp;
|
||||
struct fs *fp;
|
||||
char *cp;
|
||||
{
|
||||
printf ("%s: %s\n", fp->fs_fsmnt, cp);
|
||||
printf ("%s: %s\n", fp->fs_fsmnt, cp);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user