[Libsysio-commit] cplant: libsysio/src Makefile.am chdir.c chmod.c chown.c dev.c file.c getdirentrie
Brought to you by:
lward
Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv28674/src
Modified Files:
Tag: cplant
Makefile.am chdir.c chmod.c chown.c dev.c file.c
getdirentries.c inode.c ioctx.c link.c lseek.c mknod.c mount.c
open.c read.c rmdir.c statvfs.c statvfs64.c truncate.c
unlink.c write.c
Log Message:
Merge HEAD changes into cplant branch
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -w -b -B -p -r1.7 -r1.7.2.1
--- Makefile.am 14 Aug 2003 18:39:33 -0000 1.7
+++ Makefile.am 14 Oct 2003 23:39:36 -0000 1.7.2.1
@@ -2,8 +2,9 @@ lib_LIBRARIES = libsysio.a
libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \
fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \
- lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \
- stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c
+ link.c lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rename.c \
+ rmdir.c stat.c stat64.c statvfs.c symlink.c truncate.c unlink.c \
+ utime.c write.c access.c
include $(top_srcdir)/Rules.make
Index: chdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -w -b -B -p -r1.4.2.2 -r1.4.2.3
--- chdir.c 6 Oct 2003 21:14:21 -0000 1.4.2.2
+++ chdir.c 14 Oct 2003 23:39:36 -0000 1.4.2.3
@@ -64,12 +64,13 @@
*/
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <assert.h>
-#include <sys/types.h>
#include <sys/queue.h>
#include "sysio.h"
@@ -81,6 +82,49 @@
struct pnode *_sysio_cwd = NULL;
+/*
+ * Change to directory specified by the given pnode.
+ */
+int
+_sysio_p_chdir(struct pnode *pno)
+{
+ int err;
+ struct intnl_stat stbuf;
+
+ /*
+ * Revalidate
+ */
+ err = _sysio_p_validate(pno, NULL, NULL);
+ if (err)
+ return err;
+ if (!pno->p_base->pb_ino)
+ return -ENOTDIR;
+ /*
+ * Stat the node and ensure it's a directory.
+ */
+ err =
+ pno->p_base->pb_ino->i_ops.inop_getattr(pno,
+ NULL,
+ &stbuf);
+ if (err)
+ return err;
+ if (!S_ISDIR(stbuf.st_mode))
+ return -ENOTDIR;
+
+ /*
+ * Release old if set.
+ */
+ if (_sysio_cwd)
+ P_RELE(_sysio_cwd);
+
+ /*
+ * Finally, change to the new.
+ */
+ _sysio_cwd = pno;
+
+ return 0;
+}
+
int
chdir(const char *path)
{
@@ -93,11 +137,7 @@ chdir(const char *path)
return -1;
}
- if (_sysio_cwd)
- P_RELE(_sysio_cwd);
-
- _sysio_cwd = pno;
- return 0;
+ return _sysio_p_chdir(pno);
}
/*
Index: chmod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- chmod.c 24 Mar 2003 22:09:06 -0000 1.3
+++ chmod.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -51,6 +51,21 @@
#include "sysio.h"
#include "inode.h"
+#include "file.h"
+
+static int
+do_chmod(struct pnode *pno, struct inode *ino, mode_t mode)
+{
+ int err;
+ struct intnl_stat stbuf;
+ unsigned mask;
+
+ (void )memset(&stbuf, 0, sizeof(struct intnl_stat));
+ stbuf.st_mode = mode & 0777;
+ mask = SETATTR_MODE;
+ err = _sysio_setattr(pno, ino, mask, &stbuf);
+ return err;
+}
int
chmod(const char *path, mode_t mode)
@@ -58,18 +73,35 @@ chmod(const char *path, mode_t mode)
struct intent intent;
int err;
struct pnode *pno;
- struct intnl_stat stbuf;
- unsigned mask;
INTENT_INIT(&intent, INT_SETATTR, NULL, NULL);
err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno);
if (err)
goto out;
- (void )memset(&stbuf, 0, sizeof(struct intnl_stat));
- stbuf.st_mode = mode & 0777;
- mask = SETATTR_MODE;
- err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf);
+ err = do_chmod(pno, pno->p_base->pb_ino, mode);
P_RELE(pno);
+out:
+ if (err) {
+ errno = -err;
+ err = -1;
+ }
+ return err;
+}
+
+int
+fchmod(int fd, mode_t mode)
+{
+ int err;
+ struct file *fil;
+
+ err = 0;
+ fil = _sysio_fd_find(fd);
+ if (!fil) {
+ err = -EBADF;
+ goto out;
+ }
+
+ err = do_chmod(NULL, fil->f_ino, mode);
out:
if (err) {
errno = -err;
Index: chown.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- chown.c 24 Mar 2003 22:09:06 -0000 1.3
+++ chown.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -51,18 +51,15 @@
#include "sysio.h"
#include "inode.h"
+#include "file.h"
-int
-chown(const char *path, uid_t owner, gid_t group)
+static int
+_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group)
{
int err;
- struct pnode *pno;
struct intnl_stat stbuf;
unsigned mask;
- err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno);
- if (err)
- goto out;
(void )memset(&stbuf, 0, sizeof(struct intnl_stat));
mask = 0;
if (owner != (uid_t )-1) {
@@ -73,11 +70,44 @@ chown(const char *path, uid_t owner, gid
stbuf.st_gid = group;
mask |= SETATTR_GID;
}
- if (!mask)
- goto done;
- err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf);
-done:
+ err = _sysio_setattr(pno, ino, mask, &stbuf);
+ return err;
+}
+
+int
+chown(const char *path, uid_t owner, gid_t group)
+{
+ int err;
+ struct pnode *pno;
+
+ err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno);
+ if (err)
+ goto out;
+
+ err = _do_chown(pno, pno->p_base->pb_ino, owner, group);
P_RELE(pno);
+out:
+ if (err) {
+ errno = -err;
+ err = -1;
+ }
+ return err;
+}
+
+int
+fchown(int fd, uid_t owner, gid_t group)
+{
+ int err;
+ struct file *fil;
+
+ err = 0;
+ fil = _sysio_fd_find(fd);
+ if (!fil) {
+ err = -EBADF;
+ goto out;
+ }
+
+ err = _do_chown(NULL, fil->f_ino, owner, group);
out:
if (err) {
errno = -err;
Index: dev.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v
retrieving revision 1.2
retrieving revision 1.2.10.1
diff -u -w -b -B -p -r1.2 -r1.2.10.1
--- dev.c 24 Mar 2003 22:09:06 -0000 1.2
+++ dev.c 14 Oct 2003 23:39:36 -0000 1.2.10.1
@@ -63,7 +63,9 @@ const struct inode_ops _sysio_nodev_ops
_sysio_nodev_inop_readlink,
_sysio_nodev_inop_open,
_sysio_nodev_inop_close,
+ _sysio_nodev_inop_link,
_sysio_nodev_inop_unlink,
+ _sysio_nodev_inop_rename,
_sysio_nodev_inop_ipreadv,
_sysio_nodev_inop_ipwritev,
_sysio_nodev_inop_iodone,
@@ -72,7 +74,9 @@ const struct inode_ops _sysio_nodev_ops
_sysio_nodev_inop_datasync,
_sysio_nodev_inop_ioctl,
_sysio_nodev_inop_mknod,
+#ifdef _HAVE_STATVFS
_sysio_nodev_inop_statvfs,
+#endif
_sysio_nodev_inop_gone
};
@@ -167,45 +171,10 @@ _sysio_dev_lookup(mode_t mode, dev_t dev
}
int
-_sysio_dev_e_notdir()
-{
-
- return -ENOTDIR;
-}
-
-int
-_sysio_dev_e_badf()
-{
-
- return -EBADF;
-}
-
-int
-_sysio_dev_e_inval()
-{
-
- return -EINVAL;
-}
-
-int
-_sysio_dev_e_nxio()
-{
-
- return -ENXIO;
-}
-
-int
-_sysio_dev_e_illop()
+_sysio_dev_illop()
{
abort();
-}
-
-int
-_sysio_dev_e_notty()
-{
-
- return -ENOTTY;
}
void
Index: file.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/file.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -w -b -B -p -r1.5 -r1.5.2.1
--- file.c 6 Aug 2003 19:12:46 -0000 1.5
+++ file.c 14 Oct 2003 23:39:36 -0000 1.5.2.1
@@ -97,14 +97,12 @@ _sysio_fgone(struct file *fil)
* IO operation completion handler.
*/
void
-_sysio_fcompletio(struct ioctx *ioctx)
+_sysio_fcompletio(struct ioctx *ioctx, struct file *fil)
{
- struct file *fil;
if (ioctx->ioctx_errno)
return;
- fil = (struct file *)ioctx->ioctx_data;
assert(ioctx->ioctx_ino == fil->f_ino);
fil->f_pos = ioctx->ioctx_offset + ioctx->ioctx_cc;
}
Index: getdirentries.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -w -b -B -p -r1.2 -r1.2.2.1
--- getdirentries.c 31 Jul 2003 22:21:35 -0000 1.2
+++ getdirentries.c 14 Oct 2003 23:39:36 -0000 1.2.2.1
@@ -1,7 +1,6 @@
-#ifdef __GNUC__
-#include <alloca.h>
-#else
#include <stdlib.h>
+#ifdef __GLIBC__
+#include <alloca.h>
#endif
#include <string.h>
#include <errno.h>
@@ -19,8 +18,11 @@
#define __restrict
#endif
-ssize_t
-getdirentries64(int fd, char *buf, size_t nbytes, off64_t * __restrict basep)
+static ssize_t
+_getdirentries64(int fd,
+ char *buf,
+ size_t nbytes,
+ _SYSIO_OFF_T * __restrict basep)
{
struct file *fil;
ssize_t cc;
@@ -44,6 +46,13 @@ getdirentries64(int fd, char *buf, size_
return cc;
}
+#if _LARGEFILE64_SOURCE
+#undef getdirentries64
+sysio_sym_strong_alias(_getdirentries64, getdirentries64)
+#endif
+
+#undef getdirentries
+
#ifndef DIRENT64_IS_NATURAL
#ifndef EOVERFLOW
@@ -56,33 +65,59 @@ getdirentries64(int fd, char *buf, size_
#define _namlen(dp) (strlen((dp)->d_name))
#endif
+#ifndef _rndup
+#define _rndup(n, boundary) \
+ ((((n) + (boundary) - 1 ) / (boundary)) * (boundary))
+#endif
+
+#if !(defined(BSD) || defined(REDSTORM))
ssize_t
-getdirentries(int fd, char *buf, size_t nbytes, off_t * __restrict basep)
+getdirentries(int fd,
+ char *buf,
+ size_t nbytes,
+ off_t * __restrict basep)
+#else
+int
+getdirentries(int fd,
+ char *buf,
+ int nbytes,
+ long * __restrict basep)
+#endif
{
size_t inbytes;
void *ibuf;
- off64_t ibase;
+ _SYSIO_OFF_T ibase;
ssize_t cc;
struct dirent *dp, *nxtdp;
- struct dirent64 *od64p = NULL, *d64p = NULL;
+#if defined(BSD) || defined(REDSTORM)
+ int off;
+#endif
+ struct intnl_dirent *od64p, *d64p;
size_t n;
size_t reclen;
char *cp;
#define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0])
-#ifdef __GNUC__
+#ifdef __GLIBC__
#define _dreclen(namlen) \
((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \
~(__alignof__ (struct dirent) - 1))
#define _fast_alloc(n) alloca(n)
#define _fast_free(p)
-#else /* !defined(__GNUC__) */
-#define _dreclen(namelen) \
- (_rndup(_dbaselen + (namlen) + 1, sizeof(unsigned long long))
+#else /* !defined(__GLIBC__) */
+#define _dreclen(namlen) \
+ _rndup(_dbaselen + (namlen) + 1, sizeof(int))
#define _fast_alloc(n) malloc(n)
#define _fast_free(p) free(p)
#endif
+#if defined(BSD) || defined(REDSTORM)
+ if (nbytes < 0) {
+ errno = -EINVAL;
+ return -1;
+ }
+#endif
+
inbytes = nbytes;
if (inbytes > 8 * 1024) {
/*
@@ -99,7 +134,7 @@ getdirentries(int fd, char *buf, size_t
dp = (struct dirent *)buf;
ibase = *basep;
- cc = getdirentries64(fd, ibuf, inbytes, &ibase);
+ cc = _getdirentries64(fd, ibuf, inbytes, &ibase);
if (cc < 0) {
cc = -errno;
goto out;
@@ -110,6 +145,9 @@ getdirentries(int fd, char *buf, size_t
goto out;
}
+#if defined(BSD) || defined(REDSTORM)
+ off = *basep;
+#endif
od64p = NULL;
d64p = ibuf;
for (;;) {
@@ -121,14 +159,22 @@ getdirentries(int fd, char *buf, size_t
n = strlen(d64p->d_name);
#endif
reclen = _dreclen(n);
- if (reclen >= nbytes)
+ if (reclen >= (unsigned )nbytes)
break;
dp->d_ino = (ino_t )d64p->d_ino;
+#if !(defined(BSD) || defined(REDSTORM))
dp->d_off = (off_t )d64p->d_off;
+#endif
if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) &&
- dp->d_ino != d64p->d_ino) &&
+ dp->d_ino != d64p->d_ino)
+ ||
+#if !(defined(BSD) || defined(REDSTORM))
(sizeof(dp->d_off) != sizeof(d64p->d_off) &&
- dp->d_off != d64p->d_off)) {
+ dp->d_off != d64p->d_off)
+#else
+ (off + (int )reclen < off)
+#endif
+ ) {
cc = -EOVERFLOW;
break;
}
@@ -142,6 +188,9 @@ getdirentries(int fd, char *buf, size_t
od64p = d64p;
d64p = (void *)d64p + d64p->d_reclen;
nbytes -= reclen;
+#if defined(BSD) || defined(REDSTORM)
+ off += reclen;
+#endif
dp = nxtdp;
}
@@ -154,10 +203,15 @@ out:
}
cc = (char *)dp - buf;
if (cc)
- *basep = od64p->d_off;
+ *basep =
+#if !(defined(BSD) || defined(REDSTORM))
+ od64p->d_off;
+#else
+ off;
+#endif
return cc;
-#ifdef __GNUC__
+#ifdef __GLIBC__
#undef _fast_alloc
#undef _fast_free
#endif
@@ -165,6 +219,5 @@ out:
#undef _dbaselen
}
#else /* !defined(DIRENT64_IS_NATURAL) */
-sysio_sym_strong_alias(getdirentries64, getdirentries)
+sysio_sym_strong_alias(_getdirentries64, getdirentries)
#endif
-
Index: inode.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -w -b -B -p -r1.8.2.1 -r1.8.2.2
--- inode.c 26 Aug 2003 17:21:39 -0000 1.8.2.1
+++ inode.c 14 Oct 2003 23:39:36 -0000 1.8.2.2
@@ -606,6 +606,30 @@ _sysio_p_find_alias(struct pnode *parent
}
/*
+ * Prune idle path base nodes freom the passed sub-tree, including the root.
+ */
+static void
+_sysio_prune(struct pnode_base *rpb)
+{
+ struct pnode_base *nxtpb, *pb;
+
+ nxtpb = rpb->pb_children.lh_first;
+ while ((pb = nxtpb)) {
+ nxtpb = pb->pb_sibs.le_next;
+ if (pb->pb_aliases.lh_first)
+ continue;
+ if (pb->pb_children.lh_first) {
+ _sysio_prune(pb);
+ continue;
+ }
+ _sysio_pb_gone(pb);
+ }
+ if (rpb->pb_children.lh_first)
+ return;
+ _sysio_pb_gone(rpb);
+}
+
+/*
* Prune idle nodes from the passed sub-tree, including the root.
*
* Returns the number of aliases on the same mount that could not be pruned.
@@ -623,6 +647,10 @@ _sysio_p_prune(struct pnode *root)
while ((pb = nxtpb)) {
nxtpb = pb->pb_sibs.le_next;
nxtpno = pb->pb_aliases.lh_first;
+ if (!nxtpno) {
+ _sysio_prune(pb);
+ continue;
+ }
while ((pno = nxtpno)) {
nxtpno = pno->p_links.le_next;
if (pno->p_mount != root->p_mount) {
@@ -664,10 +692,10 @@ _sysio_p_prune(struct pnode *root)
if (_sysio_do_unmount(pno->p_mount) != 0) {
P_RELE(pno);
count++;
- continue;
}
+ continue;
#endif
- } else
+ }
_sysio_p_gone(pno);
}
}
@@ -682,9 +710,9 @@ _sysio_p_prune(struct pnode *root)
/*
* All that is left is the root. Try for it too.
*/
- if (root->p_ref)
+ if (root->p_ref) {
count++;
- else if (root->p_mount->mnt_root == root) {
+ } else if (root->p_mount->mnt_root == root) {
#ifndef AUTOMOUNT_FILE_NAME
count++;
#else
Index: ioctx.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v
retrieving revision 1.2
retrieving revision 1.2.16.1
diff -u -w -b -B -p -r1.2 -r1.2.16.1
--- ioctx.c 7 Mar 2003 03:31:36 -0000 1.2
+++ ioctx.c 14 Oct 2003 23:39:36 -0000 1.2.16.1
@@ -78,40 +78,67 @@ _sysio_ioctx_init()
* Allocate and initialisze a new IO context.
*/
struct ioctx *
-_sysio_ioctx_new(struct inode *ino, struct io_arguments *ioargs)
+_sysio_ioctx_new(struct inode *ino,
+ const struct iovec *iov,
+ size_t iovlen,
+ _SYSIO_OFF_T offset)
{
struct ioctx *ioctx;
ioctx =
- malloc(sizeof(struct ioctx) +
- ioargs->ioarg_iovlen * sizeof(struct iovec));
+ malloc(sizeof(struct ioctx) + iovlen * sizeof(struct iovec));
if (!ioctx)
return NULL;
I_REF(ino);
+ ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx);
+ (void )memcpy((void *)ioctx->ioctx_iovec,
+ iov,
+ iovlen * sizeof(struct iovec));
+ IOCTX_INIT(ioctx,
+ 0,
+ (ioid_t )ioctx,
+ ino,
+ ioctx->ioctx_iovec,
+ iovlen,
+ offset);
+
/*
* Link request onto the outstanding requests queue.
*/
LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link);
- ioctx->ioctx_id = (ioid_t )ioctx;
- ioctx->ioctx_ino = ino;
- ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx);
- (void )memcpy((void *)ioctx->ioctx_iovec,
- ioargs->ioarg_iovec,
- ioargs->ioarg_iovlen * sizeof(struct iovec));
- ioctx->ioctx_iovlen = ioargs->ioarg_iovlen;
- ioctx->ioctx_offset = ioargs->ioarg_offset;
- ioctx->ioctx_cc = 0;
- ioctx->ioctx_errno = 0;
- ioctx->ioctx_cb = ioargs->ioarg_completion;
- ioctx->ioctx_data = ioargs->ioarg_completion_arg;
-
return ioctx;
}
/*
+ * Add an IO completion call-back to the end of the context call-back queue.
+ * These are called in iowait() as the last thing, right before the context
+ * is destroyed.
+ *
+ * They are called in order. Beware.
+ */
+int
+_sysio_ioctx_cb(struct ioctx *ioctx,
+ void (*f)(struct ioctx *, void *),
+ void *data)
+{
+ struct ioctx_callback *entry;
+
+ entry = malloc(sizeof(struct ioctx_callback));
+ if (!entry)
+ return -ENOMEM;
+
+ entry->iocb_f = f;
+ entry->iocb_data = data;
+
+ TAILQ_INSERT_TAIL(&ioctx->ioctx_cbq, entry, iocb_next);
+
+ return 0;
+}
+
+/*
* Find an IO context given it's identifier.
*
* NB: This is dog-slow. If there are alot of these, we will need to change
@@ -170,26 +197,37 @@ _sysio_ioctx_wait(struct ioctx *ioctx)
void
_sysio_ioctx_complete(struct ioctx *ioctx)
{
+#if 0
struct inode *ino;
+#endif
+ struct ioctx_callback *entry;
- /*
- * Unlink from the file record's outstanding request queue.
- */
- LIST_REMOVE(ioctx, ioctx_link);
-
+#if 0
/*
* Wait for IO to complete and remember completion values.
*/
ino = ioctx->ioctx_ino;
while (ino && !(*ino->i_ops.inop_iodone)(ioctx))
;
+#endif
+
/*
- * Notify interested parties.
+ * Run the call-back queue.
*/
- if (ioctx->ioctx_cb)
- (*ioctx->ioctx_cb)(ioctx);
+ while ((entry = ioctx->ioctx_cbq.tqh_first)) {
+ TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next);
+ (*entry->iocb_f)(ioctx, entry->iocb_data);
+ free(entry);
+ }
- I_RELE(ino);
+ if (ioctx->ioctx_fast)
+ return;
+
+ /*
+ * Unlink from the file record's outstanding request queue.
+ */
+ LIST_REMOVE(ioctx, ioctx_link);
+ I_RELE(ioctx->ioctx_ino);
free(ioctx);
}
Index: link.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/link.c,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -u -w -b -B -p -r1.1 -r1.1.6.1
--- link.c 27 Sep 2003 19:42:03 -0000 1.1
+++ link.c 14 Oct 2003 23:39:36 -0000 1.1.6.1
@@ -72,7 +72,7 @@ link(const char *oldpath, const char *ne
err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new);
if (err && !new)
goto error2;
- if (!err || (err && err != -ENOENT)) {
+ if (err && err != -ENOENT) {
err = -EEXIST;
goto error1;
}
Index: lseek.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2
--- lseek.c 6 Oct 2003 21:14:22 -0000 1.6.2.1
+++ lseek.c 14 Oct 2003 23:39:36 -0000 1.6.2.2
@@ -53,8 +53,8 @@
#include "sysio-symbols.h"
-static off64_t
-_sysio_lseek(int fd, off64_t offset, int whence)
+static _SYSIO_OFF_T
+_sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence)
{
int err;
struct file *fil;
@@ -117,11 +117,44 @@ sysio_sym_weak_alias(_sysio_lseek, __lse
extern off_t
lseek(int fd, off_t offset, int whence)
{
+ _SYSIO_OFF_T off;
+ off_t rtn;
- return (off_t )_sysio_lseek(fd, offset, whence);
+ off = _sysio_lseek(fd, offset, whence);
+ if (off < 0)
+ return -1;
+ rtn = (off_t )off;
+ if ((_SYSIO_OFF_T )rtn != off) {
+ errno = EINVAL;
+ return -1;
+ }
+ return rtn;
}
#ifdef __GLIBC__
#undef __lseek
sysio_sym_weak_alias(lseek, __lseek)
+#endif
+
+#if 0
+#ifdef __linux__
+#undef llseek
+int
+llseek(unsigned int fd __IS_UNUSED,
+ unsigned long offset_high __IS_UNUSED,
+ unsigned long offset_low __IS_UNUSED,
+ loff_t *result __IS_UNUSED,
+ unsigned int whence __IS_UNUSED)
+{
+
+ /*
+ * Something is very wrong if this was called.
+ */
+ errno = ENOTSUP;
+ return -1;
+}
+
+#undef __llseek
+sysio_sym_weak_alias(llseek, __llseek)
+#endif
#endif
Index: mknod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- mknod.c 26 Mar 2003 00:06:05 -0000 1.3
+++ mknod.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -62,6 +62,10 @@
#undef mknod
#undef __xmknod
+#if defined(BSD) || defined(REDSTORM)
+#define _MKNOD_VER 0
+#endif
+
int
__xmknod(int __ver, const char *path, mode_t mode, dev_t *dev)
{
Index: mount.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v
retrieving revision 1.5.8.1
retrieving revision 1.5.8.2
diff -u -w -b -B -p -r1.5.8.1 -r1.5.8.2
--- mount.c 26 Aug 2003 17:21:39 -0000 1.5.8.1
+++ mount.c 14 Oct 2003 23:39:36 -0000 1.5.8.2
@@ -563,8 +563,7 @@ _sysio_automount(struct pnode *mntpno)
struct inode *ino;
struct intnl_stat stbuf;
struct iovec iovec;
- struct io_arguments ioarguments;
- struct ioctx *ioctx;
+ struct ioctx iocontext;
ssize_t cc;
char *fstype, *source, *opts;
unsigned flags;
@@ -598,13 +597,14 @@ _sysio_automount(struct pnode *mntpno)
err = _sysio_open(mntpno, O_RDONLY, 0);
if (err)
goto out;
- IOARG_INIT(&ioarguments, &iovec, 1, 0, NULL, NULL);
- err = (*ino->i_ops.inop_ipreadv)(ino, &ioarguments, &ioctx);
+ IOCTX_INIT(&iocontext, 1, (ioid_t )&iocontext, ino, &iovec, 1, 0);
+ err = (*ino->i_ops.inop_ipreadv)(ino, &iocontext);
if (err) {
+ _sysio_ioctx_complete(&iocontext);
(void )(*ino->i_ops.inop_close)(ino);
goto out;
}
- cc = _sysio_ioctx_wait(ioctx);
+ cc = _sysio_ioctx_wait(&iocontext);
err = (*ino->i_ops.inop_close)(ino);
if (err)
goto out;
Index: open.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/open.c,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -w -b -B -p -r1.8.2.1 -r1.8.2.2
--- open.c 6 Oct 2003 21:14:22 -0000 1.8.2.1
+++ open.c 14 Oct 2003 23:39:36 -0000 1.8.2.2
@@ -118,6 +118,8 @@ _sysio_open(struct pnode *pno, int flags
return err;
}
+#undef open
+
int
open(const char *path, int flags, ...)
{
@@ -146,7 +148,12 @@ open(const char *path, int flags, ...)
* Will need mode too.
*/
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ mode =
+#ifndef REDSTORM
+ va_arg(ap, mode_t);
+#else
+ va_arg(ap, int);
+#endif
va_end(ap);
mode &= ~_sysio_umask; /* apply umask */
Index: read.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/read.c,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2
--- read.c 6 Oct 2003 21:14:22 -0000 1.3.2.1
+++ read.c 14 Oct 2003 23:39:36 -0000 1.3.2.2
@@ -59,13 +59,13 @@
* Schedule asynchronous read of iovec at some file extent.
*/
static struct ioctx *
-do_ipreadv(struct file *fil,
+do_ixreadv(struct file *fil,
const struct iovec *iov, size_t count,
- off_t offset)
+ _SYSIO_OFF_T offset,
+ void (*fcompletio)(struct ioctx *, struct file *))
{
struct inode *ino;
int err;
- struct io_arguments ioarguments;
struct ioctx *ioctx;
if (fil->f_flags & O_WRONLY) {
@@ -81,12 +81,23 @@ do_ipreadv(struct file *fil,
errno = EBADF;
return NULL;
}
- IOARG_INIT(&ioarguments,
- iov, count,
- offset,
- (void (*)(void *))_sysio_fcompletio, fil);
- err = ino->i_ops.inop_ipreadv(fil->f_ino, &ioarguments, &ioctx);
+ ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset);
+ if (!ioctx ||
+ (fcompletio &&
+ _sysio_ioctx_cb(ioctx,
+ (void (*)(struct ioctx *, void *))fcompletio,
+ fil) != 0)) {
+ err = -ENOMEM;
+ goto out;
+ }
+ err = ino->i_ops.inop_ipreadv(fil->f_ino, ioctx);
+out:
if (err) {
+ if (ioctx) {
+ ioctx->ioctx_cc = -1;
+ ioctx->ioctx_errno = -err;
+ _sysio_ioctx_complete(ioctx);
+ }
errno = -err;
return NULL;
}
@@ -97,7 +108,7 @@ do_ipreadv(struct file *fil,
* API interface to accomplish asynch read into iovec from given file offset.
*/
ioid_t
-ipreadv(int fd, const struct iovec *iov, size_t count, off_t offset)
+ipreadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset)
{
struct file *fil;
struct ioctx *ioctxp;
@@ -108,7 +119,7 @@ ipreadv(int fd, const struct iovec *iov,
return IOID_FAIL;
}
- ioctxp = do_ipreadv(fil, iov, count, offset);
+ ioctxp = do_ixreadv(fil, iov, count, offset, NULL);
return ioctxp ? ioctxp->ioctx_id : IOID_FAIL;
}
@@ -116,7 +127,7 @@ ipreadv(int fd, const struct iovec *iov,
* API interface to accomplish asynch read into buf from given file offset.
*/
ioid_t
-ipread(int fd, void *buf, size_t count, off_t offset)
+ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset)
{
struct iovec iov[1];
@@ -131,7 +142,7 @@ ipread(int fd, void *buf, size_t count,
* API interface to accomplish read into iovec from given file offset.
*/
ssize_t
-preadv(int fd, const struct iovec *iov, size_t count, off_t offset)
+preadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset)
{
ioid_t ioid;
@@ -144,8 +155,8 @@ preadv(int fd, const struct iovec *iov,
/*
* API interface to accomplish read into buf from given file offset.
*/
-ssize_t
-pread(int fd, void *buf, size_t count, off_t offset)
+static ssize_t
+_pread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset)
{
ioid_t ioid;
@@ -155,6 +166,21 @@ pread(int fd, void *buf, size_t count, o
return iowait(ioid);
}
+#if _LARGEFILE64_SOURCE
+#undef pread64
+sysio_sym_weak_alias(_pread, pread64)
+
+ssize_t
+pread(int fd, void *buf, size_t count, off_t offset)
+{
+
+ return _pread(fd, buf, count, offset);
+}
+#else
+#undef pread
+sysio_sym_weak_alias(_pread, pread)
+#endif
+
/*
* API interface to accomplish asynch read into iovec from current file offset.
*/
@@ -170,7 +196,7 @@ ireadv(int fd, const struct iovec *iov,
return IOID_FAIL;
}
- ioctxp = do_ipreadv(fil, iov, count, fil->f_pos);
+ ioctxp = do_ixreadv(fil, iov, count, fil->f_pos, _sysio_fcompletio);
if (!ioctxp)
return IOID_FAIL;
return ioctxp->ioctx_id;
Index: rmdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3
+++ rmdir.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -68,6 +68,13 @@ rmdir(const char *path)
goto error;
}
err = pno->p_base->pb_ino->i_ops.inop_rmdir(pno);
+ if (err)
+ goto error;
+ /*
+ * Invalide the path-base node. The inode reference was dropped
+ * by the driver.
+ */
+ pno->p_base->pb_ino = NULL;
error:
P_RELE(pno);
out:
Index: statvfs.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- statvfs.c 24 Mar 2003 22:09:07 -0000 1.3
+++ statvfs.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -41,6 +41,10 @@
* le...@sa...
*/
+#ifdef _HAVE_STATVFS
+
+#if !(defined(BSD) || defined(REDSTORM))
+
#include <unistd.h>
#include <errno.h>
#include <assert.h>
@@ -136,3 +140,5 @@ err:
out:
return err;
}
+#endif /* if !(defined(BSD) || defined(REDSTORM)) */
+#endif /* defined(_HAVE_STATVFS) */
Index: statvfs64.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- statvfs64.c 24 Mar 2003 22:09:07 -0000 1.3
+++ statvfs64.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -41,6 +41,9 @@
* le...@sa...
*/
+#ifdef _HAVE_STATVFS
+
+#if !(defined(BSD) || defined(REDSTORM))
#include <unistd.h>
#include <errno.h>
#include <assert.h>
@@ -93,3 +96,5 @@ out:
}
return err;
}
+#endif /* if !(defined(BSD) || defined(REDSTORM)) */
+#endif /* define(_HAVE_STATVFS) */
Index: truncate.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- truncate.c 24 Mar 2003 22:09:07 -0000 1.3
+++ truncate.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -53,11 +53,13 @@
#include "inode.h"
#include "file.h"
+#include "sysio-symbols.h"
+
/*
* Truncate file, given path (alias) or index node.
*/
static int
-do_truncate(struct pnode *pno, struct inode *ino, off_t length)
+do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length)
{
struct intnl_stat stbuf;
unsigned mask;
@@ -75,8 +77,8 @@ do_truncate(struct pnode *pno, struct in
return _sysio_setattr(pno, ino, mask, &stbuf);
}
-int
-truncate(const char *path, off_t length)
+static int
+_truncate(const char *path, _SYSIO_OFF_T length)
{
int err;
struct pnode *pno;
@@ -95,8 +97,24 @@ out:
return err;
}
+#if _LARGEFILE64_SOURCE
+#undef truncate64
+sysio_sym_weak_alias(_truncate, truncate64)
+
+#undef truncate
int
-ftruncate(int fd, off_t length)
+truncate(const char *path, off_t length)
+{
+
+ return _truncate(path, length);
+}
+#else
+#undef truncate
+sysio_sym_weak_alias(_truncate, truncate)
+#endif
+
+static int
+_ftruncate(int fd, _SYSIO_OFF_T length)
{
int err;
struct file *fil;
@@ -115,3 +133,19 @@ out:
}
return err;
}
+
+#if _LARGEFILE64_SOURCE
+#undef ftruncate64
+sysio_sym_weak_alias(_ftruncate, ftruncate64)
+
+#undef ftruncate
+int
+ftruncate(int fd, off_t length)
+{
+
+ return _ftruncate(fd, length);
+}
+#else
+#undef ftruncate
+sysio_sym_weak_alias(_ftruncate, ftruncate)
+#endif
Index: unlink.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -w -b -B -p -r1.3 -r1.3.10.1
--- unlink.c 24 Mar 2003 22:09:07 -0000 1.3
+++ unlink.c 14 Oct 2003 23:39:36 -0000 1.3.10.1
@@ -68,6 +68,13 @@ unlink(const char *path)
goto error;
}
err = (*pno->p_base->pb_ino->i_ops.inop_unlink)(pno);
+ if (err)
+ goto error;
+ /*
+ * Invalidate the path-base node. The inode reference was
+ * dropped by the driver.
+ */
+ pno->p_base->pb_ino = NULL;
error:
P_RELE(pno);
out:
Index: write.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/write.c,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2
--- write.c 6 Oct 2003 21:14:22 -0000 1.3.2.1
+++ write.c 14 Oct 2003 23:39:36 -0000 1.3.2.2
@@ -52,8 +52,10 @@
#include "sysio.h"
#include "file.h"
#include "inode.h"
-#include "fs.h"
-#include "mount.h"
+
+#include "sysio-symbols.h"
+
+#include "sysio-symbols.h"
#include "sysio-symbols.h"
@@ -61,16 +63,16 @@
* Schedule asynchronous write of iovec at some file extent.
*/
static struct ioctx *
-do_ipwritev(struct file *fil,
+do_ixwritev(struct file *fil,
const struct iovec *iov, size_t count,
- off_t offset)
+ _SYSIO_OFF_T offset,
+ void (*fcompletio)(struct ioctx *, struct file *))
{
struct inode *ino;
int err;
- struct io_arguments ioarguments;
struct ioctx *ioctx;
- if (!(fil->f_flags & (O_WRONLY|O_RDWR))) {
+ if (fil->f_flags & O_RDONLY) {
errno = EBADF;
return IOID_FAIL;
}
@@ -80,19 +82,26 @@ do_ipwritev(struct file *fil,
/*
* Huh? It's dead.
*/
- errno = -EBADF;
+ errno = EBADF;
return NULL;
}
- if (IS_RDONLY(NULL, ino)) {
- errno = -EROFS;
- return NULL;
+ ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset);
+ if (!ioctx ||
+ (fcompletio &&
+ _sysio_ioctx_cb(ioctx,
+ (void (*)(struct ioctx *, void *))fcompletio,
+ fil) != 0)) {
+ err = -ENOMEM;
+ goto out;
}
- IOARG_INIT(&ioarguments,
- iov, count,
- offset,
- (void (*)(void *))_sysio_fcompletio, fil);
- err = ino->i_ops.inop_ipwritev(fil->f_ino, &ioarguments, &ioctx);
+ err = ino->i_ops.inop_ipwritev(fil->f_ino, ioctx);
+out:
if (err) {
+ if (ioctx) {
+ ioctx->ioctx_cc = -1;
+ ioctx->ioctx_errno = -err;
+ _sysio_ioctx_complete(ioctx);
+ }
errno = -err;
return NULL;
}
@@ -100,10 +109,10 @@ do_ipwritev(struct file *fil,
}
/*
- * API interface to accomplish asynch write from iovec at given file offset.
+ * API interface to accomplish asynch write into iovec from given file offset.
*/
ioid_t
-ipwritev(int fd, const struct iovec *iov, size_t count, off_t offset)
+ipwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset)
{
struct file *fil;
struct ioctx *ioctxp;
@@ -114,15 +123,15 @@ ipwritev(int fd, const struct iovec *iov
return IOID_FAIL;
}
- ioctxp = do_ipwritev(fil, iov, count, offset);
+ ioctxp = do_ixwritev(fil, iov, count, offset, NULL);
return ioctxp ? ioctxp->ioctx_id : IOID_FAIL;
}
/*
- * API interface to accomplish asynch write from buf from given file offset.
+ * API interface to accomplish asynch write into buf from given file offset.
*/
ioid_t
-ipwrite(int fd, const void *buf, size_t count, off_t offset)
+ipwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset)
{
struct iovec iov[1];
@@ -134,10 +143,10 @@ ipwrite(int fd, const void *buf, size_t
}
/*
- * API interface to accomplish write from iovec at given file offset.
+ * API interface to accomplish write into iovec from given file offset.
*/
ssize_t
-pwritev(int fd, const struct iovec *iov, size_t count, off_t offset)
+pwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset)
{
ioid_t ioid;
@@ -148,10 +157,10 @@ pwritev(int fd, const struct iovec *iov,
}
/*
- * API interface to accomplish write from buf from given file offset.
+ * API interface to accomplish write into buf from given file offset.
*/
-ssize_t
-pwrite(int fd, const void *buf, size_t count, off_t offset)
+static ssize_t
+_pwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset)
{
ioid_t ioid;
@@ -161,8 +170,23 @@ pwrite(int fd, const void *buf, size_t c
return iowait(ioid);
}
+#if _LARGEFILE64_SOURCE
+#undef pwrite64
+sysio_sym_weak_alias(_pwrite, pwrite64)
+
+ssize_t
+pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+
+ return _pwrite(fd, buf, count, offset);
+}
+#else
+#undef pwrite
+sysio_sym_weak_alias(_pwrite, pwrite)
+#endif
+
/*
- * API interface to accomplish asynch write from iovec at current file offset.
+ * API interface to accomplish asynch write into iovec from current file offset.
*/
ioid_t
iwritev(int fd, const struct iovec *iov, int count)
@@ -176,14 +200,14 @@ iwritev(int fd, const struct iovec *iov,
return IOID_FAIL;
}
- ioctxp = do_ipwritev(fil, iov, count, fil->f_pos);
+ ioctxp = do_ixwritev(fil, iov, count, fil->f_pos, _sysio_fcompletio);
if (!ioctxp)
return IOID_FAIL;
return ioctxp->ioctx_id;
}
/*
- * API interface to accomplish asynch write from buf at current file offset.
+ * API interface to accomplish asynch write into buf from current file offset.
*/
ioid_t
iwrite(int fd, const void *buf, size_t count)
|