/* Copyright (c) 1993 Xerox Corporation. All rights reserved. */ /* $Id$ $Date$ * * PCR - I/O public interface * * This monster interface is a list of all the I/O related procs that need * to exist to support POSIX 1, together with a few PCR-specific * extensions. * * All procs may be called with signals enabled. */ #ifndef ←←PCR←IO←h #define ←←PCR←IO←h 1 #include <th/PCR←ThTypes.h> #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> #include <fcntl.h> #include <utime.h> /* * directory enumeration */ extern PCR←ERes PCR←IO←EnumDir( const char *dirName, PCR←ERes (*callbackProc)(const char *fileName, PCR←Any data), PCR←Any callbackData, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* Invoke callback proc for each file in named directory in arbitrary order. If callback proc ever returns a result r other than PCR←ERes←okay, the enumeration terminates returning r. */ /* * Working directory */ extern PCR←ERes PCR←IO←ChDir( const char *path, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←GetCWD( char **bufp, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←ApplyToCWD( PCR←ERes (*proc)(const char *path, PCR←Any data), PCR←Any data, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←MakeFullPathName( const char *path, char **bufp, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* * file and directory create/delete */ extern PCR←ERes PCR←IO←MkDir( const char *path, mode←t mode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←RmDir( const char *path, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Open( const char *path, int oflag, mode←t mode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←MkFIFO( const char *path, mode←t mode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Link( const char *path1, const char *path2, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Unlink( const char *path, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Rename( const char *old, const char *new, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern mode←t PCR←IO←UMask(mode←t mask); /* * Access control and other metadata */ extern PCR←ERes PCR←IO←Access( const char *path, int amode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←ChMod( const char *path, mode←t mode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←ChOwn( const char *path, uid←t owner, gid←t group, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←UTime( const char *path, struct utimbuf *p, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Stat( const char *path, struct PCR←stat *sbuf, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FStat( int fildes, struct PCR←stat *sbuf, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FPathConf( int fildes, int name, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←PathConf( const char *path, int name, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* * I/O operations */ extern PCR←ERes PCR←IO←Pipe( int fildes[2], const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Dup( int fildes, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Dup2( int fildes, int fildes2, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Close( int fildes, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Read( int fildes, char *buf, unsigned int nbyte, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Write( int fildes, char *buf, unsigned int nbyte, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←LSeek( int fildes, off←t offset, int whence, off←t *where, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FCntl( int fildes, int cmd, PCR←Any arg, int *ansp, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* * Wait for ready. */ typedef unsigned short PCR←IO←WaitReadyEvents; #define PCR←IO←WaitReadyEvents←none 0 #define PCR←IO←WaitReadyEvents←IN 0x01 #define PCR←IO←WaitReadyEvents←PRI 0x02 #define PCR←IO←WaitReadyEvents←OUT 0x04 #define PCR←IO←WaitReadyEvents←ERR 0x10 #define PCR←IO←WaitReadyEvents←HUP 0x20 extern PCR←ERes PCR←IO←WaitReady( int fildes, PCR←IO←WaitReadyEvents events, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* Analogous to System V Poll() call, but only one descriptor is allowed. On success, the result is the returned "revents" value. The result is only a hint, since a concurrent thread may change the descriptor's state. */ /* * Non-POSIX, best-effort (may return ENOSYS in some cases) ... */ extern PCR←ERes PCR←IO←Ctl( int fildes, int request, int param, void *buf, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Sync( const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FSync( int fildes, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FChMod( int fildes, mode←t mode, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FChOwn( int fildes, uid←t owner, gid←t group, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←Truncate( const char *path, off←t length, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←FTruncate( int fildes, off←t length, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←SymLink( const char *name1, const char *name2, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); extern PCR←ERes PCR←IO←ReadLink( const char *path, char *buf, int bufSize, const PCR←sigset←t *sigMask, PCR←Msec wakeup ); /* Success => path exists and is a symlink; EINVAL => path exists but is not a symlink. Store contents of link in *buf, append trailing null. Return actual length of link contents (not counting the trailing null), even if that exceeds bufSize. */ /* * Local/Global descriptor support */ extern /* readonly */ int PCR←IO←lfdLim; extern /* readonly */ int PCR←IO←gfdLim; extern /* readonly */ int PCR←IO←gfdStd[3]; extern PCR←Bool PCR←IO←FDIsValid(int fd); #define PCR←IO←←FDIsValid(fd) (\ ((fd) >= 0) && ((fd) < PCR←IO←gfdLim) ) #define PCR←IO←FDIsValid PCR←IO←←FDIsValid extern PCR←Bool PCR←IO←FDIsLocal(int fd); #define PCR←IO←←FDIsLocal(fd) ((fd) < PCR←IO←lfdLim) #define PCR←IO←FDIsLocal(fd) PCR←IO←←FDIsLocal(fd) extern PCR←Bool PCR←IO←FDIsValidLocal(int fd); #define PCR←IO←←FDIsValidLocal(fd) (((fd) >= 0) && ((fd) < PCR←IO←lfdLim)) #define PCR←IO←FDIsValidLocal(fd) PCR←IO←←FDIsValidLocal(fd) extern PCR←Bool PCR←IO←FDIsGlobal(int fd); #define PCR←IO←←FDIsGlobal(fd) ((fd) >= PCR←IO←lfdLim) #define PCR←IO←FDIsGlobal(fd) PCR←IO←←FDIsGlobal(fd) extern PCR←Bool PCR←IO←FDIsValidGlobal(int fd); #define PCR←IO←←FDIsValidGlobal(fd) \ (((fd) >= PCR←IO←lfdLim) && ((fd) < PCR←IO←gfdLim)) #define PCR←IO←FDIsValidGlobal(fd) PCR←IO←←FDIsValidGlobal(fd) extern PCR←ERes PCR←IO←GlobalFDFromFD(int fd); /* This bumps the reference count of the global fd. Thus, PCR←IO←Close(PCR←IO←GlobalFDFromFD(fd)) is a noop. */ #endif /* ! ←←PCR←IO←h */ /* $Log$ */