X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libsysio%2Fdrivers%2Fyod%2Ffs_yod.c;h=56a9f66905883fbe726a30e8c13033089b460c6c;hb=e59595df1694838b8f32527e0e6806b4730f78d1;hp=62eb9f23ff6e1a501a79c63d814ea1afee16c502;hpb=8692f4651696ff4324db3ad738d3fa62f68d7347;p=fs%2Flustre-release.git diff --git a/libsysio/drivers/yod/fs_yod.c b/libsysio/drivers/yod/fs_yod.c index 62eb9f2..56a9f66 100644 --- a/libsysio/drivers/yod/fs_yod.c +++ b/libsysio/drivers/yod/fs_yod.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -160,10 +160,10 @@ static int yod_inop_setattr(struct pnode *pno, struct inode *ino, unsigned mask, struct intnl_stat *stbuf); -static ssize_t yod_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - off64_t *basep); +static ssize_t yod_filldirentries(struct inode *ino, + off64_t *posp, + char *buf, + size_t nbytes); static int yod_inop_mkdir(struct pnode *pno, mode_t mode); static int yod_inop_rmdir(struct pnode *pno); static int yod_inop_symlink(struct pnode *pno, const char *data); @@ -195,7 +195,7 @@ static struct inode_ops yod_i_ops = { yod_inop_lookup, yod_inop_getattr, yod_inop_setattr, - yod_getdirentries, + yod_filldirentries, yod_inop_mkdir, yod_inop_rmdir, yod_inop_symlink, @@ -293,6 +293,7 @@ yod_i_new(struct filesys *fs, struct intnl_stat *buf) 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 @@ -307,12 +308,7 @@ yod_i_new(struct filesys *fs, struct intnl_stat *buf) 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, + buf, 0, &yod_i_ops, nino); @@ -416,7 +412,6 @@ error: _sysio_pb_gone(rootpb); if (fs) { FS_RELE(fs); - _sysio_fs_gone(fs); } return err; @@ -480,21 +475,22 @@ yod_fsswop_mount(const char *source, } static int -yod_i_invalid(struct inode *inop, struct intnl_stat stbuf) +yod_i_invalid(struct inode *inop, struct intnl_stat *stat) { /* * Validate passed in inode against stat struct info */ struct yod_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; @@ -529,7 +525,7 @@ yod_iget(struct filesys *fs, * Validate? */ if (*inop) { - if (!yod_i_invalid(*inop, stbuf)) + if (!yod_i_invalid(*inop, &stbuf)) return 0; /* * Invalidate. @@ -553,7 +549,7 @@ yod_iget(struct filesys *fs, /* * Insertion was forced but it's already present! */ - if (yod_i_invalid(ino, stbuf)) { + if (yod_i_invalid(ino, &stbuf)) { /* * Cached inode has stale attrs * make way for the new one @@ -744,13 +740,13 @@ out: } static ssize_t -yod_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - off64_t *basep) +yod_filldirentries(struct inode *ino, + char *buf, + _SYSIO_OFF_T *posp, + size_t nbytes) { struct yod_inode *nino = I2NI(ino); - loff_t result; + _SYSIO_OFF_T result; ssize_t cc; assert(nino->ni_fd >= 0); @@ -758,14 +754,19 @@ yod_getdirentries(struct inode *ino, result = *basep; if (*basep != nino->ni_fpos && (result = lseek_yod(nino->ni_fd, - *basep, + *posp, SEEK_SET) == -1)) return -errno; nino->ni_fpos = result; + memset(buf, 0, nbytes); + /* + * This is almost certainly broken. The resulting position parameter + * points to the block just filled, not the next. + */ cc = getdirentries_yod(nino->ni_fd, buf, nbytes, &result); if (cc < 0) return -errno; - nino->ni_fpos += cc; + nino->ni_fpos = *posp = result; return cc; }