#include <unistd.h>
#include <errno.h>
#include <assert.h>
-#include <syscall.h>
+#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#endif
#include <utime.h>
#include <sys/queue.h>
-#include <sys/uio.h>
+#include "xtio.h"
#include "sysio.h"
#include "fs.h"
#include "mount.h"
(dest)->st_blocks = (src)->st_blocks; \
(dest)->st_flags = (src)->st_flags; \
(dest)->st_gen = (src)->st_gen; \
-} while (0);
+} while (0)
#else
#define COPY_STAT(src, dest) \
do { \
(dest)->st_ctime = (src)->st_ctime; \
(dest)->st_blksize = (src)->st_blksize; \
(dest)->st_blocks = (src)->st_blocks; \
-} while (0);
+} while (0)
#endif
/*
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);
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_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn);
static int yod_inop_sync(struct inode *ino);
static int yod_inop_datasync(struct inode *ino);
static int yod_inop_ioctl(struct inode *ino,
yod_inop_lookup,
yod_inop_getattr,
yod_inop_setattr,
- yod_getdirentries,
+ yod_filldirentries,
yod_inop_mkdir,
yod_inop_rmdir,
yod_inop_symlink,
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
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);
_sysio_pb_gone(rootpb);
if (fs) {
FS_RELE(fs);
- _sysio_fs_gone(fs);
}
return err;
}
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;
* Validate?
*/
if (*inop) {
- if (!yod_i_invalid(*inop, stbuf))
+ if (!yod_i_invalid(*inop, &stbuf))
return 0;
/*
* Invalidate.
/*
* 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
}
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);
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;
}
}
static int
-yod_inop_fcntl(struct inode *ino __IS_UNUSED, int cmd, va_list ap __IS_UNUSED)
+yod_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
{
- switch (cmd)
- {
- case F_DUPFD: /* do something to the ino */
+ struct yod_inode *nino = I2NI(ino);
+ long arg;
+ int err;
+
+ if (nino->ni_fd < 0)
+ abort();
+
+ err = 0;
+ switch (cmd) {
+ case F_GETFD:
+ case F_GETFL:
+#ifdef F_GETOWN
+ case F_GETOWN:
+#endif
+ *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd);
+ if (*rtn == -1)
+ err = -errno;
+ break;
+ case F_DUPFD:
+ case F_SETFD:
+ case F_SETFL:
+ case F_GETLK:
+ case F_SETLK:
+ case F_SETLKW:
+#ifdef F_SETOWN
+ case F_SETOWN:
+#endif
+ arg = va_arg(ap, long);
+ *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd, arg);
+ if (*rtn == -1)
+ err = -errno;
break;
default:
- errno = EINVAL;
- return -1;
+ *rtn = -1;
+ err = -EINVAL;
}
- return 0;
-
+ return err;
}
static int