[Libsysio-commit] HEAD: libsysio/drivers/native fs_native.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/drivers/native Modified Files: fs_native.c Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -w -b -B -p -r1.66 -r1.67 --- fs_native.c 17 Jun 2008 17:18:57 -0000 1.66 +++ fs_native.c 11 Jul 2008 18:23:57 -0000 1.67 @@ -164,13 +164,11 @@ static int native_inop_lookup(struct pno struct intent *intnt, const char *path); static int native_inop_getattr(struct pnode *pno, - struct inode *ino, struct intnl_stat *stbuf); static int native_inop_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stbuf); -static ssize_t native_filldirentries(struct inode *ino, +static ssize_t native_filldirentries(struct pnode *pno, _SYSIO_OFF_T *posp, char *buf, size_t nbytes); @@ -179,25 +177,23 @@ static int native_inop_rmdir(struct pnod static int native_inop_symlink(struct pnode *pno, const char *data); 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_close(struct pnode *pno); 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_read(struct inode *ino, struct ioctx *ioctx); -static int native_inop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T native_inop_pos(struct inode *ino, _SYSIO_OFF_T off); +static int native_inop_read(struct ioctx *ioctx); +static int native_inop_write(struct ioctx *ioctx); +static _SYSIO_OFF_T native_inop_pos(struct pnode *pno, _SYSIO_OFF_T off); static int native_inop_iodone(struct ioctx *ioctx); -static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int native_inop_sync(struct inode *ino); -static int native_inop_datasync(struct inode *ino); -static int native_inop_ioctl(struct inode *ino, +static int native_inop_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn); +static int native_inop_sync(struct pnode *pno); +static int native_inop_datasync(struct pnode *pno); +static int native_inop_ioctl(struct pnode *pno, 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); +static int native_inop_statvfs(struct pnode *pno, struct intnl_statvfs *buf); #endif static void native_inop_gone(struct inode *ino); @@ -686,12 +682,13 @@ native_inop_lookup(struct pnode *pno, } static int -native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stat) +native_inop_getattr(struct pnode *pno, struct intnl_stat *stat) { - struct native_inode *nino; int err; + char *path; + struct inode *ino; + struct filesys *fs; + time_t t; /* * We just cannot use the cached attributes when getattr is @@ -702,35 +699,16 @@ native_inop_getattr(struct pnode *pno, * pretty volatile anyway. */ err = 0; /* compiler cookie */ - if (pno) { - char *path; - struct filesys *fs; - time_t t; path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; + ino = pno->p_base->pb_ino; + assert(ino); fs = pno->p_mount->mnt_fs; t = _SYSIO_LOCAL_TIME(); err = native_stat(path, ino, t + FS2NFS(fs)->nfs_atimo, stat); free(path); - } else if ((nino = I2NI(ino))->ni_fd >= 0) - /* - * Don't have access to the fs record anymore. Just - * refresh but keep the current timeout. - */ - err = native_stat(NULL, ino, nino->ni_attrtim, 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(stat, - &ino->i_stbuf, - sizeof(struct intnl_stat)); - err = 0; - } return err; } @@ -761,23 +739,22 @@ _ut(const char *path, time_t actime, tim static int native_inop_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stat) { char *path; + struct inode *ino; struct native_inode *nino; int fd; int err; path = NULL; + ino = pno->p_base->pb_ino; nino = ino ? I2NI(ino) : NULL; fd = -1; if (nino) fd = nino->ni_fd; if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; @@ -1004,12 +981,13 @@ native_ifilldirentries(struct native_ino } static ssize_t -native_filldirentries(struct inode *ino, +native_filldirentries(struct pnode *pno, _SYSIO_OFF_T *posp, char *buf, size_t nbytes) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; #ifdef DIR_CVT_64 char *bp; size_t count; @@ -1023,6 +1001,9 @@ native_filldirentries(struct inode *ino, #endif ssize_t cc; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); assert(nino->ni_fd >= 0); #ifdef DIR_CVT_64 @@ -1233,11 +1214,15 @@ native_inop_open(struct pnode *pno, int } static int -native_inop_close(struct inode *ino) +native_inop_close(struct pnode *pno) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); if (nino->ni_fd < 0) abort(); @@ -1489,6 +1474,7 @@ order_xtv(const struct intnl_xtvec *xtv1 static int doio(char op, struct ioctx *ioctx) { + struct inode *ino; struct native_inode *nino; #if 0 int dolocks; @@ -1501,7 +1487,9 @@ doio(char op, struct ioctx *ioctx) struct intnl_xtvec *front, *rear, tmp; #endif - nino = I2NI(ioctx->ioctx_ino); + ino = ioctx->ioctx_pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); #if 0 dolocks = ioctx->ioctx_xtvlen > 1 && nino->ni_seekok; if (dolocks) { @@ -1565,25 +1553,29 @@ doio(char op, struct ioctx *ioctx) } static int -native_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +native_inop_read(struct ioctx *ioctx) { return doio('r', ioctx); } static int -native_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +native_inop_write(struct ioctx *ioctx) { return doio('w', ioctx); } static _SYSIO_OFF_T -native_inop_pos(struct inode *ino, _SYSIO_OFF_T off) +native_inop_pos(struct pnode *pno, _SYSIO_OFF_T off) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); err = native_pos(nino->ni_fd, &off, SEEK_SET); return err < 0 ? err : off; } @@ -1599,15 +1591,19 @@ native_inop_iodone(struct ioctx *ioctxp } static int -native_inop_fcntl(struct inode *ino, +native_inop_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; long arg; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); if (nino->ni_fd < 0) abort(); @@ -1655,14 +1651,15 @@ native_inop_mknod(struct pnode *pno __IS #ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, - struct inode *ino, struct intnl_statvfs *buf) { char *path; + struct inode *ino; int rc; struct statfs fs; path = NULL; + ino = pno->p_base->pb_ino; if (!ino || I2NI(ino)->ni_fd < 0) { path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -1703,10 +1700,13 @@ native_inop_statvfs(struct pnode *pno, #endif static int -native_inop_sync(struct inode *ino) +native_inop_sync(struct pnode *pno) { + struct inode *ino; int err; + ino = pno->p_base->pb_ino; + assert(ino); assert(I2NI(ino)->ni_fd >= 0); err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); @@ -1716,11 +1716,14 @@ native_inop_sync(struct inode *ino) } static int -native_inop_datasync(struct inode *ino) +native_inop_datasync(struct pnode *pno) { + struct inode *ino; struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); nino = I2NI(ino); assert(nino->ni_fd >= 0); @@ -1739,14 +1742,17 @@ native_inop_datasync(struct inode *ino) #ifdef HAVE_LUSTRE_HACK static int -native_inop_ioctl(struct inode *ino, +native_inop_ioctl(struct pnode *pno, unsigned long int request, va_list ap) { + struct inode *ino; struct native_inode *nino; long arg1, arg2, arg3, arg4; int rtn; + ino = pno->p_base->pb_ino; + assert(ino); nino = I2NI(ino); assert(nino->ni_fd >= 0); arg1 = va_arg(ap, long); @@ -1763,7 +1769,7 @@ native_inop_ioctl(struct inode *ino, } #else static int -native_inop_ioctl(struct inode *ino __IS_UNUSED, +native_inop_ioctl(struct pnode *pno __IS_UNUSED, unsigned long int request __IS_UNUSED, va_list ap __IS_UNUSED) { |