Thread: [Libsysio-commit] gmdev: libsysio/drivers/yod fs_yod.c
Brought to you by:
lward
From: Ruth K. <rk...@us...> - 2004-03-04 18:29:30
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3889/drivers/yod Modified Files: Tag: gmdev fs_yod.c Log Message: The gmdev branch records what is currently sitting in the Cplant repository. Changes to fs_yod.c also make it compatible with the strided-io mods. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -w -b -B -p -r1.11 -r1.11.2.1 --- fs_yod.c 25 Feb 2004 16:23:59 -0000 1.11 +++ fs_yod.c 4 Mar 2004 18:08:06 -0000 1.11.2.1 @@ -140,12 +140,13 @@ struct yod_inode_identifier { * system objects. */ struct yod_inode { + unsigned ni_seekok : 1; /* can seek? */ struct yod_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 */ - off_t ni_fpos; /* current pos */ + _SYSIO_OFF_T ni_fpos; /* current pos */ }; static int yod_inop_lookup(struct pnode *pno, @@ -172,10 +173,8 @@ static int yod_inop_close(struct inode * static int yod_inop_link(struct pnode *old, struct pnode *new); static int yod_inop_unlink(struct pnode *pno); static int yod_inop_rename(struct pnode *old, struct pnode *new); -static int yod_inop_ipreadv(struct inode *ino, - struct ioctx *ioctx); -static int yod_inop_ipwritev(struct inode *ino, - struct ioctx *ioctx); +static int yod_inop_read(struct inode *ino, struct ioctx *ioctx); +static int yod_inop_write(struct inode *ino, struct ioctx *ioctx); static int yod_inop_iodone(struct ioctx *ioctx); static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap); static int yod_inop_sync(struct inode *ino); @@ -184,6 +183,12 @@ static int yod_inop_ioctl(struct inode * unsigned long int request, va_list ap); static int yod_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +static void *yod_inop_mmap(struct inode *ino, + void *start, + size_t length, + int prot, + int flags, + _SYSIO_OFF_T offset); #ifdef _HAVE_STATVFS static int yod_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -205,14 +210,15 @@ static struct inode_ops yod_i_ops = { yod_inop_link, yod_inop_unlink, yod_inop_rename, - yod_inop_ipreadv, - yod_inop_ipwritev, + yod_inop_read, + yod_inop_write, yod_inop_iodone, yod_inop_fcntl, yod_inop_sync, yod_inop_datasync, yod_inop_ioctl, yod_inop_mknod, + yod_inop_mmap, #ifdef _HAVE_STATVFS yod_inop_statvfs, #endif @@ -892,6 +898,13 @@ yod_inop_open(struct pnode *pno, int fla nino->ni_fpos = 0; nino->ni_fd = fd; + /* + * Need to know whether we can seek on this + * descriptor. + */ + nino->ni_seekok = + lseek_yod(nino->ni_fd, 0, SEEK_CUR) != 0 ? 0 : 1; + return 0; } @@ -978,75 +991,55 @@ yod_inop_unlink(struct pnode *pno) * now. */ static int -doio(ssize_t (*f)(int, const struct iovec *, int), - struct inode *ino, +doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct yod_inode *), struct ioctx *ioctx) { - struct yod_inode *nino = I2NI(ino); - loff_t result; - - assert(nino->ni_fd >= 0); - - if ((ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) || - !(S_ISREG(ino->i_mode) || - S_ISCHR(ino->i_mode) || - S_ISSOCK(ino->i_mode) || - S_ISFIFO(ino->i_mode))) - return -EINVAL; + struct yod_inode *nino = I2NI(ioctx->ioctx_ino); + if (ioctx->ioctx_xtvlen != 1) { /* - * This implementation first positions the real system descriptor, then - * performs the operation. This is silly because it's not atomic. - * - * An alternative, more complex, less efficient but atomic, - * implementation might consider each entry of the iovec separately. - * Then, the system implementations of the POSIX p{reaad,write} calls - * could be used. - * - * Avoid the reposition call if we're already at the right place. - * Allows us to access pipes and fifos. + * No scatter/gather supported in yod I/O */ - result = ioctx->ioctx_offset; - if (ioctx->ioctx_offset != nino->ni_fpos) { - result = lseek_yod(nino->ni_fd, - ioctx->ioctx_offset, - SEEK_SET); - if (result == -1) { - ioctx->ioctx_cc = -1; - ioctx->ioctx_errno = errno; - goto out; - } - nino->ni_fpos = result; + return -EINVAL; } - /* - * Call the appropriate (read/write) IO function to - * transfer the data now. - */ + ioctx->ioctx_cc = - (*f)(nino->ni_fd, ioctx->ioctx_iovec, ioctx->ioctx_iovlen); - if (ioctx->ioctx_cc < 0) - ioctx->ioctx_errno = errno; - if (ioctx->ioctx_cc > 0) + _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, + ioctx->ioctx_iov, ioctx->ioctx_iovlen, + (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, + nino); + if (ioctx->ioctx_cc < 0) { + ioctx->ioctx_errno = -ioctx->ioctx_cc; + ioctx->ioctx_cc = -1; + return -1; + } nino->ni_fpos += ioctx->ioctx_cc; -out: ioctx->ioctx_done = 1; return 0; } -/* - * Helper function passed to doio(), above, to accomplish a real readv. - */ static ssize_t -_readv(int fd, const struct iovec *vector, int count) +yod_read_simple(void *buf, + size_t nbytes, + _SYSIO_OFF_T off, + struct yod_inode *nino) { - int i; - ssize_t total = 0; + if (off != nino->ni_fpos) { + _SYSIO_OFF_T rtn; - for (i = 0; i < count; i++) - total += read_yod(fd, - vector[i].iov_base, - vector[i].iov_len); - return total; + rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); + if (rtn < 0) + return -1; + nino->ni_fpos = rtn; + } + return read_yod(nino->ni_fd, buf, nbytes); +} + +static int +yod_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +{ + + return doio(yod_read_simple, ioctx); } static int @@ -1073,36 +1066,29 @@ out: return err; } -static int -yod_inop_ipreadv(struct inode *ino, - struct ioctx *ioctx) -{ - - return doio(_readv, ino, ioctx); -} - -/* - * Helper function passed to doio(), above, to accomplish a real writev. - */ static ssize_t -_writev(int fd, const struct iovec *vector, int count) +yod_write_simple(void *buf, + size_t nbytes, + _SYSIO_OFF_T off, + struct yod_inode *nino) { - int i; - ssize_t total = 0; - for (i = 0; i < count; i++) - total += write_yod(fd, - vector[i].iov_base, - vector[i].iov_len); - return total; + if (off != nino->ni_fpos) { + _SYSIO_OFF_T rtn; + + rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); + if (rtn < 0) + return -1; + nino->ni_fpos = rtn; + } + return write_yod(nino->ni_fd, buf, nbytes); } static int -yod_inop_ipwritev(struct inode *ino, - struct ioctx *ioctx) +yod_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) { - return doio(_writev, ino, ioctx); + return doio(yod_write_simple, ioctx); } static int @@ -1237,3 +1223,14 @@ yod_fsop_gone(struct filesys *fs __IS_UN * yod file interface. */ } + +static void * +yod_inop_mmap(struct inode *ino __IS_UNUSED, + void *start __IS_UNUSED, + size_t length __IS_UNUSED, + int prot __IS_UNUSED, + int flags __IS_UNUSED, + _SYSIO_OFF_T offset __IS_UNUSED) +{ + return (void *)-ENOSYS; +} |
From: Ruth K. <rk...@us...> - 2004-04-22 19:31:38
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5112 Modified Files: Tag: gmdev fs_yod.c Log Message: merge from head Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.2 diff -u -w -b -B -p -r1.11.2.1 -r1.11.2.2 --- fs_yod.c 4 Mar 2004 18:08:06 -0000 1.11.2.1 +++ fs_yod.c 22 Apr 2004 19:31:29 -0000 1.11.2.2 @@ -996,17 +996,11 @@ doio(ssize_t (*f)(void *, size_t, _SYSIO { struct yod_inode *nino = I2NI(ioctx->ioctx_ino); - if (ioctx->ioctx_xtvlen != 1) { - /* - * No scatter/gather supported in yod I/O - */ - return -EINVAL; - } - ioctx->ioctx_cc = _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, + (ssize_t (*)(void *, size_t, + _SYSIO_OFF_T, void *))f, nino); if (ioctx->ioctx_cc < 0) { ioctx->ioctx_errno = -ioctx->ioctx_cc; |
From: Ruth K. <rk...@us...> - 2004-04-27 22:55:49
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29858/yod Modified Files: Tag: gmdev fs_yod.c Log Message: merge head changes into gmdev branch Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.11.2.2 retrieving revision 1.11.2.3 diff -u -w -b -B -p -r1.11.2.2 -r1.11.2.3 --- fs_yod.c 22 Apr 2004 19:31:29 -0000 1.11.2.2 +++ fs_yod.c 27 Apr 2004 22:55:40 -0000 1.11.2.3 @@ -173,6 +173,7 @@ static int yod_inop_close(struct inode * static int yod_inop_link(struct pnode *old, struct pnode *new); static int yod_inop_unlink(struct pnode *pno); static int yod_inop_rename(struct pnode *old, struct pnode *new); +static _SYSIO_OFF_T yod_inop_pos (struct inode *ino, _SYSIO_OFF_T off); static int yod_inop_read(struct inode *ino, struct ioctx *ioctx); static int yod_inop_write(struct inode *ino, struct ioctx *ioctx); static int yod_inop_iodone(struct ioctx *ioctx); @@ -212,6 +213,7 @@ static struct inode_ops yod_i_ops = { yod_inop_rename, yod_inop_read, yod_inop_write, + yod_inop_pos, yod_inop_iodone, yod_inop_fcntl, yod_inop_sync, @@ -1085,6 +1087,16 @@ yod_inop_write(struct inode *ino __IS_UN return doio(yod_write_simple, ioctx); } +static _SYSIO_OFF_T +yod_inop_pos(struct inode *ino, _SYSIO_OFF_T off) +{ + struct yod_inode *nino = I2NI(ino); + int err; + + err = lseek_yod(nino->ni_fd, off, SEEK_SET); + return err < 0 ? err : off; +} + static int yod_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) { |