libsysio-commit Mailing List for libsysio (Page 22)
Brought to you by:
lward
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(25) |
May
(28) |
Jun
(25) |
Jul
(30) |
Aug
(60) |
Sep
(52) |
Oct
(100) |
Nov
(15) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(89) |
Feb
(48) |
Mar
(22) |
Apr
(59) |
May
(16) |
Jun
(15) |
Jul
(50) |
Aug
(26) |
Sep
(40) |
Oct
(27) |
Nov
(12) |
Dec
|
2005 |
Jan
(24) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(6) |
Jul
|
Aug
(14) |
Sep
(21) |
Oct
(10) |
Nov
|
Dec
|
2006 |
Jan
(8) |
Feb
(5) |
Mar
(2) |
Apr
(6) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2007 |
Jan
(3) |
Feb
(5) |
Mar
(20) |
Apr
(41) |
May
(21) |
Jun
(3) |
Jul
(5) |
Aug
(12) |
Sep
(21) |
Oct
(5) |
Nov
(16) |
Dec
|
2008 |
Jan
|
Feb
(2) |
Mar
(4) |
Apr
(23) |
May
|
Jun
(22) |
Jul
(13) |
Aug
|
Sep
|
Oct
(9) |
Nov
(3) |
Dec
(13) |
2009 |
Jan
(14) |
Feb
(10) |
Mar
(2) |
Apr
(11) |
May
(7) |
Jun
(1) |
Jul
(1) |
Aug
(36) |
Sep
(12) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Lee W. <lw...@us...> - 2004-09-23 16:51:44
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517/src Modified Files: Tag: defer-cwd fcntl.c Log Message: Now, wrap all syscalls. Including .../include/native.h will deliver the _sysio_native_stat structure -- used to be __native_stat -- and all syscalls for internals use. These will be the proper calls for a build with or without _LARGEFILE64_SOURCE, Alpha, etc. We were having some problems with inconsitent/incorrect use. Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -w -b -B -p -r1.21 -r1.21.2.1 --- fcntl.c 5 Aug 2004 18:29:57 -0000 1.21 +++ fcntl.c 23 Sep 2004 16:51:18 -0000 1.21.2.1 @@ -61,7 +61,7 @@ _sysio_fcntl(int fd, int cmd, va_list ap { long arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, fd, cmd, arg); + *rtn = syscall(SYSIO_SYS_fcntl, fd, cmd, arg); return *rtn == -1 ? -errno : 0; } #endif |
From: Lee W. <lw...@us...> - 2004-09-23 16:51:29
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517/drivers/native Modified Files: Tag: defer-cwd fs_native.c Log Message: Now, wrap all syscalls. Including .../include/native.h will deliver the _sysio_native_stat structure -- used to be __native_stat -- and all syscalls for internals use. These will be the proper calls for a build with or without _LARGEFILE64_SOURCE, Alpha, etc. We were having some problems with inconsitent/incorrect use. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.48.2.1 retrieving revision 1.48.2.2 diff -u -w -b -B -p -r1.48.2.1 -r1.48.2.2 --- fs_native.c 12 Sep 2004 04:41:44 -0000 1.48.2.1 +++ fs_native.c 23 Sep 2004 16:51:17 -0000 1.48.2.2 @@ -73,6 +73,7 @@ #include "xtio.h" #include "sysio.h" +#include "native.h" #include "fs.h" #include "mount.h" #include "inode.h" @@ -83,13 +84,13 @@ #include <sys/uio.h> #endif -#if defined(SYS_getdirentries) +#if defined(SYSIO_SYS_getdirentries) #define DIR_STREAMED 0 #define DIR_CVT_64 0 -#elif defined(SYS_getdents64) +#elif defined(SYSIO_SYS_getdents64) #define DIR_STREAMED 1 #define DIR_CVT_64 0 -#elif defined(SYS_getdents) +#elif defined(SYSIO_SYS_getdents) #define DIR_STREAMED 1 #if defined(_LARGEFILE64_SOURCE) #define DIR_CVT_64 1 @@ -111,82 +112,6 @@ struct linux_dirent { #endif /* - * Local host file system driver. - */ - -#if defined(ALPHA_LINUX) - -/* stat struct from asm/stat.h, as returned - * by alpha linux kernel - */ -struct __native_stat { - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; - long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - unsigned int st_blksize; - int st_blocks; - unsigned int st_flags; - unsigned int st_gen; -}; - -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ - (dest)->st_flags = (src)->st_flags; \ - (dest)->st_gen = (src)->st_gen; \ -} while (0); - -#else -#define __native_stat intnl_stat -#define COPY_STAT(src, dest) *(dest) = *(src) -#endif - -#if defined(USE_NATIVE_STAT) -#define __SYS_STAT SYS_lstat -#define __SYS_FSTAT SYS_fstat -#define __SYS_TRUNCATE SYS_truncate -#define __SYS_FTRUNCATE SYS_ftruncate -#else -#define __SYS_STAT SYS_lstat64 -#define __SYS_FSTAT SYS_fstat64 -#define __SYS_TRUNCATE SYS_truncate64 -#define __SYS_FTRUNCATE SYS_ftruncate64 -#endif - -#if defined(USE_NATIVE_FDATASYNC) -#define __SYS_FDATASYNC SYS_osf_fdatasync -#else -#define __SYS_FDATASYNC SYS_fdatasync -#endif - -#if defined(USE_NATIVE_UTIME) -#define __SYS_UTIME SYS_utimes -#else -#define __SYS_UTIME SYS_utime -#endif - -/* * Native file system information we keep per FS. */ struct native_filesystem { @@ -349,7 +274,7 @@ native_stat(const char *path, struct ino struct native_inode *nino; time_t t; int err; - struct __native_stat stbuf; + struct _sysio_native_stat stbuf; nino = ino ? I2NI(ino) : NULL; @@ -365,9 +290,9 @@ native_stat(const char *path, struct ino return 0; } if (path) - err = syscall(__SYS_STAT, path, &stbuf); + err = syscall(SYSIO_SYS_stat, path, &stbuf); else if (nino && nino->ni_fd >= 0) - err = syscall(__SYS_FSTAT, nino->ni_fd, &stbuf); + err = syscall(SYSIO_SYS_fstat, nino->ni_fd, &stbuf); else abort(); if (err) { @@ -378,11 +303,11 @@ native_stat(const char *path, struct ino if (nino) { nino->ni_attrvalid = 1; nino->ni_attrtim = t; - COPY_STAT(&stbuf, &nino->ni_stat); + SYSIO_COPY_STAT(&stbuf, &nino->ni_stat); (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); return 0; } - COPY_STAT(&stbuf, buf); + SYSIO_COPY_STAT(&stbuf, buf); return 0; } @@ -443,7 +368,7 @@ _sysio_native_init() * zero. All permission bits to open/creat/setattr are absolute -- * They've already had a umask applied, when appropriate. */ - _sysio_umask = syscall(SYS_umask, 0); + _sysio_umask = syscall(SYSIO_SYS_umask, 0); return _sysio_fssw_register("native", &native_fssw_ops); } @@ -875,8 +800,8 @@ native_inop_setattr(struct pnode *pno, mode = stbuf->st_mode & 07777; err = fd < 0 - ? syscall(SYS_chmod, path, mode) - : syscall(SYS_fchmod, fd, mode); + ? syscall(SYSIO_SYS_chmod, path, mode) + : syscall(SYSIO_SYS_fchmod, fd, mode); if (err) err = -errno; } @@ -894,7 +819,7 @@ native_inop_setattr(struct pnode *pno, ut.modtime = stbuf->st_mtime; if (mask & SETATTR_ATIME) ut.actime = stbuf->st_atime; - err = syscall(__SYS_UTIME, path, &ut); + err = syscall(SYSIO_SYS_utime, path, &ut); if (err) err = -errno; } @@ -907,7 +832,7 @@ native_inop_setattr(struct pnode *pno, */ err = fd < 0 - ? syscall(SYS_chown, + ? syscall(SYSIO_SYS_chown, path, mask & SETATTR_UID ? stbuf->st_uid @@ -915,7 +840,7 @@ native_inop_setattr(struct pnode *pno, mask & SETATTR_GID ? stbuf->st_gid : (gid_t )-1) - : syscall(SYS_fchown, + : syscall(SYSIO_SYS_fchown, fd, mask & SETATTR_UID ? stbuf->st_uid @@ -933,8 +858,8 @@ native_inop_setattr(struct pnode *pno, * Do the truncate last. It can't be undone. */ (void )(fd < 0 - ? syscall(__SYS_TRUNCATE, path, stbuf->st_size) - : syscall(__SYS_FTRUNCATE, fd, stbuf->st_size)); + ? syscall(SYSIO_SYS_truncate, path, stbuf->st_size) + : syscall(SYSIO_SYS_ftruncate, fd, stbuf->st_size)); } if (!err) goto out; @@ -944,7 +869,7 @@ native_inop_setattr(struct pnode *pno, */ if (mask & (SETATTR_UID|SETATTR_GID)) { (void )(fd < 0 - ? syscall(SYS_chown, + ? syscall(SYSIO_SYS_chown, path, mask & SETATTR_UID ? stbp->st_uid @@ -952,7 +877,7 @@ native_inop_setattr(struct pnode *pno, mask & SETATTR_GID ? stbp->st_gid : (gid_t )-1) - : syscall(SYS_fchown, + : syscall(SYSIO_SYS_fchown, fd, mask & SETATTR_UID ? stbp->st_uid @@ -966,12 +891,12 @@ native_inop_setattr(struct pnode *pno, ut.actime = stbp->st_atime; ut.modtime = stbp->st_mtime; - (void )syscall(__SYS_UTIME, path, &ut); + (void )syscall(SYSIO_SYS_utime, path, &ut); } if (mask & SETATTR_MODE) { fd < 0 - ? syscall(SYS_chmod, path, stbp->st_mode & 07777) - : syscall(SYS_fchmod, stbp->st_mode & 07777); + ? syscall(SYSIO_SYS_chmod, path, stbp->st_mode & 07777) + : syscall(SYSIO_SYS_fchmod, stbp->st_mode & 07777); } out: /* @@ -993,11 +918,11 @@ native_pos(int fd, _SYSIO_OFF_T *offset, assert(*offset >= 0); off = *offset; -#if _LARGEFILE64_SOURCE && defined(SYS__llseek) +#if _LARGEFILE64_SOURCE && defined(SYSIO_SYS__llseek) { int err; err = - syscall(SYS__llseek, + syscall(SYSIO_SYS__llseek, (unsigned int)fd, (unsigned int)(off >> 32), (unsigned int)off, @@ -1008,7 +933,7 @@ native_pos(int fd, _SYSIO_OFF_T *offset, } #else off = - syscall(SYS_lseek, + syscall(SYSIO_SYS_lseek, fd, off, whence); @@ -1043,16 +968,16 @@ native_filldirentries(struct native_inod nino->ni_fpos = *basep; cc = -#if defined(SYS_getdirentries) - syscall(SYS_getdirentries, +#if defined(SYSIO_SYS_getdirentries) + syscall(SYSIO_SYS_getdirentries, nino->ni_fd, buf, nbytes, basep); -#elif defined(SYS_getdents64) - syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); -#elif defined(SYS_getdents) - syscall(SYS_getdents, nino->ni_fd, buf, nbytes); +#elif defined(SYSIO_SYS_getdents64) + syscall(SYSIO_SYS_getdents64, nino->ni_fd, buf, nbytes); +#elif defined(SYSIO_SYS_getdents) + syscall(SYSIO_SYS_getdents, nino->ni_fd, buf, nbytes); #endif if (cc < 0) @@ -1162,7 +1087,7 @@ native_inop_mkdir(struct pnode *pno, mod if (!path) return -ENOMEM; - err = syscall(SYS_mkdir, path, mode); + err = syscall(SYSIO_SYS_mkdir, path, mode); if (err != 0) err = -errno; free(path); @@ -1179,7 +1104,7 @@ native_inop_rmdir(struct pnode *pno) if (!path) return -ENOMEM; - err = syscall(SYS_rmdir, path); + err = syscall(SYSIO_SYS_rmdir, path); if (err != 0) err = -errno; free(path); @@ -1196,7 +1121,7 @@ native_inop_symlink(struct pnode *pno, c if (!path) return -ENOMEM; - err = syscall(SYS_symlink, data, path); + err = syscall(SYSIO_SYS_symlink, data, path); if (err != 0) err = -errno; free(path); @@ -1212,7 +1137,7 @@ native_inop_readlink(struct pnode *pno, path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; - i = syscall(SYS_readlink, path, buf, bufsiz); + i = syscall(SYSIO_SYS_readlink, path, buf, bufsiz); if (i < 0) i = -errno; free(path); @@ -1245,7 +1170,7 @@ native_inop_open(struct pnode *pno, int #ifdef O_LARGEFILE flags |= O_LARGEFILE; #endif - fd = syscall(SYS_open, path, flags, mode); + fd = syscall(SYSIO_SYS_open, path, flags, mode); if (!pno->p_base->pb_ino && fd >= 0) { int err; @@ -1258,7 +1183,7 @@ native_inop_open(struct pnode *pno, int &pno->p_base->pb_ino, 1); if (err) { - (void )syscall(SYS_close, fd); + (void )syscall(SYSIO_SYS_close, fd); if (err == -EEXIST) abort(); fd = err; @@ -1281,10 +1206,10 @@ native_inop_open(struct pnode *pno, int /* * Keep existing. */ - (void )syscall(SYS_close, fd); + (void )syscall(SYSIO_SYS_close, fd); return 0; } - (void )syscall(SYS_close, nino->ni_fd); + (void )syscall(SYSIO_SYS_close, nino->ni_fd); } /* * Invariant; First open. Must init. @@ -1321,7 +1246,7 @@ native_inop_close(struct inode *ino) return 0; } - err = syscall(SYS_close, nino->ni_fd); + err = syscall(SYSIO_SYS_close, nino->ni_fd); if (err) return -errno; @@ -1345,7 +1270,7 @@ native_inop_link(struct pnode *old, stru goto out; } - err = syscall(SYS_link, opath, npath); + err = syscall(SYSIO_SYS_link, opath, npath); if (err != 0) err = -errno; @@ -1380,7 +1305,7 @@ native_inop_unlink(struct pnode *pno) * (usually .NFSXXXXXX, where the X's are replaced by the PID and some * unique characters) in order to simulate the proper semantic. */ - if (syscall(SYS_unlink, path) != 0) + if (syscall(SYSIO_SYS_unlink, path) != 0) err = -errno; free(path); return err; @@ -1399,7 +1324,7 @@ native_inop_rename(struct pnode *old, st goto out; } - err = syscall(SYS_rename, opath, npath); + err = syscall(SYSIO_SYS_rename, opath, npath); if (err != 0) err = -errno; @@ -1415,15 +1340,6 @@ out: static ssize_t dopio(void *buf, size_t count, _SYSIO_OFF_T off, struct native_io *nio) { -#if defined(_LARGEFILE64_SOURCE) && \ - defined(SYS_pread64) && \ - defined(SYS_pwrite64) -#define _NATIVE_SYSCALL_PREAD SYS_pread64 -#define _NATIVE_SYSCALL_PWRITE SYS_pwrite64 -#else -#define _NATIVE_SYSCALL_PREAD SYS_pread -#define _NATIVE_SYSCALL_PWRITE SYS_pwrite -#endif ssize_t cc; if (!(off == nio->nio_nino->ni_fpos || nio->nio_nino->ni_seekok)) @@ -1439,7 +1355,9 @@ dopio(void *buf, size_t count, _SYSIO_OF return -1; } cc = - syscall(nio->nio_op == 'r' ? SYS_read : SYS_write, + syscall(nio->nio_op == 'r' + ? SYSIO_SYS_read + : SYSIO_SYS_write, nio->nio_nino->ni_fd, buf, count); @@ -1448,16 +1366,14 @@ dopio(void *buf, size_t count, _SYSIO_OF } else cc = syscall((nio->nio_op == 'r' - ? _NATIVE_SYSCALL_PREAD - : _NATIVE_SYSCALL_PWRITE), + ? SYSIO_SYS_pread + : SYSIO_SYS_pwrite), nio->nio_nino->ni_fd, buf, count, off); return cc; -#undef _NATIVE_SYSCALL_PREAD -#undef _NATIVE_SYSCALL_PWRITE } static ssize_t @@ -1498,7 +1414,7 @@ doiov(const struct iovec *iov, cc = #ifndef REDSTORM count <= MAX_IOVEC - ? syscall(nio->nio_op == 'r' ? SYS_readv : SYS_writev, + ? syscall(nio->nio_op == 'r' ? SYSIO_SYS_readv : SYSIO_SYS_writev, nio->nio_nino->ni_fd, iov, count) @@ -1543,13 +1459,7 @@ lockop_all(struct native_inode *nino, flock.l_len = xtv->xtv_len; xtv++; err = - syscall( -#if !_LARGEFILE64_SOURCE - SYS_fcntl64 -#else - SYS_fcntl -#endif - , + syscall(SYSIO_SYS_fcntl, nino->ni_fd, F_SETLK, &flock); @@ -1703,7 +1613,7 @@ native_inop_fcntl(struct inode *ino, #ifdef F_GETOWN case F_GETOWN: #endif - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd); + *rtn = syscall(SYSIO_SYS_fcntl, nino->ni_fd, cmd); if (*rtn == -1) err = -errno; break; @@ -1717,7 +1627,7 @@ native_inop_fcntl(struct inode *ino, case F_SETOWN: #endif arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd, arg); + *rtn = syscall(SYSIO_SYS_fcntl, nino->ni_fd, cmd, arg); if (*rtn == -1) err = -errno; break; @@ -1755,16 +1665,16 @@ native_inop_statvfs(struct pnode *pno, } /* - * The syscall interface does not support SYS_fstatvfs. + * The syscall interface does not support SYSIO_SYS_fstatvfs. * Should possibly return ENOSYS, but thought it - * better to use SYS_fstatfs and fill in as much of + * better to use SYSIO_SYS_fstatfs and fill in as much of * the statvfs structure as possible. This allows * for more of a test of the sysio user interface. */ rc = path - ? syscall(SYS_statfs, path, &fs) - : syscall(SYS_fstatfs, I2NI(ino)->ni_fd, &fs); + ? syscall(SYSIO_SYS_statfs, path, &fs) + : syscall(SYSIO_SYS_fstatfs, I2NI(ino)->ni_fd, &fs); if (path) free(path); if (rc < 0) @@ -1792,7 +1702,7 @@ native_inop_sync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); - err = syscall(SYS_fsync, I2NI(ino)->ni_fd); + err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); if (err) err = -errno; return err; @@ -1805,13 +1715,13 @@ native_inop_datasync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); -#ifdef NATIVE_FDATASYNC - err = syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); +#ifdef SYSIO_SYS_fdatasync + err = syscall(SYSIO_SYS_fdatasync, I2NI(ino)->ni_fd); #else #if 0 #warning No fdatasync system call -- Using fsync instead! #endif - err = syscall(SYS_fsync, I2NI(ino)->ni_fd); + err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); #endif if (err) err = -errno; @@ -1833,7 +1743,7 @@ native_inop_ioctl(struct inode *ino, arg3 = va_arg(ap, long); arg4 = va_arg(ap, long); - return syscall(SYS_ioctl, I2NI(ino)->ni_fd, request, + return syscall(SYSIO_SYS_ioctl, I2NI(ino)->ni_fd, request, arg1, arg2, arg3, arg4); } #else @@ -1857,7 +1767,7 @@ native_inop_gone(struct inode *ino) struct native_inode *nino = I2NI(ino); if (nino->ni_fd >= 0) - (void )syscall(SYS_close, nino->ni_fd); + (void )syscall(SYSIO_SYS_close, nino->ni_fd); free(ino->i_private); } |
From: Lee W. <lw...@us...> - 2004-09-23 16:51:28
|
Update of /cvsroot/libsysio/libsysio/drivers/sockets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517/drivers/sockets Modified Files: Tag: defer-cwd sockets.c Log Message: Now, wrap all syscalls. Including .../include/native.h will deliver the _sysio_native_stat structure -- used to be __native_stat -- and all syscalls for internals use. These will be the proper calls for a build with or without _LARGEFILE64_SOURCE, Alpha, etc. We were having some problems with inconsitent/incorrect use. Index: sockets.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/sockets/sockets.c,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -w -b -B -p -r1.10.2.1 -r1.10.2.2 --- sockets.c 12 Sep 2004 04:41:44 -0000 1.10.2.1 +++ sockets.c 23 Sep 2004 16:51:17 -0000 1.10.2.2 @@ -65,6 +65,7 @@ #include "xtio.h" #include "sysio.h" +#include "native.h" #include "fs.h" #include "inode.h" #include "file.h" @@ -157,7 +158,7 @@ sockets_inop_close(struct inode *ino) if (ski->ski_fd < 0) return -EBADF; - err = syscall(SYS_close, ski->ski_fd); + err = syscall(SYSIO_SYS_close, ski->ski_fd); if (err) return -errno; ski->ski_fd = -1; @@ -208,7 +209,7 @@ static ssize_t _readv(int fd, const struct iovec *vector, int count) { - return syscall(SYS_readv, fd, vector, count); + return syscall(SYSIO_SYS_readv, fd, vector, count); } static int @@ -226,7 +227,7 @@ static ssize_t _writev(int fd, const struct iovec *vector, int count) { - return syscall(SYS_writev, fd, vector, count); + return syscall(SYSIO_SYS_writev, fd, vector, count); } static int @@ -267,7 +268,7 @@ sockets_inop_fcntl(struct inode *ino __I case F_GETFD: case F_GETFL: case F_GETOWN: - *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd); + *rtn = syscall(SYSIO_SYS_fcntl, I2SKI(ino)->ski_fd, cmd); break; case F_DUPFD: case F_SETFD: @@ -277,7 +278,7 @@ sockets_inop_fcntl(struct inode *ino __I case F_SETLKW: case F_SETOWN: arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd, arg); + *rtn = syscall(SYSIO_SYS_fcntl, I2SKI(ino)->ski_fd, cmd, arg); break; default: *rtn = -1; @@ -292,7 +293,7 @@ sockets_inop_sync(struct inode *ino) assert(I2SKI(ino)->ski_fd >= 0); - return syscall(SYS_fsync, I2SKI(ino)->ski_fd); + return syscall(SYSIO_SYS_fsync, I2SKI(ino)->ski_fd); } static int @@ -301,7 +302,7 @@ sockets_inop_datasync(struct inode *ino) assert(I2SKI(ino)->ski_fd >= 0); - return syscall(SYS_fdatasync, I2SKI(ino)->ski_fd); + return syscall(SYSIO_SYS_fdatasync, I2SKI(ino)->ski_fd); } #ifdef HAVE_LUSTRE_HACK @@ -323,7 +324,7 @@ sockets_inop_ioctl(struct inode *ino, arg3 = va_arg(ap, long); arg4 = va_arg(ap, long); - return syscall(SYS_ioctl, I2SKI(ino)->ski_fd, request, + return syscall(SYSIO_SYS_ioctl, I2SKI(ino)->ski_fd, request, arg1, arg2, arg3, arg4); } #else @@ -401,12 +402,12 @@ socket(int domain, int type, int protoco } ski = I2SKI(ino); -#ifndef SYS_socketcall - ski->ski_fd = syscall(SYS_socket, domain, type, protocol); +#ifndef SYSIO_SYS_socketcall + ski->ski_fd = syscall(SYSIO_SYS_socket, domain, type, protocol); #else { unsigned long avec[3] = {domain, type, protocol}; - ski->ski_fd = syscall(SYS_socketcall, SYS_SOCKET, avec); + ski->ski_fd = syscall(SYSIO_SYS_socketcall, SYS_SOCKET, avec); } #endif if (ski->ski_fd < 0) { @@ -471,8 +472,8 @@ accept(int s, struct sockaddr *addr, soc } ski = I2SKI(ino); -#ifndef SYS_socketcall - ski->ski_fd = syscall(SYS_accept, I2SKI(ofil->f_ino)->ski_fd, +#ifndef SYSIO_SYS_socketcall + ski->ski_fd = syscall(SYSIO_SYS_accept, I2SKI(ofil->f_ino)->ski_fd, addr, addrlen); #else { @@ -480,7 +481,7 @@ accept(int s, struct sockaddr *addr, soc (unsigned long) I2SKI(ofil->f_ino)->ski_fd, (unsigned long) addr, (unsigned long) addrlen}; - ski->ski_fd = syscall(SYS_socketcall, SYS_ACCEPT, avec); + ski->ski_fd = syscall(SYSIO_SYS_socketcall, SYS_ACCEPT, avec); } #endif if (ski->ski_fd < 0) { @@ -523,13 +524,16 @@ bind(int sockfd, const struct sockaddr * goto out; } -#ifndef SYS_socketcall - if (syscall(SYS_bind, I2SKI(fil->f_ino)->ski_fd, my_addr, addrlen)) { +#ifndef SYSIO_SYS_socketcall + if (syscall(SYSIO_SYS_bind, + I2SKI(fil->f_ino)->ski_fd, + my_addr, + addrlen)) { #else avec[0] = I2SKI(fil->f_ino)->ski_fd; avec[1] = (unsigned long )my_addr; avec[2] = addrlen; - if (syscall(SYS_socketcall, SYS_BIND, avec) != 0) { + if (syscall(SYSIO_SYS_socketcall, SYS_BIND, avec) != 0) { #endif err = -errno; goto out; @@ -556,12 +560,14 @@ listen(int s, int backlog) goto out; } -#ifndef SYS_socketcall - if (syscall(SYS_listen, I2SKI(fil->f_ino)->ski_fd, backlog) != 0) { +#ifndef SYSIO_SYS_socketcall + if (syscall(SYSIO_SYS_listen, + I2SKI(fil->f_ino)->ski_fd, + backlog) != 0) { #else avec[0] = I2SKI(fil->f_ino)->ski_fd; avec[1] = backlog; - if (syscall(SYS_socketcall, SYS_LISTEN, avec) != 0) { + if (syscall(SYSIO_SYS_socketcall, SYS_LISTEN, avec) != 0) { #endif err = -errno; goto out; @@ -588,14 +594,14 @@ connect(int sockfd, const struct sockadd goto out; } -#ifndef SYS_socketcall - if (syscall(SYS_connect, I2SKI(fil->f_ino)->ski_fd, +#ifndef SYSIO_SYS_socketcall + if (syscall(SYSIO_SYS_connect, I2SKI(fil->f_ino)->ski_fd, serv_addr, addrlen) != 0) { #else avec[0] = I2SKI(fil->f_ino)->ski_fd; avec[1] = (unsigned long )serv_addr; avec[2] = addrlen; - if (syscall(SYS_socketcall, SYS_CONNECT, avec) != 0) { + if (syscall(SYSIO_SYS_socketcall, SYS_CONNECT, avec) != 0) { #endif err = -errno; goto out; |
From: Lee W. <lw...@us...> - 2004-09-23 16:51:27
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517 Modified Files: Tag: defer-cwd configure.in Log Message: Now, wrap all syscalls. Including .../include/native.h will deliver the _sysio_native_stat structure -- used to be __native_stat -- and all syscalls for internals use. These will be the proper calls for a build with or without _LARGEFILE64_SOURCE, Alpha, etc. We were having some problems with inconsitent/incorrect use. Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.17.2.1 retrieving revision 1.17.2.2 diff -u -w -b -B -p -r1.17.2.1 -r1.17.2.2 --- configure.in 12 Sep 2004 04:41:44 -0000 1.17.2.1 +++ configure.in 23 Sep 2004 16:51:16 -0000 1.17.2.2 @@ -246,61 +246,6 @@ fi AC_MSG_RESULT($alpha_linux_env) AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes) -# check for 64 bit stat, fstat, truncate, ftruncate syscalls -# -AC_MSG_CHECKING(for 64 bit stat and truncate syscalls) -AC_TRY_COMPILE([ -#include <sys/stat.h> -#include <syscall.h> -extern int syscall();], -[char path[] = "/"; -int fd = 0; -struct stat buf; -syscall(SYS_stat64,path,&buf); -syscall(SYS_fstat64,fd,&buf); -syscall(SYS_truncate64, path, buf.st_size); -syscall(SYS_ftruncate64, fd, buf.st_size); -], - sysstat64_exists=yes, - sysstat64_exists=no) -AC_MSG_RESULT($sysstat64_exists) -if test x$sysstat64_exists = xno; then - AC_DEFINE(USE_NATIVE_STAT) -fi - -# Check for fdatasync syscall -# -AC_MSG_CHECKING(for fdatasync system call) -if test x$alpha_linux_env = xyes; then - _syscallnum=SYS_osf_fdatasync -else - _syscallnum=SYS_fdatasync -fi -AC_TRY_COMPILE([ -#include <syscall.h> -extern int syscall();], -[int fd = 0; -syscall(SYS_fdatasync, fd);], - syscall_fdatasync_exists=yes, - syscall_fdatasync_exists=no) -AC_MSG_RESULT($syscall_fdatasync_exists) -if test x$syscall_fdatasync_exists = xyes; then - AC_DEFINE_UNQUOTED(NATIVE_FDATASYNC, $_syscallnum) -fi - -# Check for SYS_utime -# -AC_MSG_CHECKING(for utime system call) -AC_TRY_COMPILE([ -#include <syscall.h> -extern int syscall();], -[syscall(SYS_utime);], - syscall_utime_exists=yes, - syscall_utime_exists=no) -AC_MSG_RESULT($syscall_utime_exists) -if test x$syscall_utime_exists = xno; then - AC_DEFINE(USE_NATIVE_UTIME) -fi # Check for __st_ino # AC_MSG_CHECKING(for __st_ino) |
From: Lee W. <lw...@us...> - 2004-09-23 16:51:27
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517/dev/stdfd Modified Files: Tag: defer-cwd stdfd.c Log Message: Now, wrap all syscalls. Including .../include/native.h will deliver the _sysio_native_stat structure -- used to be __native_stat -- and all syscalls for internals use. These will be the proper calls for a build with or without _LARGEFILE64_SOURCE, Alpha, etc. We were having some problems with inconsitent/incorrect use. Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -w -b -B -p -r1.10 -r1.10.2.1 --- stdfd.c 27 Aug 2004 18:10:05 -0000 1.10 +++ stdfd.c 23 Sep 2004 16:51:16 -0000 1.10.2.1 @@ -53,6 +53,7 @@ #include "xtio.h" #include "sysio.h" +#include "native.h" #include "inode.h" #include "dev.h" @@ -64,8 +65,8 @@ #define dowrite(f, b, n) write_yod(f, b, n) #define doread(f, b, n) read_yod(f, b, n) #else -#define dowrite(f, b, n) syscall(SYS_write, f, b, n) -#define doread(f, b, n) syscall(SYS_read, f, b, n) +#define dowrite(f, b, n) syscall(SYSIO_SYS_write, f, b, n) +#define doread(f, b, n) syscall(SYSIO_SYS_read, f, b, n) #endif /* |
From: Lee W. <lw...@us...> - 2004-09-23 16:46:39
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18661 Modified Files: Tag: defer-cwd inode.c Log Message: If _sysio_i_undead called twice it will try to unlink an already unlinked inode the 2nd time. Fixed. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -w -b -B -p -r1.20 -r1.20.2.1 --- inode.c 27 Aug 2004 18:10:05 -0000 1.20 +++ inode.c 23 Sep 2004 16:46:29 -0000 1.20.2.1 @@ -322,6 +322,8 @@ void _sysio_i_undead(struct inode *ino) { + if (ino->i_zombie) + return; LIST_REMOVE(ino, i_link); ino->i_zombie = 1; } |
From: Lee W. <lw...@us...> - 2004-09-21 18:07:44
|
Update of /cvsroot/libsysio/libsysio/misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15784 Modified Files: Tag: defer-cwd init-env.sh Log Message: We no longer support the chdir command at startup from the SYSIO_NAMESPACE initialization env variable. Removed that command. Index: init-env.sh =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/init-env.sh,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -w -b -B -p -r1.5 -r1.5.2.1 --- init-env.sh 24 Jun 2004 19:58:28 -0000 1.5 +++ init-env.sh 21 Sep 2004 18:07:32 -0000 1.5.2.1 @@ -34,7 +34,6 @@ export SYSIO_NAMESPACE="\ {open, nm=\"/dev/fd/1\",fd=1,m=1} \ {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ {open, nm=\"/dev/fd/2\",fd=2,m=1} \ - {cd, dir=\"$HOME\"} \ ${_extras} \ " unset _root_flags |
From: Lee W. <lw...@us...> - 2004-09-21 17:37:12
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8982/dev/stdfd Modified Files: stdfd.c Log Message: Michael Levenhagen points out that the stdfd device does not support fcntl. We now support F_SETFL and F_GETFL on this device. Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- stdfd.c 21 Sep 2004 16:18:13 -0000 1.11 +++ stdfd.c 21 Sep 2004 17:36:57 -0000 1.12 @@ -46,8 +46,10 @@ #endif #include <errno.h> +#include <stdarg.h> #include <sys/syscall.h> #include <unistd.h> +#include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/queue.h> @@ -151,10 +153,13 @@ stdfd_read_simple(void *buf, _SYSIO_OFF_T off __IS_UNUSED, struct inode *ino) { - int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); + int cc; - return doread(fd, buf, nbytes); + cc = doread(fd, buf, nbytes); + if (cc < 0) + cc = -errno; + return cc; } static int @@ -171,8 +176,12 @@ stdfd_write_simple(const void *buf, struct inode *ino) { int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); + int cc; - return dowrite(fd, buf, nbytes); + cc = dowrite(fd, buf, nbytes); + if (cc < 0) + cc = -errno; + return cc; } static int @@ -198,14 +207,34 @@ stdfd_iodone(struct ioctx *iocp __IS_UNU } static int -stdfd_fcntl(struct inode *ino __IS_UNUSED, - int cmd __IS_UNUSED, - va_list ap __IS_UNUSED, +stdfd_fcntl(struct inode *ino, + int cmd, + va_list ap, int *rtn) { + int err; + int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); + long arg; + err = 0; + switch (cmd) { + case F_GETFL: + *rtn = syscall(SYS_fcntl, fd, cmd); + if (*rtn == -1) + err = -errno; + break; + case F_SETFL: + arg = va_arg(ap, long); + *rtn = syscall(SYS_fcntl, fd, cmd, arg); + if (*rtn == -1) + err = -errno; + va_end(ap); + break; + default: *rtn = -1; - return -EINVAL; + err = -EINVAL; + } + return err; } static int |
From: Lee W. <lw...@us...> - 2004-09-21 16:27:11
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27545 Modified Files: fs_native.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -w -b -B -p -r1.48 -r1.49 --- fs_native.c 10 Sep 2004 16:42:39 -0000 1.48 +++ fs_native.c 21 Sep 2004 16:26:59 -0000 1.49 @@ -210,7 +210,6 @@ struct native_inode { int ni_oflags; /* flags, from open */ unsigned ni_nopens; /* soft ref count */ _SYSIO_OFF_T ni_fpos; /* current pos */ - struct intnl_stat ni_stat; /* cached attrs */ }; /* @@ -329,52 +328,34 @@ static struct mount *native_internal_mou * stat -- by path. */ static int -native_stat(const char *path, struct native_inode *nino, struct intnl_stat *buf) +native_stat(const char *path, struct inode *ino, struct intnl_stat *buf) { + struct native_inode *nino; int err; struct __native_stat stbuf; - err = syscall(__SYS_STAT, path, &stbuf); - if (err) { - err = -errno; - goto out; - } - if (!nino) { - COPY_STAT(&stbuf, buf); - goto out; - } - COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; -} - -/* - * stat -- by fildes - */ -static int -native_fstat(int fd, struct native_inode *nino, struct intnl_stat *buf) -{ - int err; - struct __native_stat stbuf; + nino = ino ? I2NI(ino) : NULL; - err = syscall(__SYS_FSTAT, fd, &stbuf); - if (err) { - err = -errno; - goto out; + if (path) + err = syscall(__SYS_STAT, path, &stbuf); + else if (nino && nino->ni_fd >= 0) + err = syscall(__SYS_FSTAT, nino->ni_fd, &stbuf); + else + abort(); + if (err) + return -errno; + if (nino) { + COPY_STAT(&stbuf, &ino->i_stbuf); + if (buf) + (void )memcpy(buf, + &ino->i_stbuf, + sizeof(struct intnl_stat)); + return 0; } - if (!nino) { + if (!buf) + return 0; COPY_STAT(&stbuf, buf); - goto out; - } - COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; + return 0; } /* @@ -390,6 +371,7 @@ native_i_new(struct filesys *fs, struct if (!nino) return NULL; bzero(&nino->ni_ident, sizeof(nino->ni_ident)); + nino->ni_seekok = 0; nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; #ifdef HAVE_GENERATION @@ -401,16 +383,10 @@ native_i_new(struct filesys *fs, struct nino->ni_oflags = 0; nino->ni_nopens = 0; nino->ni_fpos = 0; - (void )memcpy(&nino->ni_stat, buf, sizeof(struct intnl_stat)); ino = _sysio_i_new(fs, &nino->ni_fileid, -#ifndef AUTOMOUNT_FILE_NAME - buf->st_mode & S_IFMT, -#else - buf->st_mode, /* all of the bits! */ -#endif - buf->st_rdev, + buf, 0, &native_i_ops, nino); @@ -440,7 +416,7 @@ _sysio_native_init() * Create private, internal, view of the hosts name space. */ static int -create_internal_namespace() +create_internal_namespace(const void *data __IS_UNUSED) { int err; struct mount *mnt; @@ -462,6 +438,7 @@ create_internal_namespace() * have access to fully qualified path names in the various routines. * Initialize that name space now. */ + fs = NULL; mnt = NULL; rootino = NULL; rootpb = NULL; @@ -523,7 +500,7 @@ error: static int native_fsswop_mount(const char *source, unsigned flags, - const void *data __IS_UNUSED, + const void *data, struct pnode *tocover, struct mount **mntp) { @@ -539,10 +516,11 @@ native_fsswop_mount(const char *source, return -ENOENT; if (!native_internal_mount) { - err = create_internal_namespace(); + err = create_internal_namespace(data); if (err) return err; - } + } else if (data && *(char *)data) + return -EINVAL; /* * Lookup the source in the internally maintained name space. @@ -578,21 +556,22 @@ native_fsswop_mount(const char *source, } static int -native_i_invalid(struct inode *inop, struct intnl_stat stbuf) +native_i_invalid(struct inode *inop, struct intnl_stat *stat) { /* * Validate passed in inode against stat struct info */ struct native_inode *nino = I2NI(inop); - if ((nino->ni_ident.dev != stbuf.st_dev || - nino->ni_ident.ino != stbuf.st_ino || + if ((nino->ni_ident.dev != stat->st_dev || + nino->ni_ident.ino != stat->st_ino || #ifdef HAVE_GENERATION - nino->ni_ident.gen != stbuf.st_gen || + nino->ni_ident.gen != stat->st_gen || #endif - ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || - (((inop)->i_rdev != stbuf.st_rdev) && - (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) + ((inop)->i_stbuf.st_mode & S_IFMT) != (stat->st_mode & S_IFMT)) || + (((inop)->i_stbuf.st_rdev != stat->st_rdev) && + (S_ISCHR((inop)->i_stbuf.st_mode) || + S_ISBLK((inop)->i_stbuf.st_mode)))) return 1; return 0; @@ -610,24 +589,24 @@ native_iget(struct filesys *fs, { int err; struct inode *ino; - struct intnl_stat stbuf; + struct intnl_stat ostbuf, stbuf; struct native_inode_identifier ident; struct file_identifier fileid; /* - * Get file status. + * Save old attributes and get current file status. */ - err = native_stat(path, *inop ? I2NI(*inop) : NULL, &stbuf); - if (err) { - *inop = NULL; + if (*inop) + ostbuf = (*inop)->i_stbuf; + err = native_stat(path, *inop, &stbuf); + if (err) return err; - } /* * Validate? */ if (*inop) { - if (!native_i_invalid(*inop, stbuf)) + if (!native_i_invalid(*inop, &ostbuf)) return 0; /* * Invalidate. @@ -648,11 +627,12 @@ native_iget(struct filesys *fs, fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, &fileid); if (ino && - (forced || (ino->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT))) { + (forced || + (ino->i_stbuf.st_mode & S_IFMT) != (stbuf.st_mode & S_IFMT))) { /* * Insertion was forced or dup inum but it's already present! */ - if (native_i_invalid(ino, stbuf)) { + if (native_i_invalid(ino, &ostbuf)) { /* * Cached inode has stale attrs * make way for the new one @@ -733,7 +713,7 @@ native_inop_lookup(struct pnode *pno, static int native_inop_getattr(struct pnode *pno, struct inode *ino, - struct intnl_stat *stbuf) + struct intnl_stat *stat) { char *path; struct native_inode *nino; @@ -745,18 +725,18 @@ native_inop_getattr(struct pnode *pno, path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; - err = native_stat(path, nino, stbuf); + err = native_stat(path, ino, stat); free(path); } else if (nino->ni_fd >= 0) - err = native_fstat(nino->ni_fd, nino, stbuf); + err = native_stat(NULL, ino, stat); else { /* * Dev inodes don't open in this driver. We won't have * a file descriptor with which to do the deed then. Satisfy * the request from the cached copy of the attributes. */ - (void )memcpy(stbuf, - &nino->ni_stat, + (void )memcpy(stat, + &ino->i_stbuf, sizeof(struct intnl_stat)); err = 0; } @@ -768,22 +748,18 @@ static int native_inop_setattr(struct pnode *pno, struct inode *ino, unsigned mask, - struct intnl_stat *stbuf) + struct intnl_stat *stat) { char *path; struct native_inode *nino; int fd; - struct intnl_stat *stbp, _stbuf; int err; path = NULL; nino = ino ? I2NI(ino) : NULL; fd = -1; - stbp = &_stbuf; - if (nino) { + if (nino) fd = nino->ni_fd; - stbp = &nino->ni_stat; - } if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { if (!pno) return -EEXIST; @@ -795,10 +771,7 @@ native_inop_setattr(struct pnode *pno, /* * Get current status for undo. */ - err = - fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp); + err = native_stat(path, ino, NULL); if (err) goto out; @@ -808,7 +781,7 @@ native_inop_setattr(struct pnode *pno, /* * Alter permissions attribute. */ - mode = stbuf->st_mode & 07777; + mode = stat->st_mode & 07777; err = fd < 0 ? syscall(SYS_chmod, path, mode) @@ -824,12 +797,12 @@ native_inop_setattr(struct pnode *pno, /* * Alter access and/or modify time attributes. */ - ut.actime = stbuf->st_atime; - ut.modtime = stbuf->st_mtime; + ut.actime = stat->st_atime; + ut.modtime = stat->st_mtime; if (mask & SETATTR_MTIME) - ut.modtime = stbuf->st_mtime; + ut.modtime = stat->st_mtime; if (mask & SETATTR_ATIME) - ut.actime = stbuf->st_atime; + ut.actime = stat->st_atime; err = syscall(__SYS_UTIME, path, &ut); if (err) err = -errno; @@ -846,18 +819,18 @@ native_inop_setattr(struct pnode *pno, ? syscall(SYS_chown, path, mask & SETATTR_UID - ? stbuf->st_uid + ? stat->st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbuf->st_gid + ? stat->st_gid : (gid_t )-1) : syscall(SYS_fchown, fd, mask & SETATTR_UID - ? stbuf->st_uid + ? stat->st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbuf->st_gid + ? stat->st_gid : (gid_t )-1); if (err) err = -errno; @@ -869,8 +842,8 @@ native_inop_setattr(struct pnode *pno, * Do the truncate last. It can't be undone. */ (void )(fd < 0 - ? syscall(__SYS_TRUNCATE, path, stbuf->st_size) - : syscall(__SYS_FTRUNCATE, fd, stbuf->st_size)); + ? syscall(__SYS_TRUNCATE, path, stat->st_size) + : syscall(__SYS_FTRUNCATE, fd, stat->st_size)); } if (!err) goto out; @@ -883,39 +856,37 @@ native_inop_setattr(struct pnode *pno, ? syscall(SYS_chown, path, mask & SETATTR_UID - ? stbp->st_uid + ? ino->i_stbuf.st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbp->st_gid + ? ino->i_stbuf.st_gid : (gid_t )-1) : syscall(SYS_fchown, fd, mask & SETATTR_UID - ? stbp->st_uid + ? ino->i_stbuf.st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbp->st_gid + ? ino->i_stbuf.st_gid : (gid_t )-1)); } if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { struct utimbuf ut; - ut.actime = stbp->st_atime; - ut.modtime = stbp->st_mtime; + ut.actime = ino->i_stbuf.st_atime; + ut.modtime = ino->i_stbuf.st_mtime; (void )syscall(__SYS_UTIME, path, &ut); } if (mask & SETATTR_MODE) { fd < 0 - ? syscall(SYS_chmod, path, stbp->st_mode & 07777) - : syscall(SYS_fchmod, stbp->st_mode & 07777); + ? syscall(SYS_chmod, path, ino->i_stbuf.st_mode & 07777) + : syscall(SYS_fchmod, ino->i_stbuf.st_mode & 07777); } out: /* * We must refresh the cached attributes on success. */ - if (!err && (fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp)) != 0) + if (!err && native_stat(path, ino, NULL) != 0) abort(); if (path) free(path); @@ -1804,6 +1775,7 @@ static void native_fsop_gone(struct filesys *fs __IS_UNUSED) { + free(fs->fs_private); /* * Do nothing. There is no private part maintained for the * native file interface. |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:53
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/drivers/native Modified Files: Tag: defer-cwd fs_native.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.48.2.1 retrieving revision 1.48.2.2 diff -u -w -b -B -p -r1.48.2.1 -r1.48.2.2 --- fs_native.c 12 Sep 2004 04:41:44 -0000 1.48.2.1 +++ fs_native.c 21 Sep 2004 16:18:13 -0000 1.48.2.2 @@ -187,19 +187,6 @@ do { #endif /* - * Native file system information we keep per FS. - */ -struct native_filesystem { - time_t nfs_atimo; /* attr timeout (sec) */ -}; - -/* - * Given fs, return driver private part. - */ -#define FS2NFS(fs) \ - ((struct native_filesystem *)(fs)->fs_private) - -/* * Native file identifiers format. */ struct native_inode_identifier { @@ -216,16 +203,13 @@ struct native_inode_identifier { */ struct native_inode { unsigned - ni_seekok : 1, /* can seek? */ - ni_attrvalid : 1; /* cached attrs ok? */ + ni_seekok : 1; /* can seek? */ struct native_inode_identifier ni_ident; /* unique identifier */ struct file_identifier ni_fileid; /* ditto */ int ni_fd; /* host fildes */ int ni_oflags; /* flags, from open */ unsigned ni_nopens; /* soft ref count */ _SYSIO_OFF_T ni_fpos; /* current pos */ - struct intnl_stat ni_stat; /* cached attrs */ - time_t ni_attrtim; /* attrs time stamp */ }; /* @@ -347,41 +331,29 @@ static int native_stat(const char *path, struct inode *ino, struct intnl_stat *buf) { struct native_inode *nino; - time_t t; int err; struct __native_stat stbuf; nino = ino ? I2NI(ino) : NULL; - t = _SYSIO_LOCAL_TIME(); - /* - * Use cached? - */ - if (nino && - nino->ni_attrvalid && - nino->ni_attrtim <= t && - (t - nino->ni_attrtim) < FS2NFS(ino->i_fs)->nfs_atimo) { - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - return 0; - } if (path) err = syscall(__SYS_STAT, path, &stbuf); else if (nino && nino->ni_fd >= 0) err = syscall(__SYS_FSTAT, nino->ni_fd, &stbuf); else abort(); - if (err) { - if (nino) - nino->ni_attrvalid = 0; + if (err) return -errno; - } if (nino) { - nino->ni_attrvalid = 1; - nino->ni_attrtim = t; - COPY_STAT(&stbuf, &nino->ni_stat); - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); + COPY_STAT(&stbuf, &ino->i_stbuf); + if (buf) + (void )memcpy(buf, + &ino->i_stbuf, + sizeof(struct intnl_stat)); return 0; } + if (!buf) + return 0; COPY_STAT(&stbuf, buf); return 0; } @@ -400,7 +372,6 @@ native_i_new(struct filesys *fs, struct return NULL; bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_seekok = 0; - nino->ni_attrvalid = 1; nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; #ifdef HAVE_GENERATION @@ -412,17 +383,10 @@ native_i_new(struct filesys *fs, struct nino->ni_oflags = 0; nino->ni_nopens = 0; nino->ni_fpos = 0; - (void )memcpy(&nino->ni_stat, buf, sizeof(struct intnl_stat)); - nino->ni_attrtim = _SYSIO_LOCAL_TIME(); ino = _sysio_i_new(fs, &nino->ni_fileid, -#ifndef AUTOMOUNT_FILE_NAME - buf->st_mode & S_IFMT, -#else - buf->st_mode, /* all of the bits! */ -#endif - buf->st_rdev, + buf, 0, &native_i_ops, nino); @@ -452,12 +416,8 @@ _sysio_native_init() * Create private, internal, view of the hosts name space. */ static int -create_internal_namespace(const void *data) +create_internal_namespace(const void *data __IS_UNUSED) { - char *opts; - ssize_t len; - char *cp; - struct native_filesystem *nfs; int err; struct mount *mnt; struct inode *rootino; @@ -465,11 +425,6 @@ create_internal_namespace(const void *da static struct qstr noname = { NULL, 0, 0 }; struct filesys *fs; struct intnl_stat stbuf; - unsigned long ul; - static struct option_value_info v[] = { - { "atimo", "30" }, - { NULL, NULL } - }; if (native_internal_mount) { /* @@ -479,26 +434,6 @@ create_internal_namespace(const void *da } /* - * Get mount options. - */ - opts = NULL; - if (data && (len = strlen((char *)data))) { - opts = malloc(len + 1); - if (!opts) - return -ENOMEM; - (void )strcpy(opts, data); - if (_sysio_get_args(opts, v) - opts != (ssize_t )len) - return -EINVAL; - } - ul = strtoul(v[0].ovi_value, &cp, 0); - if (*cp != '\0' || ul >= UINT_MAX) - return -EINVAL; - if (opts) { - free(opts); - opts = NULL; - } - - /* * We maintain an artificial, internal, name space in order to * have access to fully qualified path names in the various routines. * Initialize that name space now. @@ -507,25 +442,7 @@ create_internal_namespace(const void *da mnt = NULL; rootino = NULL; rootpb = NULL; - /* - * This really should be per-mount. Hmm, but that's best done - * as proper sub-mounts in the core and not this driver. We reconcile - * now, here, by putting the mount options on the file system. That - * means they are global and only can be passed at the initial mount. - * - * Maybe do it right some day? - */ - nfs = malloc(sizeof(struct native_filesystem)); - if (!nfs) { - err = -ENOMEM; - goto error; - } - nfs->nfs_atimo = ul; - if ((unsigned long)nfs->nfs_atimo != ul) { - err = -EINVAL; - goto error; - } - fs = _sysio_fs_new(&native_inodesys_ops, 0, nfs); + fs = _sysio_fs_new(&native_inodesys_ops, 0, NULL); if (!fs) { err = -ENOMEM; goto error; @@ -566,7 +483,6 @@ error: if (mnt) { if (_sysio_do_unmount(mnt) != 0) abort(); - nfs = NULL; fs = NULL; rootpb = NULL; rootino = NULL; @@ -576,12 +492,7 @@ error: if (fs) { FS_RELE(fs); _sysio_fs_gone(fs); - nfs = NULL; } - if (nfs) - free(nfs); - if (opts) - free(opts); return err; } @@ -645,21 +556,22 @@ native_fsswop_mount(const char *source, } static int -native_i_invalid(struct inode *inop, struct intnl_stat stbuf) +native_i_invalid(struct inode *inop, struct intnl_stat *stat) { /* * Validate passed in inode against stat struct info */ struct native_inode *nino = I2NI(inop); - if ((nino->ni_ident.dev != stbuf.st_dev || - nino->ni_ident.ino != stbuf.st_ino || + if ((nino->ni_ident.dev != stat->st_dev || + nino->ni_ident.ino != stat->st_ino || #ifdef HAVE_GENERATION - nino->ni_ident.gen != stbuf.st_gen || + nino->ni_ident.gen != stat->st_gen || #endif - ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || - (((inop)->i_rdev != stbuf.st_rdev) && - (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) + ((inop)->i_stbuf.st_mode & S_IFMT) != (stat->st_mode & S_IFMT)) || + (((inop)->i_stbuf.st_rdev != stat->st_rdev) && + (S_ISCHR((inop)->i_stbuf.st_mode) || + S_ISBLK((inop)->i_stbuf.st_mode)))) return 1; return 0; @@ -677,24 +589,24 @@ native_iget(struct filesys *fs, { int err; struct inode *ino; - struct intnl_stat stbuf; + struct intnl_stat ostbuf, stbuf; struct native_inode_identifier ident; struct file_identifier fileid; /* - * Get file status. + * Save old attributes and get current file status. */ + if (*inop) + ostbuf = (*inop)->i_stbuf; err = native_stat(path, *inop, &stbuf); - if (err) { - *inop = NULL; + if (err) return err; - } /* * Validate? */ if (*inop) { - if (!native_i_invalid(*inop, stbuf)) + if (!native_i_invalid(*inop, &ostbuf)) return 0; /* * Invalidate. @@ -715,11 +627,12 @@ native_iget(struct filesys *fs, fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, &fileid); if (ino && - (forced || (ino->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT))) { + (forced || + (ino->i_stbuf.st_mode & S_IFMT) != (stbuf.st_mode & S_IFMT))) { /* * Insertion was forced or dup inum but it's already present! */ - if (native_i_invalid(ino, stbuf)) { + if (native_i_invalid(ino, &ostbuf)) { /* * Cached inode has stale attrs * make way for the new one @@ -800,7 +713,7 @@ native_inop_lookup(struct pnode *pno, static int native_inop_getattr(struct pnode *pno, struct inode *ino, - struct intnl_stat *stbuf) + struct intnl_stat *stat) { char *path; struct native_inode *nino; @@ -812,18 +725,18 @@ native_inop_getattr(struct pnode *pno, path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; - err = native_stat(path, ino, stbuf); + err = native_stat(path, ino, stat); free(path); } else if (nino->ni_fd >= 0) - err = native_stat(NULL, ino, stbuf); + err = native_stat(NULL, ino, stat); else { /* * Dev inodes don't open in this driver. We won't have * a file descriptor with which to do the deed then. Satisfy * the request from the cached copy of the attributes. */ - (void )memcpy(stbuf, - &nino->ni_stat, + (void )memcpy(stat, + &ino->i_stbuf, sizeof(struct intnl_stat)); err = 0; } @@ -835,22 +748,18 @@ static int native_inop_setattr(struct pnode *pno, struct inode *ino, unsigned mask, - struct intnl_stat *stbuf) + struct intnl_stat *stat) { char *path; struct native_inode *nino; int fd; - struct intnl_stat *stbp, _stbuf; int err; path = NULL; nino = ino ? I2NI(ino) : NULL; fd = -1; - stbp = &_stbuf; - if (nino) { + if (nino) fd = nino->ni_fd; - stbp = &nino->ni_stat; - } if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { if (!pno) return -EEXIST; @@ -862,7 +771,7 @@ native_inop_setattr(struct pnode *pno, /* * Get current status for undo. */ - err = native_stat(path, ino, stbp); + err = native_stat(path, ino, NULL); if (err) goto out; @@ -872,7 +781,7 @@ native_inop_setattr(struct pnode *pno, /* * Alter permissions attribute. */ - mode = stbuf->st_mode & 07777; + mode = stat->st_mode & 07777; err = fd < 0 ? syscall(SYS_chmod, path, mode) @@ -888,12 +797,12 @@ native_inop_setattr(struct pnode *pno, /* * Alter access and/or modify time attributes. */ - ut.actime = stbuf->st_atime; - ut.modtime = stbuf->st_mtime; + ut.actime = stat->st_atime; + ut.modtime = stat->st_mtime; if (mask & SETATTR_MTIME) - ut.modtime = stbuf->st_mtime; + ut.modtime = stat->st_mtime; if (mask & SETATTR_ATIME) - ut.actime = stbuf->st_atime; + ut.actime = stat->st_atime; err = syscall(__SYS_UTIME, path, &ut); if (err) err = -errno; @@ -910,18 +819,18 @@ native_inop_setattr(struct pnode *pno, ? syscall(SYS_chown, path, mask & SETATTR_UID - ? stbuf->st_uid + ? stat->st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbuf->st_gid + ? stat->st_gid : (gid_t )-1) : syscall(SYS_fchown, fd, mask & SETATTR_UID - ? stbuf->st_uid + ? stat->st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbuf->st_gid + ? stat->st_gid : (gid_t )-1); if (err) err = -errno; @@ -933,8 +842,8 @@ native_inop_setattr(struct pnode *pno, * Do the truncate last. It can't be undone. */ (void )(fd < 0 - ? syscall(__SYS_TRUNCATE, path, stbuf->st_size) - : syscall(__SYS_FTRUNCATE, fd, stbuf->st_size)); + ? syscall(__SYS_TRUNCATE, path, stat->st_size) + : syscall(__SYS_FTRUNCATE, fd, stat->st_size)); } if (!err) goto out; @@ -947,37 +856,37 @@ native_inop_setattr(struct pnode *pno, ? syscall(SYS_chown, path, mask & SETATTR_UID - ? stbp->st_uid + ? ino->i_stbuf.st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbp->st_gid + ? ino->i_stbuf.st_gid : (gid_t )-1) : syscall(SYS_fchown, fd, mask & SETATTR_UID - ? stbp->st_uid + ? ino->i_stbuf.st_uid : (uid_t )-1, mask & SETATTR_GID - ? stbp->st_gid + ? ino->i_stbuf.st_gid : (gid_t )-1)); } if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { struct utimbuf ut; - ut.actime = stbp->st_atime; - ut.modtime = stbp->st_mtime; + ut.actime = ino->i_stbuf.st_atime; + ut.modtime = ino->i_stbuf.st_mtime; (void )syscall(__SYS_UTIME, path, &ut); } if (mask & SETATTR_MODE) { fd < 0 - ? syscall(SYS_chmod, path, stbp->st_mode & 07777) - : syscall(SYS_fchmod, stbp->st_mode & 07777); + ? syscall(SYS_chmod, path, ino->i_stbuf.st_mode & 07777) + : syscall(SYS_fchmod, ino->i_stbuf.st_mode & 07777); } out: /* * We must refresh the cached attributes on success. */ - if (!err && native_stat(path, ino, stbp) != 0) + if (!err && native_stat(path, ino, NULL) != 0) abort(); if (path) free(path); |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:53
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/drivers/incore Modified Files: fs_incore.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- fs_incore.c 27 Aug 2004 18:11:24 -0000 1.21 +++ fs_incore.c 21 Sep 2004 16:18:13 -0000 1.22 @@ -85,7 +85,6 @@ */ struct incore_inode { LIST_ENTRY(incore_inode) ici_link; /* i-nodes list link */ - unsigned ici_revalidate : 1; /* synch sys inode? */ struct intnl_stat ici_st; /* attrs */ struct file_identifier ici_fileid; /* file ID */ void *ici_data; /* file data */ @@ -419,7 +418,6 @@ incore_i_alloc(struct incore_filesys *ic icino = malloc(sizeof(struct incore_inode)); if (!icino) return NULL; - icino->ici_revalidate = 0; icino->ici_st = *st; icino->ici_fileid.fid_data = &icino->ici_st.st_ino; icino->ici_fileid.fid_len = sizeof(icino->ici_st.st_ino); @@ -634,8 +632,7 @@ _sysio_incore_fsswop_mount(const char *s rooti = _sysio_i_new(fs, &icino->ici_fileid, - icino->ici_st.st_mode, - 0, + &icino->ici_st, 1, &_sysio_incore_dir_ops, icino); @@ -809,10 +806,7 @@ _sysio_incore_dirop_lookup(struct pnode if (*inop) { icino = I2IC(*inop); assert(icino); - if (icino->ici_revalidate) { - (*inop)->i_mode = icino->ici_st.st_mode; - icino->ici_revalidate = 0; - } + (*inop)->i_stbuf = icino->ici_st; return 0; } @@ -856,8 +850,7 @@ _sysio_incore_dirop_lookup(struct pnode ino = _sysio_i_new(ino->i_fs, &icino->ici_fileid, - icino->ici_st.st_mode, - 0, + &icino->ici_st 1, ops, icino); @@ -911,7 +904,6 @@ _sysio_incore_inop_setattr(struct pnode if (mask & SETATTR_MODE) { icino->ici_st.st_mode = (icino->ici_st.st_mode & S_IFMT) | (stbuf->st_mode & 07777); - icino->ici_revalidate = 1; } if (mask & SETATTR_MTIME) icino->ici_st.st_mtime = stbuf->st_mtime; @@ -923,6 +915,7 @@ _sysio_incore_inop_setattr(struct pnode icino->ici_st.st_gid = stbuf->st_gid; icino->ici_st.st_ctime = time(NULL); + ino->i_stbuf = icino->ici_st; out: return err; } @@ -1167,8 +1160,7 @@ _sysio_incore_dirop_mkdir(struct pnode * ino = _sysio_i_new(pno->p_parent->p_base->pb_ino->i_fs, &icino->ici_fileid, - stat.st_mode, - 0, + &stat, 1, &_sysio_incore_dir_ops, icino); @@ -1274,7 +1266,7 @@ _sysio_incore_dirop_rmdir(struct pnode * } static int -incore_create(struct pnode *pno, struct intnl_stat *st) +incore_create(struct pnode *pno, struct intnl_stat *stat) { struct inode *dino, *ino; struct incore_inode *icino; @@ -1283,7 +1275,7 @@ incore_create(struct pnode *pno, struct dino = pno->p_parent->p_base->pb_ino; assert(dino); - icino = incore_i_alloc(FS2ICFS(dino->i_fs), st); + icino = incore_i_alloc(FS2ICFS(dino->i_fs), stat); if (!icino) return -ENOSPC; @@ -1293,10 +1285,9 @@ incore_create(struct pnode *pno, struct ino = _sysio_i_new(dino->i_fs, &icino->ici_fileid, - st->st_mode, - st->st_rdev, + stat, 1, - S_ISREG(st->st_mode) + S_ISREG(stat->st_mode) ? &_sysio_incore_file_ops : &_sysio_incore_dev_ops, icino); @@ -1311,7 +1302,7 @@ incore_create(struct pnode *pno, struct err = incore_directory_insert(I2IC(dino), &pno->p_base->pb_name, - st->st_ino, + stat->st_ino, INCORE_D_TYPEOF(icino->ici_st.st_mode)); if (err) { I_RELE(ino); @@ -1372,7 +1363,7 @@ _sysio_incore_dirop_link(struct pnode *o int err; assert(!new->p_base->pb_ino); - assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); + assert(!S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)); /* * Can bump the link count? |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:53
|
Update of /cvsroot/libsysio/libsysio/drivers/sockets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/drivers/sockets Modified Files: sockets.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: sockets.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/sockets/sockets.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- sockets.c 5 Aug 2004 18:29:57 -0000 1.10 +++ sockets.c 21 Sep 2004 16:18:14 -0000 1.11 @@ -358,6 +358,7 @@ _sysio_sockets_inew() static ino_t inum = 1; struct socket_info *ski; struct inode *ino; + static struct intnl_stat zero_stat; ski = malloc(sizeof(struct socket_info)); if (!ski) @@ -370,8 +371,7 @@ _sysio_sockets_inew() ino = _sysio_i_new(sockets_fs, &ski->ski_fileid, - 0, - 0, + &zero_stat, 0, &sockets_i_ops, ski); |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:52
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/dev/stdfd Modified Files: stdfd.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- stdfd.c 27 Aug 2004 18:10:05 -0000 1.10 +++ stdfd.c 21 Sep 2004 16:18:13 -0000 1.11 @@ -49,6 +49,7 @@ #include <sys/syscall.h> #include <unistd.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "xtio.h" @@ -151,7 +152,7 @@ stdfd_read_simple(void *buf, struct inode *ino) { - int fd = SYSIO_MINOR_DEV(ino->i_rdev); + int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); return doread(fd, buf, nbytes); } @@ -169,7 +170,7 @@ stdfd_write_simple(const void *buf, _SYSIO_OFF_T off __IS_UNUSED, struct inode *ino) { - int fd = SYSIO_MINOR_DEV(ino->i_rdev); + int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); return dowrite(fd, buf, nbytes); } |
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/src Modified Files: access.c chdir.c file.c file_hack.c fs.c fsync.c getdirentries.c inode.c ioctl.c ioctx.c iowait.c link.c mkdir.c mount.c namei.c rmdir.c symlink.c truncate.c unlink.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: access.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/access.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- access.c 31 Jul 2004 14:28:51 -0000 1.9 +++ access.c 21 Sep 2004 16:18:30 -0000 1.10 @@ -44,53 +44,35 @@ #include <stdlib.h> #include <errno.h> #include <unistd.h> +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" +#include "inode.h" #include "sysio-symbols.h" -int -SYSIO_INTERFACE_NAME(access)(const char *path, int amode) +/* + * Check given access type on given inode. + */ +static int +_sysio_check_permission(struct inode *ino, + uid_t uid, gid_t gid, + gid_t gids[], size_t ngids, + int amode) { - gid_t *list, *entry; - size_t n; - int err = 0; - unsigned mask, mode; - struct stat stbuf; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; + mode_t mask; + struct intnl_stat *stat; /* * Check amode. */ if ((amode & (R_OK|W_OK|X_OK)) != amode) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - n = getgroups(0, NULL); - list = NULL; - if (n) { - list = malloc(n * sizeof(gid_t)); - if (!list) { - err = -ENOMEM; - goto out; - } - } - err = getgroups(n, list); - if (err != (int ) n) - goto out; + return -EINVAL; - err = SYSIO_INTERFACE_NAME(stat)(path, &stbuf); - if (err) { - err = -errno; - goto out; - } if (!amode) - SYSIO_INTERFACE_RETURN(0, 0); - + return 0; mask = 0; if (amode & R_OK) @@ -100,29 +82,91 @@ SYSIO_INTERFACE_NAME(access)(const char if (amode & X_OK) mask |= S_IXUSR; - mode = stbuf.st_mode; - if (stbuf.st_uid == getuid() && (mode & mask) == mask) - goto out; + stat = &ino->i_stbuf; + if (stat->st_uid == uid && (stat->st_mode & mask) == mask) + return 0; mask >>= 3; - if (stbuf.st_gid == getgid() && (mode & mask) == mask) - goto out; + if (stat->st_gid == gid && (stat->st_mode & mask) == mask) + return 0; - entry = list; - while (n--) - if (stbuf.st_gid == *entry++ && (mode & mask) == mask) - goto out; + while (ngids) { + ngids--; + if (stat->st_gid == *gids++ && (stat->st_mode & mask) == mask) + return 0; + } mask >>= 3; - if ((mode & mask) == mask) - goto out; + if ((stat->st_mode & mask) == mask) + return 0; - err = -EACCES; + return -EACCES; +} -out: - if (list) - free(list); +/* + * Determine if a given access is permitted to a give file. + */ +int +_sysio_permitted(struct inode *ino, int amode) +{ + int err; + gid_t *gids; + int n; + void *p; + + err = 0; + gids = NULL; + for (;;) { + n = getgroups(0, NULL); + if (!n) + break; + p = realloc(gids, n * sizeof(gid_t)); + if (!p && gids) { + err = -ENOMEM; + break; + } + gids = p; + err = getgroups(n, gids); + if (err < 0) { + if (errno == EINVAL) + continue; + err = -errno; + break; + } + err = + _sysio_check_permission(ino, + geteuid(), getegid(), + gids, (size_t )n, + amode); + break; + } + if (!gids) + return err; + free(gids); + return err; +} + +int +SYSIO_INTERFACE_NAME(access)(const char *path, int amode) +{ + struct intent intent; + int err; + struct pnode *pno; + + SYSIO_INTERFACE_DISPLAY_BLOCK; + + SYSIO_INTERFACE_ENTER; + INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); + err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); + if (err) + SYSIO_INTERFACE_RETURN(-1, err); + err = + _sysio_check_permission(pno->p_base->pb_ino, + getuid(), getgid(), + NULL, 0, + amode); + P_RELE(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- chdir.c 16 Sep 2004 14:41:32 -0000 1.21 +++ chdir.c 21 Sep 2004 16:18:30 -0000 1.22 @@ -90,7 +90,7 @@ _sysio_p_chdir(struct pnode *pno) int err; /* - * Revalidate the pnode, and ensure it's a directory + * Revalidate the pnode, and ensure it's an accessable directory */ err = _sysio_p_validate(pno, NULL, NULL); if (err) @@ -95,10 +95,14 @@ _sysio_p_chdir(struct pnode *pno) err = _sysio_p_validate(pno, NULL, NULL); if (err) return err; - if (!(pno->p_base->pb_ino && - S_ISDIR(pno->p_base->pb_ino->i_mode))) - return -ENOTDIR; + S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode))) + err = -ENOTDIR; + else + err = _sysio_permitted(pno->p_base->pb_ino, X_OK); + if (err) + return err; + /* * Release old if set. */ Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- file.c 28 Jul 2004 14:56:52 -0000 1.16 +++ file.c 21 Sep 2004 16:18:30 -0000 1.17 @@ -45,6 +45,7 @@ #include <assert.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: file_hack.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file_hack.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- file_hack.c 28 Jul 2004 06:39:21 -0000 1.5 +++ file_hack.c 21 Sep 2004 16:18:30 -0000 1.6 @@ -46,6 +46,7 @@ #include <assert.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- fs.c 27 Jul 2004 15:00:43 -0000 1.13 +++ fs.c 21 Sep 2004 16:18:30 -0000 1.14 @@ -46,6 +46,7 @@ #include <errno.h> #include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- fsync.c 27 Jul 2004 15:00:43 -0000 1.7 +++ fsync.c 21 Sep 2004 16:18:30 -0000 1.8 @@ -44,6 +44,7 @@ #include <unistd.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- getdirentries.c 27 Jul 2004 15:00:43 -0000 1.17 +++ getdirentries.c 21 Sep 2004 16:18:30 -0000 1.18 @@ -101,7 +101,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren if (!(fil && fil->f_ino)) SYSIO_INTERFACE_RETURN(-1, -EBADF); - if (!S_ISDIR(fil->f_ino->i_mode)) + if (!S_ISDIR(fil->f_ino->i_stbuf.st_mode)) SYSIO_INTERFACE_RETURN(-1, -ENOTDIR); cc = Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- inode.c 27 Aug 2004 18:10:05 -0000 1.20 +++ inode.c 21 Sep 2004 16:18:31 -0000 1.21 @@ -218,8 +218,7 @@ hash(struct file_identifier *fid) struct inode * _sysio_i_new(struct filesys *fs, struct file_identifier *fid, - mode_t type, - dev_t rdev, + struct intnl_stat *stat, unsigned immunity, struct inode_ops *ops, void *private) @@ -240,14 +239,16 @@ _sysio_i_new(struct filesys *fs, return NULL; ino->i_ops = *ops; operations = *ops; - if (S_ISBLK(type) || S_ISCHR(type) || S_ISFIFO(type)) { + if (S_ISBLK(stat->st_mode) || + S_ISCHR(stat->st_mode) || + S_ISFIFO(stat->st_mode)) { struct inode_ops *o; /* * Replace some operations sent with * those from the device table. */ - o = _sysio_dev_lookup(type, rdev); + o = _sysio_dev_lookup(stat->st_mode, stat->st_rdev); operations.inop_open = o->inop_open; operations.inop_close = o->inop_close; operations.inop_read = o->inop_read; @@ -258,7 +259,7 @@ _sysio_i_new(struct filesys *fs, operations.inop_datasync = o->inop_datasync; operations.inop_ioctl = o->inop_ioctl; } - I_INIT(ino, fs, type, rdev, &operations, fid, immunity, private); + I_INIT(ino, fs, stat, &operations, fid, immunity, private); ino->i_ref = 1; TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- ioctl.c 27 Jul 2004 15:00:48 -0000 1.11 +++ ioctl.c 21 Sep 2004 16:18:31 -0000 1.12 @@ -44,6 +44,7 @@ #include <errno.h> #include <sys/ioctl.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- ioctx.c 27 Jul 2004 15:00:48 -0000 1.19 +++ ioctx.c 21 Sep 2004 16:18:31 -0000 1.20 @@ -47,6 +47,7 @@ #include <assert.h> #include <sys/uio.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "xtio.h" Index: iowait.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/iowait.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- iowait.c 27 Jul 2004 15:00:48 -0000 1.9 +++ iowait.c 21 Sep 2004 16:18:31 -0000 1.10 @@ -43,6 +43,7 @@ #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- link.c 27 Jul 2004 15:00:48 -0000 1.10 +++ link.c 21 Sep 2004 16:18:31 -0000 1.11 @@ -67,7 +67,7 @@ SYSIO_INTERFACE_NAME(link)(const char *o err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) goto out; - if (S_ISDIR(old->p_base->pb_ino->i_mode)) { + if (S_ISDIR(old->p_base->pb_ino->i_stbuf.st_mode)) { err = -EPERM; goto error1; } Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- mkdir.c 27 Jul 2004 15:00:48 -0000 1.13 +++ mkdir.c 21 Sep 2004 16:18:31 -0000 1.14 @@ -45,6 +45,7 @@ #include <errno.h> #include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- mount.c 27 Jul 2004 15:00:48 -0000 1.16 +++ mount.c 21 Sep 2004 16:18:31 -0000 1.17 @@ -155,7 +155,7 @@ _sysio_do_mount(struct filesys *fs, if (err) goto error; - if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_mode)) { + if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_stbuf.st_mode)) { err = -ENOTDIR; goto error; } Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- namei.c 27 Jul 2004 15:00:48 -0000 1.14 +++ namei.c 21 Sep 2004 16:18:31 -0000 1.15 @@ -49,6 +49,7 @@ #include <string.h> #include <errno.h> #include <assert.h> +#include <unistd.h> #include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> @@ -89,12 +90,16 @@ lookup(struct pnode *parent, struct intent *intnt, const char *path) { - struct pnode *pno; int err; + struct pnode *pno; if (!parent->p_base->pb_ino) return -ENOTDIR; + err = _sysio_permitted(parent->p_base->pb_ino, X_OK); + if (err) + return err; + /* * Short-circuit `.' and `..'; We don't cache those. */ @@ -200,7 +205,7 @@ _sysio_path_walk(struct pnode *parent, s */ for (;;) { ino = nd->nd_pno->p_base->pb_ino; - if (S_ISLNK(ino->i_mode) && + if (S_ISLNK(ino->i_stbuf.st_mode) && (next.len || !(nd->nd_flags & ND_NOFOLLOW))) { char *lpath; ssize_t cc; @@ -249,10 +254,10 @@ _sysio_path_walk(struct pnode *parent, s } #ifdef AUTOMOUNT_FILE_NAME else if (ino && - S_ISDIR(ino->i_mode) && + S_ISDIR(ino->i_stbuf.st_mode) && (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && nd->nd_amcnt < MAX_MOUNT_DEPTH && - ino->i_mode & S_ISUID) { + ino->i_stbuf.st_mode & S_ISUID) { struct pnode *pno; /* @@ -336,7 +341,7 @@ _sysio_path_walk(struct pnode *parent, s /* * Parent must be a directory. */ - if (ino && !S_ISDIR(ino->i_mode)) { + if (ino && !S_ISDIR(ino->i_stbuf.st_mode)) { err = -ENOTDIR; break; } @@ -415,7 +420,8 @@ _sysio_path_walk(struct pnode *parent, s * Make sure the last processed component was a directory. The * trailing slashes are illegal behind anything else. */ - if (!(err || S_ISDIR(nd->nd_pno->p_base->pb_ino->i_mode))) + if (!(err || + S_ISDIR(nd->nd_pno->p_base->pb_ino->i_stbuf.st_mode))) err = -ENOTDIR; } Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- rmdir.c 27 Jul 2004 15:00:48 -0000 1.15 +++ rmdir.c 21 Sep 2004 16:18:31 -0000 1.16 @@ -45,6 +45,7 @@ #include <errno.h> #include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- symlink.c 27 Jul 2004 15:00:48 -0000 1.11 +++ symlink.c 21 Sep 2004 16:18:31 -0000 1.12 @@ -45,6 +45,7 @@ #include <errno.h> #include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- truncate.c 27 Jul 2004 15:00:48 -0000 1.12 +++ truncate.c 21 Sep 2004 16:18:31 -0000 1.13 @@ -71,9 +71,9 @@ do_truncate(struct pnode *pno, struct in ino = pno->p_base->pb_ino; if (!ino) return -EBADF; - if (S_ISDIR(ino->i_mode)) /* for others too? */ + if (S_ISDIR(ino->i_stbuf.st_mode)) /* for others too? */ return -EISDIR; - if (!S_ISREG(ino->i_mode)) + if (!S_ISREG(ino->i_stbuf.st_mode)) return -EINVAL; (void )memset(&stbuf, 0, sizeof(stbuf)); Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- unlink.c 27 Jul 2004 15:00:48 -0000 1.14 +++ unlink.c 21 Sep 2004 16:18:31 -0000 1.15 @@ -45,6 +45,7 @@ #include <errno.h> #include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:40
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/include Modified Files: inode.h Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- inode.h 27 Jul 2004 15:00:41 -0000 1.21 +++ inode.h 21 Sep 2004 16:18:30 -0000 1.22 @@ -135,9 +135,8 @@ struct inode { i_immune : 1, /* immune from GC */ i_zombie : 1; /* stale inode */ unsigned i_ref; /* soft ref counter */ - mode_t i_mode; /* mode (see stat.h) */ - dev_t i_rdev; /* dev (if device) */ struct inode_ops i_ops; /* operations */ + struct intnl_stat i_stbuf; /* attrs */ struct filesys *i_fs; /* file system ptr */ struct file_identifier *i_fid; /* file ident */ void *i_private; /* driver data */ @@ -147,14 +146,13 @@ struct inode { /* * Init an i-node record. */ -#define I_INIT(ino, fs, mode, rdev, ops, fid, immunity, private) \ +#define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ - (ino)->i_mode = (mode); \ - (ino)->i_rdev = (rdev); \ (ino)->i_ops = *(ops); \ + (ino)->i_stbuf = *(stat); \ (ino)->i_fs = (fs); \ (ino)->i_fid = (fid); \ (ino)->i_private = (private); \ @@ -423,8 +421,7 @@ extern void _sysio_i_shutdown(void); #endif extern struct inode *_sysio_i_new(struct filesys *fs, struct file_identifier *fid, - mode_t type, - dev_t rdev, + struct intnl_stat *stat, unsigned immunity, struct inode_ops *ops, void *private); @@ -466,6 +463,7 @@ extern int _sysio_path_walk(struct pnode #ifdef AUTOMOUNT_FILE_NAME extern void _sysio_next_component(const char *path, struct qstr *name); #endif +extern int _sysio_permitted(struct inode *ino, int amode); extern int _sysio_namei(struct pnode *pno, const char *path, unsigned flags, |
From: Lee W. <lw...@us...> - 2004-09-21 16:18:39
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25715/drivers/yod Modified Files: fs_yod.c Log Message: From Henry Pierce at Cray; A chdir() to a directory without `x' permission should not succeed but does. This required that inodes now carry the full attributes -- Not just the mode bits. That's a bug change. Driver writers; 1) _sysio_i_new is altered. It needs the full intnl_stat structure now. 2) Your lookup function should refresh the inode attributes. 3) We don't keep an inode dirty bit. Hopefully, you've been pushing changes at the time of the operation instead of waiting until the inode was flushed or somesuch. Maybe you keep an internal dirty bit? Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- fs_yod.c 30 Aug 2004 15:58:00 -0000 1.18 +++ fs_yod.c 21 Sep 2004 16:18:14 -0000 1.19 @@ -307,11 +307,7 @@ yod_i_new(struct filesys *fs, struct int ino = _sysio_i_new(fs, &nino->ni_fileid, -#ifndef AUTOMOUNT_FILE_NAME - buf->st_mode & S_IFMT, -#else buf->st_mode, /* all of the bits! */ -#endif 0, 0, &yod_i_ops, |
From: Lee W. <lw...@us...> - 2004-09-16 14:41:41
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13425/src Modified Files: chdir.c Log Message: Henry Pierce noticed that the Linux-ish support for getcwd with a zero buffer size was gone. This had been done to make it POSIX compatible. However, we went overboard. It only must be applied when the passed buffer is non-null. The feature returns with this deposit. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- chdir.c 26 Aug 2004 09:02:28 -0000 1.20 +++ chdir.c 16 Sep 2004 14:41:32 -0000 1.21 @@ -154,7 +154,7 @@ _sysio_p_path(struct pnode *pno, char ** cur = pno; - if (!size) + if (!size && buf && *buf) return -EINVAL; /* |
From: Lee W. <lw...@us...> - 2004-09-16 00:24:52
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19302 Modified Files: Tag: defer-cwd lseek.c Log Message: Added llseek and __llseek for Linux. This can't be supported in all cases. It'll fail if the caller attempts to manipulate the high 32 bits and we're not build with _LARGFILE_SOURCE or the high 33, silently, if not built that way and the caller didn't mean the high bit of the low offset ot be a sign bit. Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -u -w -b -B -p -r1.24 -r1.24.2.1 --- lseek.c 9 Aug 2004 15:30:06 -0000 1.24 +++ lseek.c 15 Sep 2004 14:56:48 -0000 1.24.2.1 @@ -163,7 +163,6 @@ sysio_sym_weak_alias(SYSIO_INTERFACE_NAM PREPEND(__, SYSIO_INTERFACE_NAME(lseek))) #endif -#if 0 #ifdef __linux__ #undef llseek int @@ -173,17 +172,34 @@ SYSIO_INTERFACE_NAME(llseek)(unsigned in loff_t *result __IS_UNUSED, unsigned int whence __IS_UNUSED) { + loff_t off; SYSIO_INTERFACE_DISPLAY_BLOCK; /* - * Something is very wrong if this was called. + * This is just plain goofy. */ SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOTSUP); +#if !_LARGEFILE64_SOURCE + if (offset_high) { + /* + * We are using 32-bit internals. This just isn't + * going to work. + */ + SYSIO_INTERFACE_RETURN(-1, -EOVERFLOW); + } +#else + off = offset_high; + off <<= 32; + off |= offset_low; +#endif + off = _sysio_lseek(fd, off, whence); + if (off < 0) + SYSIO_INTERFACE_RETURN((off_t )-1, (int )off); + *result = off; + SYSIO_INTERFACE_RETURN(0, 0); } #undef __llseek sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(llseek), PREPEND(__, SYSIO_INTERFACE_NAME(llseek))) #endif -#endif |
From: Lee W. <lw...@us...> - 2004-09-15 13:58:41
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7570/tests Modified Files: Tag: defer-cwd Makefile.am Log Message: Build a run-time library to be used with test programs. This will cause sysio to be referenced and initialized automatically without requiring an explicit call. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -w -b -B -p -r1.20 -r1.20.2.1 --- Makefile.am 30 Aug 2004 15:58:01 -0000 1.20 +++ Makefile.am 15 Sep 2004 13:58:31 -0000 1.20.2.1 @@ -115,5 +115,9 @@ drv_data.c: $(CONFIG_DEPENDENCIES) $(top test -z "drv_data.c" && rm -f drv_data.c; \ $(SHELL) $(top_srcdir)/tests/gendrvdata.sh $(DRIVERS) > drv_data.c +lib_LIBRARIES=libruntime.a + +libruntime_a_SOURCES=sysio-run-start.c startup.c drv_init_all.c drv_data.c + AM_CFLAGS = -L$(LIBBUILD_DIR) include $(top_srcdir)/Rules.make |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:53
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854/include Modified Files: Tag: defer-cwd sysio.h Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -w -b -B -p -r1.26 -r1.26.2.1 --- sysio.h 3 Jul 2004 05:47:13 -0000 1.26 +++ sysio.h 12 Sep 2004 04:41:44 -0000 1.26.2.1 @@ -145,13 +145,40 @@ struct intnl_stat; struct pnode; +#if 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); +#if DEFER_INIT_CWD +extern int _sysio_boot(const char *buf, const char *path); +#else extern int _sysio_boot(const char *buf); +#endif + +/* + * Option-value pair information. + */ +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); /* * SYSIO name label macros |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:53
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854/src Modified Files: Tag: defer-cwd chdir.c init.c mount.c namei.c utime.c Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -w -b -B -p -r1.20 -r1.20.2.1 --- chdir.c 26 Aug 2004 09:02:28 -0000 1.20 +++ chdir.c 12 Sep 2004 04:41:44 -0000 1.20.2.1 @@ -79,6 +79,10 @@ #include "file.h" #include "sysio-symbols.h" +#if DEFER_INIT_CWD +const char *_sysio_init_cwd = NULL; +#endif + struct pnode *_sysio_cwd = NULL; /* @@ -234,6 +238,19 @@ SYSIO_INTERFACE_NAME(getcwd)(char *buf, SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER; +#if DEFER_INIT_CWD + if (!_sysio_cwd) { + struct pnode *pno; + + /* + * Can no longer defer initialization of the current working + * directory. Force namei to make it happen now. + */ + if (_sysio_namei(NULL, ".", 0, NULL, &pno) != 0) + abort(); + P_RELE(pno); + } +#endif err = _sysio_p_path(_sysio_cwd, &buf, buf ? size : 0); SYSIO_INTERFACE_RETURN(err ? NULL : buf, err); } Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -w -b -B -p -r1.14 -r1.14.2.1 --- init.c 30 Aug 2004 19:06:34 -0000 1.14 +++ init.c 12 Sep 2004 04:41:44 -0000 1.14.2.1 @@ -68,16 +68,6 @@ #endif /* - * The namespace assembly buffer passes args with a `name'=`value' - * syntax. We use the following to record that in various - * routines below. - */ -struct named_argument { - const char *name; /* arg name */ - char *value; /* arg value */ -}; - -/* * White space characters. */ #define IGNORE_WHITE " \t\r\n" @@ -90,9 +80,6 @@ int _sysio_init() { int err; -#ifdef WITH_SOCKETS - int _sysio_sockets_init(void); -#endif err = _sysio_ioctx_init(); if (err) @@ -112,11 +99,6 @@ _sysio_init() if (err) goto error; #endif -#ifdef WITH_SOCKETS - err = _sysio_sockets_init(); - if (err) - goto error; -#endif goto out; error: @@ -160,8 +142,8 @@ _sysio_shutdown() * or NUL character is success. * */ -static const char * -get_token(const char *buf, +const char * +_sysio_get_token(const char *buf, int accepts, const char *delim, const char *ignore, @@ -210,15 +192,20 @@ get_token(const char *buf, * * NB: Alters the passed buffer. */ -static char * -get_args(char *buf, struct named_argument *vec) +char * +_sysio_get_args(char *buf, struct option_value_info *vec) { char *nxt; char *name, *value; - struct named_argument *v; + struct option_value_info *v; for (;;) { - nxt = (char *)get_token(buf, 1, "=,", IGNORE_WHITE, name = buf); + nxt = + (char *)_sysio_get_token(buf, + 1, + "=,", + IGNORE_WHITE, + name = buf); if (!nxt || (nxt != buf && *name == '\0' && buf + strlen(buf) == nxt)) { buf = NULL; @@ -226,15 +213,20 @@ get_args(char *buf, struct named_argumen } if (*name == '\0') break; - buf = (char *)get_token(nxt, 1, ",", IGNORE_WHITE, value = nxt); + buf = + (char *)_sysio_get_token(nxt, + 1, + ",", + IGNORE_WHITE, + value = nxt); if (*value == '\0') value = NULL; - for (v = vec; v->name; v++) - if (strcmp(v->name, name) == 0) + for (v = vec; v->ovi_name; v++) + if (strcmp(v->ovi_name, name) == 0) break; - if (!v->name) + if (!v->ovi_name) return NULL; - v->value = value; + v->ovi_value = value; } return buf; @@ -269,7 +261,7 @@ static int do_creat(char *args) { size_t len; - struct named_argument v[] = { + struct option_value_info v[] = { { "ft", NULL }, /* file type */ { "nm", NULL }, /* name */ { "pm", NULL }, /* permissions */ @@ -289,27 +281,27 @@ do_creat(char *args) int err; len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && - v[1].value && - v[2].value)) + if (_sysio_get_args(args, v) - args != (ssize_t )len || + !(v[0].ovi_value && + v[1].ovi_value && + v[2].ovi_value)) return -EINVAL; - perms = strtol(v[2].value, (char **)&cp, 0); + perms = strtol(v[2].ovi_value, (char **)&cp, 0); if (*cp || perms < 0 || (perms == LONG_MAX && errno == ERANGE) || ((unsigned)perms & ~07777)) return -EINVAL; - if (v[3].value) { - owner = strtol(v[3].value, (char **)&cp, 0); + if (v[3].ovi_value) { + owner = strtol(v[3].ovi_value, (char **)&cp, 0); if (*cp || ((owner == LONG_MIN || owner == LONG_MAX) && errno == ERANGE)) return -EINVAL; } else owner = getuid(); - if (v[4].value) { - group = strtol(v[4].value, (char **)&cp, 0); + if (v[4].ovi_value) { + group = strtol(v[4].ovi_value, (char **)&cp, 0); if (*cp || ((group == LONG_MIN || group == LONG_MAX) && errno == ERANGE)) @@ -321,9 +313,10 @@ do_creat(char *args) return -ENOENT; err = 0; mode = perms; - if (strcmp(v[0].value, "dir") == 0) { + if (strcmp(v[0].ovi_value, "dir") == 0) { INTENT_INIT(&intent, INT_CREAT, &mode, 0); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + err = + _sysio_namei(dir, v[1].ovi_value, ND_NEGOK, &intent, &pno); if (err) return err; if (pno->p_base->pb_ino) @@ -338,12 +331,13 @@ do_creat(char *args) err = (*ino->i_ops.inop_mkdir)(pno, mode); } P_RELE(pno); - } else if (strcmp(v[0].value, "chr") == 0) { - if (!(v[5].value && parse_mm(v[5].value, &dev) == 0)) + } else if (strcmp(v[0].ovi_value, "chr") == 0) { + if (!(v[5].ovi_value && parse_mm(v[5].ovi_value, &dev) == 0)) return -EINVAL; mode |= S_IFCHR; INTENT_INIT(&intent, INT_CREAT, &mode, 0); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + err = + _sysio_namei(dir, v[1].ovi_value, ND_NEGOK, &intent, &pno); if (err) return err; if (pno->p_base->pb_ino) @@ -358,18 +352,19 @@ do_creat(char *args) err = (*ino->i_ops.inop_mknod)(pno, mode, dev); } P_RELE(pno); - } else if (strcmp(v[0].value, "blk") == 0) { + } else if (strcmp(v[0].ovi_value, "blk") == 0) { /* * We don't support block special files yet. */ return -EINVAL; - } else if (strcmp(v[0].value, "file") == 0) { + } else if (strcmp(v[0].ovi_value, "file") == 0) { int i; struct inode *ino; i = O_CREAT|O_EXCL; INTENT_INIT(&intent, INT_CREAT, &mode, &i); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + err = + _sysio_namei(dir, v[1].ovi_value, ND_NEGOK, &intent, &pno); if (err) return err; err = _sysio_open(pno, O_CREAT|O_EXCL, mode); @@ -378,7 +373,7 @@ do_creat(char *args) return err; } ino = pno->p_base->pb_ino; - if (!err && v[6].value) { + if (!err && v[6].ovi_value) { struct iovec iovec; struct intnl_xtvec xtvec; struct ioctx io_context; @@ -386,8 +381,8 @@ do_creat(char *args) /* * Deposit optional file content. */ - iovec.iov_base = v[6].value; - iovec.iov_len = strlen(v[6].value); + iovec.iov_base = v[6].ovi_value; + iovec.iov_len = strlen(v[6].ovi_value); xtvec.xtv_off = 0; xtvec.xtv_len = iovec.iov_len; IOCTX_INIT(&io_context, @@ -430,7 +425,7 @@ static int do_mnt(char *args) { size_t len; - struct named_argument v[] = { + struct option_value_info v[] = { { "dev", NULL }, /* source (type:dev) */ { "dir", NULL }, /* target dir */ { "fl", NULL }, /* flags */ @@ -442,35 +437,46 @@ do_mnt(char *args) struct pnode *dir; len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value)) + if (_sysio_get_args(args, v) - args != (ssize_t )len || + !(v[0].ovi_value && v[1].ovi_value)) return -EINVAL; - ty = (char *)get_token(v[0].value, 1, ":", "", name = v[0].value); + ty = + (char *)_sysio_get_token(v[0].ovi_value, + 1, + ":", + "", + name = v[0].ovi_value); flags = 0; - if (v[2].value) { + if (v[2].ovi_value) { char *cp; /* * Optional flags. */ - flags = strtoul(v[2].value, &cp, 0); + flags = strtoul(v[2].ovi_value, &cp, 0); if (*cp || (flags == ULONG_MAX && errno == ERANGE)) return -EINVAL; } - if (strlen(v[1].value) == 1 && v[1].value[0] == PATH_SEPARATOR) { + if (strlen(v[1].ovi_value) == 1 && v[1].ovi_value[0] == PATH_SEPARATOR) { /* * Aha! It's root they want. Have to do that special. */ - return _sysio_mount_root(ty, name, flags, v[3].value); + return _sysio_mount_root(ty, name, flags, v[3].ovi_value); } if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) return -ENOENT; - return _sysio_mount(dir, ty, v[1].value, name, flags, v[3].value); + return _sysio_mount(dir, + ty, + v[1].ovi_value, + name, + flags, + v[3].ovi_value); } +#if 0 /* * Chdir * @@ -480,7 +486,7 @@ static int do_cd(char *args) { size_t len; - struct named_argument v[] = { + struct option_value_info v[] = { { "dir", NULL }, /* directory */ { NULL, NULL } }; @@ -488,12 +494,12 @@ do_cd(char *args) struct pnode *dir, *pno; len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || !v[0].value) + if (_sysio_get_args(args, v) - args != (ssize_t )len || !v[0].ovi_value) return -EINVAL; if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) return -ENOENT; - err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); + err = _sysio_namei(dir, v[0].ovi_value, 0, NULL, &pno); if (err) return err; err = _sysio_p_chdir(pno); @@ -501,6 +507,7 @@ do_cd(char *args) P_RELE(pno); return err; } +#endif /* * Does a chmod @@ -511,7 +518,7 @@ static int do_chmd(char *args) { size_t len; - struct named_argument v[] = { + struct option_value_info v[] = { { "src", NULL }, /* path */ { "pm", NULL }, /* perms */ { NULL, NULL } @@ -523,10 +530,10 @@ do_chmd(char *args) struct pnode *dir, *pno; len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value)) + if (_sysio_get_args(args, v) - args != (ssize_t )len || + !(v[0].ovi_value && v[1].ovi_value)) return -EINVAL; - perms = strtol(v[1].value, &cp, 0); + perms = strtol(v[1].ovi_value, &cp, 0); if (*cp || perms < 0 || (perms == LONG_MAX && errno == ERANGE) || @@ -537,7 +544,7 @@ do_chmd(char *args) if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) return -ENOENT; - err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); + err = _sysio_namei(dir, v[0].ovi_value, 0, NULL, &pno); if (err) return err; err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_MODE, &stbuf); @@ -550,7 +557,7 @@ static int do_open(char *args) { size_t len; - struct named_argument v[] = { + struct option_value_info v[] = { { "nm", NULL }, /* path */ { "fd", NULL }, /* fildes */ { "m", NULL }, /* mode */ @@ -578,14 +585,14 @@ do_open(char *args) #endif len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value && v[2].value)) + if (_sysio_get_args(args, v) - args != (ssize_t )len || + !(v[0].ovi_value && v[1].ovi_value && v[2].ovi_value)) return -EINVAL; - l = strtol(v[1].value, (char **)&cp, 0); + l = strtol(v[1].ovi_value, (char **)&cp, 0); if (*cp || l < 0 || _irecheck(l, errno)) return -EINVAL; fd = (int )l; - ul = strtoul(v[1].value, (char **)&cp, 0); + ul = strtoul(v[1].ovi_value, (char **)&cp, 0); if (*cp || (ul == ULONG_MAX && errno == ERANGE)) return -EINVAL; @@ -595,7 +602,7 @@ do_open(char *args) return -ENOENT; INTENT_INIT(&intent, INT_OPEN, &m, NULL); pno = NULL; - err = _sysio_namei(dir, v[0].value, 0, &intent, &pno); + err = _sysio_namei(dir, v[0].ovi_value, 0, &intent, &pno); if (err) return err; fil = NULL; @@ -635,14 +642,16 @@ do_command(char *buf) char *args, *cmd; len = strlen(buf); - args = (char *)get_token(buf, 1, ",", IGNORE_WHITE, cmd = buf); + args = (char *)_sysio_get_token(buf, 1, ",", IGNORE_WHITE, cmd = buf); if (args) { if (strcmp("creat", cmd) == 0) return do_creat(args); if (strcmp("mnt", cmd) == 0) return do_mnt(args); +#if 0 if (strcmp("cd", cmd) == 0) return do_cd(args); +#endif if (strcmp("chmd", cmd) == 0) return do_chmd(args); if (strcmp("open", cmd) == 0) @@ -656,15 +665,23 @@ do_command(char *buf) * commands */ int -_sysio_boot(const char *buf) +_sysio_boot(const char *buf +#if DEFER_INIT_CWD + , const char *path +#endif + ) { char c, *tok; + ssize_t len; int err; + if (!buf) + buf = ""; /* * Allocate token buffer. */ - tok = malloc(strlen(buf)); + len = strlen(buf); + tok = malloc(len ? len : 1); if (!tok) return -ENOMEM; err = 0; @@ -684,7 +701,12 @@ _sysio_boot(const char *buf) /* * Get the command. */ - buf = (char *)get_token(buf + 1, 0, "}", IGNORE_WHITE, tok); + buf = + (char *)_sysio_get_token(buf + 1, + 0, + "}", + IGNORE_WHITE, + tok); if (!buf) { err = -EINVAL; break; @@ -697,5 +719,10 @@ _sysio_boot(const char *buf) break; } free(tok); +#if DEFER_INIT_CWD + if (err) + return err; + _sysio_init_cwd = path; +#endif return err; } Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -w -b -B -p -r1.16 -r1.16.2.1 --- mount.c 27 Jul 2004 15:00:48 -0000 1.16 +++ mount.c 12 Sep 2004 04:41:44 -0000 1.16.2.1 @@ -258,6 +258,7 @@ _sysio_mount_root(const char *source, return err; _sysio_root = mnt->mnt_root; +#if !DEFER_INIT_CWD /* * It is very annoying to have to set the current working directory. * So... If it isn't set, make it the root now. @@ -266,6 +267,7 @@ _sysio_mount_root(const char *source, _sysio_cwd = _sysio_root; P_REF(_sysio_cwd); } +#endif return 0; } Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -w -b -B -p -r1.14 -r1.14.2.1 --- namei.c 27 Jul 2004 15:00:48 -0000 1.14 +++ namei.c 12 Sep 2004 04:41:44 -0000 1.14.2.1 @@ -177,6 +177,27 @@ _sysio_path_walk(struct pnode *parent, s parent = nd->nd_root; } +#if DEFER_INIT_CWD + if (!parent) { + const char *icwd; + + if (!_sysio_init_cwd) + abort(); + + /* + * Finally have to set the curretn working directory. We can + * not tolerate errors here or else risk leaving the process + * in a very unexpected location. We abort then unless all goes + * well. + */ + icwd = _sysio_init_cwd; + _sysio_init_cwd = NULL; + if (_sysio_namei(NULL, icwd, 0, NULL, &parent) != 0 || + _sysio_p_chdir(parent) != 0) + abort(); + } +#endif + /* * (Re)Validate the parent. */ Index: utime.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/utime.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- utime.c 27 Jul 2004 15:00:48 -0000 1.6 +++ utime.c 12 Sep 2004 04:41:44 -0000 1.6.2.1 @@ -41,6 +41,7 @@ * le...@sa... */ +#include <stdlib.h> #include <string.h> #include <errno.h> #include <time.h> @@ -50,11 +51,22 @@ #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> +#include <sys/time.h> #include "sysio.h" #include "inode.h" #include "file.h" +time_t +_sysio_local_time() +{ + struct timeval tv; + + if (gettimeofday(&tv, NULL) != 0) + abort(); + return tv.tv_sec; +} + int SYSIO_INTERFACE_NAME(utime)(const char *path, const struct utimbuf *buf) { @@ -69,7 +81,7 @@ SYSIO_INTERFACE_NAME(utime)(const char * if (err) goto out; if (!buf) { - _utbuffer.actime = _utbuffer.modtime = time(NULL); + _utbuffer.actime = _utbuffer.modtime = _SYSIO_LOCAL_TIME(); buf = &_utbuffer; } (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:53
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854/tests Modified Files: Tag: defer-cwd startup.c Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: startup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/startup.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- startup.c 9 Aug 2004 15:33:03 -0000 1.6 +++ startup.c 12 Sep 2004 04:41:44 -0000 1.6.2.1 @@ -13,6 +13,7 @@ int _test_sysio_startup() { int err; + const char *cwd; const char *s; err = _sysio_init(); @@ -22,23 +23,28 @@ _test_sysio_startup() if (err) return err; s = getenv("SYSIO_NAMESPACE"); - if (s) - err = _sysio_boot(s); - else if (!(s = getenv("SYSIO_MANUAL"))) { + if (!(s || (s = getenv("SYSIO_MANUAL")))) { /* * Assume a native mount at root. */ - err = _sysio_boot("{mnt,dev=\"native:/\",dir=/,fl=0}"); + s = "{mnt,dev=\"native:/\",dir=/,fl=0}"; } + cwd = getenv("SYSIO_CWD"); +#if DEFER_INIT_CWD + err = _sysio_boot(s, cwd ? cwd : "/"); +#else + err = _sysio_boot(s); +#endif if (err) return err; - s = getenv("SYSIO_CWD"); - if (s) { +#if !DEFER_INIT_CWD + if (!cwd) + s = "/"; err = chdir(s); if (err) return err; - } +#endif return 0; } |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:53
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854/drivers/native Modified Files: Tag: defer-cwd fs_native.c Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -w -b -B -p -r1.48 -r1.48.2.1 --- fs_native.c 10 Sep 2004 16:42:39 -0000 1.48 +++ fs_native.c 12 Sep 2004 04:41:44 -0000 1.48.2.1 @@ -187,6 +187,19 @@ do { #endif /* + * Native file system information we keep per FS. + */ +struct native_filesystem { + time_t nfs_atimo; /* attr timeout (sec) */ +}; + +/* + * Given fs, return driver private part. + */ +#define FS2NFS(fs) \ + ((struct native_filesystem *)(fs)->fs_private) + +/* * Native file identifiers format. */ struct native_inode_identifier { @@ -203,7 +216,8 @@ struct native_inode_identifier { */ struct native_inode { unsigned - ni_seekok : 1; /* can seek? */ + ni_seekok : 1, /* can seek? */ + ni_attrvalid : 1; /* cached attrs ok? */ struct native_inode_identifier ni_ident; /* unique identifier */ struct file_identifier ni_fileid; /* ditto */ int ni_fd; /* host fildes */ @@ -211,6 +225,7 @@ struct native_inode { unsigned ni_nopens; /* soft ref count */ _SYSIO_OFF_T ni_fpos; /* current pos */ struct intnl_stat ni_stat; /* cached attrs */ + time_t ni_attrtim; /* attrs time stamp */ }; /* @@ -329,52 +344,46 @@ static struct mount *native_internal_mou * stat -- by path. */ static int -native_stat(const char *path, struct native_inode *nino, struct intnl_stat *buf) +native_stat(const char *path, struct inode *ino, struct intnl_stat *buf) { + struct native_inode *nino; + time_t t; int err; struct __native_stat stbuf; - err = syscall(__SYS_STAT, path, &stbuf); - if (err) { - err = -errno; - goto out; - } - if (!nino) { - COPY_STAT(&stbuf, buf); - goto out; - } - COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; -} + nino = ino ? I2NI(ino) : NULL; + t = _SYSIO_LOCAL_TIME(); /* - * stat -- by fildes + * Use cached? */ -static int -native_fstat(int fd, struct native_inode *nino, struct intnl_stat *buf) -{ - int err; - struct __native_stat stbuf; - - err = syscall(__SYS_FSTAT, fd, &stbuf); - if (err) { - err = -errno; - goto out; + if (nino && + nino->ni_attrvalid && + nino->ni_attrtim <= t && + (t - nino->ni_attrtim) < FS2NFS(ino->i_fs)->nfs_atimo) { + (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); + return 0; } - if (!nino) { - COPY_STAT(&stbuf, buf); - goto out; + if (path) + err = syscall(__SYS_STAT, path, &stbuf); + else if (nino && nino->ni_fd >= 0) + err = syscall(__SYS_FSTAT, nino->ni_fd, &stbuf); + else + abort(); + if (err) { + if (nino) + nino->ni_attrvalid = 0; + return -errno; } + if (nino) { + nino->ni_attrvalid = 1; + nino->ni_attrtim = t; COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; + return 0; + } + COPY_STAT(&stbuf, buf); + return 0; } /* @@ -390,6 +399,8 @@ native_i_new(struct filesys *fs, struct if (!nino) return NULL; bzero(&nino->ni_ident, sizeof(nino->ni_ident)); + nino->ni_seekok = 0; + nino->ni_attrvalid = 1; nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; #ifdef HAVE_GENERATION @@ -402,6 +413,7 @@ native_i_new(struct filesys *fs, struct nino->ni_nopens = 0; nino->ni_fpos = 0; (void )memcpy(&nino->ni_stat, buf, sizeof(struct intnl_stat)); + nino->ni_attrtim = _SYSIO_LOCAL_TIME(); ino = _sysio_i_new(fs, &nino->ni_fileid, @@ -440,8 +452,12 @@ _sysio_native_init() * Create private, internal, view of the hosts name space. */ static int -create_internal_namespace() +create_internal_namespace(const void *data) { + char *opts; + ssize_t len; + char *cp; + struct native_filesystem *nfs; int err; struct mount *mnt; struct inode *rootino; @@ -449,6 +465,11 @@ create_internal_namespace() static struct qstr noname = { NULL, 0, 0 }; struct filesys *fs; struct intnl_stat stbuf; + unsigned long ul; + static struct option_value_info v[] = { + { "atimo", "30" }, + { NULL, NULL } + }; if (native_internal_mount) { /* @@ -458,14 +479,53 @@ create_internal_namespace() } /* + * Get mount options. + */ + opts = NULL; + if (data && (len = strlen((char *)data))) { + opts = malloc(len + 1); + if (!opts) + return -ENOMEM; + (void )strcpy(opts, data); + if (_sysio_get_args(opts, v) - opts != (ssize_t )len) + return -EINVAL; + } + ul = strtoul(v[0].ovi_value, &cp, 0); + if (*cp != '\0' || ul >= UINT_MAX) + return -EINVAL; + if (opts) { + free(opts); + opts = NULL; + } + + /* * We maintain an artificial, internal, name space in order to * have access to fully qualified path names in the various routines. * Initialize that name space now. */ + fs = NULL; mnt = NULL; rootino = NULL; rootpb = NULL; - fs = _sysio_fs_new(&native_inodesys_ops, 0, NULL); + /* + * This really should be per-mount. Hmm, but that's best done + * as proper sub-mounts in the core and not this driver. We reconcile + * now, here, by putting the mount options on the file system. That + * means they are global and only can be passed at the initial mount. + * + * Maybe do it right some day? + */ + nfs = malloc(sizeof(struct native_filesystem)); + if (!nfs) { + err = -ENOMEM; + goto error; + } + nfs->nfs_atimo = ul; + if ((unsigned long)nfs->nfs_atimo != ul) { + err = -EINVAL; + goto error; + } + fs = _sysio_fs_new(&native_inodesys_ops, 0, nfs); if (!fs) { err = -ENOMEM; goto error; @@ -506,6 +566,7 @@ error: if (mnt) { if (_sysio_do_unmount(mnt) != 0) abort(); + nfs = NULL; fs = NULL; rootpb = NULL; rootino = NULL; @@ -515,7 +576,12 @@ error: if (fs) { FS_RELE(fs); _sysio_fs_gone(fs); + nfs = NULL; } + if (nfs) + free(nfs); + if (opts) + free(opts); return err; } @@ -523,7 +589,7 @@ error: static int native_fsswop_mount(const char *source, unsigned flags, - const void *data __IS_UNUSED, + const void *data, struct pnode *tocover, struct mount **mntp) { @@ -539,10 +605,11 @@ native_fsswop_mount(const char *source, return -ENOENT; if (!native_internal_mount) { - err = create_internal_namespace(); + err = create_internal_namespace(data); if (err) return err; - } + } else if (data && *(char *)data) + return -EINVAL; /* * Lookup the source in the internally maintained name space. @@ -617,7 +684,7 @@ native_iget(struct filesys *fs, /* * Get file status. */ - err = native_stat(path, *inop ? I2NI(*inop) : NULL, &stbuf); + err = native_stat(path, *inop, &stbuf); if (err) { *inop = NULL; return err; @@ -745,10 +812,10 @@ native_inop_getattr(struct pnode *pno, path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; - err = native_stat(path, nino, stbuf); + err = native_stat(path, ino, stbuf); free(path); } else if (nino->ni_fd >= 0) - err = native_fstat(nino->ni_fd, nino, stbuf); + err = native_stat(NULL, ino, stbuf); else { /* * Dev inodes don't open in this driver. We won't have @@ -795,10 +862,7 @@ native_inop_setattr(struct pnode *pno, /* * Get current status for undo. */ - err = - fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp); + err = native_stat(path, ino, stbp); if (err) goto out; @@ -913,9 +977,7 @@ out: /* * We must refresh the cached attributes on success. */ - if (!err && (fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp)) != 0) + if (!err && native_stat(path, ino, stbp) != 0) abort(); if (path) free(path); @@ -1804,6 +1866,7 @@ static void native_fsop_gone(struct filesys *fs __IS_UNUSED) { + free(fs->fs_private); /* * Do nothing. There is no private part maintained for the * native file interface. |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:52
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854 Modified Files: Tag: defer-cwd Rules.make configure.in Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: Rules.make =================================================================== RCS file: /cvsroot/libsysio/libsysio/Rules.make,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -w -b -B -p -r1.8 -r1.8.2.1 --- Rules.make 6 Jul 2004 14:01:03 -0000 1.8 +++ Rules.make 12 Sep 2004 04:41:44 -0000 1.8.2.1 @@ -16,4 +16,4 @@ DEV_CPPFLAGS = $(STDFD_DEV_CPPFLAGS) AM_CPPFLAGS = \ -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=600 \ $(AUTOMOUNT) $(ZERO_SUM_MEMORY) $(DEV_CPPFLAGS) $(SOCKETS_CPPFLAGS) \ - -I$(top_srcdir)/include + $(DEFER_INIT_CWD) -I$(top_srcdir)/include Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -w -b -B -p -r1.17 -r1.17.2.1 --- configure.in 20 May 2004 19:31:48 -0000 1.17 +++ configure.in 12 Sep 2004 04:41:44 -0000 1.17.2.1 @@ -101,6 +101,17 @@ AC_ARG_WITH(zero-sum-memory, [with_zero_sum_memory=no]) AC_SUBST(ZERO_SUM_MEMORY) +AC_ARG_WITH(defer-init-cwd, + AC_HELP_STRING([--with-defer-init-cwd], + [defer initialization of current working directory]), + [ case "${withval}" in + yes) DEFER_INIT_CWD=-DDEFER_INIT_CWD=1 ;; + no) ;; + *) AC_MSG_ERROR(bad value ${withval} for --with-defer-init-cwd) ;; + esac], + [with_defer_init_cwd=no]) +AC_SUBST(DEFER_INIT_CWD) + AC_ARG_WITH(cplant_yod, AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]), [ case "${withval}" in |
From: Lee W. <lw...@us...> - 2004-09-12 04:41:52
|
Update of /cvsroot/libsysio/libsysio/drivers/sockets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7854/drivers/sockets Modified Files: Tag: defer-cwd sockets.c Log Message: The sockets driver init routine was being called twice. Fixed. Added an attribute cache to the native driver. By default, attributes remain valid for 30 seconds. If a mount-time option specifies "atimeo=#" then that is used instead. Note, this *only* works on the first mount and applies globally. If given for a sub-mount, the option is ignored. Removed the "cd" command from the boot initialization code. All paths mentioned must be fully qualified. This to pave the way for the deferred initial working directory effort. Added deferred initial working directory. Must be enabled by specifying the --with-defer-init-cwd. Changes _sysio_boot to take 2 parameters. The new, 2nd, parameter is the desired initial working directory. What it does is defer the actual chdir to that initial working directory until namei is asked to resolve a relative pathname or the application calls chdir itself, explicitly. Upon being asked, the first time, to resolve a relative pathname (sans a previous explicit chdir) namei will execute the deferred chdir en-passant. Note that since there is no way to pre-examine the deferred initial working directory path and no way to pass an error back should the en-passant chdir fail, namei will abort the core on error. Get it right! Always! Index: sockets.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/sockets/sockets.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -w -b -B -p -r1.10 -r1.10.2.1 --- sockets.c 5 Aug 2004 18:29:57 -0000 1.10 +++ sockets.c 12 Sep 2004 04:41:44 -0000 1.10.2.1 @@ -116,7 +116,7 @@ struct filesys_ops sockets_filesys_ops = (void (*)(struct filesys *))sockets_illop }; -static struct filesys *sockets_fs; +static struct filesys *sockets_fs = NULL; static struct inode_ops sockets_i_ops; @@ -127,6 +127,8 @@ int _sysio_sockets_init() { + assert(!sockets_fs); + sockets_i_ops = _sysio_nodev_ops; sockets_i_ops.inop_close = sockets_inop_close; sockets_i_ops.inop_read = sockets_inop_read; |