[Libsysio-commit] HEAD: libsysio/drivers/yod Makefile.am fs_yod.c
Brought to you by:
lward
|
From: Ruth K. <rk...@us...> - 2003-10-20 17:13:19
|
Update of /cvsroot/libsysio/libsysio/drivers/yod
In directory sc8-pr-cvs1:/tmp/cvs-serv8041
Modified Files:
Makefile.am fs_yod.c
Log Message:
merge cplant changes
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -b -B -p -r1.2 -r1.3
--- Makefile.am 14 Aug 2003 18:39:33 -0000 1.2
+++ Makefile.am 20 Oct 2003 16:33:59 -0000 1.3
@@ -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.5
retrieving revision 1.6
diff -u -w -b -B -p -r1.5 -r1.6
--- fs_yod.c 17 Oct 2003 21:30:29 -0000 1.5
+++ fs_yod.c 20 Oct 2003 16:34:00 -0000 1.6
@@ -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,7 +171,9 @@ 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 ioctx *ioctx);
static int yod_inop_ipwritev(struct inode *ino,
@@ -180,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 = {
@@ -196,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,
@@ -205,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
};
@@ -282,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
@@ -531,6 +543,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
@@ -701,7 +714,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.
*/
@@ -724,15 +737,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);
}
@@ -920,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)
@@ -941,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;
}
@@ -1009,11 +1040,40 @@ 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)
{
- return read_yod(fd,
- vector[0].iov_base,
- vector[0].iov_len);
+ 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)
+{
+ 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
@@ -1082,6 +1142,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,
@@ -1127,6 +1188,7 @@ yod_inop_statvfs(struct pnode *pno,
buf->f_namemax = fs.f_namelen;
return 0;
}
+#endif
static int
yod_inop_sync(struct inode *ino)
@@ -1170,13 +1232,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);
-
}
|