Thread: [Libsysio-commit] RedStorm: libsysio/drivers/native fs_native.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2003-05-12 11:48:48
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv27060/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Modifications for the Cray RedStorm compute node operating system. This is a BSD-based libc. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -u -w -b -B -p -r1.11 -r1.11.4.1 --- fs_native.c 23 Apr 2003 18:18:38 -0000 1.11 +++ fs_native.c 12 May 2003 11:48:45 -0000 1.11.4.1 @@ -57,8 +57,12 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> +#if 0 #include <sys/vfs.h> +#endif +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <utime.h> #include <sys/queue.h> @@ -133,12 +137,6 @@ do { #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 @@ -182,7 +180,7 @@ static int native_inop_setattr(struct pn static ssize_t native_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); static int native_inop_mkdir(struct pnode *pno, mode_t mode); static int native_inop_rmdir(struct pnode *pno); static int native_inop_symlink(struct pnode *pno, const char *data); @@ -204,9 +202,11 @@ static int native_inop_ioctl(struct inod unsigned long int request, va_list ap); static int native_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void native_inop_gone(struct inode *ino); static struct inode_ops native_i_ops = { @@ -229,7 +229,9 @@ static struct inode_ops native_i_ops = { native_inop_datasync, native_inop_ioctl, native_inop_mknod, +#ifdef _HAVE_STATVFS native_inop_statvfs, +#endif native_inop_gone }; @@ -774,28 +776,75 @@ out: return err; } +static int +native_pos(int fd, +#ifdef _LARGEFILE64_SOURCE + loff_t *offset +#else + _SYSIO_OFF_T *offset +#endif + ) +{ + + assert(fd >= 0); + assert(*offset >= 0); + +#ifdef _LARGEFILE64_SOURCE + { + int err; + err = + syscall(SYS_llseek, + (unsigned int)nino->ni_fd, + (unsigned int)*offset >> 32, + (unsigned int)*offset, + offset, + SEEK_SET); + if (err == -1) + return -errno; + } +#else + *offset = + syscall(SYS_lseek, + fd, + *offset, + SEEK_SET); + if (*offset == -1) + return -errno; +#endif + + return 0; +} + + static ssize_t native_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep) + _SYSIO_OFF_T *basep) { struct native_inode *nino = I2NI(ino); + int err; +#ifdef _LARGEFILE64_SOURCE loff_t result; +#else + _SYSIO_OFF_T result; +#endif ssize_t cc; assert(nino->ni_fd >= 0); result = *basep; - if (*basep != nino->ni_fpos && - syscall(SYS_lseek, - nino->ni_fd, - *basep, - &result, - SEEK_SET) == -1) - return -errno; + if (*basep != nino->ni_fpos) { + err = native_pos(nino->ni_fd, &result); + if (err) + return err; + } nino->ni_fpos = result; +#ifndef USE_NATURAL_GETDENTS cc = syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); +#else + cc = syscall(SYS_getdents, nino->ni_fd, buf, nbytes); +#endif if (cc < 0) return -errno; nino->ni_fpos += cc; @@ -1002,13 +1051,14 @@ doio(ssize_t (*f)(int, const struct iove { struct native_inode *nino = I2NI(ino); struct ioctx *ioctx; +#ifdef _LARGEFILE64_SOURCE loff_t result; +#else + _SYSIO_OFF_T result; +#endif assert(nino->ni_fd >= 0); - if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) - return -EINVAL; - /* * Get a new IO context. */ @@ -1016,9 +1066,15 @@ doio(ssize_t (*f)(int, const struct iove if (!ioctx) return -ENOMEM; + if ((ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) || + !(S_ISCHR(ino->i_mode) || + S_ISSOCK(ino->i_mode) || + S_ISFIFO(ino->i_mode))) + return -EINVAL; + /* * This implementation first positions the real system descriptor, then - * performs the operation. This is silly because it's not atomic. + * performs the operation. This is not atomic. * * An alternative, more complex, less efficient but atomic, * implementation might consider each entry of the iovec separately. @@ -1029,18 +1085,17 @@ doio(ssize_t (*f)(int, const struct iove * Allows us to access pipes and fifos. */ result = nino->ni_fpos; - if (ioctx->ioctx_offset != nino->ni_fpos && - !(S_ISCHR(ino->i_mode) || - S_ISSOCK(ino->i_mode) || - S_ISFIFO(ino->i_mode)) && - syscall(SYS_lseek, - nino->ni_fd, - ioctx->ioctx_offset, - &result, - SEEK_SET) == -1) { + if (ioctx->ioctx_offset != nino->ni_fpos) { + int err; + + err = native_pos(nino->ni_fd, &result); + if (err) { ioctx->ioctx_cc = -1; - ioctx->ioctx_errno = errno; - } else { + ioctx->ioctx_errno = -err; + goto out; + } + } + /* * Call the appropriate (read/write) IO function to * transfer the data now. @@ -1052,9 +1107,9 @@ doio(ssize_t (*f)(int, const struct iove ioctx->ioctx_errno = errno; if (ioctx->ioctx_cc > 0) nino->ni_fpos += ioctx->ioctx_cc; - } *ioctxp = ioctx; +out: return 0; } @@ -1128,6 +1183,7 @@ native_inop_mknod(struct pnode *pno __IS return -ENOSYS; } +#ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1173,6 +1229,7 @@ native_inop_statvfs(struct pnode *pno, buf->f_namemax = fs.f_namelen; return 0; } +#endif static int native_inop_sync(struct inode *ino) @@ -1189,7 +1246,12 @@ native_inop_datasync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); - return syscall(__SYS_FDATASYNC, I2NI(ino)->ni_fd); +#ifdef NATIVE_FDATASYNC + return syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); +#else +#warning No fdatasync system call -- Using fsync instead! + return syscall(SYS_fsync, I2NI(ino)->ni_fd); +#endif } static int |
From: Lee W. <lw...@us...> - 2003-05-19 14:26:34
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv29970/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: It's SYS__llseek, not SYS_llseek. Fixed a cast. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.2 retrieving revision 1.11.4.3 diff -u -w -b -B -p -r1.11.4.2 -r1.11.4.3 --- fs_native.c 19 May 2003 13:51:20 -0000 1.11.4.2 +++ fs_native.c 19 May 2003 14:26:31 -0000 1.11.4.3 @@ -793,9 +793,9 @@ native_pos(int fd, { int err; err = - syscall(SYS_llseek, - (unsigned int)nino->ni_fd, - (unsigned int)*offset >> 32, + syscall(SYS__llseek, + (unsigned int)fd, + (unsigned int)(*offset >> 32), (unsigned int)*offset, offset, SEEK_SET); |
From: Lee W. <lw...@us...> - 2003-05-19 14:37:04
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv4131/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Finish redstorm port to the point of compilation. This is very hard to get setup to build. Definately see the README. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.1 retrieving revision 1.11.4.2 diff -u -w -b -B -p -r1.11.4.1 -r1.11.4.2 --- fs_native.c 12 May 2003 11:48:45 -0000 1.11.4.1 +++ fs_native.c 19 May 2003 13:51:20 -0000 1.11.4.2 @@ -1249,7 +1249,9 @@ native_inop_datasync(struct inode *ino) #ifdef NATIVE_FDATASYNC return syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); #else +#if 0 #warning No fdatasync system call -- Using fsync instead! +#endif return syscall(SYS_fsync, I2NI(ino)->ni_fd); #endif } |
From: Lee W. <lw...@us...> - 2003-05-27 12:36:04
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv32136/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: IO into a regular file is permissible. How *did* this happen? Geez! Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.3 retrieving revision 1.11.4.4 diff -u -w -b -B -p -r1.11.4.3 -r1.11.4.4 --- fs_native.c 19 May 2003 14:26:31 -0000 1.11.4.3 +++ fs_native.c 27 May 2003 12:35:55 -0000 1.11.4.4 @@ -1067,7 +1067,8 @@ doio(ssize_t (*f)(int, const struct iove return -ENOMEM; if ((ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) || - !(S_ISCHR(ino->i_mode) || + !(S_ISREG(ino->i_mode) || + S_ISCHR(ino->i_mode) || S_ISSOCK(ino->i_mode) || S_ISFIFO(ino->i_mode))) return -EINVAL; |
From: Lee W. <lw...@us...> - 2003-07-29 21:31:27
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv12924/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Pull in recent changes from the HEAD branch, to incorporate fixes there. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.4 retrieving revision 1.11.4.5 diff -u -w -b -B -p -r1.11.4.4 -r1.11.4.5 --- fs_native.c 27 May 2003 12:35:55 -0000 1.11.4.4 +++ fs_native.c 29 Jul 2003 19:05:08 -0000 1.11.4.5 @@ -149,6 +149,9 @@ do { struct native_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -312,8 +315,12 @@ native_i_new(struct filesys *fs, struct nino = malloc(sizeof(struct native_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -498,6 +505,27 @@ native_fsswop_mount(const char *source, return err; } +static int +native_i_validate(struct inode *inop, struct intnl_stat stbuf) +{ + /* + * 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 && +#ifdef HAVE_GENERATION + nino->ni_ident.gen == stbuf.st_gen && +#endif + ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && + ((!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || + (inop)->i_rdev == stbuf.st_rdev))) + return 0; + + return 1; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -527,11 +555,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct native_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!native_i_validate(*inop, stbuf)) return 0; /* * Invalidate. @@ -542,23 +566,40 @@ native_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (native_i_validate(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = native_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; @@ -1032,7 +1073,8 @@ 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. */ - err = syscall(SYS_unlink, path); + if (!syscall(SYS_unlink, path)) + err = -errno; free(path); return err; } |
From: Ruth K. <rk...@us...> - 2003-08-04 15:37:08
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv22767 Modified Files: Tag: RedStorm fs_native.c Log Message: seek to new value Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.5 retrieving revision 1.11.4.6 diff -u -w -b -B -p -r1.11.4.5 -r1.11.4.6 --- fs_native.c 29 Jul 2003 19:05:08 -0000 1.11.4.5 +++ fs_native.c 4 Aug 2003 15:37:05 -0000 1.11.4.6 @@ -1127,7 +1127,7 @@ doio(ssize_t (*f)(int, const struct iove * Avoid the reposition call if we're already at the right place. * Allows us to access pipes and fifos. */ - result = nino->ni_fpos; + result = ioctx->ioctx_offset; if (ioctx->ioctx_offset != nino->ni_fpos) { int err; |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:49
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv12723/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Merged with current head. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.6 retrieving revision 1.11.4.7 diff -u -w -b -B -p -r1.11.4.6 -r1.11.4.7 --- fs_native.c 4 Aug 2003 15:37:05 -0000 1.11.4.6 +++ fs_native.c 26 Sep 2003 21:28:34 -0000 1.11.4.7 @@ -120,9 +120,19 @@ do { (dest)->st_gen = (src)->st_gen; \ } while (0); +/* SYS_lseek has a different interface on alpha + */ +#define CALL_LSEEK(fd, off, rc, wh) \ + (rc = syscall(SYS_lseek, fd, off, wh)) + #else + #define __native_stat intnl_stat #define COPY_STAT(src, dest) *(dest) = *(src) + +#define CALL_LSEEK(fd, off, rc, wh) \ + (syscall(SYS_lseek, fd, off, &rc, wh)) + #endif #if defined(USE_NATIVE_STAT) @@ -137,6 +147,12 @@ do { #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 @@ -295,10 +311,12 @@ static int native_fstat(int fd, struct intnl_stat *buf) { int err; + struct __native_stat stbuf; - err = syscall(__SYS_FSTAT, fd, buf); + err = syscall(__SYS_FSTAT, fd, &stbuf); if (err) err = -errno; + COPY_STAT(&stbuf, buf); return err; } @@ -506,24 +524,24 @@ native_fsswop_mount(const char *source, } static int -native_i_validate(struct inode *inop, struct intnl_stat stbuf) +native_i_invalid(struct inode *inop, struct intnl_stat stbuf) { /* * 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 != stbuf.st_dev || + nino->ni_ident.ino != stbuf.st_ino || #ifdef HAVE_GENERATION - nino->ni_ident.gen == stbuf.st_gen && + nino->ni_ident.gen != stbuf.st_gen || #endif - ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && - ((!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || - (inop)->i_rdev == stbuf.st_rdev))) - return 0; - + ((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)))) return 1; + + return 0; } /* @@ -555,7 +573,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - if (!native_i_validate(*inop, stbuf)) + if (!native_i_invalid(*inop, stbuf)) return 0; /* * Invalidate. @@ -579,7 +597,7 @@ native_iget(struct filesys *fs, /* * Insertion was forced but it's already present! */ - if (native_i_validate(ino, stbuf)) { + if (native_i_invalid(ino, stbuf)) { /* * Cached inode has stale attrs * make way for the new one @@ -1055,7 +1073,7 @@ static int native_inop_unlink(struct pnode *pno) { char *path; - int err; + int err = 0; path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -1073,7 +1091,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)) + if (syscall(SYS_unlink, path) != 0) err = -errno; free(path); return err; @@ -1100,6 +1118,9 @@ doio(ssize_t (*f)(int, const struct iove #endif assert(nino->ni_fd >= 0); + + if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) + return -EINVAL; /* * Get a new IO context. |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv15049/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Updated with recent changes in HEAD branch. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.7 retrieving revision 1.11.4.8 diff -u -w -b -B -p -r1.11.4.7 -r1.11.4.8 --- fs_native.c 26 Sep 2003 21:28:34 -0000 1.11.4.7 +++ fs_native.c 27 Sep 2003 20:20:40 -0000 1.11.4.8 @@ -136,12 +136,12 @@ do { #endif #if defined(USE_NATIVE_STAT) -#define __SYS_STAT SYS_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_stat64 +#define __SYS_STAT SYS_lstat64 #define __SYS_FSTAT SYS_fstat64 #define __SYS_TRUNCATE SYS_truncate64 #define __SYS_FTRUNCATE SYS_ftruncate64 @@ -206,7 +206,9 @@ static int native_inop_symlink(struct pn static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); static int native_inop_open(struct pnode *pno, int flags, mode_t mode); static int native_inop_close(struct inode *ino); +static int native_inop_link(struct pnode *old, struct pnode *new); static int native_inop_unlink(struct pnode *pno); +static int native_inop_rename(struct pnode *old, struct pnode *new); static int native_inop_ipreadv(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -239,7 +241,9 @@ static struct inode_ops native_i_ops = { native_inop_readlink, native_inop_open, native_inop_close, + native_inop_link, native_inop_unlink, + native_inop_rename, native_inop_ipreadv, native_inop_ipwritev, native_inop_iodone, @@ -1070,6 +1074,32 @@ native_inop_close(struct inode *ino) } static int +native_inop_link(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + err = 0; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_link, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; +} + +static int native_inop_unlink(struct pnode *pno) { char *path; @@ -1185,6 +1215,30 @@ _readv(int fd, const struct iovec *vecto { return syscall(SYS_readv, fd, vector, count); +} + +static int +native_inop_rename(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_rename, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; } static int |
From: Lee W. <lw...@us...> - 2003-09-30 00:06:33
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv22549/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: -Fix prototype for getdirentries for Red Storm -Remove entry point for llseek in the core. That was goofy. Linux defines it as a syscall but there is no entry in libc. -Move __USE_LARGEFILE64 to _LARGEFILE64_SOURCE; We only want the xxx64() routines if asked explicitly. -Fix driver/native/fs_native.c _LARGEFILE64_SOURCE defines. The symbol is always defined. The test should be whether it is true/false not just defined. -Fix driver/native/fs_native.c to use SYS_lseek if SYS__llseek is not present. The 64-bit machines don't seem to use that interface. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.8 retrieving revision 1.11.4.9 diff -u -w -b -B -p -r1.11.4.8 -r1.11.4.9 --- fs_native.c 27 Sep 2003 20:20:40 -0000 1.11.4.8 +++ fs_native.c 29 Sep 2003 14:57:01 -0000 1.11.4.9 @@ -841,7 +841,7 @@ out: static int native_pos(int fd, -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t *offset #else _SYSIO_OFF_T *offset @@ -852,7 +852,7 @@ native_pos(int fd, assert(fd >= 0); assert(*offset >= 0); -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE && defined(SYS__llseek) { int err; err = @@ -887,7 +887,7 @@ native_getdirentries(struct inode *ino, { struct native_inode *nino = I2NI(ino); int err; -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; @@ -1141,7 +1141,7 @@ doio(ssize_t (*f)(int, const struct iove { struct native_inode *nino = I2NI(ino); struct ioctx *ioctx; -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; |
From: Lee W. <lw...@us...> - 2003-10-10 18:06:41
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv5485/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Integrate RedStorm_merge branch. This incorporates changes required for the Red Storm cnos. Some things didn't make it: a) The mount call change. We *really* want the original libsysio version. Special, libsysio only, flags are unavailable without it. Semantic differences are possible without it. b) The Red Storm specific startup and initial mounts source. These should be moved into the Cray-specific C library -- With startup.c? One thing enhanced; The native driver doio routine from RedStorm_merge err'd if an iovec was more than one entry long. This will break things in the future. Added code, in doio, to loop over iovecs, calling the low-level transfer function (pread) for each element. Notes: The typedef and defined failure value for ioid_t need to be placed in a more accessible place for the Cray. User-level source should *not* include sysio.h ever. The async IO call prototypes (those that begin with an `i') should be prototyped somewhere outside libsysio. Look at ASCI Red in order to promote backward compatibility? The mount prototype in the catamount `C' lib includes should be altered to reflect ours. Prototypes for _sysio_start() and _sysio_shutdown() should be available externally for startup.c. It, too, shouldn't include sysio.h. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.9 retrieving revision 1.11.4.10 diff -u -w -b -B -p -r1.11.4.9 -r1.11.4.10 --- fs_native.c 29 Sep 2003 14:57:01 -0000 1.11.4.9 +++ fs_native.c 10 Oct 2003 18:06:37 -0000 1.11.4.10 @@ -73,6 +73,21 @@ #include "fs_native.h" +#ifdef REDSTORM +#include <catamount/syscall.h> /* ! in sys include? */ +#endif + +#ifdef REDSTORM +/* + * The cnos IO routines on Red Storm can't do scatter/gather IO. We + * must use a different interface, then. The doio() routine will loop + * over the vector entries. + */ +typedef ssize_t (*iof)(int, void *, size_t, _SYSIO_OFF_T); +#else +typedef ssize_t (*iof)(int, const struct iovec *, int); +#endif + /* * Local host file system driver. */ @@ -120,19 +135,11 @@ do { (dest)->st_gen = (src)->st_gen; \ } while (0); -/* SYS_lseek has a different interface on alpha - */ -#define CALL_LSEEK(fd, off, rc, wh) \ - (rc = syscall(SYS_lseek, fd, off, wh)) - #else #define __native_stat intnl_stat #define COPY_STAT(src, dest) *(dest) = *(src) -#define CALL_LSEEK(fd, off, rc, wh) \ - (syscall(SYS_lseek, fd, off, &rc, wh)) - #endif #if defined(USE_NATIVE_STAT) @@ -887,15 +894,18 @@ native_getdirentries(struct inode *ino, { struct native_inode *nino = I2NI(ino); int err; +#ifndef SYS_getdirentries #if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; #endif +#endif ssize_t cc; assert(nino->ni_fd >= 0); +#ifndef SYS_getdirentries result = *basep; if (*basep != nino->ni_fpos) { err = native_pos(nino->ni_fd, &result); @@ -908,9 +918,20 @@ native_getdirentries(struct inode *ino, #else cc = syscall(SYS_getdents, nino->ni_fd, buf, nbytes); #endif +#else /* defined(SYS_getdirentries) */ + cc = + syscall(SYS_getdirentries, + nino->ni_fd, + buf, + nbytes, + basep, + &nino->ni_fpos); +#endif /* !defined(SYS_getdirentries) */ if (cc < 0) return -errno; +#ifndef SYS_getdirentries nino->ni_fpos += cc; +#endif return cc; } @@ -1134,18 +1155,20 @@ native_inop_unlink(struct pnode *pno) * now. */ static int -doio(ssize_t (*f)(int, const struct iovec *, int), +doio(iof f, struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp) { struct native_inode *nino = I2NI(ino); struct ioctx *ioctx; +#ifndef REDSTORM #if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; #endif +#endif assert(nino->ni_fd >= 0); @@ -1166,6 +1189,7 @@ doio(ssize_t (*f)(int, const struct iove S_ISFIFO(ino->i_mode))) return -EINVAL; +#ifndef REDSTORM /* * This implementation first positions the real system descriptor, then * performs the operation. This is not atomic. @@ -1188,15 +1212,43 @@ doio(ssize_t (*f)(int, const struct iove ioctx->ioctx_errno = -err; goto out; } + nino->ni_fpos = result; } +#endif /* * Call the appropriate (read/write) IO function to * transfer the data now. */ - nino->ni_fpos = result; +#ifdef REDSTORM + { + size_t count = ioctx->ioctx_iovlen; + struct iovec *iov = ioctx->ioctx_iovec; + ssize_t cc; + + while (count) { + cc = + (*f)(nino->ni_fd, + iov->base, + iov->len, + nino->ni_fpos); + if (cc < 0) { + if (ioctx->ioctx_cc) { + /* + * No data written at all. Return + * error. + */ + ioctx->ioctx_cc = -1; + } + break; + } + count--, iov++; + } + } +#else /* !defined(REDSTORM) */ ioctx->ioctx_cc = (*f)(nino->ni_fd, ioctx->ioctx_iovec, ioctx->ioctx_iovlen); +#endif /* defined(REDSTORM) */ if (ioctx->ioctx_cc < 0) ioctx->ioctx_errno = errno; if (ioctx->ioctx_cc > 0) @@ -1210,12 +1262,21 @@ out: /* * Helper function passed to doio(), above, to accomplish a real readv. */ +#ifdef REDSTORM static ssize_t -_readv(int fd, const struct iovec *vector, int count) +native_read(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) +{ + + return syscall(SYS_pread, fd, buf, count, offset); +} +#else +static ssize_t +native_read(int fd, const struct iovec *vector, int count) { return syscall(SYS_readv, fd, vector, count); } +#endif static int native_inop_rename(struct pnode *old, struct pnode *new) @@ -1247,18 +1308,27 @@ native_inop_ipreadv(struct inode *ino, struct ioctx **ioctxp) { - return doio(_readv, ino, ioargs, ioctxp); + return doio(native_read, ino, ioargs, ioctxp); } /* * Helper function passed to doio(), above, to accomplish a real writev. */ +#ifdef REDSTORM static ssize_t -_writev(int fd, const struct iovec *vector, int count) +native_write(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) +{ + + return syscall(SYS_pwrite, fd, buf, count, offset); +} +#else +static ssize_t +native_write(int fd, const struct iovec *vector, int count) { return syscall(SYS_writev, fd, vector, count); } +#endif static int native_inop_ipwritev(struct inode *ino, @@ -1266,7 +1336,7 @@ native_inop_ipwritev(struct inode *ino, struct ioctx **ioctxp) { - return doio(_writev, ino, ioargs, ioctxp); + return doio(native_write, ino, ioargs, ioctxp); } static int |