X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libsysio%2Finclude%2Fsysio.h;h=c9eab42cd61aa12a1883ec39f37e10bcbab92c0d;hb=79e65c81349f539aa2960a1889144ce71d91351e;hp=fb05d75ced0d5d862feec5319f936e580cfa8709;hpb=b8292c00324fbe9a25910ce53d03569186ea3e2c;p=fs%2Flustre-release.git diff --git a/libsysio/include/sysio.h b/libsysio/include/sysio.h index fb05d75..c9eab42 100644 --- a/libsysio/include/sysio.h +++ b/libsysio/include/sysio.h @@ -48,22 +48,16 @@ #include #include -#ifndef _IOID_T_DEFINED -#define _IOID_T_DEFINED +#include "sysio-cmn.h" +#include "creds.h" + +#if defined(_DIRENT_H) && _DIRENT_H /* - * FIXME: - * - * This section about ioid_t and it's failure belong in + * Need directory access routines too. */ -typedef void *ioid_t; - -#define IOID_FAIL 0 -#endif - -#if !defined(__IS_UNUSED) && defined(__GNUC__) -#define __IS_UNUSED __attribute__ ((unused)) +#define _DECLARE_DIR_ACCESS 1 #else -#define __IS_UNUSED +#define _DECLARE_DIR_ACCESS 0 #endif #ifndef PATH_SEPARATOR @@ -80,36 +74,11 @@ typedef void *ioid_t; #define MAX_SYMLINK 250 #endif -#ifndef _LARGEFILE64_SOURCE -/* - * Not glibc I guess. Define this ourselves. - */ -#define _LARGEFILE64_SOURCE 0 -#endif - -/* - * Define internal file-offset type and it's maximum value. - */ -#if _LARGEFILE64_SOURCE -#define _SYSIO_OFF_T off64_t -#ifdef LLONG_MAX -#define _SYSIO_OFF_T_MAX (LLONG_MAX) -#else -/* - * Don't have LLONG_MAX before C99. We'll need to define it ourselves. - */ -#define _SYSIO_OFF_T_MAX (9223372036854775807LL) -#endif -#else -#define _SYSIO_OFF_T off_t -#define _SYSIO_OFF_T_MAX LONG_MAX -#endif - /* * Internally, all directory entries are carried in the 64-bit capable * structure. */ -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE #define intnl_dirent dirent64 #else #define intnl_dirent dirent @@ -120,7 +89,7 @@ struct dirent; * Internally, all file status is carried in the 64-bit capable * structure. */ -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE #define intnl_stat stat64 #else #define intnl_stat stat @@ -128,7 +97,7 @@ struct dirent; struct stat; #ifdef _HAVE_STATVFS -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE #define intnl_statvfs statvfs64 #else #define intnl_statvfs statvfs @@ -138,43 +107,56 @@ struct statvfs; struct intnl_statvfs; #endif -/* - * Internally, all file status is carried in the 64-bit capable - * structure. - */ -#if _LARGEFILE64_SOURCE -#define intnl_xtvec xtvec64 -#else -#define intnl_xtvec xtvec -#endif -struct intnl_xtvec; - -struct iovec; - struct utimbuf; struct intnl_stat; struct pnode; +#ifdef DEFER_INIT_CWD +extern const char *_sysio_init_cwd; +#endif + extern struct pnode *_sysio_cwd; extern mode_t _sysio_umask; extern int _sysio_init(void); extern void _sysio_shutdown(void); -extern int _sysio_boot(const char *buf); +#ifdef ZERO_SUM_MEMORY +extern void _sysio_access_shutdown(void); +#endif + +#if 0 +struct _sysio_boot_ctl { + const char *onam; + const char *oarg; +}; +#endif + +extern int _sysio_boot(const char *opt, const char *arg); /* - * SYSIO name label macros + * Option-value pair information. */ -#define XPREPEND(p,x) p ## x -#define PREPEND(p,x) XPREPEND(p,x) -#define SYSIO_LABEL_NAMES 0 -#if SYSIO_LABEL_NAMES -#define SYSIO_INTERFACE_NAME(x) PREPEND(sysio__, x) -#else -#define SYSIO_INTERFACE_NAME(x) x +struct option_value_info { + const char *ovi_name; /* name */ + char *ovi_value; /* value */ +}; + +extern const char * _sysio_get_token(const char *buf, + int accepts, + const char *delim, + const char *ignore, + char *tbuf); +extern char * _sysio_get_args(char *buf, struct option_value_info *vec); + +#define _SYSIO_LOCAL_TIME() _sysio_local_time() + +extern time_t _sysio_local_time(void); + +#ifdef SYSIO_TRACING +extern void _sysio_cprintf(const char *fmt, ...); #endif /* @@ -193,11 +175,16 @@ extern int SYSIO_INTERFACE_NAME(close)(int d); extern int SYSIO_INTERFACE_NAME(dup)(int oldfd); extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd); extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...); +extern int SYSIO_INTERFACE_NAME(fcntl64)(int fd, int cmd, ...); extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf); +#ifdef _LARGEFILE64_SOURCE +extern int SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf); +extern int SYSIO_INTERFACE_NAME(lstat64)(const char *path, struct stat64 *buf); +#endif extern int SYSIO_INTERFACE_NAME(fsync)(int fd); extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size); extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, int whence); #endif @@ -208,7 +195,7 @@ extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , #else extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, size_t nbytes, off_t *basep); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd, char *buf, size_t nbytes, @@ -217,39 +204,59 @@ extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd, #endif extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode); extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...); #endif extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode); #endif extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf); #endif +extern ssize_t SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count); +extern ssize_t SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, + off_t offset); +extern ssize_t SYSIO_INTERFACE_NAME(readv)(int fd, + const struct iovec *iov, + int count); +extern ssize_t SYSIO_INTERFACE_NAME(write)(int fd, + const void *buf, + size_t count); +extern ssize_t SYSIO_INTERFACE_NAME(pwrite)(int fd, + const void *buf, + size_t count, + off_t offset); +extern ssize_t SYSIO_INTERFACE_NAME(writev)(int fd, + const struct iovec *iov, + int count); #ifdef _HAVE_STATVFS extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, struct statvfs64 *buf); #endif extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf); #endif #endif extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length); #endif extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length); -#if _LARGEFILE64_SOURCE +#ifdef _LARGEFILE64_SOURCE extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length); #endif extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path); extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2); +#ifdef HAVE_POSIX_1003_READLINK +extern ssize_t SYSIO_INTERFACE_NAME(readlink)(const char *path, +#else extern int SYSIO_INTERFACE_NAME(readlink)(const char *path, +#endif char *buf, size_t bufsiz); extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath); @@ -259,71 +266,6 @@ extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd); extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...); extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask); -extern int SYSIO_INTERFACE_NAME(iodone)(ioid_t ioid); -extern ssize_t SYSIO_INTERFACE_NAME(iowait)(ioid_t ioid); -extern ioid_t SYSIO_INTERFACE_NAME(ipreadv)(int fd, const struct iovec *iov, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ioid_t SYSIO_INTERFACE_NAME(ipread64v)(int fd, const struct iovec *iov, - size_t count, off64_t offset); -#endif -extern ioid_t SYSIO_INTERFACE_NAME(ipread)(int fd, void *buf, size_t count, - off_t offset); -#if _LARGEFILE64_SOURCE -extern ioid_t SYSIO_INTERFACE_NAME(ipread64)(int fd, void *buf, size_t count, - off64_t offset); -#endif -extern ssize_t SYSIO_INTERFACE_NAME(preadv)(int fd, const struct iovec *iov, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(pread64v)(int fd, const struct iovec *iov, - size_t count, off64_t offset); -#endif -extern ssize_t SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, - off_t offset); -#if _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(pread64)(int fd, void *buf, size_t count, - off64_t offset); -#endif -extern ioid_t SYSIO_INTERFACE_NAME(ireadv)(int fd, const struct iovec *iov, - int count); -extern ioid_t SYSIO_INTERFACE_NAME(iread)(int fd, void *buf, size_t count); -extern ssize_t SYSIO_INTERFACE_NAME(readv)(int fd, const struct iovec *iov, - int count); -extern ssize_t SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count); -extern ioid_t SYSIO_INTERFACE_NAME(ipwritev)(int fd, const struct iovec *iov, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite64v)(int fd, const struct iovec *iov, - size_t count, off64_t offset); -#endif -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite)(int fd, const void *buf, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ioid_t SYSIO_INTERFACE_NAME(ipwrite64)(int fd, const void *buf, - size_t count, off64_t offset); -#endif -extern ssize_t SYSIO_INTERFACE_NAME(pwritev)(int fd, const struct iovec *iov, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(pwrite64v)(int fd, const struct iovec *iov, - size_t count, off64_t offset); -#endif -extern ssize_t SYSIO_INTERFACE_NAME(pwrite)(int fd, const void *buf, - size_t count, off_t offset); -#if _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(pwrite64)(int fd, const void *buf, - size_t count, off64_t offset); -#endif -extern ioid_t SYSIO_INTERFACE_NAME(iwritev)(int fd, - const struct iovec *iov, - int count); -extern ioid_t SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, - size_t count); -extern ssize_t SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov, - int count); -extern ssize_t SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, - size_t count); extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, mode_t mode, dev_t dev); extern int SYSIO_INTERFACE_NAME(utime)(const char *path, @@ -333,68 +275,27 @@ extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target, unsigned long mountflags, const void *data); extern int SYSIO_INTERFACE_NAME(umount)(const char *target); +#if _DECLARE_DIR_ACCESS +extern DIR *SYSIO_INTERFACE_NAME(opendir)(const char *name); +extern int SYSIO_INTERFACE_NAME(closedir)(DIR *dir); +extern struct dirent *SYSIO_INTERFACE_NAME(readdir)(DIR *dir); -/* for debugging */ -#if 0 -#define ASSERT(cond) \ - if (!(cond)) { \ - printf("ASSERTION(" #cond ") failed: " __FILE__ ":" \ - __FUNCTION__ ":%d\n", __LINE__); \ - abort(); \ - } - -#define ERROR(fmt, a...) \ - do { \ - printf("ERROR(" __FILE__ ":%d):" fmt, __LINE__, ##a); \ - while(0) - +extern int SYSIO_INTERFACE_NAME(scandir)(const char *dir, + struct dirent ***namelist, + int(*filter)(const struct dirent *), +#ifdef HAVE_POSIX2008_SCANDIR + int(*compar)(const struct dirent **, + const struct dirent **) #else -#define ERROR(fmt) do{}while(0) -#define ASSERT do{}while(0) + int(*compar)(const void *, const void *) #endif - -/* - * SYSIO interface frame macros - * - * + DISPLAY_BLOCK; Allocates storage on the stack for use by the set of - * macros. - * + ENTER; Performs entry point work - * + RETURN; Returns a value and performs exit point work - * - * NB: For RETURN, the arguments are the return value and value for errno. - * If the value for errno is non-zero then that value, *negated*, is set - * into errno. - */ -#define SYSIO_INTERFACE_DISPLAY_BLOCK \ - int _saved_errno; -#define SYSIO_INTERFACE_ENTER \ - do { \ - _saved_errno = errno; \ - SYSIO_ENTER; \ - } while (0) -#define SYSIO_INTERFACE_RETURN(rtn, err) \ - do { \ - SYSIO_LEAVE; \ - errno = (err) ? -(err) : _saved_errno; \ - return (rtn); \ - } while(0) - -/* syscall enter/leave hook functions */ -#if 0 -extern void _sysio_sysenter(); -extern void _sysio_sysleave(); - -#define SYSIO_ENTER \ - do { \ - _sysio_sysenter(); \ - } while(0) - -#define SYSIO_LEAVE \ - do { \ - _sysio_sysleave(); \ - } while(0) -#else -#define SYSIO_ENTER -#define SYSIO_LEAVE - + ); +#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) +extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, + char *buf, + size_t nbytes, + off_t *basep); #endif +#endif /* _DECLARE_DIR_ACCESS */ + +#undef _DECLARE_DIR_ACCESS