[comp.os.minix] fs patches part 2/3

poole@forty2.UUCP (Simon Poole) (03/14/89)

echo x - FILES
gres '^X' '' > FILES << '/'
X  crc | size | name
X===================
X               FILES			This file
X00544   9333   FSCHANGES.DOC		Description of changes
X49984   1205   README			
X02730   1072   fcntl.2
X01743    805   fifolisten.c		Example program using fifo's
X53439    364   mkfifo.3
X17345   1201   open.2
X22052    553   read.2
X31043   1286   stat.2
X13621    567   write.2
X
Xcommands
X--------
X31089   1784   fsck.c.cdiff
X03194    379   ls.c.cdiff
X62778    273   mkfifo.c			Create fifo's.
X
Xfs
X--
X14635    798   Makefile.cdiff
X39121    556   cache.c.cdiff
X01293    958   const.h.cdiff
X05941   2127   device.c.cdiff
X54808    434   file.h.cdiff
X41517   1724   filedes.c.cdif
X52501    780   inode.c.cdiff
X25274   4424   misc.c.cdiff
X32537  10465   open.c
X27921    367   param.h.cdiff
X19754   7234   pipe.c.cdiff
X31446   5161   read.c.cdiff
X02378   1403   table.c.cdiff
X
Xh
X-
X31763    327   callnr.h.cdiff
X28233    525   com.h.cdiff
X47040   1030   const.h.cdiff
X35876    980   fcntl.h
X05657   2279   stat.h.cdiff
X
Xlib
X---
X56105    204   mkfifo.c
X40442    227   open.c
/
echo x - FSCHANGES.DOC
gres '^X' '' > FSCHANGES.DOC << '/'
XFSCHANGES.DOC
X=============
X
XS.Poole 13.3.89
X
XThis file contains a list of all changes I've made to the fs, with (where
Xneeded) an explanation of why each change was made, reading this should
Xbe worthwhile even if you don't apply the patches, if you plan on hacking
Xthe fs. But first, what do these patches do:
X
X	 - cleanup one or two minor bugs in the fs
X         - add named pipes / fifos to the fs (changed fsck and ls
X           to accomodate this)
X         - add a fcntl(2)  call to fs 
X         - change open(2) so that it accepts the
X               O_NONBLOCK
X               O_APPEND
X               O_CREAT
X               O_TRUNC
X               O_EXCL
X           flags
X         - non-blocking IO on pipes
X         - the necessary libc changes and .h files to support above
X   
XWhat I haven't done (yet?):
X
X         - `multi-tasking' fs (this is probably possible without
X           throwing the design of fs completly overboard, but I'm
X           still thinking about it)
X         - close-on-exec flags (this is trivial, I haven't included
X           it with these changes, as it involves changing mm too)
X         - non-blocking IO on character special devices (this is in the
X           works) (NOTE: the necessary changes to the fs are nearly all
X	   made, I have in fact a version of the ST tty.c that does
X	   non-blocking reads, this will probably be posted (perhaps
X	   with a RS232 driver in the near future))
X         - fixed all utilities with respect to named pipes
X	 - added symbolic links (this is just something I find
X           useful)
X
XNote that programs that do not use the new features, do NOT need
Xto be recompiled, the price for this is a somewhat more uglier 
Xthan necessary interface to open(2) (uses two different message 
Xtypes).
X
XChanges on a file by file base:
X===============================
X(Numbers in square brackets are line numbers in the book) 
X
Xh/callnr.h:
X-----------
X
XAdded define for FCNTL call. [140]
X
Xh/const.h:
X----------
X
XAdded defines for I_SYM_LINK (symbolic link) and I_NAMED_PIPE (fifo),
Xthis information is duplicated in h/stat.h and is really redundant.
X[64-70]
X
Xh/com.h:
X--------
X
XAdded defines for TTY_OPEN and TTY_CLOSE (these are not used yet,
Xbut since the whole of minix has to be recompiled after changes to
Xany file in h, we can save some time by defining these now). [197]
X
Xh/fcntl.h
X---------
X
XNew, contains defines for open(2) and fcntl(2) calls.
X
Xh/stat.h
X--------
X
XAdded defines for S_IFIFO (fifo) and S_IFLNK (this currently commented
Xout, since some programs use this to determine if symbolic links are
Xallowed on the system).
X
XAdded defines for some POSIX compatible macros and defines.
X[465-475]
X
Xfs/Makefile:
X------------
X
XAdded ../h/fcntl.h to list of header files
X
Xfs/cache.c:
X-----------
X
XChanged call of dev_io (in rw_block) to new version (second parameter
Xsignals non-blocking I/O). [8311]
X
Xfs/const.h:
X-----------
X
XChanged XPIPE from 0 to -(NR_TASKS+1) and added XOPEN. Some code in
Xpipe.c depended of XPIPE being the magic value 0, this is fixed (the
Xnew scheme allows adding of more pseudo-tasks, which the old one didn't).
X[7521]
X
Xfs/device.c
X-----------
X
XAdded nonblock flag to call of dev_open. [12233]
X
XAdded nonblock flag to call of dev_io, this is passed to the driver in
Xthe TTY_FLAGS field of the message, it would be cleaner to define a new
Xmessage type for this. [12261] 
X
Xtty_open should call a driver specific open function before setting
Xthe process group, since non of drivers has this yet, there was no
Xpoint in doing it.
X
Xfs/file.h:
X----------
X
XAdded field filp_flags to struct filp, while it would have been
Xpossible to encode the flags from open(2) and fcntl(2) in
Xfilp_mode, this way it seems slightly cleaner. [7706]
X
Xfs/filedes.c:
X-------------
X
XAdded start parameter to get_fd, this is used in fcntl(F_DUPFD..)
Xto determine the start point of a search for a free file descriptor.
XZap filp_mode field in get_fd. [8871,8887]
X
Xfs/inode.c:
X-----------
X
XAdded expicit check for a pipe in put_inode so that we can truncate
Xit before we write it back to disk, moved the reseting of i_pipe so
Xthat it is always done (this field isn't cleared when inodes are 
Xallocated, not clearing it here leads to really nice bugs).
X[8435-8437]
X
Xfs/misc.c:
X----------
X
XAdded include of fcntl.h.
XCleaned up do_dup a bit.
X
XNew function do_fcntl: 
X
Xthe code is very simple, one nice thing would be if the code from 
Xdo_dup could be intergrated with F_DUPFD, but I didn't see an
Xefficient way to do this. (Note the parameter addr is a misnomer, should
Xreally be arg, but the name space of fs is already so polluted by lower
Xcase defines (see param.h) that I didn't bother.)
X
XChange to do_exit: 
X
Xdecrement susp_count if the exiting process is blocked in open(2) 
X(task == XOPEN). [12115]
X 
Xfs/open.c:
X----------
X[9450-...]
X
XHere is where most of the changes are located. Practically all of the
Xcommon code of creat(2) and open(2) has been moved to one routine
X(common_open).
X
XAdded include of fcntl.h.
X
XChanges to do_create: 
X
Xdo_create now simply calls common_open with the flags: 
X                O_WRONLY | O_CREAT | O_TRUNC.
X
XChanges to do_mknod: 
X
Xallow non superuser to use do_mknod for creating fifos.
X
XChanges to do_open: 
X
Xdo_open checks the flags passed to it against a bitmask defined in 
Xfcntl.h, if O_CREAT is set (3 parameter open call) the call must have 
Xbeen made with a M1 type message, otherwise with a M3 message (this is 
Xfully backwards compatible with the old version), then common_open is 
Xcalled. (Note do_open currently depends on the `mode' field being the
Xsame for M1 and M3 messages)
X
XNew function common_open: 
X
Xcommon_open combines the functionality of do_create and do_open 
Xtriggered by flags:
X
X      O_CREAT : try to create the file, if the file already exists,
X                procede as if normal open(2), except if O_EXCL is
X                set.
X
X      O_EXCL  : fail if O_CREAT and file exists.
X
X      O_TRUNC : truncate regular file.
X
XI've assumed that O_CREAT and O_TRUNC need write access to the file
Xif it already exists.
X
XThe return codes from dev_open and pipe_open are checked and returned
Xto the caller if an error exists (the original do_open failed to do
Xthis).
X(NOTE: the global variable fd is used to hold, the file descriptor
Xreturned from get_fd, this bit of magic is needed for suspend in
Xpipe.c)
X
XNew function pipe_open: 
X
Xpipe_open opens a fifo (named pipe). From a organisational point of 
Xview this really belongs in pipe.c, to keep the the diffs small it 
Xis kept in open.c. First it checks for another process blocked in 
Xopen(2) waiting for an open for reading/writing (reading if this open 
Xis for writing, writing if this open is for reading), if another process 
Xexists and it has opend the pipe in the required mode, all other processes 
Xhanging in open on this pipe are revived (all because named pipes allow 
Xfor mutiple readers/writers). Otherwise: if O_NONBLOCK is cleared the caller 
Xis suspended (note that the filp slot must still be allocated now (the call 
Xcan not be restarted) so that we can check for blocked callers in the next 
Xopen, suspend is passed the pseudo task XOPEN), if O_NONBLOCK is set an open 
Xfor reading return sucessfully (reads will return 0 until there is a writing 
Xprocess), a open for writing will return ENXIO. 
X
XChanges to do_close: 
X
Xrip was set to rfilp->filp_ino but in some places rfilp->filp_ino 
Xwas still used; fixed. [9692,9706,9708,9712]
X
Xfs/param.h:
X-----------
X
XAdded defines for c_mode and c_name (used in open.c).
X
Xfs/pipe.c:
X----------
X[10350-...]
X
XAdded include of fcntl.h.
X
XChanges to do_pipe:
X
XChanged get_fd call to new version (see filedes.c). [10398]
X
XChanges to pipe_check:
X
XAdded oflags ('open flags') parameter. [10433]
XIf process is reading from a pipe and no input is available, block if
XO_NONBLOCK is cleared, otherwise return EAGAIN. Note: the `virgin' flag
Xis bogus (it is always TRUE), see read.c.
XPass susp_count instead of 1 to release, to release all writers.
X
XIf process is writing to a pipe and no room is available, block if
XO_NONBLOCK is cleared, otherwise return EAGAIN. Note: my copy of the
Xdraft standard does not specify in which of the many possible ways 
Xthe situation should be handled, returning EAGAIN and not writing
Xanything seemed to be the most resonable solution (note: the message
Xprinted by perror(3) for EAGAIN should be fixed).
XPass susp_count instead of 1 to release, to release all readers.
X
XChanges to suspend:
X
XIncrement susp_count if task that caller is blocked in is XOPEN.
X
XChanges to revive:
X
XHandle case that suspended process is blocked in open (task XOPEN),
Xwe simply have to return the file descriptor that was already 
Xallocated in common_open.
X
XChanges to do_unpause:
X
XAllow signals to abort open(2) calls, why this isn't done for
Xread and writes on pipes, I don't know.
X
Xfs/read.c:
X----------
X
XChanges to read_write:
X
XAdded variable oflags (`open flags') and regular (TRUE if regular 
Xfile or pipe).
X
XUpdated dev_io call to new version. [9837]
X
XIf O_APPEND flag is set, the current file position is always set to
Xthe end of the file. [9848]
X
XPass oflags to pipe_check. Note that the virg parameter is always TRUE
Xand should probably be removed. [9857]
X
XChanged various checks for regular files and pipes to use the variable
Xregular.
X
Xfs/table.c:
X-----------
X
XAdded entry for do_fnctl.
/
echo x - commands/fsck.c.cdiff
gres '^X' '' > commands/fsck.c.cdiff << '/'
X*** fsck.c	Thu Mar 13 17:06:05 1989
X--- /usr/src/commands/fsck.c	Thu Feb  7 19:33:37 1989
X***************
X*** 123,129 ****
X  
X  /* counters for each type of inode/zone */
X  int nfreeinode, nregular, ndirectory, nblkspec, ncharspec, nbadinode;
X! int nfreezone, ztype[NLEVEL];
X  
X  int repair, automatic, listing, listsuper, makefs;	/* flags */
X  int badfs;			/* set if fs bad and repair flag off */
X--- 123,129 ----
X  
X  /* counters for each type of inode/zone */
X  int nfreeinode, nregular, ndirectory, nblkspec, ncharspec, nbadinode;
X! int npipe, nfreezone, ztype[NLEVEL];
X  
X  int repair, automatic, listing, listsuper, makefs;	/* flags */
X  int badfs;			/* set if fs bad and repair flag off */
X***************
X*** 145,151 ****
X  initvars(){
X  	register level;
X  
X! 	nregular = ndirectory = nblkspec = ncharspec = nbadinode = 0;
X  	for (level = 0; level < NLEVEL; level++)
X  		ztype[level] = 0;
X  	changed = 0;
X--- 145,151 ----
X  initvars(){
X  	register level;
X  
X! 	nregular = ndirectory = nblkspec = ncharspec = nbadinode = npipe = 0;
X  	for (level = 0; level < NLEVEL; level++)
X  		ztype[level] = 0;
X  	changed = 0;
X***************
X*** 1334,1339 ****
X--- 1334,1342 ----
X  	case I_CHAR_SPECIAL:
X  		ncharspec++;
X  		return(1);
X+ 	case I_NAMED_PIPE:
X+ 		npipe++;
X+ 		return(1);
X  	default:
X  		nbadinode++;
X  		printf("bad mode of ");
X***************
X*** 1441,1446 ****
X--- 1444,1450 ----
X  	pr("%6u    Director%s\n",		  ndirectory,	"y", "ies");
X  	pr("%6u    Block special file%s\n",	  nblkspec,	 "",   "s");
X  	pr("%6u    Character special file%s\n", ncharspec,	 "",   "s");
X+ 	pr("%6u    Named pipe%s\n",               npipe,	 "",   "s");
X  	if (nbadinode != 0)
X  		pr("%6u    Bad inode%s\n",	  nbadinode,	 "",   "s");
X  	pr("%6u    Free inode%s\n",		  nfreeinode,	 "",   "s");
/
echo x - commands/ls.c.cdiff
gres '^X' '' > commands/ls.c.cdiff << '/'
X*** ls.c	Thu Mar 13 17:06:09 1989
X--- /usr/src/commands/ls.c	Thu Feb  5 18:33:18 1989
X***************
X*** 327,332 ****
X--- 327,334 ----
X  	if (m == I_DIRECTORY) c = 'd';
X  	else if (m == I_BLOCK_SPECIAL) c = 'b';
X  	else if (m == I_CHAR_SPECIAL) c = 'c';
X+ 	else if (m == I_NAMED_PIPE) c = 'p';
X+  	else if (m == I_SYM_LINK) c = 'l';
X  	else c = '-';
X  
X  	m = fp->mode & 07777;
/
echo x - commands/mkfifo.c
gres '^X' '' > commands/mkfifo.c << '/'
X/* mkfifo - build a named pipe		Stolen from mknod by S.Poole */
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X/* mkfifo name makes a fifo. */
X
X  if (argc != 2) {
X	std_err("Usage: mkfifo name\n");
X	exit(1);
X  }
X
X  if (mkfifo(argv[1], 0666))
X	perror("mkfifo");
X  exit(0);
X}
X
X
X
/
echo x - fcntl.2
gres '^X' '' > fcntl.2 << '/'
X.TH FCNTL 2 SYSTEM CALLS
X.SH NAME
Xfcntl \- file control
X.SH SYNOPSIS
X.DS
X#include <fcntl.h>
X
Xfcntl( file_des, cmd, ...)
Xint file_des, cmd;
X.DE
X
X.SH DESCRIPTION
X.I Fcntl
Ximplements miscellanious operations on file descritors:
X.I file_des 
Xmust be  a legal file descriptor.
X.I Cmd
Xone of the following:
X.DS
XF_DUPFD	return a new file descriptor which is the 
X	lowest numbered free descriptor greater than 
X	or equal to the third parameter, arg (int).
XF_GETFD get close-on-exec flag for this file descriptor,
X	if 0 the file will remain open across exec(2), 
X	otherwise it will be closed (NOT IMPLEMENTED).
XF_SETFD	set close-on-exec flag for this file descriptor, 
X	arg (int) 0 or 1 as described in F_GETD 
X	(NOT IMPLEMENTED).
XF_GETFL	returns the file status flags for this file 
X	descriptor (see fcntl.h).
XF_SETFL	set file status flags for this file descriptor, 
X	the flags are passed in the third parameter 
X	arg (int), only O_NONBLOCK and O_APPEND can be set.
X.DE
X
X.SH RETURN CODES
X>= 0 : depends on
X.I cmd
X.br
X-1 : Error.
X
X.SH REFERENCES
Xdup(2), dup2(2), exec(2), open(2)
X
/
echo x - open.2
gres '^X' '' > open.2 << '/'
X.TH OPEN 2 SYSTEM CALLS
X.SH NAME
Xopen \- open a file descriptor
X.SH SYNOPIS
X.DS
X#include <fcntl.h>
X
Xint open( file_name, flag )
Xchar *file_name;
Xint   flag;
X
Xor
X
Xint open( file_name, flag, mode )
Xchar *file_name;
Xint   flag;
Xint   mode;
X
X.DE
X
X.SH DESCRIPTION
X.I file_name
Xis opened as specified by 
X.I flag
X:
X.DS
XO_RDONLY	for reading
XO_WRONLY	for writing
XO_RDWR		for both reading and writing
XO_CREAT		create file if it does not exist
XO_APPEND	every write appends to the file
XO_NONBLOCK	don't block in I/O
XO_EXCL		if O_CREAT is specified and file exists, fail
XO_TRUNC		truncate file
X.DE
X
XIf O_CREAT is not specified the file must exist. The three parameter
Xversion of 
X.I open
Xmust be used if the O_CREAT flag is specifed, 
X.I mode 
Xis used together with the processes umask to construct the initial permissons
Xof the file (if the file exists, this is ignored).
X.PP
XIf O_NONBLOCK is specified and the 
X.I file_name 
Xis a pipe, an open for reading returns without delay, an open for writing
Xwill return ENXIO if no reading process exists. 
X.SH RETURN CODES
X>=0 : The descriptor for the file.
X.br
X-1 : Error.
X
X.SH REFERENCES
Xclose(2), creat(2), fcntl(2), lseek(2), read(2), umask(2), write(2), fopen(3)
X
/
echo x - read.2
gres '^X' '' > read.2 << '/'
X.TH READ 2 SYSTEM CALLS
X.SH NAME
Xread \- read from a file
X.SH SYNOPSIS
X.DS
Xint read( desc, buffer, size )
Xint   desc;
Xchar *buffer;
Xint   size;
X.DE
X.SH DESCRIPTION
XUp to 
X.I size
Xbytes are read from the file referenced by
Xthe file descriptor 
X.I desc.  
XThe data is placed into the
Xstorage pointed to by 
X.I buffer.
X
XIf the file is a pipe and the O_NONBLOCK flag is set, a read that would block
Xwill return EAGAIN.
X.SH RETURN CODES 
Xo/w : Number of bytes actually read.
X0 : At the end of the file.
X-1 : Error.
X.SH REFERENCES
Xfcntl(2), open(2), write(2)
/
echo x - stat.2
gres '^X' '' > stat.2 << '/'
X.TH STAT 2 SYSTEM CALLS
X.SH NAME
Xstat \- read an inode
X.SH SYNOPSIS
X.DS
X#include <sys/types.h>
X#include <stat.h>
X
Xstat( file_name, s )
Xchar *file_name;
Xstruct stat *s;
X.DE
X
X.SH DESCRIPTION
X.I Stat 
Xreads the inode for the file 
X.I file_name
X,
X.I s 
Xpoints
Xto a structure containing the following:
X
X.DS
X(dev_t)		  s->st_dev	device file is on
X(ino_t)		  s->st_ino	inode number
X(unsigned short)  s->st_mode	protection
X(short int)	  s->st_nlink	number of links
X(unsigned short)  s->st_uid	owner's user id
X(unsigned short)  s->st_gid	owner's group id
X(dev_t)		  s->st_rdev	device type, if is device
X(off_t)		  s->st_size	file size
X(time_t)	  s->st_atime	time of last modification
X(time_t)	  s->st_mtime	time of last modification
X(time_t)	  s->st_ctime	time of last modification
X.DE
X
X(s->st_mode & S_IFMT) is one of the following:
X.DS
X	S_IFREG 	  regular
X	S_IFDIR 	  directory
X	S_IFCHR 	  character special
X	S_IFBLK 	  block special
X	S_IFFIFO	  fifo
X.DE
X
XThe following may be set in s->st_mode:
X.DS
X	S_ISUID   	  set user id on execution
X	S_ISGID   	  set group id on execution
X.DE
X
XThe lower 9 bits of s->st_mode are the three sets of "rwx"
Xpermissions for the USER, GROUP and OTHERS respectively.
X
X.SH RETURN CODES
X0 : Ok.
X-1 : Error.
X
X.SH REFERENCES
Xchmod(2), chown(2), fstat(2), utime(2)
/
echo x - write.2
gres '^X' '' > write.2 << '/'
X.TH WRITE 2 SYSTEM CALLS
X.SH NAME
Xwrite \- write to a file
X.SH SYNOPSIS
X.DS
Xint write( desc, buffer, size )
Xint   desc;
Xchar *buffer;
Xint   size;
X.DE
X.SH DESCRIPTION
X.I Size 
Xbytes from the storage pointed to by
X.I buffer
Xare written to the file referenced by the descriptor
X.I desc.
X
XIf the O_NONBLOCK flag associated with 
X.I desc
Xis set and the file is a pipe, EAGAIN will be returned if the write cannot
Xbe completed (note: no data is transferred).
X.SH RETURN CODE
Xo/w : Number of bytes actually written.
X.br
X-1 : Error.
X.SH REFERENCES
Xfcntl(2), open(2), read(2)
/
echo x - mkfifo.3
gres '^X' '' > mkfifo.3 << '/'
X.TH MKFIFO 3 C-LIBARY
X.SH NAME
Xmkfifo \- create a fifo (named pipe)
X.SH SYNOPSIS
Xint mkfifo( fifo_name, mode )
Xchar *fifo_name;
Xint mode;
X.SH SYNOPSIS
XCreate a FIFO special file, named by
X.I fifo_name. 
XThe file permissions are constructed from 
X.I mode 
Xand the processes umask.
X.SH RETURN CODES
X0: call successful
X.br
X-1: error
X.SH REFERENCES
Xmknod(2), umask(2)
/
echo x - fifolisten.c
gres '^X' '' > fifolisten.c << '/'
X/*
X * Demo program for fifos (named pipes)
X * Simon Poole 1989
X */
X
X#include <fcntl.h>
X
X#define BUFFERSIZE 512
X
Xmain (argc,argv)
X	int argc;
X	char *argv[];
X{
X	int pipe_fd,log_fd,count,i;
X	char buf[BUFFERSIZE];
X
X	if (mkfifo("log_fifo",0666) < 0) {
X		perror("mkfifo");
X		exit(1);
X	}
X	if ((log_fd = open("log",O_WRONLY|O_CREAT,0644)) < 0) {
X		perror("open (log file)");
X		exit(1);
X	}
X	for (;;) {
X		if ((pipe_fd = open("log_fifo",O_RDONLY)) < 0) {
X			perror("open (pipe)");
X			exit(1);
X		}
X		do {
X			if ((count = read(pipe_fd,buf,BUFFERSIZE)) < 0) {
X				perror("read (pipe)");
X				exit(1);
X			}
X			if (count > 0)
X				if (count != write(log_fd,buf,count)) {
X					perror("write (log file)");
X					exit(1);
X				}
X		} while (count > 0);
X		if (close(pipe_fd) < 0) {
X			perror("close (pipe)");
X			exit(1);
X		}
X	}
X}
X
/
echo x - h/callnr.h.cdiff
gres '^X' '' > h/callnr.h.cdiff << '/'
X*** callnr.h	Thu Feb 11 01:51:07 1989
X--- ../callnr.h	Thu Feb 11 01:52:49 1989
X***************
X*** 38,43 ****
X--- 39,45 ----
X  #define GETGID	          47
X  #define SIGNAL	          48
X  #define IOCTL             54
X+ #define FCNTL		  55
X  #define EXEC	          59
X  #define UMASK	          60 
X  #define CHROOT	          61 
/
echo x - h/com.h.cdiff
gres '^X' '' > h/com.h.cdiff << '/'
X*** com.h	Thu Jan  2 09:41:37 1988
X--- ../com.h	Thu Mar  8 00:34:34 1989
X***************
X*** 51,56 ****
X--- 51,58 ----
X  #	define TTY_WRITE   4	/* fcn code for writing to tty */
X  #	define TTY_IOCTL   5	/* fcn code for ioctl */
X  #	define TTY_SETPGRP 6	/* fcn code for setpgrp */
X+ #	define TTY_OPEN    7	/* fcn code for opening tty */
X+ #	define TTY_CLOSE   8	/* fcn code for closing tty */
X  #	define SUSPEND	-998	/* used in interrupts when tty has no data */
X  
X  /* Names of message fields for messages to CLOCK task. */
/
echo x - h/const.h.cdiff
gres '^X' '' > h/const.h.cdiff << '/'
X*** const.h	Thu Jan  5 16:29:18 1989
X--- ../const.h	Thu Mar  5 21:28:49 1989
X***************
X*** 72,81 ****
X--- 72,83 ----
X  
X  /* Flag bits for i_mode in the inode. */
X  #define I_TYPE          0170000	/* this field gives inode type */
X+ #define I_SYM_LINK	0120000 /* symbolic link */
X  #define I_REGULAR       0100000	/* regular file, not dir or special */
X  #define I_BLOCK_SPECIAL 0060000	/* block special file */
X  #define I_DIRECTORY     0040000	/* file is a directory */
X  #define I_CHAR_SPECIAL  0020000	/* character special file */
X+ #define I_NAMED_PIPE	0010000 /* named pipe (FIFO) */
X  #define I_SET_UID_BIT   0004000	/* set effective uid on exec */
X  #define I_SET_GID_BIT   0002000	/* set effective gid on exec */
X  #define ALL_MODES       0006777	/* all bits for user, group and others */
X***************
X*** 84,86 ****
X--- 86,89 ----
X  #define W_BIT           0000002	/* rWx protection bit */
X  #define X_BIT           0000001	/* rwX protection bit */
X  #define I_NOT_ALLOC     0000000	/* this inode is free */
X+ 
/
echo x - h/fcntl.h
gres '^X' '' > h/fcntl.h << '/'
X/* fcntl.h for modified minix fs */
X
X
X/* For fcntl(2)  */
X
X#define     F_DUPFD	0		/* DUP */
X#define     F_GETFD	1		/* get close-on-exec flag */
X#define     F_SETFD	2		/* set close-on-exec flag */
X#define     F_GETFL	3		/* get file status flags */
X#define     F_SETFL	4		/* set file status flags */
X
X/* For open(2) only */
X
X#define     O_RDONLY	000000
X#define     O_WRONLY	000001
X#define     O_RDWR	000002
X
X/* For open and fcntl */
X#define     O_NONBLOCK  000004
X#define     O_APPEND    000010
X#define     O_CREAT     001000
X#define     O_TRUNC     002000
X#define	    O_EXCL	004000
X
X/* other names, for convienience */
X#define FNDELAY		O_NONBLOCK	/* BSD */
X#define O_NDELAY	O_NONBLOCK	/* SysV */
X#define FAPPEND		O_APPEND	/* BSD */
X#define FTRUNC		O_TRUNC		/* BSD */
X#define FCREAT		O_CREAT		/* BSD */
X#define FEXCL		O_EXCL		/* BSD */
X
X
X/* used in fs */
X#define     O_LEGAL (O_WRONLY|O_RDWR|O_NONBLOCK|O_APPEND|O_CREAT|O_TRUNC|O_EXCL)
X#define     F_FL_LEGAL	(O_NONBLOCK|O_APPEND)
X
/
echo x - h/stat.h.cdiff
gres '^X' '' > h/stat.h.cdiff << '/'
X*** stat.h	Thu Jan  5 16:29:17 1989
X--- ../stat.h	Thu Feb 23 22:21:38 1989
X***************
X*** 1,3 ****
X--- 1,5 ----
X+ /* stat.h */
X+ 
X  struct stat {
X      short int st_dev;
X      unsigned short st_ino;
X***************
X*** 18,26 ****
X  #define S_IFCHR 0020000		/* character special */
X  #define S_IFBLK 0060000		/* block special */
X  #define S_IFREG 0100000		/* regular */
X! #define S_ISUID   04000		/* set user id on execution */
X! #define S_ISGID   02000		/* set group id on execution */
X  #define S_ISVTX   01000		/* save swapped text even after use */
X  #define S_IREAD   00400		/* read permission, owner */
X  #define S_IWRITE  00200		/* write permission, owner */
X  #define S_IEXEC   00100		/* execute/search permission, owner */
X--- 20,55 ----
X  #define S_IFCHR 0020000		/* character special */
X  #define S_IFBLK 0060000		/* block special */
X  #define S_IFREG 0100000		/* regular */
X! #define S_IFIFO 0010000		/* named pipe (FIFO) */
X! /* #define S_IFLNK	0120000	/* symbolic link */
X! #define S_ISUID   04000		/* set user id on execution (POSIX) */
X! #define S_ISGID   02000		/* set group id on execution (POSIX) */
X  #define S_ISVTX   01000		/* save swapped text even after use */
X  #define S_IREAD   00400		/* read permission, owner */
X  #define S_IWRITE  00200		/* write permission, owner */
X  #define S_IEXEC   00100		/* execute/search permission, owner */
X+ 
X+ /* POSIX defines */
X+ #define S_IRWXU	  00700		/* owner rwx */
X+ #define S_IRUSR   00400		/* owner r   */
X+ #define S_IWUSR   00200		/* owner  w  */
X+ #define S_IXUSR   00100		/* owner   x */
X+ #define S_IRWXG	  00070		/* group rwx */
X+ #define S_IRGRP   00040		/* group r   */
X+ #define S_IWGRP   00020		/* group  w  */
X+ #define S_IXGRP   00010		/* group   x */
X+ #define S_IRWXO	  00007		/* other rwx */
X+ #define S_IROTH   00004		/* other r   */
X+ #define S_IWOTH   00002		/* other  w  */
X+ #define S_IXOTH   00001		/* other   x */
X+ 
X+ /* POSIX macros */
X+ #define S_ISDIR(m)	(S_IFDIR & (m))		/* directory? */
X+ #define S_ISCHR(m)	(S_IFCHR & (m))		/* character special? */
X+ #define S_ISBLK(m)	(S_IFBLK & (m))		/* block special? */
X+ #define S_ISREG(m)	(S_IFREG & (m))		/* regular file? */
X+ #define S_ISFIFO(m)	(S_IFFIFO & (m))	/* fifo? */
X+ 
X+ /* compatibilty with ? */
X+ #define S_IPIPE S_IFIFO
X+ 
/
echo x - lib/mkfifo.c
gres '^X' '' > lib/mkfifo.c << '/'
X#include "lib.h"
X#include "../h/stat.h"
X
XPUBLIC int mkfifo(name, mode)
Xchar *name;
Xint mode;
X{
X  mode = (mode & 0777) | S_IFIFO; 
X  return callm1(FS, MKNOD, len(name), mode, 0, name, NIL_PTR, NIL_PTR);
X}
/
echo x - lib/open.c
gres '^X' '' > lib/open.c << '/'
X#include "lib.h"
X#include "../h/fcntl.h"
X
XPUBLIC int open(name, flags, mode)
Xchar* name;
Xint flags,mode;
X{
X  if (flags & O_CREAT) return callm1(FS, OPEN, len(name), flags, mode, name);
X  return callm3(FS, OPEN, flags, name);
X}
/
-- 
----------------------------------------------------------------------------
UUCP:   ...mcvax!cernvax!forty2!poole			Simon Poole
BITNET: K538915@CZHRZU1A
----------------------------------------------------------------------------