[Libsysio-commit] cplant: libsysio/drivers/yod Makefile.am fs_yod.c
Brought to you by:
lward
|
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio/drivers/yod
In directory sc8-pr-cvs1:/tmp/cvs-serv28674/drivers/yod
Modified Files:
Tag: cplant
Makefile.am fs_yod.c
Log Message:
Merge HEAD changes into cplant branch
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -w -b -B -p -r1.2 -r1.2.4.1
--- Makefile.am 14 Aug 2003 18:39:33 -0000 1.2
+++ Makefile.am 14 Oct 2003 23:39:36 -0000 1.2.4.1
@@ -1,6 +1,6 @@
lib_LIBRARIES = libsysio_yod.a
-EXTRA_DIST = fs_yod.h
+EXTRA_DIST = ../../include/cplant-yod.h fs_yod.h
libsysio_yod_a_SOURCES = fs_yod.c
Index: fs_yod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.2
diff -u -w -b -B -p -r1.2.4.1 -r1.2.4.2
--- fs_yod.c 20 Aug 2003 21:05:49 -0000 1.2.4.1
+++ fs_yod.c 14 Oct 2003 23:39:36 -0000 1.2.4.2
@@ -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>
#include <sys/uio.h>
@@ -167,13 +171,13 @@ static int yod_inop_symlink(struct pnode
static int yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz);
static int yod_inop_open(struct pnode *pno, int flags, mode_t mode);
static int yod_inop_close(struct inode *ino);
+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 io_arguments *ioargs,
- struct ioctx **ioctxp);
+ struct ioctx *ioctx);
static int yod_inop_ipwritev(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp);
+ 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);
@@ -182,9 +186,11 @@ 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);
+#ifdef _HAVE_STATVFS
static int yod_inop_statvfs(struct pnode *pno,
struct inode *ino,
struct intnl_statvfs *buf);
+#endif
static void yod_inop_gone(struct inode *ino);
static struct inode_ops yod_i_ops = {
@@ -198,7 +204,9 @@ static struct inode_ops yod_i_ops = {
yod_inop_readlink,
yod_inop_open,
yod_inop_close,
+ yod_inop_link,
yod_inop_unlink,
+ yod_inop_rename,
yod_inop_ipreadv,
yod_inop_ipwritev,
yod_inop_iodone,
@@ -207,7 +215,9 @@ static struct inode_ops yod_i_ops = {
yod_inop_datasync,
yod_inop_ioctl,
yod_inop_mknod,
+#ifdef _HAVE_STATVFS
yod_inop_statvfs,
+#endif
yod_inop_gone
};
@@ -228,7 +238,7 @@ static struct filesys_ops yod_inodesys_o
};
/*
- * Placeholder internal mount as in native driver
+ * Placeholder internal mount as in yod driver
*/
static struct mount *yod_internal_mount = NULL;
@@ -284,6 +293,7 @@ yod_i_new(struct filesys *fs, struct int
nino = malloc(sizeof(struct yod_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
@@ -534,6 +544,7 @@ yod_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
@@ -704,7 +715,7 @@ yod_inop_setattr(struct pnode *pno,
}
if (err)
mask &= ~(SETATTR_UID|SETATTR_GID);
- if (mask & SETATTR_LEN) {
+ else if (mask & SETATTR_LEN) {
/*
* Do the truncate last. It can't be undone.
*/
@@ -727,15 +738,6 @@ yod_inop_setattr(struct pnode *pno,
? st.st_gid
: (gid_t )-1);
}
-#if 0
- if (mask & (SETATTR_MTIME|SETATTR_ATIME)) {
- struct utimbuf ut;
-
- ut.actime = st.st_atime;
- ut.modtime = st.st_mtime;
- (void )utime_yod(path, &ut);
- }
-#endif
if (mask & SETATTR_MODE) {
chmod_yod(path, st.st_mode & 0777);
}
@@ -923,10 +924,36 @@ yod_inop_close(struct inode *ino)
}
static int
+yod_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 = link_yod(opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
+}
+
+static int
yod_inop_unlink(struct pnode *pno)
{
char *path;
- int err;
+ int err = 0;
path = _sysio_pb_path(pno->p_base, '/');
if (!path)
@@ -944,7 +971,8 @@ yod_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 = unlink_yod(path);
+ if (unlink_yod(path) != 0)
+ err = -errno;
free(path);
return err;
}
@@ -958,30 +986,21 @@ yod_inop_unlink(struct pnode *pno)
static int
doio(ssize_t (*f)(int, const struct iovec *, int),
struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
struct yod_inode *nino = I2NI(ino);
- struct ioctx *ioctx;
loff_t result;
assert(nino->ni_fd >= 0);
- if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0)
+ if (ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0)
return -EINVAL;
/*
- * Get a new IO context.
- */
- ioctx = _sysio_ioctx_new(ino, ioargs);
- if (!ioctx)
- return -ENOMEM;
-
- /*
* 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,
+ * An alteryod, 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.
@@ -1013,7 +1032,6 @@ doio(ssize_t (*f)(int, const struct iove
nino->ni_fpos += ioctx->ioctx_cc;
}
- *ioctxp = ioctx;
return 0;
}
@@ -1021,20 +1039,48 @@ doio(ssize_t (*f)(int, const struct iove
* Helper function passed to doio(), above, to accomplish a real readv.
*/
static ssize_t
-_readv(int fd, const struct iovec *vector, int count __IS_UNUSED)
+_readv(int fd, const struct iovec *vector, int count)
+{
+ int i;
+ ssize_t total = 0;
+
+ for (i = 0; i < count; i++)
+ total += read_yod(fd,
+ vector[i].iov_base,
+ vector[i].iov_len);
+ return total;
+}
+
+static int
+yod_inop_rename(struct pnode *old, struct pnode *new)
{
- return read_yod(fd,
- vector[0].iov_base,
- vector[0].iov_len);
+ 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 = rename_yod(opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
}
static int
yod_inop_ipreadv(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
- return doio(_readv, ino, ioargs, ioctxp);
+ return doio(_readv, ino, ioctx);
}
/*
@@ -1055,11 +1101,10 @@ _writev(int fd, const struct iovec *vect
static int
yod_inop_ipwritev(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
- return doio(_writev, ino, ioargs, ioctxp);
+ return doio(_writev, ino, ioctx);
}
static int
@@ -1096,6 +1141,7 @@ yod_inop_mknod(struct pnode *pno __IS_UN
return -ENOSYS;
}
+#ifdef _HAVE_STATVFS
static int
yod_inop_statvfs(struct pnode *pno,
struct inode *ino,
@@ -1146,6 +1192,7 @@ yod_inop_statvfs(struct pnode *pno,
buf->f_namemax = fs.f_namelen;
return 0;
}
+#endif
static int
yod_inop_sync(struct inode *ino)
@@ -1189,13 +1236,11 @@ yod_inop_gone(struct inode *ino)
}
static void
-yod_fsop_gone(struct filesys *fs)
+yod_fsop_gone(struct filesys *fs __IS_UNUSED)
{
/*
- * Release fs private data
+ * Do nothing. There is no private part maintained for the
+ * yod file interface.
*/
-
- if (fs->fs_private) free(fs->fs_private);
-
}
|