[Libsysio-commit] b_lustre: libsysio/src access.c Makefile.am chdir.c fcntl.c file.c getdirentries.c
Brought to you by:
lward
|
From: Mei <me...@us...> - 2003-08-15 07:58:36
|
Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv25257/src
Modified Files:
Tag: b_lustre
Makefile.am chdir.c fcntl.c file.c getdirentries.c inode.c
ioctl.c lseek.c namei.c open.c read.c write.c
Added Files:
Tag: b_lustre
access.c
Log Message:
merge changes from HEAD to b_lustre
--- 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 <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int
access(const char *path, int amode)
{
gid_t *list, *entry;
size_t n;
int err = 0;
unsigned mask, mode;
struct stat stbuf;
err = 0;
n = getgroups(0, NULL);
list = NULL;
if (n) {
list = malloc(n * sizeof(gid_t));
if (!list) {
err = -1;
goto out;
}
}
err = getgroups(n, list);
if (err != (int ) n)
goto out;
err = stat(path, &stbuf);
if (err)
goto out;
mask = 0;
if (amode & R_OK)
mask |= S_IRUSR;
if (amode & W_OK)
mask |= S_IWUSR;
if (amode & X_OK)
mask |= S_IXUSR;
mode = stbuf.st_mode;
if (stbuf.st_uid == getuid() && (mode & mask) == mask)
goto out;
mask >>= 3;
if (stbuf.st_gid == getgid() && (mode & mask) == mask)
goto out;
entry = list;
while (n--)
if (stbuf.st_gid == *entry++ && (mode & mask) == mask)
goto out;
mask >>= 3;
if ((mode & mask) == mask)
goto out;
err = -1;
out:
if (list)
free(list);
return err;
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -w -b -B -p -r1.5.4.1 -r1.5.4.2
--- Makefile.am 19 Jun 2003 12:18:28 -0000 1.5.4.1
+++ Makefile.am 15 Aug 2003 07:43:15 -0000 1.5.4.2
@@ -3,6 +3,14 @@ lib_LIBRARIES = libsysio.a
libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \
fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \
lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \
- stat64.c statvfs.c symlink.c truncate.c unlink.c write.c bypass.c
+ stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c \
+ bypass.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: chdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v
retrieving revision 1.3.8.2
retrieving revision 1.3.8.3
diff -u -w -b -B -p -r1.3.8.2 -r1.3.8.3
--- chdir.c 29 Jun 2003 10:15:32 -0000 1.3.8.2
+++ chdir.c 15 Aug 2003 07:43:15 -0000 1.3.8.3
@@ -256,3 +256,12 @@ getcwd(char *buf, size_t size)
SYSIO_LEAVE;
return buf;
}
+
+#if defined(__GLIBC__) && defined(ALPHA_LINUX)
+char *
+__getcwd(char *buf, size_t size)
+{
+ return getcwd(buf, size);
+}
+#endif
+
Index: fcntl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -w -b -B -p -r1.3.2.4 -r1.3.2.5
--- fcntl.c 29 Jun 2003 10:15:32 -0000 1.3.2.4
+++ fcntl.c 15 Aug 2003 07:43:15 -0000 1.3.2.5
@@ -106,3 +106,18 @@ out:
SYSIO_LEAVE;
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;
+}
+#endif
Index: file.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/file.c,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -u -w -b -B -p -r1.4 -r1.4.8.1
--- file.c 9 Mar 2003 17:18:57 -0000 1.4
+++ file.c 15 Aug 2003 07:43:15 -0000 1.4.8.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.8.1
retrieving revision 1.1.8.2
diff -u -w -b -B -p -r1.1.8.1 -r1.1.8.2
--- getdirentries.c 29 Jun 2003 10:15:32 -0000 1.1.8.1
+++ getdirentries.c 15 Aug 2003 07:43:15 -0000 1.1.8.2
@@ -63,7 +63,7 @@ getdirentries(int fd, char *buf, size_t
off64_t ibase;
ssize_t cc;
struct dirent *dp, *nxtdp;
- struct dirent64 *od64p, *d64p;
+ struct dirent64 *od64p = NULL, *d64p = NULL;
size_t n;
size_t reclen;
char *cp;
Index: inode.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -w -b -B -p -r1.7.2.1 -r1.7.2.2
--- inode.c 17 Jun 2003 03:38:31 -0000 1.7.2.1
+++ inode.c 15 Aug 2003 07:43:15 -0000 1.7.2.2
@@ -271,6 +271,7 @@ _sysio_i_gone(struct inode *ino)
printf("_sysio_i_gone: inode(%lu, 0%o) still have ref %d\n",
ino->i_num, ino->i_mode, ino->i_ref);
#endif
+ if (!ino->i_zombie)
LIST_REMOVE(ino, i_link);
TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes);
(*ino->i_ops.inop_gone)(ino);
@@ -278,6 +279,17 @@ _sysio_i_gone(struct inode *ino)
assert(n_inodes);
n_inodes--;
+}
+
+/*
+ * Stale inode, zombie it and move it out of the way
+ */
+void
+_sysio_i_undead(struct inode *ino)
+{
+
+ LIST_REMOVE(ino, i_link);
+ ino->i_zombie = 1;
}
/*
Index: ioctl.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/ioctl.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
--- ioctl.c 29 Jun 2003 10:15:32 -0000 1.1.1.1.12.1
+++ ioctl.c 15 Aug 2003 07:43:15 -0000 1.1.1.1.12.2
@@ -77,3 +77,19 @@ out:
SYSIO_LEAVE;
return err;
}
+
+
+#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);
+
+ return rc;
+}
+#endif
Index: lseek.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -w -b -B -p -r1.4.2.1 -r1.4.2.2
--- lseek.c 29 Jun 2003 10:15:32 -0000 1.4.2.1
+++ lseek.c 15 Aug 2003 07:43:15 -0000 1.4.2.2
@@ -58,7 +58,7 @@ _sysio_lseek(int fd, off64_t offset, int
{
int err;
struct file *fil;
- off_t off;
+ off_t off = 0;
struct intnl_stat stbuf;
err = 0;
@@ -118,3 +118,31 @@ lseek(int fd, off_t offset, int whence)
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);
+}
+
+loff_t
+__lseek64( int fd, loff_t offset, int whence)
+{
+ return lseek( fd, offset, whence );
+}
+
+loff_t
+__llseek( int fd, loff_t offset, int whence)
+{
+ return __lseek64(fd, offset, whence);
+}
+
+loff_t
+__llseek64( int fd, loff_t offset, int whence)
+{
+ return __lseek64(fd, offset, whence);
+}
+
+#endif
Index: namei.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v
retrieving revision 1.5.4.2
retrieving revision 1.5.4.3
diff -u -w -b -B -p -r1.5.4.2 -r1.5.4.3
--- namei.c 18 May 2003 15:36:49 -0000 1.5.4.2
+++ namei.c 15 Aug 2003 07:43:15 -0000 1.5.4.3
@@ -293,8 +293,7 @@ _sysio_path_walk(struct pnode *parent, s
* Must send the intent-path again.
*/
path = nd->nd_path;
- } else if (err == -ENOENT)
- err = 0;
+ }
if (!err) {
P_RELE(pno);
nd->nd_amcnt++;
@@ -435,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.
@@ -449,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.2.3
retrieving revision 1.7.2.4
diff -u -w -b -B -p -r1.7.2.3 -r1.7.2.4
--- open.c 15 Aug 2003 06:17:24 -0000 1.7.2.3
+++ open.c 15 Aug 2003 07:43:15 -0000 1.7.2.4
@@ -49,6 +49,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/queue.h>
+#include <features.h>
#include "sysio.h"
#include "inode.h"
@@ -57,6 +58,13 @@
#include "mount.h"
#include "sysio-symbols.h"
+#ifdef __GLIBC__
+#undef open
+#undef __open
+#undef open64
+#undef __open64
+#endif
+
/*
* Open file support.
*/
@@ -235,3 +243,49 @@ 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.3
retrieving revision 1.2.8.4
diff -u -w -b -B -p -r1.2.8.3 -r1.2.8.4
--- read.c 29 Jun 2003 10:15:32 -0000 1.2.8.3
+++ read.c 15 Aug 2003 07:43:15 -0000 1.2.8.4
@@ -234,3 +234,11 @@ read_list(int fd,
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: write.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/write.c,v
retrieving revision 1.2.10.3
retrieving revision 1.2.10.4
diff -u -w -b -B -p -r1.2.10.3 -r1.2.10.4
--- write.c 29 Jun 2003 10:15:32 -0000 1.2.10.3
+++ write.c 15 Aug 2003 07:43:15 -0000 1.2.10.4
@@ -239,3 +239,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
+
|