[Libsysio-commit] RedStorm_merge: libsysio/src link.c rename.c utime.c Makefile.am access.c chdir.c
Brought to you by:
lward
|
From: Sonja T. <so...@us...> - 2003-10-09 15:04:19
|
Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv7240/src
Modified Files:
Tag: RedStorm_merge
Makefile.am access.c chdir.c chmod.c chown.c dev.c fcntl.c
file.c getdirentries.c inode.c ioctl.c lseek.c mount.c namei.c
open.c read.c rmdir.c stat.c stat64.c statvfs.c truncate.c
unlink.c write.c
Added Files:
Tag: RedStorm_merge
link.c rename.c utime.c
Log Message:
Merging redstorm changes
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/queue.h>
#include "sysio.h"
#include "mount.h"
#include "inode.h"
int
link(const char *oldpath, const char *newpath)
{
struct intent intent;
int err;
struct pnode *old, *new;
INTENT_INIT(&intent, 0, NULL, NULL);
err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old);
if (err)
goto out;
if (S_ISDIR(old->p_base->pb_ino->i_mode)) {
err = -EPERM;
goto error2;
}
INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL);
err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new);
if (err && !new)
goto error2;
if (!err || (err && err != -ENOENT)) {
err = -EEXIST;
goto error1;
}
if (old->p_mount->mnt_root != new->p_mount->mnt_root) {
err = -EXDEV;
goto error1;
}
err = old->p_base->pb_ino->i_ops.inop_link(old, new);
if (err)
goto error1;
/*
* The new path-base node must point to the inode referenced by
* the old. As well, we need to record the new reference of the inode.
*/
new->p_base->pb_ino = old->p_base->pb_ino;
I_REF(new->p_base->pb_ino);
error1:
P_RELE(new);
error2:
P_RELE(old);
if (err) {
errno = -err;
err = -1;
}
out:
return err;
}
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/queue.h>
#include "sysio.h"
#include "mount.h"
#include "inode.h"
int
rename(const char *oldpath, const char *newpath)
{
struct intent intent;
int err;
struct pnode *old, *new;
struct pnode_base *nxtpb, *pb;
struct intnl_stat ostbuf, nstbuf;
/*
* Resolve oldpath to a path node.
*/
INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL);
err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old);
if (err)
goto out;
/*
* Resolve newpath to a path node.
*/
INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL);
err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new);
if (err && !new)
goto error2;
if (old->p_mount->mnt_root != new->p_mount->mnt_root) {
/*
* Oops. They're trying to move it across mounts.
*/
err = -EXDEV;
goto error1;
}
/*
* Make sure the old pnode can't be found in the ancestor chain
* for the new. If it can, they are trying to move into a subdirectory
* of the old.
*/
nxtpb = new->p_base;
do {
pb = nxtpb;
nxtpb = pb->pb_parent;
if (pb == old->p_base) {
err = -EINVAL;
goto error1;
}
} while (pb != nxtpb);
while (new->p_base->pb_ino) {
/*
* Existing entry. We're replacing the new. Make sure that's
* ok.
*/
err =
old->p_base->pb_ino->i_ops.inop_getattr(old, NULL, &ostbuf);
if (err)
goto error1;
err =
new->p_base->pb_ino->i_ops.inop_getattr(new, NULL, &nstbuf);
if (err) {
if (err != ENOENT)
goto error1;
/*
* Rats! It disappeared beneath us.
*/
(void )_sysio_p_validate(new, NULL, NULL);
continue;
}
if (S_ISDIR(ostbuf.st_mode)) {
if (!S_ISDIR(nstbuf.st_mode)) {
err = -ENOTDIR;
goto error1;
}
if (nstbuf.st_nlink > 2) {
err = -ENOTEMPTY;
goto error1;
}
} else if (S_ISDIR(nstbuf.st_mode)) {
err = -EEXIST;
goto error1;
}
}
/*
* It's not impossible to clean up the altered name space after
* a rename. However, it is onerous and I don't want to do it right
* now. If it becomes an issue, we can do it later. For now, I've
* elected to use the semantic that says, basically, the entire
* sub-tree must be unreferenced.
*/
if (_sysio_p_prune(new) != 1) {
err = -EBUSY;
goto error1;
}
err = old->p_base->pb_ino->i_ops.inop_rename(old, new);
if (err)
goto error1;
error1:
P_RELE(new);
error2:
P_RELE(old);
if (err) {
errno = -err;
err = -1;
goto out;
}
_sysio_p_gone(old); /* kill it! */
out:
return err;
}
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#include <string.h>
#include <errno.h>
#include <time.h>
#include <assert.h>
#include <sys/types.h>
#include <utime.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/queue.h>
#include "sysio.h"
#include "inode.h"
#include "file.h"
int
utime(const char *path, const struct utimbuf *buf)
{
struct intent intent;
int err;
struct pnode *pno;
struct utimbuf _utbuffer;
struct intnl_stat stbuf;
INTENT_INIT(&intent, INT_SETATTR, NULL, NULL);
err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno);
if (err)
goto out;
if (!buf) {
_utbuffer.actime = _utbuffer.modtime = time(NULL);
buf = &_utbuffer;
}
(void )memset(&stbuf, 0, sizeof(struct intnl_stat));
stbuf.st_atime = buf->actime;
stbuf.st_mtime = buf->modtime;
err =
_sysio_setattr(pno,
pno->p_base->pb_ino,
SETATTR_ATIME | SETATTR_MTIME,
&stbuf);
P_RELE(pno);
out:
if (err) {
errno = -err;
err = -1;
}
return err;
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v
retrieving revision 1.5.6.3
retrieving revision 1.5.6.3.2.1
diff -u -w -b -B -p -r1.5.6.3 -r1.5.6.3.2.1
--- Makefile.am 30 Jul 2003 14:00:02 -0000 1.5.6.3
+++ Makefile.am 9 Oct 2003 15:04:09 -0000 1.5.6.3.2.1
@@ -2,7 +2,15 @@ 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 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
+
+if WITH_CPLANT_YOD
+YOD_DRIVER_FLAGS = -DCPLANT_YOD
+else
+YOD_DRIVER_FLAGS =
+endif
+AM_CPPFLAGS += ${YOD_DRIVER_FLAGS}
Index: access.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/access.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -u -w -b -B -p -r1.1.2.1 -r1.1.2.1.2.1
--- access.c 29 Jul 2003 20:17:22 -0000 1.1.2.1
+++ access.c 9 Oct 2003 15:04:09 -0000 1.1.2.1.2.1
@@ -52,10 +52,9 @@ access(const char *path, int amode)
{
gid_t *list, *entry;
size_t n;
- int err;
+ int err = 0;
unsigned mask, mode;
struct stat stbuf;
- int oerrno;
err = 0;
@@ -69,7 +68,7 @@ access(const char *path, int amode)
}
}
err = getgroups(n, list);
- if (err)
+ if (err != (int ) n)
goto out;
err = stat(path, &stbuf);
@@ -85,36 +84,27 @@ access(const char *path, int amode)
mask |= S_IXUSR;
mode = stbuf.st_mode;
- if (stbuf.st_uid == getuid() && (mode & mask) != mask) {
- err = -1;
+ if (stbuf.st_uid == getuid() && (mode & mask) == mask)
goto out;
- }
+
mask >>= 3;
- entry = list;
- while (n--) {
- if (stbuf.st_gid == *entry++) {
- if ((mode & mask) != mask) {
- err = -1;
+ if (stbuf.st_gid == getgid() && (mode & mask) == mask)
goto out;
- }
- break;
- }
- }
- if (stbuf.st_gid == getgid() && (mode & mask) != mask) {
- err = -1;
+
+ entry = list;
+ while (n--)
+ if (stbuf.st_gid == *entry++ && (mode & mask) == mask)
goto out;
- }
+
mask >>= 3;
- if ((mode & mask) != mask) {
- err = -1;
+ if ((mode & mask) == mask)
goto out;
- }
+
+ err = -1;
out:
- oerrno = errno;
if (list)
free(list);
- errno = oerrno;
return err;
}
Index: chdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v
retrieving revision 1.3
retrieving revision 1.3.14.1
diff -u -w -b -B -p -r1.3 -r1.3.14.1
--- chdir.c 9 Mar 2003 16:57:47 -0000 1.3
+++ chdir.c 9 Oct 2003 15:04:09 -0000 1.3.14.1
@@ -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"
@@ -77,24 +78,51 @@
#include "mount.h"
#include "file.h"
+#include "sysio-symbols.h"
+
struct pnode *_sysio_cwd = NULL;
+
+/*
+ * Change to directory specified by the given pnode.
+ */
int
-chdir(const char *path)
+_sysio_p_chdir(struct pnode *pno)
{
int err;
- struct pnode *pno;
+ struct intnl_stat stbuf;
- err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno);
- if (err) {
- errno = -err;
- return -1;
- }
+ /*
+ * 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;
}
@@ -98,60 +126,19 @@ chdir(const char *path)
return 0;
}
-char *
-getwd(char *buf)
+int
+chdir(const char *path)
{
- size_t len, n;
- struct pnode *tmp;
- char *cp;
+ int err;
+ struct pnode *pno;
- /*
- * First pass: Traverse to the root of the sub-tree, remembering
- * lengths.
- */
- len = 0;
- tmp = _sysio_cwd;
- do {
- n = tmp->p_base->pb_name.len;
- len += tmp->p_base->pb_name.len;
- if (n)
- len++;
- tmp = tmp->p_parent;
- /*
- * Traverse mount points.
- */
- while (tmp->p_mount->mnt_root == tmp &&
- tmp != tmp->p_mount->mnt_covers)
- tmp = tmp->p_mount->mnt_root;
- } while (tmp != tmp->p_parent);
- if (!len)
- len++;
- /*
- * Fill in the path buffer -- Backwards, since we're starting
- * from the end.
- */
- cp = buf;
- *cp = PATH_SEPARATOR;
- cp += len;
- *cp = '\0'; /* NUL term */
- tmp = _sysio_cwd;
- do {
- cp -= tmp->p_base->pb_name.len;
- n = tmp->p_base->pb_name.len;
- if (n) {
- (void )strncpy(cp, tmp->p_base->pb_name.name, n);
- *--cp = PATH_SEPARATOR;
+ err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno);
+ if (err) {
+ errno = -err;
+ return -1;
}
- tmp = tmp->p_parent;
- /*
- * Traverse mount points.
- */
- while (tmp->p_mount->mnt_root == tmp &&
- tmp != tmp->p_mount->mnt_covers)
- tmp = tmp->p_mount->mnt_root;
- } while (tmp != tmp->p_parent);
- return buf;
+ return _sysio_p_chdir(pno);
}
/*
@@ -178,12 +165,6 @@ _sysio_p_path(struct pnode *pno, char **
n = 0;
do {
/*
- * Traverse back through mounts.
- */
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
- /*
* Add length of this component to running sum and
* account for this vertex.
*/
@@ -217,20 +198,13 @@ _sysio_p_path(struct pnode *pno, char **
*cp = '\0'; /* NUL terminate */
do {
/*
- * Traverse back through mounts.
- */
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
- /*
* Add component and separator.
*/
cp -= pno->p_base->pb_name.len;
- if (pno->p_base->pb_name.len)
- (void )memcpy(cp--,
- pno->p_base->pb_name.name,
+ (void )memcpy(cp, pno->p_base->pb_name.name,
pno->p_base->pb_name.len);
- *cp = PATH_SEPARATOR;
+
+ *--cp = PATH_SEPARATOR;
pno = pno->p_parent;
} while (pno != pno->p_parent);
@@ -249,3 +224,19 @@ getcwd(char *buf, size_t size)
}
return buf;
}
+
+#ifdef __GLIBC__
+sysio_sym_weak_alias(getcwd, __getcwd)
+#endif
+
+#ifdef PATH_MAX
+char *
+getwd(char *buf)
+{
+
+ if (!buf)
+ return -EFAULT;
+
+ return getcwd(buf, PATH_MAX);
+}
+#endif
Index: chmod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -w -b -B -p -r1.3 -r1.3.2.1
--- chmod.c 24 Mar 2003 22:09:06 -0000 1.3
+++ chmod.c 9 Oct 2003 15:04:09 -0000 1.3.2.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.2.1
diff -u -w -b -B -p -r1.3 -r1.3.2.1
--- chown.c 24 Mar 2003 22:09:06 -0000 1.3
+++ chown.c 9 Oct 2003 15:04:09 -0000 1.3.2.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.6.1
retrieving revision 1.2.6.1.2.1
diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.1.2.1
--- dev.c 12 May 2003 11:48:45 -0000 1.2.6.1
+++ dev.c 9 Oct 2003 15:04:09 -0000 1.2.6.1.2.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,9 +74,7 @@ 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
};
@@ -169,45 +169,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: fcntl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v
retrieving revision 1.3
retrieving revision 1.3.8.1
diff -u -w -b -B -p -r1.3 -r1.3.8.1
--- fcntl.c 4 Apr 2003 20:09:47 -0000 1.3
+++ fcntl.c 9 Oct 2003 15:04:09 -0000 1.3.8.1
@@ -51,6 +51,8 @@
#include "inode.h"
#include "file.h"
+#include "sysio-symbols.h"
+
int
fcntl(int fd, int cmd, ...)
{
@@ -95,3 +97,14 @@ out:
}
return err;
}
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(fcntl, _fcntl);
+#endif
+
+
+#ifdef __GLIBC__
+#undef __fcntl
+sysio_sym_weak_alias(fcntl, __fcntl)
+#endif
+
Index: file.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/file.c,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -w -b -B -p -r1.4 -r1.4.6.1
--- file.c 9 Mar 2003 17:18:57 -0000 1.4
+++ file.c 9 Oct 2003 15:04:10 -0000 1.4.6.1
@@ -128,7 +128,7 @@ fd_grow(size_t n)
if (n < 8)
n = 8;
- if (n > _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size)
+ if (n >= _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size)
n = (n + 1) * 2;
noftab = realloc(_sysio_oftab, n * sizeof(struct file *));
if (!noftab)
Index: getdirentries.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v
retrieving revision 1.1.10.2
retrieving revision 1.1.10.2.2.1
diff -u -w -b -B -p -r1.1.10.2 -r1.1.10.2.2.1
--- getdirentries.c 19 May 2003 14:05:34 -0000 1.1.10.2
+++ getdirentries.c 9 Oct 2003 15:04:10 -0000 1.1.10.2.2.1
@@ -18,8 +18,8 @@
#define __restrict
#endif
-ssize_t
-getdirentries64(int fd,
+static ssize_t
+_getdirentries64(int fd,
char *buf,
size_t nbytes,
_SYSIO_OFF_T * __restrict basep)
@@ -46,6 +46,13 @@ getdirentries64(int fd,
return cc;
}
+#if _LARGEFILE64_SOURCE
+#undef getdirentries64
+sysio_sym_strong_alias(_getdirentries64, getdirentries64)
+#endif
+
+#undef getdirentries
+
#ifndef DIRENT64_IS_NATURAL
#ifndef EOVERFLOW
@@ -85,7 +92,7 @@ getdirentries(int fd,
#if defined(BSD) || defined(REDSTORM)
int off;
#endif
- struct intnl_dirent *od64p, *d64p;
+ struct intnl_dirent *od64p = NULL, *d64p = NULL;
size_t n;
size_t reclen;
char *cp;
@@ -127,7 +134,7 @@ getdirentries(int fd,
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;
@@ -212,6 +219,9 @@ out:
#undef _dbaselen
}
#else /* !defined(DIRENT64_IS_NATURAL) */
-sysio_sym_strong_alias(getdirentries64, getdirentries)
+sysio_sym_strong_alias(_getdirentries64, getdirentries)
#endif
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(getdirentries, _getdirentries)
+#endif
Index: inode.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v
retrieving revision 1.7.4.1
retrieving revision 1.7.4.1.2.1
diff -u -w -b -B -p -r1.7.4.1 -r1.7.4.1.2.1
--- inode.c 29 Jul 2003 19:05:08 -0000 1.7.4.1
+++ inode.c 9 Oct 2003 15:04:10 -0000 1.7.4.1.2.1
@@ -497,43 +497,19 @@ _sysio_p_gone(struct pnode *pno)
int
_sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path)
{
- struct pnode *parent;
- int err;
struct inode *ino;
+ struct pnode_base *rootpb;
+ int err;
- err = 0;
-
+ ino = pno->p_base->pb_ino;
/*
- * Make sure we can use the parent. We don't validate that
- * unless we have to. Beware of this! It's assuming the caller
- * recently revalidated. Namei will do this for instance.
- */
- parent = pno->p_parent;
- if (!parent->p_base->pb_ino) {
- err = _sysio_p_validate(parent, NULL, NULL);
- if (err) {
- /*
- * I really, really want to smash the association
- * of the passed path node with it's i-node. Can't
- * do it, though, since at least one FS driver can
- * still accomplish IO accesses to the currently
- * held i-node. For now, the driver needs to
- * record that the i-node has become (semi) invalid
- * and return appropriate errors itself.
- *
- * We *might* be able to do this, now, with the
- * recent changes to the open file table. Must check
- * on it. It is so annoying to have these half
- * dead i-nodes hanging around.
+ * An invalid pnode will not have an associated inode. We'll use
+ * the FS root inode, then -- It *must* be valid.
*/
- return err;
- }
- }
-
- ino = pno->p_base->pb_ino;
- if (!err)
+ rootpb = pno->p_mount->mnt_root->p_base;
+ assert(rootpb->pb_ino);
err =
- parent->p_base->pb_ino->i_ops.inop_lookup(pno,
+ rootpb->pb_ino->i_ops.inop_lookup(pno,
&ino,
intnt,
path);
@@ -630,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.
@@ -647,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) {
@@ -688,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);
}
}
@@ -706,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: ioctl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.18.1
diff -u -w -b -B -p -r1.1.1.1 -r1.1.1.1.18.1
--- ioctl.c 22 Feb 2003 16:33:07 -0000 1.1.1.1
+++ ioctl.c 9 Oct 2003 15:04:10 -0000 1.1.1.1.18.1
@@ -50,6 +50,8 @@
#include "inode.h"
#include "file.h"
+#include "sysio-symbols.h"
+
int
ioctl(int fd, unsigned long request, ...)
{
@@ -75,3 +77,12 @@ out:
}
return err;
}
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(ioctl, _ioctl);
+#endif
+
+#ifdef __GLIBC__
+#undef __ioctl
+sysio_sym_weak_alias(ioctl, __ioctl)
+#endif
Index: lseek.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v
retrieving revision 1.4.4.1
retrieving revision 1.4.4.1.2.1
diff -u -w -b -B -p -r1.4.4.1 -r1.4.4.1.2.1
--- lseek.c 12 May 2003 11:48:45 -0000 1.4.4.1
+++ lseek.c 9 Oct 2003 15:04:10 -0000 1.4.4.1.2.1
@@ -58,7 +58,7 @@ _sysio_lseek(int fd, _SYSIO_OFF_T offset
{
int err;
struct file *fil;
- off_t off;
+ off_t off = 0;
struct intnl_stat stbuf;
err = 0;
@@ -103,13 +103,58 @@ out:
return fil->f_pos = off;
}
+#if _LARGEFILE64_SOURCE
+#undef lseek64
sysio_sym_weak_alias(_sysio_lseek, lseek64)
+#ifdef __GLIBC__
+#undef __lseek64
+sysio_sym_weak_alias(_sysio_lseek, __lseek64)
+#endif
+#endif
#undef lseek
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: mount.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v
retrieving revision 1.5
retrieving revision 1.5.10.1
diff -u -w -b -B -p -r1.5 -r1.5.10.1
--- mount.c 18 Apr 2003 20:24:05 -0000 1.5
+++ mount.c 9 Oct 2003 15:04:10 -0000 1.5.10.1
@@ -54,6 +54,7 @@
#include <sys/queue.h>
#include "sysio.h"
+#include "sysio-symbols.h"
#include "fs.h"
#include "mount.h"
#include "inode.h"
@@ -106,8 +107,8 @@ _sysio_do_mount(struct filesys *fs,
struct inode *ino;
/*
- * It's really poor form to allow the new root to be
- * descendant of the pnode being covered.the one being covered.
+ * It's really poor form to allow the new root to be a
+ * descendant of the pnode being covered.
*/
if (tocover) {
struct pnode_base *pb;
@@ -142,7 +143,8 @@ _sysio_do_mount(struct filesys *fs,
/*
* Get alias for the new root.
*/
- mnt->mnt_root = _sysio_p_new_alias(NULL, rootpb, mnt);
+ mnt->mnt_root =
+ _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt);
if (!mnt->mnt_root) {
err = -ENOMEM;
goto error;
@@ -270,7 +272,7 @@ _sysio_mount_root(const char *source,
}
int
-mount(const char *source,
+do_mount(const char *source,
const char *target,
const char *filesystemtype,
unsigned long mountflags,
@@ -324,6 +326,20 @@ out:
return err;
}
+#if defined(BSD) || defined(REDSTORM)
+int
+mount(const char *type,
+ const char *dir,
+ int flags,
+ void *data)
+{
+ return do_mount( data, dir, type, 0, NULL );
+}
+
+#else
+sysio_sym_weak_alias(do_mount, mount)
+#endif
+
int
umount(const char *target)
{
@@ -541,11 +557,12 @@ parse_opts(char *opts, unsigned *flagsp)
*dst++ = *src++;
while (src != cp);
}
- *dst = '\0';
if (!*src)
break;
+ *dst = '\0';
src++; /* skip comma */
}
+ *dst = '\0';
*flagsp = flags;
return opts;
Index: namei.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v
retrieving revision 1.5.6.1
retrieving revision 1.5.6.1.2.1
diff -u -w -b -B -p -r1.5.6.1 -r1.5.6.1.2.1
--- namei.c 29 Jul 2003 19:05:09 -0000 1.5.6.1
+++ namei.c 9 Oct 2003 15:04:10 -0000 1.5.6.1.2.1
@@ -434,6 +434,33 @@ _sysio_path_walk(struct pnode *parent, s
return err;
}
+#ifdef CPLANT_YOD
+static const char *
+strip_prefix(const char *path)
+{
+
+ /*
+ * for backward compatibility w/protocol switch
+ * remove 'prefix:' iff first ':' immediately
+ * precedes first '/'
+ */
+
+ char *colon, *slash;
+
+ colon = strchr(path, ':');
+ slash = strchr(path, '/');
+
+ if (slash == colon + 1)
+ return(slash);
+ else
+ return(path);
+
+}
+#define STRIP_PREFIX(p) strip_prefix(p)
+#else
+#define STRIP_PREFIX(p) p
+#endif
+
/*
* Expanded form of the path-walk routine, with the common arguments, builds
* the nameidata bundle and calls path-walk.
@@ -448,7 +475,7 @@ _sysio_namei(struct pnode *parent,
struct nameidata nameidata;
int err;
- ND_INIT(&nameidata, flags, path, _sysio_root, intnt);
+ ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt);
err = _sysio_path_walk(parent, &nameidata);
if (!err)
*pnop = nameidata.nd_pno;
Index: open.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/open.c,v
retrieving revision 1.7.4.1
retrieving revision 1.7.4.1.2.1
diff -u -w -b -B -p -r1.7.4.1 -r1.7.4.1.2.1
--- open.c 19 May 2003 13:51:20 -0000 1.7.4.1
+++ open.c 9 Oct 2003 15:04:10 -0000 1.7.4.1.2.1
@@ -40,6 +40,7 @@
*
* le...@sa...
*/
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -56,6 +57,8 @@
#include "fs.h"
#include "mount.h"
+#include "sysio-symbols.h"
+
/*
* Open file support.
*/
@@ -104,8 +107,9 @@ _sysio_open(struct pnode *pno, int flags
}
} else if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
err = -EEXIST;
- else if (!ino)
+ else if (!ino){
err = _sysio_p_validate(pno, NULL, NULL);
+ }
else {
/*
* Simple open of pre-existing file.
@@ -116,6 +120,8 @@ _sysio_open(struct pnode *pno, int flags
return err;
}
+#undef open
+
int
open(const char *path, int flags, ...)
{
@@ -203,6 +209,21 @@ error:
return -1;
}
+
+
+#ifdef __GLIBC__
+#undef __open
+sysio_sym_weak_alias(open, __open)
+#undef open64
+sysio_sym_weak_alias(open, open64)
+#undef __open64
+sysio_sym_weak_alias(open, __open64)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(open, _open);
+#endif
+
int
close(int fd)
{
@@ -214,6 +235,16 @@ close(int fd)
return err ? -1 : 0;
}
+#ifdef __GLIBC__
+#undef __close
+sysio_sym_weak_alias(close, __close)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(close, _close);
+#endif
+
+
int
creat(const char *path, mode_t mode)
{
@@ -221,6 +252,15 @@ creat(const char *path, mode_t mode)
return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode);
}
+#ifdef __GLIBC__
+#undef __creat
+sysio_sym_weak_alias(creat, __creat)
+#undef creat64
+sysio_sym_weak_alias(creat, creat64)
+#undef __creat64
+sysio_sym_weak_alias(creat, __creat64)
+#endif
+
mode_t
umask(mode_t mask)
{
@@ -230,3 +270,50 @@ umask(mode_t mask)
_sysio_umask = mask & 0777;
return omask;
}
+
+#if defined(__GLIBC__) && defined(ALPHA_LINUX)
+int
+open64(const char *fname, int flags, ...)
+{
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+
+ return open(fname, flags, mode);
+}
+
+int
+__open64(const char *fname, int flags, ...)
+{
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+
+ return open(fname, flags, mode);
+}
+int
+__open(const char *fname, int flags, ...)
+{
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+
+ return open(fname, flags, mode);
+}
+
+int
+__close(int fd) {
+
+ return close(fd);
+}
+#endif
+
Index: read.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/read.c,v
retrieving revision 1.2
retrieving revision 1.2.14.1
diff -u -w -b -B -p -r1.2 -r1.2.14.1
--- read.c 9 Mar 2003 06:36:37 -0000 1.2
+++ read.c 9 Oct 2003 15:04:10 -0000 1.2.14.1
@@ -53,13 +53,16 @@
#include "file.h"
#include "inode.h"
+#include "sysio-symbols.h"
+
/*
* 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 inode *ino;
int err;
@@ -82,7 +85,7 @@ do_ipreadv(struct file *fil,
IOARG_INIT(&ioarguments,
iov, count,
offset,
- (void (*)(void *))_sysio_fcompletio, fil);
+ (void (*)(void *))fcompletio, fil);
err = ino->i_ops.inop_ipreadv(fil->f_ino, &ioarguments, &ioctx);
if (err) {
errno = -err;
@@ -95,7 +98,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;
@@ -106,7 +109,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;
}
@@ -114,7 +117,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];
@@ -129,7 +132,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;
@@ -142,8 +145,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;
@@ -153,6 +156,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.
*/
@@ -168,7 +186,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;
@@ -210,6 +228,20 @@ read(int fd, void *buf, size_t count)
return iowait(ioid);
}
+#ifdef __GLIBC__
+#undef __read
+sysio_sym_weak_alias(read, __read)
+#endif
+
+#if _LARGEFILE64_SOURCE
+#undef read64
+sysio_sym_weak_alias(read, read64)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(read, _read);
+#endif
+
#ifdef notdef
int
read_list(int fd,
@@ -222,5 +254,13 @@ read_list(int fd,
{
errno = ENOSYS;
return -1;
+}
+#endif
+
+#if defined(__GLIBC__) && defined(ALPHA_LINUX)
+ssize_t
+__read(int fd, void *buf, size_t count)
+{
+ return read(fd, buf, count);
}
#endif
Index: rmdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -w -b -B -p -r1.3 -r1.3.2.1
--- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3
+++ rmdir.c 9 Oct 2003 15:04:10 -0000 1.3.2.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: stat.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v
retrieving revision 1.3.6.2
retrieving revision 1.3.6.2.2.1
diff -u -w -b -B -p -r1.3.6.2 -r1.3.6.2.2.1
--- stat.c 19 May 2003 13:51:20 -0000 1.3.6.2
+++ stat.c 9 Oct 2003 15:04:10 -0000 1.3.6.2.2.1
@@ -106,6 +106,9 @@ __fstat(int fd, struct stat *buf)
return __fxstat(_STAT_VER, fd, buf);
}
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(__fstat, _fstat)
+#endif
sysio_sym_weak_alias(__fstat, fstat)
int
@@ -140,13 +143,21 @@ out:
}
int
+#if defined(BSD) || defined(REDSTORM)
+_stat(const char *filename, struct stat *buf)
+#else
__stat(const char *filename, struct stat *buf)
+#endif
{
return __xstat(_STAT_VER, filename, buf);
}
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(_stat, stat)
+#else
sysio_sym_weak_alias(__stat, stat)
+#endif
int
__lxstat(int __ver, const char *__filename, struct stat *__stat_buf)
Index: stat64.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v
retrieving revision 1.3.6.1
retrieving revision 1.3.6.1.2.1
diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.1.2.1
--- stat64.c 12 May 2003 11:48:45 -0000 1.3.6.1
+++ stat64.c 9 Oct 2003 15:04:10 -0000 1.3.6.1.2.1
@@ -166,4 +166,4 @@ lstat64(const char *filename, struct sta
return __lxstat64(_STAT_VER, filename, buf);
}
-#endif /* defined(_LARGEFILE64_SOURCE) */
+#endif /* !_LARGEFILE64_SOURCE */
Index: statvfs.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v
retrieving revision 1.3.6.1
retrieving revision 1.3.6.1.2.1
diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.1.2.1
--- statvfs.c 12 May 2003 11:48:45 -0000 1.3.6.1
+++ statvfs.c 9 Oct 2003 15:04:10 -0000 1.3.6.1.2.1
@@ -43,6 +43,7 @@
#if !(defined(BSD) || defined(REDSTORM))
+#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
Index: truncate.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -w -b -B -p -r1.3 -r1.3.2.1
--- truncate.c 24 Mar 2003 22:09:07 -0000 1.3
+++ truncate.c 9 Oct 2003 15:04:10 -0000 1.3.2.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.2.1
diff -u -w -b -B -p -r1.3 -r1.3.2.1
--- unlink.c 24 Mar 2003 22:09:07 -0000 1.3
+++ unlink.c 9 Oct 2003 15:04:10 -0000 1.3.2.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.2
retrieving revision 1.2.16.1
diff -u -w -b -B -p -r1.2 -r1.2.16.1
--- write.c 7 Mar 2003 03:31:36 -0000 1.2
+++ write.c 9 Oct 2003 15:04:10 -0000 1.2.16.1
@@ -52,23 +52,24 @@
#include "sysio.h"
#include "file.h"
#include "inode.h"
-#include "fs.h"
-#include "mount.h"
+
+#include "sysio-symbols.h"
/*
* 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 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;
}
@@ -78,17 +79,13 @@ do_ipwritev(struct file *fil,
/*
* Huh? It's dead.
*/
- errno = -EBADF;
- return NULL;
- }
- if (IS_RDONLY(NULL, ino)) {
- errno = -EROFS;
+ errno = EBADF;
return NULL;
}
IOARG_INIT(&ioarguments,
iov, count,
offset,
- (void (*)(void *))_sysio_fcompletio, fil);
+ (void (*)(void *))fcompletio, fil);
err = ino->i_ops.inop_ipwritev(fil->f_ino, &ioarguments, &ioctx);
if (err) {
errno = -err;
@@ -98,10 +95,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;
@@ -112,15 +109,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];
@@ -132,10 +129,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;
@@ -146,10 +143,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;
@@ -159,8 +156,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)
@@ -174,14 +186,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)
@@ -205,6 +217,10 @@ writev(int fd, const struct iovec *iov,
return iowait(ioid);
}
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias( writev, _writev );
+#endif
+
ssize_t
write(int fd, const void *buf, size_t count)
{
@@ -216,6 +232,20 @@ write(int fd, const void *buf, size_t co
return iowait(ioid);
}
+#ifdef __GLIBC__
+#undef __write
+sysio_sym_weak_alias(write, __write)
+#endif
+
+#if _LARGEFILE64_SOURCE
+#undef write64
+sysio_sym_weak_alias(write, write64)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+sysio_sym_weak_alias(write, _write);
+#endif
+
#ifdef notdef
int
write_list(int fd,
@@ -230,3 +260,18 @@ write_list(int fd,
return -1;
}
#endif
+
+#if defined(__GLIBC__) && defined(ALPHA_LINUX)
+ssize_t
+__write(int fd, const void *buf, size_t count)
+{
+ return write(fd, buf, count);
+}
+
+ssize_t
+__writev(int fd, const struct iovec *iov, int count)
+{
+ return writev(fd, iov, count);
+}
+#endif
+
|