File:  [XINU] / xinu / sys / ckmode.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:39:03 2018 UTC (8 years, 3 months ago) by root
Branches: xinu, MAIN
CVS tags: xinu-19870308, HEAD
Xinu for VAX

/* ckmode.c - ckmode */

#include <conf.h>
#include <kernel.h>
#include <file.h>

/*------------------------------------------------------------------------
 *  ckmode  --  parse open's mode argument and generate actual mode bits
 *------------------------------------------------------------------------
 */
ckmode(mode)
char	*mode;
{
	int	mbits;
	char	ch;

	mbits = 0;
	while (ch = *mode++)
		switch (ch) {

		    case FLRMODE:
				if (mbits&FLREAD) return(SYSERR);
				mbits |= FLREAD;
				break;

		    case FLWMODE:
				if (mbits&FLWRITE) return(SYSERR);
				mbits |= FLWRITE;
				break;

		    case FLOMODE:
				if (mbits&FLOLD || mbits&FLNEW)
					return(SYSERR);
				mbits |= FLOLD;
				break;

		    case FLNMODE:
				if (mbits&FLOLD || mbits&FLNEW)
					return(SYSERR);
				mbits |= FLNEW;
				break;

		    default:	return(SYSERR);
		}
	if ((mbits&FLREAD) == (mbits&FLWRITE))	/* default: allow R + W	*/
		mbits |= FLRW;
	return(mbits);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.