[Libsysio-commit] b_lustre: libsysio/src link.c rename.c utime.c Makefile.am chdir.c chmod.c chown.c
Brought to you by:
lward
|
From: Mei <me...@us...> - 2003-11-01 03:08:27
|
Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv28091/src
Modified Files:
Tag: b_lustre
Makefile.am chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c
getdirentries.c inode.c ioctl.c ioctx.c iowait.c lseek.c
mknod.c mount.c namei.c open.c read.c rmdir.c stat.c stat64.c
statvfs.c statvfs64.c truncate.c unlink.c write.c
Added Files:
Tag: b_lustre
link.c rename.c utime.c
Log Message:
merge HEAD into b_lustre, some fixes
--- 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 != -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 == old || old->p_cover ||
new->p_mount->mnt_root == new) {
err = -EBUSY;
goto error1;
}
if (old->p_mount->mnt_fs != new->p_mount->mnt_fs) {
/*
* Oops. They're trying to move it across file systems.
*/
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 (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;
}
break;
}
/*
* 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.4.3
retrieving revision 1.5.4.4
diff -u -w -b -B -p -r1.5.4.3 -r1.5.4.4
--- Makefile.am 18 Aug 2003 13:56:04 -0000 1.5.4.3
+++ Makefile.am 1 Nov 2003 03:08:22 -0000 1.5.4.4
@@ -3,14 +3,17 @@ lib_LIBRARIES = libsysio.a
if CYGWIN
libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \
fsync.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 \
- 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 statvfs64.c symlink.c truncate.c \
+ unlink.c \
+ utime.c write.c access.c
else
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 \
- bypass.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 statvfs64.c symlink.c truncate.c \
+ unlink.c \
+ utime.c write.c access.c bypass.c
endif
include $(top_srcdir)/Rules.make
Index: chdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v
retrieving revision 1.3.8.3
retrieving revision 1.3.8.4
diff -u -w -b -B -p -r1.3.8.3 -r1.3.8.4
--- chdir.c 15 Aug 2003 07:43:15 -0000 1.3.8.3
+++ chdir.c 1 Nov 2003 03:08:22 -0000 1.3.8.4
@@ -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,86 +78,60 @@
#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;
- SYSIO_ENTER;
- err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno);
- if (err) {
- errno = -err;
- SYSIO_LEAVE;
- return -1;
- }
+ /*
+ * Revalidate the pnode, and ensure it's a directory
+ */
+ err = _sysio_p_validate(pno, NULL, NULL);
+ if (err)
+ return err;
+ if (!(pno->p_base->pb_ino &&
+ S_ISDIR(pno->p_base->pb_ino->i_mode)))
+ return -ENOTDIR;
+ /*
+ * Release old if set.
+ */
if (_sysio_cwd)
P_RELE(_sysio_cwd);
+ /*
+ * Finally, change to the new.
+ */
_sysio_cwd = pno;
- SYSIO_LEAVE;
+
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;
SYSIO_ENTER;
- /*
- * 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;
+ SYSIO_LEAVE;
+ 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);
+
+ err = _sysio_p_chdir(pno);
SYSIO_LEAVE;
- return buf;
+ return err;
}
/*
@@ -183,11 +158,13 @@ _sysio_p_path(struct pnode *pno, char **
n = 0;
do {
/*
- * Traverse back through mounts.
+ * If this is a covering path-node then the name should be
+ * the *covered* nodes name, not this one unless we are at
+ * the root of the name-space.
*/
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
+ while (pno == pno->p_mount->mnt_root && pno != pno->p_parent )
+ pno = pno->p_mount->mnt_covers;
+
/*
* Add length of this component to running sum and
* account for this vertex.
@@ -222,11 +199,13 @@ _sysio_p_path(struct pnode *pno, char **
*cp = '\0'; /* NUL terminate */
do {
/*
- * Traverse back through mounts.
+ * If this is a covering path-node then the name should be
+ * the *covered* nodes name, not this one unless we are at
+ * the root of the name-space.
*/
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
+ while (pno == pno->p_mount->mnt_root && pno != pno->p_parent )
+ pno = pno->p_mount->mnt_covers;
+
/*
* Add component and separator.
*/
@@ -257,11 +236,20 @@ getcwd(char *buf, size_t size)
return buf;
}
-#if defined(__GLIBC__) && defined(ALPHA_LINUX)
+#ifdef __GLIBC__
+sysio_sym_weak_alias(getcwd, __getcwd)
+#endif
+
+#ifdef PATH_MAX
char *
-__getcwd(char *buf, size_t size)
+getwd(char *buf)
{
- return getcwd(buf, size);
+
+ if (!buf) {
+ errno = EFAULT;
+ return NULL;
}
-#endif
+ return getcwd(buf, PATH_MAX);
+}
+#endif
Index: chmod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v
retrieving revision 1.3.4.2
retrieving revision 1.3.4.3
diff -u -w -b -B -p -r1.3.4.2 -r1.3.4.3
--- chmod.c 29 Jun 2003 10:15:32 -0000 1.3.4.2
+++ chmod.c 1 Nov 2003 03:08:22 -0000 1.3.4.3
@@ -51,23 +51,33 @@
#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)
{
int err;
struct pnode *pno;
- struct intnl_stat stbuf;
- unsigned mask;
SYSIO_ENTER;
err = _sysio_namei(_sysio_cwd, path, 0, NULL, &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) {
@@ -75,5 +85,27 @@ out:
err = -1;
}
SYSIO_LEAVE;
+ 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;
+ err = -1;
+ }
return err;
}
Index: chown.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- chown.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ chown.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -51,19 +51,16 @@
#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;
SYSIO_ENTER;
- 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) {
@@ -74,10 +71,21 @@ 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) {
@@ -85,5 +93,27 @@ out:
err = -1;
}
SYSIO_LEAVE;
+ 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;
+ err = -1;
+ }
return err;
}
Index: dev.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -w -b -B -p -r1.2 -r1.2.4.1
--- dev.c 24 Mar 2003 22:09:06 -0000 1.2
+++ dev.c 1 Nov 2003 03:08:22 -0000 1.2.4.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: dup.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v
retrieving revision 1.1.1.1.12.1
retrieving revision 1.1.1.1.12.2
diff -u -w -b -B -p -r1.1.1.1.12.1 -r1.1.1.1.12.2
--- dup.c 29 Jun 2003 10:15:32 -0000 1.1.1.1.12.1
+++ dup.c 1 Nov 2003 03:08:22 -0000 1.1.1.1.12.2
@@ -49,6 +49,8 @@
#include "sysio.h"
#include "file.h"
+#include "sysio-symbols.h"
+
int
dup2(int oldfd, int newfd)
{
@@ -83,3 +85,9 @@ dup(int oldfd)
SYSIO_LEAVE;
return rc;
}
+
+#ifdef __GLIBC__
+#undef __dup
+sysio_sym_weak_alias(dup, __dup)
+#endif
+
Index: fcntl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v
retrieving revision 1.3.2.6
retrieving revision 1.3.2.7
diff -u -w -b -B -p -r1.3.2.6 -r1.3.2.7
--- fcntl.c 18 Aug 2003 13:56:04 -0000 1.3.2.6
+++ fcntl.c 1 Nov 2003 03:08:22 -0000 1.3.2.7
@@ -56,6 +56,8 @@
#include "file.h"
#include "bypass.h"
+#include "sysio-symbols.h"
+
int
fcntl(int fd, int cmd, ...)
{
@@ -110,17 +112,12 @@ out:
return err;
}
-#if defined(__GLIBC__) && defined(ALPHA_LINUX)
-int
-__fcntl(int fd, int cmd, ...)
-{
- int rc;
- va_list ap;
-
- va_start(ap, cmd);
- rc = fcntl(fd, cmd, ap);
- va_end(ap);
-
- return rc;
-}
+#ifdef __GLIBC__
+#undef __fcntl
+sysio_sym_weak_alias(fcntl, __fcntl)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+#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.8.2
retrieving revision 1.4.8.3
diff -u -w -b -B -p -r1.4.8.2 -r1.4.8.3
--- file.c 8 Sep 2003 03:58:17 -0000 1.4.8.2
+++ file.c 1 Nov 2003 03:08:22 -0000 1.4.8.3
@@ -128,14 +128,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.1.8.2
retrieving revision 1.1.8.3
diff -u -w -b -B -p -r1.1.8.2 -r1.1.8.3
--- getdirentries.c 15 Aug 2003 07:43:15 -0000 1.1.8.2
+++ getdirentries.c 1 Nov 2003 03:08:22 -0000 1.1.8.3
@@ -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;
@@ -43,6 +45,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
@@ -55,34 +64,60 @@ 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;
SYSIO_ENTER;
#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) {
/*
@@ -100,7 +135,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;
@@ -111,6 +146,9 @@ getdirentries(int fd, char *buf, size_t
goto out;
}
+#if defined(BSD) || defined(REDSTORM)
+ off = *basep;
+#endif
od64p = NULL;
d64p = ibuf;
for (;;) {
@@ -122,14 +160,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;
}
@@ -143,6 +189,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;
}
@@ -156,11 +205,16 @@ out:
}
cc = (char *)dp - buf;
if (cc)
- *basep = od64p->d_off;
+ *basep =
+#if !(defined(BSD) || defined(REDSTORM))
+ od64p->d_off;
+#else
+ off;
+#endif
SYSIO_LEAVE;
return cc;
-#ifdef __GNUC__
+#ifdef __GLIBC__
#undef _fast_alloc
#undef _fast_free
#endif
@@ -168,6 +222,10 @@ 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)
+#undef _getdirentries
+sysio_sym_weak_alias(getdirentries, _getdirentries)
+#endif
Index: inode.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v
retrieving revision 1.7.2.3
retrieving revision 1.7.2.4
diff -u -w -b -B -p -r1.7.2.3 -r1.7.2.4
--- inode.c 16 Sep 2003 10:09:40 -0000 1.7.2.3
+++ inode.c 1 Nov 2003 03:08:22 -0000 1.7.2.4
@@ -171,6 +171,23 @@ i_reclaim()
max_inodes += t;
}
+static unsigned
+hash(struct file_identifier *fid)
+{
+ size_t n;
+ void *p;
+ unsigned hkey;
+
+ n = fid->fid_len;
+ p = fid->fid_data;
+ hkey = 0;
+ do {
+ hkey <<= 1;
+ hkey += *(unsigned char *)p++;
+ } while (--n);
+ return hkey;
+}
+
/*
* Allocate and initialize a new i-node. Returned i-node is referenced.
*
@@ -179,7 +196,6 @@ i_reclaim()
*/
struct inode *
_sysio_i_new(struct filesys *fs,
- ino_t inum,
struct file_identifier *fid,
mode_t type,
dev_t rdev,
@@ -217,10 +233,10 @@ _sysio_i_new(struct filesys *fs,
ino->i_ops.inop_datasync = o->inop_datasync;
ino->i_ops.inop_ioctl = o->inop_ioctl;
}
- I_INIT(ino, fs, inum, type, rdev, &ino->i_ops, fid, immunity, private);
+ I_INIT(ino, fs, type, rdev, &ino->i_ops, fid, immunity, private);
ino->i_ref = 1;
TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes);
- head = &fs->fs_itbl[inum % FS_ITBLSIZ];
+ head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ];
LIST_INSERT_HEAD(head, ino, i_link);
n_inodes++;
@@ -234,18 +250,17 @@ _sysio_i_new(struct filesys *fs,
* and identifier.
*/
struct inode *
-_sysio_i_find(struct filesys *fs, ino_t inum, struct file_identifier *fid)
+_sysio_i_find(struct filesys *fs, struct file_identifier *fid)
{
struct inode *ino;
struct itable_entry *head;
- head = &fs->fs_itbl[inum % FS_ITBLSIZ];
+ head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ];
/*
* Look for existing.
*/
for (ino = head->lh_first; ino; ino = ino->i_link.le_next)
- if (ino->i_num == inum &&
- ino->i_fid->fid_len == fid->fid_len &&
+ if (ino->i_fid->fid_len == fid->fid_len &&
memcmp(ino->i_fid->fid_data,
fid->fid_data,
fid->fid_len) == 0) {
@@ -268,8 +283,8 @@ _sysio_i_gone(struct inode *ino)
abort();
#else
if (ino->i_ref)
- printf("_sysio_i_gone: inode(%lu, 0%o) still have ref %d\n",
- ino->i_num, ino->i_mode, ino->i_ref);
+ printf("_sysio_i_gone: inode(mode 0%o) still have ref %d\n",
+ ino->i_mode, ino->i_ref);
#endif
if (!ino->i_zombie)
LIST_REMOVE(ino, i_link);
@@ -503,43 +518,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);
Index: ioctl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v
retrieving revision 1.1.1.1.12.3
retrieving revision 1.1.1.1.12.4
diff -u -w -b -B -p -r1.1.1.1.12.3 -r1.1.1.1.12.4
--- ioctl.c 18 Aug 2003 13:56:04 -0000 1.1.1.1.12.3
+++ ioctl.c 1 Nov 2003 03:08:22 -0000 1.1.1.1.12.4
@@ -50,6 +50,8 @@
#include "inode.h"
#include "file.h"
+#include "sysio-symbols.h"
+
#ifdef __CYGWIN__
int
ioctl(int fd, int request, ...)
@@ -84,17 +86,12 @@ out:
}
-#if defined(__GLIBC__) && defined(ALPHA_LINUX)
-int
-__ioctl(int fd, unsigned long request, ...)
-{
- va_list ap;
- int rc;
-
- va_start(ap, request);
- rc = ioctl(fd, request, ap);
- va_end(ap);
+#ifdef __GLIBC__
+#undef __ioctl
+sysio_sym_weak_alias(ioctl, __ioctl)
+#endif
- return rc;
-}
+#if defined(BSD) || defined(REDSTORM)
+#undef _ioctl
+sysio_sym_weak_alias(ioctl, _ioctl)
#endif
Index: ioctx.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v
retrieving revision 1.2
retrieving revision 1.2.10.1
diff -u -w -b -B -p -r1.2 -r1.2.10.1
--- ioctx.c 7 Mar 2003 03:31:36 -0000 1.2
+++ ioctx.c 1 Nov 2003 03:08:22 -0000 1.2.10.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
@@ -145,7 +172,8 @@ _sysio_ioctx_wait(struct ioctx *ioctx)
/*
* Wait for async operation to complete.
*/
- while (!(*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx))
+ while (!(ioctx->ioctx_done ||
+ (*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)))
;
/*
@@ -170,26 +198,25 @@ _sysio_ioctx_wait(struct ioctx *ioctx)
void
_sysio_ioctx_complete(struct ioctx *ioctx)
{
- struct inode *ino;
+ struct ioctx_callback *entry;
/*
- * Unlink from the file record's outstanding request queue.
+ * Run the call-back queue.
*/
- LIST_REMOVE(ioctx, ioctx_link);
+ while ((entry = ioctx->ioctx_cbq.tqh_first)) {
+ TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next);
+ (*entry->iocb_f)(ioctx, entry->iocb_data);
+ free(entry);
+ }
+
+ if (ioctx->ioctx_fast)
+ return;
/*
- * Wait for IO to complete and remember completion values.
- */
- ino = ioctx->ioctx_ino;
- while (ino && !(*ino->i_ops.inop_iodone)(ioctx))
- ;
- /*
- * Notify interested parties.
+ * Unlink from the file record's outstanding request queue.
*/
- if (ioctx->ioctx_cb)
- (*ioctx->ioctx_cb)(ioctx);
-
- I_RELE(ino);
+ LIST_REMOVE(ioctx, ioctx_link);
+ I_RELE(ioctx->ioctx_ino);
free(ioctx);
}
Index: iowait.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/iowait.c,v
retrieving revision 1.3.8.1
retrieving revision 1.3.8.2
diff -u -w -b -B -p -r1.3.8.1 -r1.3.8.2
--- iowait.c 19 Jun 2003 12:18:29 -0000 1.3.8.1
+++ iowait.c 1 Nov 2003 03:08:22 -0000 1.3.8.2
@@ -75,7 +75,8 @@ iodone(ioid_t ioid)
if (!ioctx)
return -1;
- return (*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx);
+ return (ioctx->ioctx_done ||
+ (*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx));
}
/*
Index: lseek.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -u -w -b -B -p -r1.4.2.3 -r1.4.2.4
--- lseek.c 15 Aug 2003 10:03:29 -0000 1.4.2.3
+++ lseek.c 1 Nov 2003 03:08:22 -0000 1.4.2.4
@@ -53,12 +53,12 @@
#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;
- off64_t off = 0;
+ _SYSIO_OFF_T off = 0;
struct intnl_stat stbuf;
err = 0;
@@ -103,46 +103,63 @@ 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)
{
- off_t rc;
+ _SYSIO_OFF_T off;
+ off_t rtn;
SYSIO_ENTER;
- rc = (off_t )_sysio_lseek(fd, offset, whence);
-
+ off = _sysio_lseek(fd, offset, whence);
+ if (off < 0) {
SYSIO_LEAVE;
- return rc;
-}
-
-#if defined(__GLIBC__) && defined(ALPHA_LINUX)
-
-off_t
-__lseek(int fd, off_t offset, int whence)
-{
- return lseek(fd, offset, whence);
+ return -1;
}
-
-loff_t
-__lseek64( int fd, loff_t offset, int whence)
-{
- return lseek( fd, offset, whence );
+ rtn = (off_t )off;
+ if ((_SYSIO_OFF_T )rtn != off) {
+ errno = EINVAL;
+ SYSIO_LEAVE;
+ return -1;
}
-
-loff_t
-__llseek( int fd, loff_t offset, int whence)
-{
- return __lseek64(fd, offset, whence);
+ SYSIO_LEAVE;
+ return rtn;
}
-loff_t
-__llseek64( int fd, loff_t offset, int whence)
-{
- return __lseek64(fd, offset, whence);
+#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.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- mknod.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ mknod.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -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
retrieving revision 1.5.2.1
diff -u -w -b -B -p -r1.5 -r1.5.2.1
--- mount.c 18 Apr 2003 20:24:05 -0000 1.5
+++ mount.c 1 Nov 2003 03:08:22 -0000 1.5.2.1
@@ -102,12 +102,10 @@ _sysio_do_mount(struct filesys *fs,
{
struct mount *mnt;
int err;
- struct intnl_stat stbuf;
- 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,19 +140,21 @@ _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;
}
- ino = mnt->mnt_root->p_base->pb_ino;
- err = ino->i_ops.inop_getattr(mnt->mnt_root, ino, &stbuf);
- if (err)
- goto error;
/*
- * Begtter be a directory object!
+ * It may have been a while since the root inode was validated;
+ * better validate again. And it better be a directory!
*/
- if (!S_ISDIR(stbuf.st_mode)) {
+ err = _sysio_p_validate(mnt->mnt_root, NULL, NULL);
+ if (err)
+ goto error;
+
+ if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_mode)) {
err = -ENOTDIR;
goto error;
}
@@ -541,11 +541,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;
@@ -561,8 +562,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;
@@ -596,13 +596,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: namei.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v
retrieving revision 1.5.4.3
retrieving revision 1.5.4.4
diff -u -w -b -B -p -r1.5.4.3 -r1.5.4.4
--- namei.c 15 Aug 2003 07:43:15 -0000 1.5.4.3
+++ namei.c 1 Nov 2003 03:08:22 -0000 1.5.4.4
@@ -222,7 +222,7 @@ _sysio_path_walk(struct pnode *parent, s
ino->i_ops.inop_readlink(nd->nd_pno,
lpath,
MAXPATHLEN);
- if (err) {
+ if (err < 0) {
free(lpath);
break;
}
Index: open.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/open.c,v
retrieving revision 1.7.2.4
retrieving revision 1.7.2.5
diff -u -w -b -B -p -r1.7.2.4 -r1.7.2.5
--- open.c 15 Aug 2003 07:43:15 -0000 1.7.2.4
+++ open.c 1 Nov 2003 03:08:22 -0000 1.7.2.5
@@ -49,7 +49,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/queue.h>
-#include <features.h>
#include "sysio.h"
#include "inode.h"
@@ -58,12 +57,7 @@
#include "mount.h"
#include "sysio-symbols.h"
-#ifdef __GLIBC__
-#undef open
-#undef __open
-#undef open64
-#undef __open64
-#endif
+#include "sysio-symbols.h"
/*
* Open file support.
@@ -125,6 +119,8 @@ _sysio_open(struct pnode *pno, int flags
return err;
}
+#undef open
+
int
open(const char *path, int flags, ...)
{
@@ -154,7 +150,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 */
@@ -210,7 +211,19 @@ 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)
+#undef _open
+sysio_sym_weak_alias(open, _open)
+#endif
int
close(int fd)
@@ -225,6 +238,16 @@ close(int fd)
return err ? -1 : 0;
}
+#ifdef __GLIBC__
+#undef __close
+sysio_sym_weak_alias(close, __close)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+#undef _close
+sysio_sym_weak_alias(close, _close)
+#endif
+
int
creat(const char *path, mode_t mode)
{
@@ -232,7 +255,19 @@ 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
+
+#if defined(BSD) || defined(REDSTORM)
+#undef _creat
+sysio_sym_weak_alias(creat, _creat)
+#endif
mode_t
umask(mode_t mask)
@@ -243,49 +278,3 @@ 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.8.7
retrieving revision 1.2.8.8
diff -u -w -b -B -p -r1.2.8.7 -r1.2.8.8
--- read.c 8 Sep 2003 03:58:17 -0000 1.2.8.7
+++ read.c 1 Nov 2003 03:08:22 -0000 1.2.8.8
@@ -57,17 +57,19 @@
#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,
- off64_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) {
@@ -83,12 +85,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;
}
@@ -99,7 +112,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;
@@ -113,8 +126,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);
SYSIO_LEAVE;
return ioctxp ? ioctxp->ioctx_id : IOID_FAIL;
}
@@ -123,7 +135,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];
@@ -138,7 +150,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;
@@ -151,8 +163,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;
@@ -162,6 +174,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.
*/
@@ -180,10 +207,13 @@ 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) {
SYSIO_LEAVE;
- return ioctxp ? ioctxp->ioctx_id : IOID_FAIL;
+ return IOID_FAIL;
+ }
+ SYSIO_LEAVE;
+ return ioctxp->ioctx_id;
}
/*
@@ -211,6 +241,11 @@ readv(int fd, const struct iovec *iov, i
return iowait(ioid);
}
+#if defined(BSD) || defined(REDSTORM)
+#undef _readv
+sysio_sym_weak_alias(readv, _readv)
+#endif
+
ssize_t
read(int fd, void *buf, size_t count)
{
@@ -222,6 +257,21 @@ read(int fd, void *buf, size_t count)
return iowait(ioid);
}
+#ifdef __GLIBC__
+#undef __read
+sysio_sym_weak_alias(read, __read)
+#endif
+
+#if defined(BSD) || defined(REDSTORM)
+#undef _read
+sysio_sym_weak_alias(read, _read)
+#endif
+
+#if _LARGEFILE64_SOURCE
+#undef read64
+sysio_sym_weak_alias(read, read64)
+#endif
+
#ifdef notdef
int
read_list(int fd,
@@ -234,13 +284,5 @@ 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.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- rmdir.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ rmdir.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -69,6 +69,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.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- stat.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ stat.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -62,8 +62,29 @@
#undef __xstat
#undef __lxstat
-#if !(defined(__GNUC__) && __GNUC__ >= 2)
-#warning Check assumptions here about stat/stat64 sizes and offsets
+#if !defined(_STAT_VER)
+#define _STAT_VER 0
+#endif
+
+#if _LARGEFILE64_SOURCE
+static void
+convstat(struct stat64 *st64_buf, struct stat *st_buf)
+{
+
+ st_buf->st_dev = st64_buf->st_dev;
+ st_buf->st_ino = st64_buf->st_ino;
+ st_buf->st_mode = st64_buf->st_mode;
+ st_buf->st_nlink = st64_buf->st_nlink;
+ st_buf->st_uid = st64_buf->st_uid;
+ st_buf->st_gid = st64_buf->st_gid;
+ st_buf->st_rdev = st64_buf->st_rdev;
+ st_buf->st_size = st64_buf->st_size;
+ st_buf->st_blksize = st64_buf->st_blksize;
+ st_buf->st_blocks = st64_buf->st_blocks;
+ st_buf->st_atime = st64_buf->st_atime;
+ st_buf->st_mtime = st64_buf->st_mtime;
+ st_buf->st_ctime = st64_buf->st_ctime;
+}
#endif
int
@@ -71,6 +92,10 @@ __fxstat(int __ver, int __fildes, struct
{
struct file *fil;
int err;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -83,15 +108,21 @@ __fxstat(int __ver, int __fildes, struct
err = -EBADF;
goto out;
}
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
err =
- fil->f_ino->i_ops.inop_getattr(NULL,
- fil->f_ino,
- (struct intnl_stat *)__stat_buf);
+ fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, buf);
out:
if (err) {
errno = -err;
err = -1;
}
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
return err;
}
@@ -109,6 +140,11 @@ __fstat(int fd, struct stat *buf)
sysio_sym_weak_alias(__fstat, fstat)
+#if defined(BSD) || defined(REDSTORM)
+#undef _fstat
+sysio_sym_weak_alias(__fstat, _fstat)
+#endif
+
int
__xstat(int __ver, const char *__filename, struct stat *__stat_buf)
{
@@ -116,6 +152,10 @@ __xstat(int __ver, const char *__filenam
int err;
struct pnode *pno;
struct inode *ino;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -127,11 +167,19 @@ __xstat(int __ver, const char *__filenam
if (err)
goto out;
ino = pno->p_base->pb_ino;
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
err =
ino->i_ops.inop_getattr(pno,
pno->p_base->pb_ino,
- (struct intnl_stat *)__stat_buf);
+ buf);
P_RELE(pno);
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
out:
if (err) {
errno = -err;
@@ -140,7 +188,7 @@ out:
return err;
}
-int
+static int
__stat(const char *filename, struct stat *buf)
{
int rc;
@@ -154,6 +202,11 @@ __stat(const char *filename, struct stat
sysio_sym_weak_alias(__stat, stat)
+#if defined(BSD) || defined(REDSTORM)
+#undef _stat
+sysio_sym_weak_alias(__stat, _stat)
+#endif
+
int
__lxstat(int __ver, const char *__filename, struct stat *__stat_buf)
{
@@ -161,6 +214,10 @@ __lxstat(int __ver, const char *__filena
int err;
struct pnode *pno;
struct inode *ino;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -171,12 +228,20 @@ __lxstat(int __ver, const char *__filena
err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno);
if (err)
goto out;
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
ino = pno->p_base->pb_ino;
err =
ino->i_ops.inop_getattr(pno,
pno->p_base->pb_ino,
- (struct intnl_stat *)__stat_buf);
+ buf);
P_RELE(pno);
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
out:
if (err) {
errno = -err;
@@ -199,3 +264,7 @@ __lstat(const char *filename, struct sta
sysio_sym_weak_alias(__lstat, lstat)
+#if defined(BSD) || defined(REDSTORM)
+#undef _lstat
+sysio_sym_weak_alias(__lstat, _lstat)
+#endif
Index: stat64.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- stat64.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ stat64.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -41,6 +41,8 @@
* le...@sa...
*/
+#ifdef _LARGEFILE64_SOURCE
+
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
@@ -179,3 +181,4 @@ lstat64(const char *filename, struct sta
SYSIO_LEAVE;
return rc;
}
+#endif /* !_LARGEFILE64_SOURCE */
Index: statvfs.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v
retrieving revision 1.3.4.2
retrieving revision 1.3.4.3
diff -u -w -b -B -p -r1.3.4.2 -r1.3.4.3
--- statvfs.c 18 Aug 2003 13:56:04 -0000 1.3.4.2
+++ statvfs.c 1 Nov 2003 03:08:22 -0000 1.3.4.3
@@ -41,6 +41,10 @@
* le...@sa...
*/
+#ifdef _HAVE_STATVFS
+
+#if !(defined(BSD) || defined(REDSTORM))
+
#include <unistd.h>
#include <errno.h>
#include <assert.h>
@@ -144,3 +148,5 @@ out:
SYSIO_LEAVE;
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.4.1
retrieving revision 1.3.4.2
diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2
--- statvfs64.c 29 Jun 2003 10:15:32 -0000 1.3.4.1
+++ statvfs64.c 1 Nov 2003 03:08:22 -0000 1.3.4.2
@@ -41,6 +41,9 @@
* le...@sa...
*/
+#ifdef _HAVE_STATVFS
+
+#if !(defined(BSD) || defined(REDSTORM))
#include <unistd.h>
#include <errno.h>
#include <assert.h>
@@ -76,7 +79,7 @@ out:
}
int
-fstatvfs(int fd, struct statvfs64 *buf)
+fstatvfs64(int fd, struct statvfs64 *buf)
{
int err;
struct file *filp;
@@ -99,3 +102,5 @@ out:
SYSIO_LEAVE;
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.4.2
retrieving revision 1.3.4.3
diff -u -w -b -B -p -r1.3.4.2 -r1.3.4.3
--- truncate.c 15 Aug 2003 07:14:01 -0000 1.3.4.2
+++ truncate.c 1 Nov 2003 03:08:23 -0000 1.3.4.3
@@ -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, off64_t length)
+do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length)
{
struct intnl_stat stbuf;
unsigned mask;
@@ -66,8 +68,10 @@ do_truncate(struct pnode *pno, struct in
ino = pno->p_base->pb_ino;
if (!ino)
return -EBADF;
+ if (S_ISDIR(ino->i_mode)) /* for others too? */
+ return -EISDIR;
if (!S_ISREG(ino->i_mode))
- return -EISDIR; /* for others too? */
+ return -EINVAL;
(void )memset(&stbuf, 0, sizeof(stbuf));
stbuf.st_size = length;
@@ -75,8 +79,8 @@ do_truncate(struct pnode *pno, struct in
return _sysio_setattr(pno, ino, mask, &stbuf);
}
-int
-truncate64(const char *path, off64_t length)
+static int
+_truncate(const char *path, _SYSIO_OFF_T length)
{
int err;
struct pnode *pno;
@@ -97,13 +101,24 @@ out:
return err;
}
-int truncate(const char *path, off_t length)
+#if _LARGEFILE64_SOURCE
+#undef truncate64
+sysio_sym_weak_alias(_truncate, truncate64)
+
+#undef truncate
+int
+truncate(const char *path, off_t length)
{
- return truncate64(path, length);
+
+ return _truncate(path, length);
}
+#else
+#undef truncate
+sysio_sym_weak_alias(_truncate, truncate)
+#endif
-int
-ftruncate64(int fd, off64_t length)
+static int
+_ftruncate(int fd, _SYSIO_OFF_T length)
{
int err;
struct file *fil;
@@ -125,8 +140,18 @@ out:
return err;
}
+#if _LARGEFILE64_SOURCE
+#undef ftruncate64
+sysio_sym_weak_alias(_ftruncate, ftruncate64)
+
+#undef ftruncate
int
ftruncate(int fd, off_t length)
{
- return ftruncate64(fd, 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.4.2
retrieving revision 1.3.4.3
diff -u -w -b -B -p -r1.3.4.2 -r1.3.4.3
--- unlink.c 29 Jun 2003 10:15:32 -0000 1.3.4.2
+++ unlink.c 1 Nov 2003 03:08:23 -0000 1.3.4.3
@@ -69,6 +69,13 @@ unlink(const char *path)
goto error;
}
err = (*pno->p_base->pb_ino->i_o...
[truncated message content] |