libsysio-commit Mailing List for libsysio (Page 45)
Brought to you by:
lward
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(25) |
May
(28) |
Jun
(25) |
Jul
(30) |
Aug
(60) |
Sep
(52) |
Oct
(100) |
Nov
(15) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(89) |
Feb
(48) |
Mar
(22) |
Apr
(59) |
May
(16) |
Jun
(15) |
Jul
(50) |
Aug
(26) |
Sep
(40) |
Oct
(27) |
Nov
(12) |
Dec
|
2005 |
Jan
(24) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(6) |
Jul
|
Aug
(14) |
Sep
(21) |
Oct
(10) |
Nov
|
Dec
|
2006 |
Jan
(8) |
Feb
(5) |
Mar
(2) |
Apr
(6) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2007 |
Jan
(3) |
Feb
(5) |
Mar
(20) |
Apr
(41) |
May
(21) |
Jun
(3) |
Jul
(5) |
Aug
(12) |
Sep
(21) |
Oct
(5) |
Nov
(16) |
Dec
|
2008 |
Jan
|
Feb
(2) |
Mar
(4) |
Apr
(23) |
May
|
Jun
(22) |
Jul
(13) |
Aug
|
Sep
|
Oct
(9) |
Nov
(3) |
Dec
(13) |
2009 |
Jan
(14) |
Feb
(10) |
Mar
(2) |
Apr
(11) |
May
(7) |
Jun
(1) |
Jul
(1) |
Aug
(36) |
Sep
(12) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mei <me...@us...> - 2003-08-18 14:23:24
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv29635 Modified Files: Tag: b_lustre configure.in Log Message: fixes for build libsysio under Cygwin: - add include/cygwin-defs.h - disable _LARGEFILE64_SOURCE - autoconf test for host_os "cygwin" - exclude getdentries.c, bypass.c, stat64.c for cygwin build - don't include <syscall.h>, <statvfs.h> Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,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 --- configure.in 15 Aug 2003 07:43:14 -0000 1.5.4.1 +++ configure.in 18 Aug 2003 13:56:04 -0000 1.5.4.2 @@ -5,6 +5,8 @@ AC_CANONICAL_HOST case "$host_os" in linux-gnu) ;; + cygwin) + ;; *) AC_MSG_WARN('***' ${host_os}: Unsupported OS target) ;; @@ -97,6 +99,8 @@ AC_ARG_WITH(cplant_tests, esac], [with_cplant_tests=no]) AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno) + +AM_CONDITIONAL(CYGWIN, test x$host_os = xcygwin) # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses |
From: Mei <me...@us...> - 2003-08-18 14:08:04
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv29635/include Modified Files: Tag: b_lustre sysio.h Added Files: Tag: b_lustre cygwin-defs.h Log Message: fixes for build libsysio under Cygwin: - add include/cygwin-defs.h - disable _LARGEFILE64_SOURCE - autoconf test for host_os "cygwin" - exclude getdentries.c, bypass.c, stat64.c for cygwin build - don't include <syscall.h>, <statvfs.h> --- NEW FILE --- /* * Copyright (C) 2003, Cluster File Systems, Inc. * * This code is issued under the GNU General Public License * * add the missing definitions for Cygwin */ #ifndef CYGWIN_DEFS_H #define CYGWIN_DEFS_H #ifndef off64_t #if defined (__alpha__) || defined (__ia64__) typedef long off64_t; #else typedef long long off64_t; #endif #endif /* * VER defs is actually not used under cygwin, simply define to 0 */ #define _MKNOD_VER (0) #define _STAT_VER (0) /* FIXME * glibc in cygwin doesn't support LARGEFILE64. disable it here, but * need further checking 64 bits file I/O support. */ #undef _LARGEFILE64_SOURCE /* * bypass should NEVER happen under cygwin. nullify them. */ struct iovec; static inline ioid_t __bypass_ireadv(int fd, const struct iovec *iov, int count) { return 0; }; static inline ioid_t __bypass_preadv(int fd, const struct iovec *iov, int count, off_t offset) { return 0; }; static inline ioid_t __bypass_iwritev(int fd, const struct iovec *iov, int count) { return 0; }; static inline ioid_t __bypass_pwritev(int fd, const struct iovec *iov, int count, off_t offset) { return 0; }; static inline int __bypass_fcntl(int fd, int cmd, va_list ap) { return -1; }; #endif /* CYGWIN_DEFS_H */ Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7.4.2 retrieving revision 1.7.4.3 diff -u -w -b -B -p -r1.7.4.2 -r1.7.4.3 --- sysio.h 15 Aug 2003 07:43:15 -0000 1.7.4.2 +++ sysio.h 18 Aug 2003 13:56:04 -0000 1.7.4.3 @@ -79,6 +79,11 @@ typedef void *ioid_t; #define MAX_SYMLINK 250 #endif +/* cygwin specific definitions */ +#ifdef __CYGWIN__ +#include "cygwin-defs.h" +#endif + /* * Internally, all directory entries are carried in the 64-bit capable * structure. @@ -150,7 +155,11 @@ extern int rmdir(const char *path); extern int symlink(const char *path1, const char *path2); extern int unlink(const char *path); extern int fdatasync(int fd); +#ifndef __CYGWIN__ extern int ioctl(int fd, unsigned long request, ...); +#else +extern int ioctl(int fd, int request, ...); +#endif extern mode_t umask(mode_t mask); extern int iodone(ioid_t ioid); extern ssize_t iowait(ioid_t ioid); |
From: Mei <me...@us...> - 2003-08-18 13:56:07
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv29635/src Modified Files: Tag: b_lustre Makefile.am fcntl.c ioctl.c read.c statvfs.c write.c Log Message: fixes for build libsysio under Cygwin: - add include/cygwin-defs.h - disable _LARGEFILE64_SOURCE - autoconf test for host_os "cygwin" - exclude getdentries.c, bypass.c, stat64.c for cygwin build - don't include <syscall.h>, <statvfs.h> Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,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 --- Makefile.am 15 Aug 2003 07:43:15 -0000 1.5.4.2 +++ Makefile.am 18 Aug 2003 13:56:04 -0000 1.5.4.3 @@ -1,10 +1,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 +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 +endif include $(top_srcdir)/Rules.make Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.2.5 retrieving revision 1.3.2.6 diff -u -w -b -B -p -r1.3.2.5 -r1.3.2.6 --- fcntl.c 15 Aug 2003 07:43:15 -0000 1.3.2.5 +++ fcntl.c 18 Aug 2003 13:56:04 -0000 1.3.2.6 @@ -46,7 +46,10 @@ #include <sys/types.h> #include <fcntl.h> #include <sys/queue.h> + +#ifndef __CYGWIN__ #include <syscall.h> +#endif #include "sysio.h" #include "inode.h" Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1.12.2 retrieving revision 1.1.1.1.12.3 diff -u -w -b -B -p -r1.1.1.1.12.2 -r1.1.1.1.12.3 --- ioctl.c 15 Aug 2003 07:43:15 -0000 1.1.1.1.12.2 +++ ioctl.c 18 Aug 2003 13:56:04 -0000 1.1.1.1.12.3 @@ -50,8 +50,13 @@ #include "inode.h" #include "file.h" +#ifdef __CYGWIN__ +int +ioctl(int fd, int request, ...) +#else int ioctl(int fd, unsigned long request, ...) +#endif { int err; struct file *fil; Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.8.5 retrieving revision 1.2.8.6 diff -u -w -b -B -p -r1.2.8.5 -r1.2.8.6 --- read.c 15 Aug 2003 10:03:29 -0000 1.2.8.5 +++ read.c 18 Aug 2003 13:56:04 -0000 1.2.8.6 @@ -48,7 +48,10 @@ #include <fcntl.h> #include <sys/uio.h> #include <sys/queue.h> + +#ifndef __CYGWIN__ #include <syscall.h> +#endif #include "sysio.h" #include "file.h" Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.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 --- statvfs.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 +++ statvfs.c 18 Aug 2003 13:56:04 -0000 1.3.4.2 @@ -44,9 +44,13 @@ #include <unistd.h> #include <errno.h> #include <assert.h> -#include <sys/statvfs.h> #include <sys/types.h> #include <sys/queue.h> +#ifndef __CYGWIN__ +#include <sys/statvfs.h> +#else +#include <sys/statfs.h> +#endif #include "sysio.h" #include "inode.h" Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.10.5 retrieving revision 1.2.10.6 diff -u -w -b -B -p -r1.2.10.5 -r1.2.10.6 --- write.c 15 Aug 2003 10:03:29 -0000 1.2.10.5 +++ write.c 18 Aug 2003 13:56:04 -0000 1.2.10.6 @@ -48,7 +48,9 @@ #include <fcntl.h> #include <sys/uio.h> #include <sys/queue.h> +#ifndef __CYGWIN__ #include <syscall.h> +#endif #include "sysio.h" #include "file.h" |
From: Sonja T. <so...@us...> - 2003-08-15 22:07:43
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv10760/libsysio/tests Modified Files: Makefile.am Added Files: README help.c helper.pm populator.pl sysio_stubs.c sysio_tests.c test_all.pl test_copy.pl test_driver.c test_driver.h test_getcwd.pl test_list.pl test_path.pl test_stats.pl test_stdfd.pl verifier.pl Log Message: Merging libsysio_tests with main Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- Makefile.am 14 Aug 2003 18:39:33 -0000 1.10 +++ Makefile.am 14 Aug 2003 21:16:33 -0000 1.11 @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd + test_getcwd test_stdfd test_driver CLEANFILES=drv_data.c @@ -46,7 +46,8 @@ DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_D CMNSRC=drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c - +check_PROGRAMS=test_driver +TESTS=test_all.pl CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) @@ -90,7 +91,12 @@ test_stdfd_CFLAGS=$(CFL) test_stdfd_LDADD=$(LIBS) test_stdfd_DEPENDENCIES=$(LIBS) -EXTRA_DIST=gendrvdata.sh test.h +test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) +test_driver_CFLAGS=$(CFL) +test_driver_LDADD=$(LIBS) +test_driver_DEPENDENCIES=$(LIBS) + +EXTRA_DIST=gendrvdata.sh test.h test_driver.h drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh test -z "drv_data.c" && rm -f drv_data.c; \ |
From: Mei <me...@us...> - 2003-08-15 10:09:34
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv15813 Modified Files: Tag: b_lustre lseek.c read.c write.c Log Message: 64 bits clean for: - lseek - write - read Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -w -b -B -p -r1.4.2.2 -r1.4.2.3 --- lseek.c 15 Aug 2003 07:43:15 -0000 1.4.2.2 +++ lseek.c 15 Aug 2003 10:03:29 -0000 1.4.2.3 @@ -58,7 +58,7 @@ _sysio_lseek(int fd, off64_t offset, int { int err; struct file *fil; - off_t off = 0; + off64_t off = 0; struct intnl_stat stbuf; err = 0; Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.8.4 retrieving revision 1.2.8.5 diff -u -w -b -B -p -r1.2.8.4 -r1.2.8.5 --- read.c 15 Aug 2003 07:43:15 -0000 1.2.8.4 +++ read.c 15 Aug 2003 10:03:29 -0000 1.2.8.5 @@ -61,7 +61,7 @@ static struct ioctx * do_ipreadv(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + off64_t offset) { struct inode *ino; int err; Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.10.4 retrieving revision 1.2.10.5 diff -u -w -b -B -p -r1.2.10.4 -r1.2.10.5 --- write.c 15 Aug 2003 07:43:15 -0000 1.2.10.4 +++ write.c 15 Aug 2003 10:03:29 -0000 1.2.10.5 @@ -63,7 +63,7 @@ static struct ioctx * do_ipwritev(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + off64_t offset) { struct inode *ino; int err; |
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 + |
From: Mei <me...@us...> - 2003-08-15 07:54:49
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv20482 Modified Files: Tag: b_lustre truncate.c Log Message: add 64 bits ability into truncate() family. Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.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 --- truncate.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 +++ truncate.c 15 Aug 2003 07:14:01 -0000 1.3.4.2 @@ -57,7 +57,7 @@ * 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, off64_t length) { struct intnl_stat stbuf; unsigned mask; @@ -76,7 +76,7 @@ do_truncate(struct pnode *pno, struct in } int -truncate(const char *path, off_t length) +truncate64(const char *path, off64_t length) { int err; struct pnode *pno; @@ -97,8 +97,13 @@ out: return err; } +int truncate(const char *path, off_t length) +{ + return truncate64(path, length); +} + int -ftruncate(int fd, off_t length) +ftruncate64(int fd, off64_t length) { int err; struct file *fil; @@ -118,4 +123,10 @@ out: } SYSIO_LEAVE; return err; +} + +int +ftruncate(int fd, off_t length) +{ + return ftruncate64(fd, length); } |
From: Mei <me...@us...> - 2003-08-15 07:54:27
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv25257/drivers/native Modified Files: Tag: b_lustre fs_native.c Log Message: merge changes from HEAD to b_lustre Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.2.2 retrieving revision 1.11.2.3 diff -u -w -b -B -p -r1.11.2.2 -r1.11.2.3 --- fs_native.c 19 Jun 2003 12:24:30 -0000 1.11.2.2 +++ fs_native.c 15 Aug 2003 07:43:15 -0000 1.11.2.3 @@ -116,9 +116,19 @@ do { (dest)->st_gen = (src)->st_gen; \ } while (0); +/* SYS_lseek has a different interface on alpha + */ +#define CALL_LSEEK(fd, off, rc, wh) \ + (rc = syscall(SYS_lseek, fd, off, wh)) + #else + #define __native_stat intnl_stat #define COPY_STAT(src, dest) *(dest) = *(src) + +#define CALL_LSEEK(fd, off, rc, wh) \ + (syscall(SYS_lseek, fd, off, &rc, wh)) + #endif #if defined(USE_NATIVE_STAT) @@ -151,6 +161,9 @@ do { struct native_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -290,10 +303,12 @@ static int native_fstat(int fd, struct intnl_stat *buf) { int err; + struct __native_stat stbuf; - err = syscall(__SYS_FSTAT, fd, buf); + err = syscall(__SYS_FSTAT, fd, &stbuf); if (err) err = -errno; + COPY_STAT(&stbuf, buf); return err; } @@ -310,8 +325,12 @@ native_i_new(struct filesys *fs, struct nino = malloc(sizeof(struct native_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -496,6 +515,27 @@ native_fsswop_mount(const char *source, return err; } +static int +native_i_invalid(struct inode *inop, struct intnl_stat stbuf) +{ + /* + * Validate passed in inode against stat struct info + */ + struct native_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev != stbuf.st_dev || + nino->ni_ident.ino != stbuf.st_ino || +#ifdef HAVE_GENERATION + nino->ni_ident.gen != stbuf.st_gen || +#endif + ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || + (((inop)->i_rdev != stbuf.st_rdev) && + (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) + return 1; + + return 0; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -525,11 +565,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct native_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!native_i_invalid(*inop, stbuf)) return 0; /* * Invalidate. @@ -540,23 +576,40 @@ native_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (native_i_invalid(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = native_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; @@ -788,10 +841,9 @@ native_getdirentries(struct inode *ino, result = *basep; if (*basep != nino->ni_fpos && - syscall(SYS_lseek, - nino->ni_fd, + CALL_LSEEK(nino->ni_fd, *basep, - &result, + result, SEEK_SET) == -1) return -errno; nino->ni_fpos = result; @@ -965,7 +1017,7 @@ static int native_inop_unlink(struct pnode *pno) { char *path; - int err; + int err = 0; path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -983,7 +1035,8 @@ native_inop_unlink(struct pnode *pno) * (usually .NFSXXXXXX, where the X's are replaced by the PID and some * unique characters) in order to simulate the proper semantic. */ - err = syscall(SYS_unlink, path); + if (syscall(SYS_unlink, path) != 0) + err = -errno; free(path); return err; } @@ -1033,10 +1086,9 @@ doio(ssize_t (*f)(int, const struct iove !(S_ISCHR(ino->i_mode) || S_ISSOCK(ino->i_mode) || S_ISFIFO(ino->i_mode)) && - syscall(SYS_lseek, - nino->ni_fd, + CALL_LSEEK(nino->ni_fd, ioctx->ioctx_offset, - &result, + result, SEEK_SET) == -1) { ioctx->ioctx_cc = -1; ioctx->ioctx_errno = errno; |
From: Mei <me...@us...> - 2003-08-15 07:54:27
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv25257/drivers/incore Modified Files: Tag: b_lustre fs_incore.c Log Message: merge changes from HEAD to b_lustre Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- fs_incore.c 23 Apr 2003 18:16:57 -0000 1.4 +++ fs_incore.c 15 Aug 2003 07:43:15 -0000 1.4.2.1 @@ -1024,7 +1024,7 @@ _sysio_incore_dirop_mkdir(struct pnode * struct incore_inode *icino, *parent; ino_t inum; int err; - struct intnl_dirent *de; + struct intnl_dirent *de = NULL; struct inode *ino; ino = pno->p_parent->p_base->pb_ino; @@ -1271,7 +1271,7 @@ incore_doio(ssize_t (*f)(struct incore_i struct ioctx *ioctx; const struct iovec *iov; size_t n; - ssize_t cc; + ssize_t cc = 0; ioctx = _sysio_ioctx_new(ino, ioargs); if (!ioctx) |
From: Mei <me...@us...> - 2003-08-15 07:48:59
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv25257/drivers/yod Added Files: Tag: b_lustre Makefile.am fs_yod.c fs_yod.h Log Message: merge changes from HEAD to b_lustre --- NEW FILE --- lib_LIBRARIES = libsysio_yod.a EXTRA_DIST = fs_yod.h libsysio_yod_a_SOURCES = fs_yod.c include $(top_srcdir)/Rules.make --- 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. */ /* [...1157 lines suppressed...] yod_inop_gone(struct inode *ino) { struct yod_inode *nino = I2NI(ino); if (nino->ni_fd) (void )close(nino->ni_fd); free(ino->i_private); } static void yod_fsop_gone(struct filesys *fs) { /* * Release fs private data */ if (fs->fs_private) free(fs->fs_private); } --- 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... */ /* * Remote file system driver support. */ extern int _sysio_yod_init(); |
From: Mei <me...@us...> - 2003-08-15 07:48:59
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv25257/include Modified Files: Tag: b_lustre inode.h sysio.h Added Files: Tag: b_lustre cplant-yod.h 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... */ /* * cplant yod I/O functions */ extern int chmod_yod(const char* path, mode_t); extern int chown_yod(const char* path, uid_t, gid_t); extern int stat_yod(const char *path, struct stat *sbuf); extern int fstat_yod(int fd, struct stat *buf); extern int statfs_yod(const char *path, struct statfs *sbuf); extern int fstatfs_yod(int fd, struct statfs *buf); extern int mkdir_yod(const char *path, mode_t mode); extern int rmdir_yod(const char *path); extern int getdirentries_yod(int fd, char *buf, size_t nbytes, loff_t *basep); extern int link_yod(const char *path1, const char *path2); extern int unlink_yod(const char *path); extern int symlink_yod(const char *path1, const char *path2 ); extern int open_yod(const char *fname, int flags, mode_t mode); extern int close_yod(int); extern ssize_t write_yod(int fd, const void *buff, size_t nbytes); extern ssize_t read_yod(int fd, void *buff, size_t nbytes); extern int fsync_yod(int fd); extern int truncate_yod(const char *path, off_t length); extern int ftruncate_yod(int fd, long length); extern off_t lseek_yod(int fd, off_t offset, int whence); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- inode.h 23 Apr 2003 19:45:51 -0000 1.6 +++ inode.h 15 Aug 2003 07:43:15 -0000 1.6.2.1 @@ -129,6 +129,7 @@ struct inode_ops { struct inode { LIST_ENTRY(inode) i_link; /* FS i-nodes link */ unsigned i_immune : 1; /* immune from GC */ + unsigned i_zombie : 1; /* stale inode */ unsigned i_ref; /* soft ref counter */ ino_t i_num; /* i-num (deprecate!) */ mode_t i_mode; /* mode (see stat.h) */ @@ -146,6 +147,7 @@ struct inode { #define I_INIT(ino, fs, inum, mode, rdev, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ + (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ (ino)->i_num = (inum); \ (ino)->i_mode = (mode); \ @@ -407,6 +409,7 @@ extern struct inode *_sysio_i_find(struc ino_t ino, struct file_identifier *fid); extern void _sysio_i_gone(struct inode *ino); +extern void _sysio_i_undead(struct inode *ino); extern int _sysio_p_find_alias(struct pnode *parent, struct qstr *name, struct pnode **pnop); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -u -w -b -B -p -r1.7.4.1 -r1.7.4.2 --- sysio.h 29 Jun 2003 10:15:32 -0000 1.7.4.1 +++ sysio.h 15 Aug 2003 07:43:15 -0000 1.7.4.2 @@ -124,9 +124,7 @@ extern void _sysio_shutdown(void); * but it's not illegal to have multiple externs, so long as they are the * same. It helps when building the library in a standalone fashion. */ -#if 0 extern int access(const char *path, int amode); -#endif extern int chdir(const char *path); extern int chmod(const char *path, mode_t mode); extern int chown(const char *path, uid_t owner, gid_t group); |
From: Mei <me...@us...> - 2003-08-15 07:48:59
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv25257/tests Modified Files: Tag: b_lustre Makefile.am test_copy.c test_getcwd.c test_list.c test_mounts.c test_path.c test_stats.c test_stdfd.c Added Files: Tag: b_lustre README help.c helper.pm populator.pl sysio_stubs.c sysio_tests.c test_all.pl test_copy.pl test_driver.c test_driver.h test_getcwd.pl test_list.pl test_path.pl test_stats.pl test_stdfd.pl verifier.pl Log Message: merge changes from HEAD to b_lustre --- NEW FILE --- To run the tests, just do ./test_all.pl (at some point I will integrate that into the build environment). This will run the 6 basic functionality tests (explained below) and report the total number of passes and failures. This is not currently working on alpha/cplant architectures, however. -----------------------SCRIPTS--------------------------------- There are a total of 8 scripts: test_copy.pl, test_list.pl, test_getcwd.pl, test_stats.pl, test_stdfd.pl, test_path.pl, populator.pl, and verifier.pl. All but the last two scripts are ran with the test_all.pl script. Here is an explanation of the scripts. All scripts take an optional "-alpha" arg for running the scripts in an alpha/cplant environment. The alpha arg makes certain assumptions about the running of the environment; for example, it does not initilization and it starts off the test driver with yod. test_copy.pl <src> <dest> : This copies a file from src to dest. : It runs a system cmp to verify that : the two files are equivalent test_list.pl [-p] <dir> : This comes in two forms. test_list.pl [-p] <fstype:mdir> <dir> : In the first form, it will : parse through the getdirentries : result in order to generate a : a listing. If the -p option is : given, it will print out the : listing. In the second form, it : mounts mdir into dir and then does : the listing test_getcwd.pl <dir> : Tests getcwd by verifying that setting the current : working directory to dir and then calling getcwd : returns dir test_stats.pl <file> : Verifies that the set of stat calls (stat, fstat, : fstatvfs, statvfs) return the same set of stats for file : and that the calls return the same items as Perl's stat : call (which would use a native library and not libsysio) test_stdfd.pl <file> : Verified that stdin, stdout, and stderr can be opened and : either written to or read from test_path.pl <path1> <path2> ... : Print each path listed and its type. : If no paths are given, paths are read : from stdin until a "quit" is given populator.pl [-seed seed] : Create a file and populate with random numbers. [-file filename] : Will use the given seed for the random number [-bytes bytes] : generator if it is given, otherwise it uses the : the current time as a seed. The seed used is : returned. If no filename is given, the file : will be named randfile.seed.procnum, where seed : is the seed used and procnum is the process number : of the script. If no bytes are given, 1024 bytes : are written. All write commands use libsysio verifier.pl <-seed seed> <-file fname> : Verifies that all bytes in the file fname : (which was created with populator) match the : random numbers which would have been used with : the populator, using the given seed. -----------------------------TEST DRIVER--------------------------------- There are 6 basic commands for the test driver, CALL, PRINT, ALLOC, FREE, HELP, and exit (EXIT, quit, or QUIT will also work). CALL is the main command for running libsysio calls. The format will depend on the particular libsysio command being ran. Basically, the format is CALL cmd args. The available commands used with CALL are (in no particular order): fstat iwrite read chdir fstatvfs iwritev readv chmod fsync list rmdir chown ftruncate lseek sizeof close getcwd lstat stat cmpstr getdirentries mkdir statvfs creat init mknod symlink debug ioctl mount truncate dup iodone open umask dup2 iowait umount endian ipread printline unlink ipreadv pread write fcntl ipwrite preadv writev fdatasync ipwritev pwritev fill iread pwrite ireadv The specifics of the commands are explained later. The return value from a command can be saved and referenced later by using a syntax similar to $foo = x. Commands can be combined, such as: CALL fstat ( $fd = CALL open foo ) ( $buf = ALLOC 128 ), with some cautionary notes. First, everything needs to be seperated by a space. File names with spaces in them need to be quoted, as in: $fd = CALL open "file with spaces" O_RDONLY Second, any value that is used needs to be identified with an identifier. In other words, the command: $buf = ALLOC ( CALL sizeof stat ) will not work, but the command $buf = ALLOC ( $size = CALL sizeof stat ) will. All commands return a 4 digit status code. The codes are: 0000 : Success. This does NOT necessarily mean that the libsysio : command returned success, only that there were no errors : in issuing the command to libsysio. To get the result of : the libsysio command, use PRINT $$ . PRINT $errno will return : the last error code. 0x001 : Invalid arguments given to command 0x002 : Invalid command issued 0x004 : Invalid variable identifier given ALLOC takes a size argument and an optional alignment argument. FREE takes the variable to free as an argument. HELP without any arguments displays the list of commands. HELP <cmd> will give information on the specific command PRINT take several forms. To just print out a variable, type PRINT $var-name. If the variable is an integer, it will return the integer. If it is a string, it will print out the string. If it is a buffer, it will print out the buffer as a series of hex digits. Note for most buffers, the test driver will not know what it contains--just because it should contain a string does not mean that the driver will know that. The other form of PRINT is: PRINT $var_name <offset> <length> <type> which will print out length units of the given type starting at the given offset. The length is the total length in bytes, so for an integer, a length of 4 would only print out one integer. The length argument is ignored for strings. Allowable types are INT SHORT CHAR and LONG. For most of the CALL commands, their format is similar to the related sysio call. The ones that do not have a corresponding sysio call are listed below: init: This MUST be called prior to any sysio calls. It initilizes : libsysio printline: If debugging is turned on, this will print a line number : with any debug lines fill <val> <type> <size> <offset> <buf>: Fills buffer buf with size : bytes of val starting at : buf+offset. The type of val : can be UINT. STR, or PTR and : is given by the type arg list <dir>: Lists contents of dir. If no dir is given, uses cwd debug <num>: Sets debug level to num sizeof <obj>: Gives the size of the obj. Valid objs are char, int, : long, flock, stat, and statvfs endian: returns 0 if the machine is little endian, one otherwise cmpstr <buf1> <buf2>: Issues a strcmp call on the two buffers to : see if they are the same. Returns 0 for a : match --- NEW FILE --- #include <stdio.h> #include "test_driver.h" void do_help() { int i, d, count = 0; fprintf(outfp, "libsysio test harness\n"); fprintf(outfp, "To get help on a specific command, use HELP <cmd>\n"); fprintf(outfp, "To exit, type exit or quit\n"); fprintf(outfp, "\nTo save the result from a function, use \"$res = CALL command\"\n"); fprintf(outfp, "To later use that res, do \"comm $res\"\n"); fprintf(outfp, "\n\nAvailable commands are (always preceded by CALL):\n\n"); /* Get total number of commands */ while (cmd_list[count].cmd) count++; d = count/4; if (count % 4) d++; for (i=0; i < d; i++) { if ( (i+d) < count ) { if ( (i + 2*d) < count) { if ( (i+3*d) < count) fprintf(outfp, "%-15s %-15s %-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd, cmd_list[i+3*d].cmd); else fprintf(outfp, "%-15s %-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd); } else fprintf(outfp, "%-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd); } else fprintf(outfp, "%-15s\n", cmd_list[i].cmd); } fprintf(outfp, "\n"); } void usage_setdebug() { fprintf(outfp, "setdebug [level]: Set debugging level to level\n"); } void usage_clear() { fprintf(outfp, "clear buf: zero out the buffer\n"); } void usage_printline() { fprintf(outfp, "printline [0|1]: Turn off (0) or on (1) the printing of line number\n"); fprintf(outfp, " : and file name with debug output\n"); } void usage_endian() { fprintf(outfp, "endian: returns 1 for bigendian machines and 0 for little endian machines\n"); } void usage_sizeof() { fprintf(outfp, "sizeof [type]: returns the size of the data type. Currently \n"); fprintf(outfp, " : supported types are char, int, long, flock, stat and \n"); fprintf(outfp, " : statvfs\n"); } void usage_get_buffer() { fprintf(outfp, "alloc [size] <align>: allocates a buffer of size bytes aligned to align\n"); fprintf(outfp, " : align is optional. If not there, buffer will be aligned on\n"); fprintf(outfp, " : a one-byte boundary. returns an index into an array that \n"); fprintf(outfp, " : holds the buffer\n"); } void usage_free_buffer() { fprintf(outfp, "free [bufidx]: frees buffer at bufidx. Returns 0 on success, -1 on failure\n"); } void usage_do_fillbuff() { fprintf(outfp, "fill [val] [type] [size] [offset] [buf] : Fills the buffer buf with size \n"); fprintf(outfp, " : bytes of val starting at buf+offset\n"); fprintf(outfp, " : The type of val is specified by type,\n"); fprintf(outfp, " : which can be UINT, STR, or PTR\n"); } void usage_do_printbuf() { fprintf(outfp, "printbuf [buf] : print out contents of the buffer stored in buf\n"); fprintf(outfp, " : Always returns 0\n"); } void usage_cmpbufs() { fprintf(outfp, "cmpstr [buf1] [buf2]: Compare the contents of buf1 with buf2 by issuing a \n"); fprintf(outfp, " strcmp call. Returns 0 if the buffers match\n"); } void usage_init() { fprintf(outfp, "init <driver> <path> <flags>: Without any arguments, initilizes libsysio\n"); fprintf(outfp, " : to default values for root directory and\n"); fprintf(outfp, " : current directory. Accepts optional\n"); fprintf(outfp, " : arguments for the root driver, the mount\n"); fprintf(outfp, " : path, and the mount flags. Must be called\n"); fprintf(outfp, " : before any other libsysio calls. Returns\n"); fprintf(outfp," : 0 on success, -1 on failure\n"); } void usage_list() { fprintf(outfp, "list <dir>: lists contents of dir. If dir is ommitted, will list contents\n"); fprintf(outfp, " : of the current working directory\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chdir() { fprintf(outfp, "chdir [dir]: change the current working directory to dir\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chmod() { fprintf(outfp, "chmod [newmode] [file]: change mode of file to newmode. newmode can be \n"); fprintf(outfp, " : specifed symbolically (eg, a+x), numerically \n"); fprintf(outfp, " : (eg, 0777), or using system defines \n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP)\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chown() { fprintf(outfp, "chown [newown[:newgrp]] [file]: change the owner of file to newown, the group\n"); fprintf(outfp, " : of file to newgrp, or both\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_open() { fprintf(outfp, "open [file] [flags] <mode>: open file with given flags. The mode is optional\n"); fprintf(outfp, " : can use defines for open, (eg, open foo O_RDONLY)\n"); fprintf(outfp, " : If flags are 0, file will be opened with O_RDWR\n"); fprintf(outfp, " : Returns the file descriptor for the opened file\n"); } void usage_close() { fprintf(outfp, "close [file]: closes the file. Returns 0 on success, -1 on failure\n"); } void usage_mount() { fprintf(outfp, "mount [fstype:source] [target]: mount source (which has fstype as its file\n"); fprintf(outfp, " : system type) onto target.\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_dup() { fprintf(outfp, "dup [oldfd]: Duplicate oldfd. Returns the duplicated file descriptor\n"); fprintf(outfp, " : Returns -1 on failure\n"); } void usage_dup2() { fprintf(outfp, "dup2 [oldfd] [newfd]: Make newfd be a copy of oldfd. Returns newfd on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_fcntl() { fprintf(outfp, "fcntl [fd] [cmd] <args> : execute fcntl cmd on file with file descriptor fd\n"); fprintf(outfp, " : using (optional) args. Accepted (but not \n"); fprintf(outfp, " : necesarily working) commands are F_DUPFD, \n"); fprintf(outfp, " : F_GETFD, F_GETFL, F_GETOWN, F_SETFD, F_SETFL,\n"); fprintf(outfp, " : F_SETOWN, F_SETLK, F_SETLKW, and F_GETLK. \n"); } void usage_fstat() { fprintf(outfp, "fstat [fd] [buf]: Get the stat structure for file descriptor fd and place it\n"); fprintf(outfp, " : in buf. Returns 0 on success, -1 on failure\n"); } void usage_fsync() { fprintf(outfp, "fsync [fd]: ensure all parts of file with file descriptor fd are output to\n"); fprintf(outfp, " : stable storage. Returns 0 on success, -1 on failure\n"); } void usage_fdatasync() { fprintf(outfp, "fdatasync [fd]: ensure all parts of file with file descriptor fd except the \n"); fprintf(outfp, " : metadata are output to stable storage. Returns 0 on \n"); fprintf(outfp, " : success, -1 on failure\n"); } void usage_ftruncate() { fprintf(outfp, "ftruncate [fd] [len]: truncate file with file descriptor fd to have be \n"); fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_getcwd() { fprintf(outfp, "getcwd [buf] [size]: get the current working directory and store it in buf\n"); fprintf(outfp, " : buf is size bytes in length. If buf is too short, an \n"); fprintf(outfp, " : error of ERANGE is returned. Returns 0 on success, -1\n"); fprintf(outfp, " : on failure\n"); } void usage_lseek() { fprintf(outfp, "lseek [fd] [offset] [whence]: Sets the offset of the file descriptor fd to\n"); fprintf(outfp, " : either offset if whence is SEEK_SET or offset\n"); fprintf(outfp, " : plus the current location if whence is SEEK_CUR\n"); fprintf(outfp, " : or offset plus the size of the file if whence\n"); fprintf(outfp, " : is SEEK_END. Returns 0 on success and -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_lstat() { fprintf(outfp, "lstat [filename] [buf]: Get the stat structure for filename and return it in\n"); fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); } void usage_getdirentries() { fprintf(outfp, "getdirentries [fd] [buf] [nbytes] [basep]: Read dir entries from directory\n"); fprintf(outfp, " : with file descriptor fd into buf\n"); fprintf(outfp, " : At most nbytes are read. Reading\n"); fprintf(outfp, " : starts at basep, and basep is set\n"); fprintf(outfp, " : to new pos. Returns the number of \n"); fprintf(outfp, " : bytes read on success or 0 on\n"); fprintf(outfp, " : failure\n"); fprintf(outfp, "Note that basep does not have to be pre-allocated. Executing cmd: \n"); fprintf(outfp, "\"getdirentries $fd $buf 4096 $basep\", where $fd is the result of an open\n"); fprintf(outfp, "and $buf is the result of an alloc (but $basep is totally new) will work\n"); fprintf(outfp, "After the execution of the command, $basep holds the new offset and can be\n"); fprintf(outfp, "used again for any further getdirentries calls\n"); } void usage_mkdir() { fprintf(outfp, "mkdir [newdir] [mode]: make a new directory, newdir, with the permissions \n"); fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); fprintf(outfp, " : -1 on failure.\n"); } void usage_creat() { fprintf(outfp, "creat [newfile] [mode]: create a new file, newfile, with the permissions \n"); fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); fprintf(outfp, " : -1 on failure.\n"); } void usage_stat() { fprintf(outfp, "stat [filename] [buf]: Get the stat structure for filename and return it in\n"); fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); } void usage_statvfs() { fprintf(outfp, "statvfs [filename] [buf]: Get the statvfs structure for filename and return\n"); fprintf(outfp, " : it in buf. Returns 0 on success and -1 on failure\n"); } void usage_fstatvfs() { fprintf(outfp, "fstatvfs [fd] [buf]: Get the stat structure for file with file descriptor fd\n"); fprintf(outfp, " : and return it in buf. Returns 0 on success and -1 on\n"); fprintf(outfp, " : failure\n"); } void usage_truncate() { fprintf(outfp, "truncate [fname] [len]: truncate file with name fname to be exactly \n"); fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_rmdir() { fprintf(outfp, "rmdir [dirname]: Remove directory at dirname. Returns 0 on success, -1 on\n"); fprintf(outfp, " : failure.\n"); } void usage_symlink() { fprintf(outfp, "symlink [path1] [path2]: Make a symbolic link from path1 to path2. Returns\n"); fprintf(outfp, " : 0 on success, -1 on failure\n"); } void usage_unlink() { fprintf(outfp, "unlink [path]: Unlink path. If path is the last name to a file, the file is \n"); fprintf(outfp, " : is removed. If it was a symbolic link, the link is removed. \n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_ioctl() { fprintf(outfp, "ioctl [fd] [cmd] <args> : Issue the ioctl command cmd on the file with file\n"); fprintf(outfp, " : descriptor fd. Any arguments are placed in args\n"); fprintf(outfp, " : At the moment, the only commands understand are the \n"); fprintf(outfp, " : ioctl commands found in /usr/include/linux/fs.h\n"); } void usage_umask() { fprintf(outfp, "ioctl [mask] : Sets the umask used by open to set initial file permissions on\n"); fprintf(outfp, " : a newly created file. Returnds the previous value of the mask\n"); } void usage_iodone() { fprintf(outfp, "iodone [ioid] : Poll for completion of the asynchronous request identifed by\n"); fprintf(outfp, " : ioid. Returns 1 if request finished\n"); } void usage_iowait() { fprintf(outfp, "iowait [ioid] : Wait for completion of the asynchronous request identifed by\n"); fprintf(outfp, " : ioid. Returns result of asynchronous request \n"); } void usage_ipreadv() { fprintf(outfp, "ipreadv [fd] [buf] [count] [off]: Reads data asynchrously to file descriptor fd \n"); fprintf(outfp, " : starting at offset off. Data comes from \n"); fprintf(outfp, " : buffer described by buf, which is a pointer to\n"); fprintf(outfp, " : an iovec strucutre. Number of buffers is \n"); fprintf(outfp, " : specified by count. Returns an iod_t on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_ipread() { fprintf(outfp, "ipread [fd] [buf] [count] [off]: Read asynchrously up to count bytes from file\n"); fprintf(outfp, " : with file descriptor fd starting at offset off\n"); fprintf(outfp, " : Read into buffer pointed at by buf. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_preadv() { fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads data from file descriptor fd starting at\n"); fprintf(outfp, " : offset off. Data goes into buffer described\n"); fprintf(outfp, " : by buf, which is a pointer to an iovec \n"); fprintf(outfp, " : structure. Number of buffers is specified by\n"); fprintf(outfp, " : count. Returns the number of bytes read\n"); } void usage_pread() { fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads count bytes of data from file descriptor\n"); fprintf(outfp, " : fd starting at offset off. Data goes into buf.\n"); fprintf(outfp, " : Returns number of bytes read or -1 on failure\n"); } void usage_ireadv() { fprintf(outfp, "ireadv [fd] [buf] [count] : Reads data asynchrously to file descriptor fd \n"); fprintf(outfp, " : Data comes from buffer described by buf, which is \n"); fprintf(outfp, " : an pointer to an iovec structure. Number of\n"); fprintf(outfp, " : buffers is specified by count. Returns an iod_t\n"); fprintf(outfp, " : on success and -1 on failure\n"); } void usage_iread() { fprintf(outfp, "iread [fd] [buf] [count]: Read asynchrously up to count bytes from file with\n"); fprintf(outfp, " : file descriptor fd into buffer pointed at by buf\n"); fprintf(outfp, " : Returns an iod_t on success and -1 on failure\n"); } void usage_readv() { fprintf(outfp, "readv [fd] [buf] [count] : Reads data from file descriptor fd. Data comes from\n"); fprintf(outfp, " : the buffer described by buf, which is a pointer to an\n"); fprintf(outfp, " : an iovec structure. Number of buffers is specified\n"); fprintf(outfp, " : by count. Returns the number of bytes read on \n"); fprintf(outfp, " : on success and -1 on failure\n"); } void usage_read() { fprintf(outfp, "read [fd] [buf] [count]: Read up to count bytes from file with file \n"); fprintf(outfp, " : descriptor fd into buffer pointed at by buf\n"); fprintf(outfp, " : Returns number of bytes read on success or 0 on \n"); fprintf(outfp, " : on failure\n"); } void usage_ipwritev() { fprintf(outfp, "ipwritev [fd] [buf] [count] [off]: writes data asynchronously to file with file\n"); fprintf(outfp, " : descriptor fd starting at offset off. Data \n"); fprintf(outfp, " : comes from buffers described by buf, which\n"); fprintf(outfp, " : is a pointer to an iovec structure. Number \n"); fprintf(outfp, " : of buffers is specified by count. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_ipwrite() { fprintf(outfp, "ipwrite [fd] [buf] [count] [off]: writes count bytes of data asynchronously to\n"); fprintf(outfp, " : file with file descriptor fd starting at \n"); fprintf(outfp, " : offset off. Data comes from buf. Returns an\n"); fprintf(outfp, " : iod_t on success and -1 on failure\n"); } void usage_pwritev() { fprintf(outfp, "pwritev [fd] [buf] [count] [off]: writes data to file with file descriptor fd\n"); fprintf(outfp, " : starting at offset off. Data comes from \n"); fprintf(outfp, " : buffers described by buf, which is a pointer\n"); fprintf(outfp, " : to an iovec structure. Number of buffers is\n"); fprintf(outfp, " : by count. Returns number of bytes read on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_pwrite() { fprintf(outfp, "pwrite [fd] [buf] [count] [off]: writes count bytes of data to file with file \n"); fprintf(outfp, " : descriptor fd starting at offset off. Data\n"); fprintf(outfp, " : Data comes from buf. Returns number of bytes\n"); fprintf(outfp, " : written on success and -1 on failure\n"); } void usage_iwritev() { fprintf(outfp, "iwritev [fd] [buf] [count] : writes data asynchronously to file with file\n"); fprintf(outfp, " : descriptor fd. Data comes from buffers described\n"); fprintf(outfp, " : by buf, which is a pointer to an iovec structure.\n"); fprintf(outfp, " : Number of buffers is specified by count. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_iwrite() { fprintf(outfp, "iwrite [fd] [buf] [count] : writes count bytes of data asynchronously to\n"); fprintf(outfp, " : file with file descriptor fd. Data comes from buf.\n"); fprintf(outfp, " : Returns an iod_t on success and -1 on failure.\n"); } void usage_writev() { fprintf(outfp, "writev [fd] [buf] [count]: writes data to file descriptor fd. Data comes from\n"); fprintf(outfp, " : buffers described by buf, which is a pointer to a \n"); fprintf(outfp, " : iovec strucutre. Number of buffers is specified by \n"); fprintf(outfp, " : count \n"); } void usage_write() { fprintf(outfp, "write [fd] [buf] [count] : writes count bytes of data to file with file \n"); fprintf(outfp, " : descriptor fd. Data comes from buf. Returns number\n"); fprintf(outfp, " : of bytes written on success and -1 on failure.\n"); } void usage_mknod() { fprintf(outfp, "mknod [path] [mode] [dev] : creates a filesystem node named path with \n"); fprintf(outfp, " : specified mode using device special file dev\n"); fprintf(outfp, " : Returns 0 on sucess and -1 on failure\n"); } void usage_umount() { fprintf(outfp, "umount [path] : Umount file at path. Returns 0 on success and -1 on failure\n"); } void usage_exit() { } --- NEW FILE --- #!/usr/bin/perl -w # # Provides a set of helper routines for use in the Perl # test scripts # package helper; use strict; use Fcntl ':mode'; BEGIN{} # Print out a given error message, close the command file # and exit sub print_and_exit { my ($cmdfh, $outfh, $exit_num, $exit_str) = @_; print STDOUT "$exit_str"; # Clean up my $cmdstr = 'FREE $buf'; $cmdstr = $cmdstr."\n"; print $cmdfh $cmdstr; my $res = <$outfh>; chop($res); if ($res ne "0000 ") { print STDOUT "ERROR! Failed to free buf (code $res)\n"; } print $cmdfh "exit\n"; close $outfh; # Give test_driver time to finish sleep 0.000001; exit $exit_num; } # Output the given command and make sure that the exit # code for the command was valid sub send_cmd { my ($cmdfh, $outfh, $cmd, $cmdstr) = @_; print $cmdfh $cmdstr; my $res = <$outfh>; chop($res); if ($res ne "0000 ") { print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n"); } } # Check the return value from the last libsysio call sub verify_cmd { my ($cmdfh, $outfh, $cmd) = @_; # Verify the system call's output my $cmdstr = 'PRINT $$'; $cmdstr .= "\n"; send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $res = <$outfh>; chop($res); if ($res eq "0xffffffff") { # Get the errno $cmdstr = 'PRINT $errno'; $cmdstr .= "\n"; send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $err = <$outfh>; chop($err); print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n"); } return $res; } # Compares two numbers. Output error message and exit if # they differ sub cmp_nums { my ($cmdfh, $outfh, $ionum, $pnum, $desc) = @_; my $str; if (!defined($ionum)) { print_and_exit($cmdfh, $outfh, 1, "ERROR! ionum for $desc undefined"); } elsif (!defined($pnum)) { print_and_exit($cmdfh, $outfh, 1, "ERROR! pnum for $desc undefined"); } if ($ionum != $pnum) { my $str = sprintf("ERROR! Sysio's number %x does not match Perl's (%x)\n", $ionum, $pnum); $str = sprintf("%s Numbers were %s\n", $str, $desc); print_and_exit($cmdfh, $outfh, 1, $str); } } sub get_type { my $mode = $_[0]; my $t = '?'; if (S_ISDIR($mode)) { $t = 'd'; } elsif (S_ISCHR($mode)) { $t = 'c'; } elsif (S_ISBLK($mode)) { $t = 'b'; } elsif (S_ISREG($mode)) { $t = 'f'; } elsif (S_ISFIFO($mode)) { $t = 'p'; } elsif (S_ISLNK($mode)) { $t = 'S'; } elsif (S_ISSOCK($mode)) { $t = 's'; } return $t; } END{} 1; --- NEW FILE --- #!/usr/bin/perl -w use IPC::Open2; use strict; use helper; sub usage { print "Usage: ./populator.pl <-seed seed> :\n"; print " <-file filename> :\n"; print " <-bytes bytes> : Create a file, filename, that\n"; print " : is bytes long and populate with\n"; print " : random numbers using the given\n"; print " : seed. Will use defaults if args\n"; print " : not given\n"; exit(-1); } sub get_buf { my $MAX_SIZE = 2147483648; my $str; my $num; my $len = 0; while ($len < 512) { $num = rand $MAX_SIZE; my $tmpstr = sprintf("%d", $num); $str .= $tmpstr; $len += length $tmpstr; } return ($len, $str); } sub write_file { my ($cmdfh, $outfh, $filename, $bytes) = @_; # Allocate the read buffer my $cmd = '$buf = ALLOC 1024'."\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmd); # Open (create) the new file $cmd = '$fd = CALL open '."$filename O_RDWR|O_CREAT S_IRWXU\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmd); # Verify the system call's output helper::verify_cmd($cmdfh, $outfh, "open"); my $left_bytes = $bytes; while ($left_bytes > 0) { # Get a buffer filled with random numbers # Buffer will be no less than 512 bytes my ($len, $buf) = get_buf; if ($len > $left_bytes) { $len = $left_bytes; } # Need to fill $buf with the buffer $cmd = "CALL fill $buf STR $len 0 ".'$buf'."\n"; helper::send_cmd($cmdfh, $outfh, "fill", $cmd); # Write out $len bytes to $filename $cmd = 'CALL write $fd $buf '."$len\n"; helper::send_cmd($cmdfh, $outfh, "write", $cmd); my $written_bytes = helper::verify_cmd($cmdfh, $outfh, "write"); $written_bytes = oct($written_bytes); if ($written_bytes != $len) { helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Meant to print out $len but only printed $written_bytes\n"); } $left_bytes -= $len; } } sub populate_file { my ($filename, $bytes, $is_alpha) = @_; eval { if ($is_alpha == 0) { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); } else { open2(\*OUTFILE, \*CMDFILE, "yod -batch -quiet -sz 1 ./test_driver --np"); } }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; } my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); } # Now write the file write_file($cmdfh, $outfh, $filename, $bytes); # Close the file my $cmd = 'CALL close $fd'."\n"; helper::send_cmd($cmdfh, $outfh, "close", $cmd); helper::verify_cmd($cmdfh, $outfh, "close"); # All done helper::print_and_exit($cmdfh, $outfh, 0, "File $filename successfully created\n"); } my $is_alpha = 0; my $seed = time; my $filename = "randfile.$seed.$$"; my $bytes = 1024; for (my $i = 0; $i < @ARGV; $i++) { if ($ARGV[$i] eq "-file") { $i++; $filename = $ARGV[$i]; } elsif ($ARGV[$i] eq "-seed") { $i++; $seed = $ARGV[$i]; } elsif ($ARGV[$i] eq "-alpha") { $is_alpha = 1; } elsif ($ARGV[$i] eq "-bytes") { $i++; $bytes = $ARGV[$i]; } } # seed the randome number generator srand $seed; populate_file($filename, $bytes, $is_alpha); exit $seed; --- NEW FILE --- #define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <sys/uio.h> #include <linux/fs.h> #include <sys/stat.h> #include <sys/statvfs.h> #include "test_driver.h" #include "sysio.h" /* * ################################################ * # Function stubs # [...2187 lines suppressed...] int do_umount(int argc, char **argv) { int err; if (argc != 1) { DBG(2, fprintf(outfp, "Invalid number (%d) of args for umount\n", argc)); return INVALID_ARGS; } err = umount(argv[0]); if (err) my_perror("umount"); my_errno = errno; last_ret_val = err; last_type = SINT; return SUCCESS; } --- NEW FILE --- #define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <errno.h> #include <ctype.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/statvfs.h> #include <fcntl.h> #include <sys/queue.h> #include <dirent.h> #include <pwd.h> #include <grp.h> #include "sysio.h" #include "mount.h" #include "test.h" #include "test_driver.h" /* * ################################################### * # Test functions # * # These functions are used to test libsysio. # * # Eventually, there should be one of these for # * # every function document in sysio.h # * ################################################### */ int initilize_sysio(char *root_driver, char *root_path, int mntflgs) { int err; char *wd; /* * Init sysio lib. */ _sysio_init(); /* * Init native file system driver and request mount of specified * source directory. */ err = drv_init_all(); if (err) { my_errno = err; my_perror("drv_init_all"); last_ret_val = errno; return SUCCESS; } err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); if (err) { my_errno = errno; my_perror("_sysio_mount_root"); perror("_sysio_mount_root"); last_ret_val = err; return SUCCESS; } /* * Attempt to set the cwd by getting it out of the * user's environment. If that does not work, set * it to / */ wd = getenv("PWD"); if (wd == NULL) { wd = malloc(5); strcpy(wd, "/"); } if (chdir(wd) != 0) { my_perror(wd); my_errno = errno; last_ret_val = errno; return SUCCESS; } DBG(3, sprintf(output, "Your current working directory is %s\n", wd)); last_ret_val = 0; return SUCCESS; } int sysio_list(char *path) { int fd; size_t n; struct dirent *buf, *dp; __off_t base; ssize_t cc; int numfiles = 0; fd = open(path, O_RDONLY); if (fd < 0) { my_errno = errno; last_ret_val = fd; my_perror(path); return SUCCESS; } n = 16 * 1024; buf = malloc(n); if (!buf) { my_perror(path); cc = -1; goto out; } base = 0; DBG(5, sprintf(output, "About to call getdirentries\n")); while ((cc = getdirentries(fd, (char *)buf, n, &base)) > 0) { dp = buf; while (cc > 0) { DBG(4, fprintf(outfp, "\t%s: ino %#08x off %#08x type %#08x\n", dp->d_name, (unsigned int)dp->d_ino, (unsigned int)dp->d_off, (int )dp->d_type)); sprintf(output, "%s\n", dp->d_name); cc -= dp->d_reclen; dp = (void *)dp + dp->d_reclen; numfiles++; } printf("Out of inner loop\n"); if (!base) break; } out: if (cc < 0) { DBG(2, sprintf(output, "cc barfed\n")); my_perror(path); } free(buf); { int oerrno = errno; if (close(fd) != 0) { DBG(2,sprintf(output, "close barfed\n")); my_perror(path); if (cc < 0) errno = oerrno; else cc = -1; } } last_ret_val = numfiles; my_errno = errno; return SUCCESS; } int sysio_mount(char *from, char *to) { int err; char *s; char *buf; char *cp; char *fstype, *source, *opts, *target; err = 0; /* * Copy everything to a buffer we can modify. */ s = buf = malloc(strlen(from) + 1); if (!buf) { my_perror(from); last_ret_val = -1; my_errno = errno; return SUCCESS; } (void )strcpy(s, from); /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get fstype. */ fstype = cp = s; while (*cp && *cp != ':' && *cp != ' ' && *cp != '\t') cp++; if (fstype == cp || *cp != ':') { DBG(1, sprintf(output, "%s: Missing FS type\n", from)); err = -1; goto out; } *cp++ = '\0'; s = cp; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get source. */ source = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (source == cp) { DBG(1, sprintf(output, "%s: Missing source\n", from)); err = -1; goto out; } if (*cp) *cp++ = '\0'; s = to; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get opts. */ opts = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (opts == cp) { DBG(1,sprintf(output, "%s: Missing target\n", to)); err = -1; goto out; } if (*cp) *cp++ = '\0'; s = cp; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get target */ target = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (target == cp) { target = opts; opts = NULL; } if (*cp) *cp++ = '\0'; err = mount(source, target, fstype, 0, opts); if (err) my_perror(from); out: free(buf); last_ret_val = err; my_errno = errno; return SUCCESS; } int sysio_chdir(char *newdir) { char *buf; if (chdir(newdir) != 0) { my_perror(newdir); return -1; } /* buf = getcwd(NULL, 0); if (!buf) { my_perror(newdir); last_ret_val = -1; my_errno = errno; return SUCCESS; } DBG(4, sprintf(output, "New dir is %s\n", buf)); free(buf); */ return SUCCESS; } static mode_t get_mode(char *arg, int type, int start_mode); #define SYMBOLIC 0 #define DEFINED 1 #define NUMERIC 2 /* * Change the permissions on a given file * * sysio_chmod <filename> <permissions> * */ int sysio_chmod(char *mode_arg, const char *path) { int err; mode_t mode; struct stat st; /* Get the current mode */ err = stat(path, &st); /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, st.st_mode); else mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); } else mode = get_mode(mode_arg, NUMERIC, st.st_mode); DBG(3,sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2,sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } last_ret_val = chmod(path, mode); my_errno = errno; return SUCCESS; } #define USER_STATE 0 /* Specifies that the users are still being listed */ #define MODE_STATE_ADD 1 #define MODE_STATE_REMOVE 2 #define READ 00444 #define WRITE 00222 #define EXECUTE 00111 #define OWNER 00700 #define GROUP 00070 #define OTHER 00007 mode_t get_mode(char *arg, int type, int start_mode) { int i, j,digit, total; char c; int state = USER_STATE; int len = strlen(arg); unsigned int users = 0; unsigned int modes = 0; if (type == DEFINED) { char curr_word[10]; total = digit = 0; j = 0; DBG(4, sprintf(output, "len is %d\n", len)); for (i=0; i < len; i++) { if (arg[i] == '|') { curr_word[j] = '\0'; DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); digit = get_obj(curr_word); if (digit < 0 ) { DBG(2, sprintf(output, "Unable to understand mode arg %s\n", curr_word)); return -1; } total |= digit; j = 0; } else curr_word[j++] = arg[i]; } curr_word[j] = '\0'; DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); digit = get_obj(curr_word); if (digit < 0 ) { DBG(3, sprintf(output, "Unable to understand mode arg %s\n", curr_word)); return -1; } total |= digit; return total; } if (type == SYMBOLIC) { for (i=0; i < len; i++) { c = arg[i]; if (state == USER_STATE) { switch(c){ case 'u': users |= OWNER; break; case 'g': users |= GROUP; break; case 'o': users |= OTHER; break; case 'a': users |= (OWNER|GROUP|OTHER); break; case '+': state = MODE_STATE_ADD; break; case '-': state = MODE_STATE_REMOVE; break; default: return 0; } } else { switch(c){ case 'r': modes |= READ; break; case 'w': modes |= WRITE; break; case 'x': modes |= EXECUTE; break; default: return 0; } } } if (state == MODE_STATE_ADD) { return (start_mode | (users & modes)); } else { return (start_mode & ~(users & modes)); } } else { /* Digits should be octal digits, so should convert */ total = 0; for (i=0; i < len; i++) { c = arg[i]; digit = atoi(&c); if (digit > 7) return 0; for (j=len-i-1; j >0; j--) digit *= 8; total += digit; } return total; } } /* * Changes the ownership of the file. The new_id * is of the format owner:group. Either the owner * or the group may be omitted, but, in order to * change the group, the : must preced the group. */ int sysio_chown(char *new_id, char *file) { char *owner = NULL; char *group = NULL; struct group *g_ent = NULL; struct passwd *o_ent = NULL; uid_t o_id=-1, g_id=-1; int len, j, i=0; int state = 0; /* Correspond to getting owner name */ len = strlen(new_id); for (i=0; i < len; i++) { if (new_id[i] == ':') { /* Group name */ if (!group) group = malloc(strlen(new_id) -i +2); state = 1; /* Now getting group name */ j = 0; if (owner) owner[i] = '\0'; } if (!state) { /* Getting owner name */ if (!owner) owner = malloc(strlen(new_id) +1 ); owner[i] = new_id[i]; } else { /* Group name */ group[j] = new_id[i]; j++; } } if (group) group[i] = '\0'; else owner[i] = '\0'; /* Are the owner and/or group symbolic or numeric? */ if (owner) { if (isdigit(owner[0])) { /* Numeric -- just convert */ o_id = (uid_t) atoi(owner); /* Make sure it is valid */ if ((o_ent = getpwuid(o_id)) == NULL) { DBG(2, sprintf(output, "Error: uid %d not found \n", o_id)); return INVALID_ARGS; } } else { /* Get the id from the passwd file */ if ((o_ent = getpwnam(owner)) == NULL) { DBG(2, sprintf(output, "Error: name %s not found\n", owner)); return INVALID_ARGS; } o_id = o_ent->pw_uid; } } if (group) { if (isdigit(group[0])) { /* Numeric -- just convert */ g_id = (uid_t) atoi(group); /* Make sure it is valid */ if ((g_ent = getgrgid(g_id)) == NULL) { DBG(2, sprintf(output, "Error: gid %d not found \n", g_id)); return INVALID_ARGS; } } else { /* Find group in group file */ if ((g_ent = getgrnam(group)) == NULL) { DBG(2, sprintf(output, "Error: group %s not found \n", group)); return INVALID_ARGS; } g_id = g_ent->gr_gid; } } /* Now issue the syscall */ DBG(4, sprintf(output, "Changing owner of file %s to %d (group %d)\n", file, o_id, g_id)); last_ret_val = chown(file, o_id, g_id); my_errno = errno; return SUCCESS; } int sysio_open(char *path, int flags) { DBG(4, sprintf(output, "Opening file %s with flags %x\n", path, flags)); last_ret_val = open(path, flags); my_errno = errno; return SUCCESS; } int sysio_open3(char *path, int flags, char *mode_arg) { mode_t mode; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); last_ret_val = open(path, flags, mode); my_errno = errno; return SUCCESS; } int sysio_close(int fd) { last_ret_val = close(fd); my_errno = errno; return SUCCESS; } int sysio_fcntl(int fd, struct cmd_map* cmdptr, char *arg) { int fd_new, index, cmd, flag; char *cmdname; void *buf; cmd = cmdptr->cmd; cmdname = cmdptr->cmd_name; switch(cmd) { case F_DUPFD: fd_new = get_obj(arg); last_ret_val = fcntl(fd, F_DUPFD, fd_new); my_errno = errno; return SUCCESS; break; case F_GETFD: case F_GETFL: case F_GETOWN: /* case F_GETSIG: case F_GETLEASE: */ last_ret_val= fcntl(fd, cmd); my_errno = errno; return SUCCESS; break; case F_SETFD: case F_SETFL: case F_SETOWN: /*case F_SETSIG: case F_SETLEASE: case F_NOTIFY: */ flag = atoi(arg); last_ret_val = fcntl(fd, cmd, flag); my_errno = errno; return SUCCESS; break; case F_SETLK: case F_SETLKW: case F_GETLK: /* Get the buffer to hold the lock structure */ index = get_obj(arg); if (index < 0) { sprintf(output, "Unable to find buffer %s\n", arg+1); return INVALID_VAR; } buf = buflist[index]; if (!buf) { sprintf(output, "Buffer at index %d (mapped by %s) is null\n", index, arg); return INVALID_VAR; } last_ret_val = fcntl(fd, cmd, (struct flock *)buf); my_errno = errno; return SUCCESS; default: /* THis should be impossible */ return INVALID_ARGS; } return INVALID_ARGS; } void print_stat(struct stat *st) { DBG(3, sprintf(output, "%sstruct stat: \n", output)); DBG(3, sprintf(output, "%s st_dev: %#16x\n", output, (unsigned int)st->st_dev)); DBG(3, sprintf(output, "%s st_ino: %#16x\n", output, (unsigned int) st->st_ino)); DBG(3, sprintf(output, "%s st_mode: %#16x\n", output, st->st_mode)); DBG(3, sprintf(output, "%s st_nlink: %#16x\n", output, st->st_nlink)); DBG(3, sprintf(output, "%s st_uid: %#16x\n", output, st->st_uid)); DBG(3, sprintf(output, "%s st_gid: %#16x\n", output, st->st_gid)); DBG(3, sprintf(output, "%s st_rdev: %#16x\n", output, (int)st->st_rdev)); DBG(3, sprintf(output, "%s st_size: %#16x\n", output, (int) st->st_size)); DBG(3, sprintf(output, "%s st_blksize: %#16x\n", output, (int) st->st_blksize)); DBG(3, sprintf(output, "%s st_blocks: %#16x\n", output, (int) st->st_blocks)); DBG(3, sprintf(output, "%s st_atime: %#16x\n", output, (unsigned int) st->st_atime)); DBG(3, sprintf(output, "%s st_mtime: %#16x\n", output, (unsigned int) st->st_mtime)); DBG(3, sprintf(output, "%s st_ctime: %#16x", output, (unsigned int) st->st_ctime)); } int sysio_fstat(int fd, void *buf) { int err; struct stat *st = (struct stat *)buf; err = fstat(fd, st); if (err < 0) { my_perror("fstat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_lstat(char *filename, void *buf) { int err; struct stat *st = (struct stat *)buf; err = lstat(filename, st); if (err < 0) { my_perror("lstat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_stat(char *filename, void *buf) { int err; struct stat *st = (struct stat *)buf; err = stat(filename, st); if (err < 0) { my_perror("stat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep) { int err; struct dirent *dp; err = getdirentries(fd, buf, nbytes, basep); last_ret_val = err; DBG(4, sprintf(output, "%sRead %d bytes\n", output, err)); dp = (struct dirent *)buf; while (err > 0) { DBG(3, sprintf(output, "%s\t%s: ino %llu off %llu len %x type %c\n", output, dp->d_name, (unsigned long long )dp->d_ino, (unsigned long long )dp->d_off, dp->d_reclen, (char )dp->d_type)); DBG(3, fprintf(outfp, "\t%s: ino %x off %x len %x type %x\n", dp->d_name, (unsigned long long )dp->d_ino, (unsigned long long )dp->d_off, dp->d_reclen, (char )dp->d_type)); err -= dp->d_reclen; dp = (void *)dp + dp->d_reclen; } my_errno = errno; return last_ret_val; } int sysio_mkdir(char *path, char *mode_arg) { int err; mode_t mode; struct stat st; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, st.st_mode); else mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); } else mode = get_mode(mode_arg, NUMERIC, st.st_mode); DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2, sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } err = mkdir(path, mode); my_errno = errno; last_ret_val = err; return SUCCESS; } int sysio_creat(char *path, char *mode_arg) { mode_t mode; int err; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2, sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } err = creat(path, mode); my_errno = errno; last_ret_val = err; return SUCCESS; } void print_statvfs(struct statvfs *st) { DBG(3, sprintf(output, "%sstruct statvfs: \n", output)); DBG(3, sprintf(output, "%s f_bsize: %x\n", output, (unsigned int) st->f_bsize)); DBG(3, sprintf(output, "%s f_frsize: %x\n", output, (unsigned int) st->f_frsize)); DBG(3, sprintf(output, "%s f_blocks: %x\n", output, (unsigned int) st->f_blocks)); DBG(3, sprintf(output, "%s f_bfree: %x\n", output, (unsigned int) st->f_bfree)); DBG(3, sprintf(output, "%s f_bavail: %x\n", output, (unsigned int) st->f_bavail)); DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); DBG(3, sprintf(output, "%s f_ffree: %x\n", output, (unsigned int) st->f_ffree)); DBG(3, sprintf(output, "%s f_favail: %x\n", output, (unsigned int) st->f_favail)); DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid)); DBG(3, sprintf(output, "%s f_flag: %x\n", output, (unsigned int) st->f_flag)); DBG(3, sprintf(output, "%s f_fnamemax: %x\n", output, (unsigned int) st->f_namemax)); } int sysio_statvfs(char *filename, void *buf) { int err; struct statvfs *st = (struct statvfs *)buf; err = statvfs(filename, st); if ( err == -1) { my_perror("statvfs"); } my_errno = errno; last_ret_val = err; print_statvfs(st); return SUCCESS; } int sysio_fstatvfs(int fd, void *buf) { int err; struct statvfs *st = (struct statvfs *)buf; err = fstatvfs(fd, st); if (err == -1) { my_perror("fstatvfs"); } my_errno = errno; last_ret_val = err; print_statvfs(st); return SUCCESS; } int sysio_umask(char *mode_arg) { mode_t mode; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); last_ret_val = umask(mode); my_errno = errno; return SUCCESS; } int sysio_mknod(char *path, char *mode_arg, dev_t dev) { int err; int mode; mode = get_obj(mode_arg); if (mode < 0) { DBG(2,sprintf(output, "Cant get mode from %s\n", mode_arg)); fprintf(stderr, "Cant get mode from %s\n", mode_arg); return INVALID_VAR; } err = mknod(path, (mode_t) mode, dev); if (err < 0) my_perror("mknod"); last_ret_val = err; my_errno = errno; return SUCCESS; } --- NEW FILE --- #!/usr/bin/perl -w # # VERY basic functionality test for sysio. To run, just type ./test_all.pl # Absolutely no guarantees for running on alpha/cplant # use strict; my $alpha_arg = ""; my $is_broke = 1; # Don't test certain areas known to not work on Cplant if ((@ARGV > 0) && ($ARGV[0] eq "-alpha")) { $alpha_arg = "-alpha"; } # Will use this directory... system("mkdir ./tmp_dir"); my $failures = 0; my $success = 0; # Get cwd.. my $cwd = $ENV{PWD}; # Get the sysio dir my $sysdir = $cwd; $sysdir =~ s/\/\w+$//; my $res; if (($alpha_arg eq "") || ($is_broke == 0)) { # Test getdirentries $res = `./test_list.pl $alpha_arg $sysdir`; chop($res); if ($res ne "list test successful") { print "Basic getdirentries test failed with message: $res\n"; $failures++; } else { print "test_list finished successfully\n"; $success++; } } # Test path my @resarr = `./test_path.pl $alpha_arg $sysdir $cwd $cwd/tmp_dir`; $res = $sysdir.": d\n"; if ($resarr[0] ne $res) { print "path test returned $resarr[0] instead of $res\n"; $failures++; } else { $res = $cwd.": d\n"; if ($resarr[1] ne $res) { print "path test returned $resarr[1] instead of $res\n"; $failures++; } else { $res = $cwd."/tmp_dir: d\n"; if ($resarr[2] ne $res) { print "path test returned $resarr[2] instead of $res\n"; $failures++; } else { print "test_path finished successfully\n"; $success++; } } } if (($alpha_arg eq "") || ($is_broke == 0)) { # Test mount $res = `./test_list.pl $alpha_arg -m native:$sysdir $cwd/tmp_dir`; chop($res); if ($res ne "list test successful") { print "Mount test failed with message: $res\n"; $failures++; } else { $success++; print "test_mount finished successfully\n"; } # Test getcwd $res = `./test_getcwd.pl $alpha_arg $sysdir`; chop($res); if ($res ne "getcwd test successful") { print "getcwd test failed with message: $res\n"; $failures++; } else { $success++; print "test_getcwd finished successfully\n"; } } # Test copy $res = `./test_copy.pl $alpha_arg $sysdir/README $cwd/tmp_dir/README`; chop($res); if ($res ne "copy test successful") { print "copy test failed with message: $res\n"; $failures++; } else { $success++; print "test_copy finished successfully\n"; } # Test stats $res = `./test_stats.pl $alpha_arg $cwd/tmp_dir/README`; chop($res); if ($res ne "stat test successful") { print "stat test failed with message: $res\n"; $failures++; } else { $success++; print "test_stats finished successfully\n"; } # Test stdfd $res = `./test_stdfd.pl $alpha_arg foo_dir`; chop($res); if ($res ne "test_stdfd successful") { print "stdfd test failed with message: $res\n"; $failures++; } else { $success++; print "test_stdfd finished successfully\n"; } print "$failures tests failed and $success tests succeeded\n"; # cleanup system(`rm -rf tmp_dir`); --- NEW FILE --- #!/usr/bin/perl -w # # copy test: Copy a file from src to dest and verify that the new file # : is the same as the old # use IPC::Open2; use strict; use helper; sub usage { print "Usage: ./test_copy.pl [-alpha] <src> <dest>: Copy a file from src to dest\n"; exit(-1); } sub process_cmd { my ($src, $dest, $is_alpha) = @_; eval { if ($is_alpha == 0) { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); } else { open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 ./test_driver --np"); } }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; } my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); } # Get the filesize of src my $size = -s $src; my $bufsize; if ( $size > 1024) { # Arbitrary limit $bufsize = 1024; } else { $bufsize = $size; } # Open src my $cmdstr = '$src = CALL open '."$src O_RDONLY\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); # Open dest $cmdstr = '$dest = CALL open... [truncated message content] |
From: Mei <me...@us...> - 2003-08-15 07:45:38
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv25257 Modified Files: Tag: b_lustre Makefile.am configure.in Log Message: merge changes from HEAD to b_lustre Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/Makefile.am,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -w -b -B -p -r1.7 -r1.7.4.1 --- Makefile.am 26 Mar 2003 00:00:15 -0000 1.7 +++ Makefile.am 15 Aug 2003 07:43:14 -0000 1.7.4.1 @@ -5,7 +5,15 @@ else TESTS = endif +if WITH_CPLANT_TESTS +SUBDIRS = $(TESTS) +else +if WITH_CPLANT_YOD +SUBDIRS = src drivers dev +else SUBDIRS = src drivers dev $(TESTS) +endif +endif EXTRA_DIST = Rules.make \ include/dev.h include/file.h include/fs.h include/inode.h \ @@ -16,6 +24,7 @@ really-clean: maintainer-clean -rm -rf .deps -rm -f Makefile.in \ drivers/native/Makefile.in drivers/incore/Makefile.in \ + drivers/yod/Makefile.in \ drivers/Makefile.in \ dev/stdfd/Makefile.in \ dev/Makefile.in \ Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -w -b -B -p -r1.5 -r1.5.4.1 --- configure.in 26 Mar 2003 00:05:59 -0000 1.5 +++ configure.in 15 Aug 2003 07:43:14 -0000 1.5.4.1 @@ -19,21 +19,19 @@ AC_HEADER_STDC AC_HEADER_STAT AC_HEADER_TIME -AC_ARG_WITH(with_native_driver, +AC_ARG_WITH(native_driver, [ --with-native-driver build native test driver], - [ with_native_driver=${withval} - case "${withval}" in + [ case "${withval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;; - esac], - [with_native_driver=yes]) + esac;], + [with_native_driver=yes;]) AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes) -AC_ARG_WITH(with_incore_driver, +AC_ARG_WITH(incore-driver, [ --with-incore-driver build incore test driver], - [ with_incore_driver=${withval} - case "${withval}" in + [ case "${withval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-incore-driver) ;; @@ -41,10 +39,9 @@ AC_ARG_WITH(with_incore_driver, [with_incore_driver=yes]) AM_CONDITIONAL(WITH_INCORE_DRIVER, test x$with_incore_driver = xyes) -AC_ARG_WITH(with_tests, +AC_ARG_WITH(tests, [ --with-tests build tests], - [ with_tests=${withval} - case "${withval}" in + [ case "${withval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-tests) ;; @@ -54,25 +51,53 @@ AM_CONDITIONAL(WITH_TESTS, test x$with_t AC_ARG_WITH(automount, [ --with-automount=[automount-file-name] with automounts], - with_automount=$withval, - [with_automount=]) -if test x$with_automount != x; then - AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"$with_automount\\\"" -fi + [ if test x${withval} != x; then + AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"${withval}\\\"" + fi]) AC_SUBST(AUTOMOUNT) -AC_ARG_WITH(with_stdfd_dev, +AC_ARG_WITH(stdfd-dev, [ --with-stdfd-dev build standard file descriptors pseudo-driver], - [ with_stdfd_dev=${withval} - case "${withval}" in - yes) - ;; + [ case "${withval}" in + yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-stdfd-dev) ;; esac], [with_stdfd_dev=yes]) AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) +AC_ARG_WITH(cplant_yod, + [ --with-cplant-yod build cplant yod I/O driver], + [ case "${withval}" in + yes) if test x${with_stdfd_dev} != xyes; then + with_stdfd_dev=yes + AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) + fi ;; + no) ;; + *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);; + esac], + [with_cplant_yod=no]) +AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) + +AC_ARG_WITH(cplant_tests, + [ --with-cplant-tests=[cplant build path] build libsysio tests for cplant platform], + [ case "${withval}" in + yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);; + no) with_cplant_tests=no;; + *) CPLANT_PATH=${withval} + CC=${CPLANT_PATH}/cplant-cc + CCDEPMODE=${CC} + CPP="${CC} -E" + AC_CHECK_FILE(${CC}, + [ if test x${with_cplant_yod} != xyes; then + with_cplant_yod=yes + AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) + fi], + [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);; + esac], + [with_cplant_tests=no]) +AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno) + # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses # $machine, $vendor, and $os, and changes them whenever convenient. @@ -154,7 +179,8 @@ AC_MSG_RESULT($alpha_linux_env) AC_MSG_CHECKING(for 64 bit stat and truncate syscalls) AC_TRY_COMPILE([ #include <sys/stat.h> -#include <syscall.h>], +#include <syscall.h> +extern int syscall();], [char path[] = "/"; int fd = 0; struct stat buf; @@ -174,7 +200,8 @@ fi # AC_MSG_CHECKING(for fdatasync system call) AC_TRY_COMPILE([ -#include <syscall.h>], +#include <syscall.h> +extern int syscall();], [int fd = 0; syscall(SYS_fdatasync, fd);], syscall_fdatasync_exists=yes, @@ -188,7 +215,8 @@ fi # AC_MSG_CHECKING(for utime system call) AC_TRY_COMPILE([ -#include <syscall.h>], +#include <syscall.h> +extern int syscall();], [syscall(SYS_utime);], syscall_utime_exists=yes, syscall_utime_exists=no) @@ -196,7 +224,7 @@ AC_MSG_RESULT($syscall_utime_exists) if test x$syscall_utime_exists = xno; then AC_DEFINE(USE_NATIVE_UTIME) fi -# Check for SYS_utime +# Check for __st_ino # AC_MSG_CHECKING(for __st_ino) AC_TRY_COMPILE([ @@ -209,6 +237,19 @@ AC_MSG_RESULT($have__st_ino) if test x$have__st_ino = xyes; then AC_DEFINE(HAVE__ST_INO) fi +# Check for st_gen +# +AC_MSG_CHECKING(for st_gen) +AC_TRY_COMPILE([ +#include <sys/stat.h>], +[struct stat st; +st.st_gen = 0;], + have_st_gen=yes, + have_st_gen=no) +AC_MSG_RESULT($have_st_gen) +if test x$have_st_gen = xyes; then + AC_DEFINE(HAVE_GENERATION) +fi AC_MSG_CHECKING(whether .text pseudo-op must be used) AC_CACHE_VAL(sysio_asm_dot_text, [dnl @@ -319,6 +360,7 @@ AC_OUTPUT( drivers/Makefile drivers/native/Makefile drivers/incore/Makefile + drivers/yod/Makefile dev/Makefile dev/stdfd/Makefile tests/Makefile) |
From: Mei <me...@us...> - 2003-08-15 07:45:38
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1:/tmp/cvs-serv25257/dev/stdfd Modified Files: Tag: b_lustre Makefile.am stdfd.c Log Message: merge changes from HEAD to b_lustre Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- Makefile.am 24 Mar 2003 22:09:02 -0000 1.2 +++ Makefile.am 15 Aug 2003 07:43:14 -0000 1.2.4.1 @@ -5,3 +5,11 @@ EXTRA_DIST = stdfd.h libsysio_stdfd_a_SOURCES = stdfd.c include $(top_srcdir)/Rules.make + +if WITH_CPLANT_YOD +YOD_DRIVER_FLAGS = -DCPLANT_YOD $(YOD_DRIVER_INCLUDE) +else +YOD_DRIVER_FLAGS = +endif + +AM_CPPFLAGS += $(YOD_DRIVER_FLAGS) Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- stdfd.c 24 Mar 2003 22:09:02 -0000 1.2 +++ stdfd.c 15 Aug 2003 07:43:15 -0000 1.2.4.1 @@ -58,6 +58,16 @@ #include "stdfd.h" +#ifdef CPLANT_YOD +#include <sys/statfs.h> +#include "cplant-yod.h" +#define dowrite(f, b, n) write_yod(f, b, n) +#define doread(f, b, n) read_yod(f, b, n) +#else +#define dowrite(f, b, n) syscall(SYS_write, f, b, n) +#define doread(f, b, n) syscall(SYS_read, f, b, n) +#endif + /* * Pre-opened standard file descriptors driver. */ @@ -120,7 +130,7 @@ doio(ssize_t (*f)(int, char *, size_t), struct ioctx *ioctx; const struct iovec *iov; size_t n; - ssize_t cc; + ssize_t cc = 0; ioctx = _sysio_ioctx_new(ino, ioargs); if (!ioctx) @@ -153,7 +163,7 @@ static ssize_t stdfd_read(int fd, char *buf, size_t nbytes) { - return syscall(SYS_read, fd, buf, nbytes); + return doread(fd, buf, nbytes); } static int @@ -171,7 +181,7 @@ stdfd_write(int fd, size_t nbytes) { - return syscall(SYS_write, fd, buf, nbytes); + return dowrite(fd, buf, nbytes); } static int |
From: Mei <me...@us...> - 2003-08-15 07:45:38
|
Update of /cvsroot/libsysio/libsysio/drivers In directory sc8-pr-cvs1:/tmp/cvs-serv25257/drivers Modified Files: Tag: b_lustre Makefile.am Log Message: merge changes from HEAD to b_lustre Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- Makefile.am 24 Mar 2003 22:09:03 -0000 1.2 +++ Makefile.am 15 Aug 2003 07:43:15 -0000 1.2.4.1 @@ -11,4 +11,10 @@ else INCORE_DRIVER = endif -SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) +if WITH_CPLANT_YOD +YOD_DRIVER = yod +else +YOD_DRIVER = +endif + +SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) $(YOD_DRIVER) |
From: Mei <me...@us...> - 2003-08-15 06:27:52
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv13929 Modified Files: Tag: b_lustre open.c Log Message: add weak symbol: open64() creat64() Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.2.2 retrieving revision 1.7.2.3 diff -u -w -b -B -p -r1.7.2.2 -r1.7.2.3 --- open.c 29 Jun 2003 10:15:32 -0000 1.7.2.2 +++ open.c 15 Aug 2003 06:17:24 -0000 1.7.2.3 @@ -55,6 +55,7 @@ #include "file.h" #include "fs.h" #include "mount.h" +#include "sysio-symbols.h" /* * Open file support. @@ -201,6 +202,8 @@ error: return -1; } +sysio_sym_weak_alias(open, open64) + int close(int fd) { @@ -220,6 +223,8 @@ creat(const char *path, mode_t mode) return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); } + +sysio_sym_weak_alias(creat, creat64) mode_t umask(mode_t mask) |
From: Ruth K. <rk...@us...> - 2003-08-14 19:22:03
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv16191/src Modified Files: Makefile.am chdir.c fcntl.c ioctl.c lseek.c namei.c open.c read.c write.c Log Message: merge cplant branch into head Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- Makefile.am 29 Jul 2003 19:53:33 -0000 1.6 +++ Makefile.am 14 Aug 2003 18:39:33 -0000 1.7 @@ -6,3 +6,10 @@ libsysio_a_SOURCES = chdir.c chmod.c cho stat64.c statvfs.c symlink.c truncate.c unlink.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: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- chdir.c 9 Mar 2003 16:57:47 -0000 1.3 +++ chdir.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -226,11 +226,10 @@ _sysio_p_path(struct pnode *pno, char ** * 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 +248,12 @@ getcwd(char *buf, size_t size) } 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 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- fcntl.c 4 Apr 2003 20:09:47 -0000 1.3 +++ fcntl.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -95,3 +95,18 @@ 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; +} +#endif Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1.1.1 -r1.2 --- ioctl.c 22 Feb 2003 16:33:07 -0000 1.1.1.1 +++ ioctl.c 14 Aug 2003 18:39:33 -0000 1.2 @@ -75,3 +75,19 @@ out: } 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.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- lseek.c 31 Jul 2003 22:21:35 -0000 1.5 +++ lseek.c 14 Aug 2003 18:39:33 -0000 1.6 @@ -113,3 +113,31 @@ lseek(int fd, off_t offset, int whence) return (off_t )_sysio_lseek(fd, offset, whence); } + +#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.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- namei.c 11 Jun 2003 20:43:34 -0000 1.6 +++ namei.c 14 Aug 2003 18:39:33 -0000 1.7 @@ -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 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- open.c 23 Apr 2003 18:13:44 -0000 1.7 +++ open.c 14 Aug 2003 18:39:33 -0000 1.8 @@ -49,6 +49,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> +#include <features.h> #include "sysio.h" #include "inode.h" @@ -56,6 +57,13 @@ #include "fs.h" #include "mount.h" +#ifdef __GLIBC__ +#undef open +#undef __open +#undef open64 +#undef __open64 +#endif + /* * Open file support. */ @@ -225,3 +233,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 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- read.c 9 Mar 2003 06:36:37 -0000 1.2 +++ read.c 14 Aug 2003 18:39:33 -0000 1.3 @@ -224,3 +224,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 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- write.c 7 Mar 2003 03:31:36 -0000 1.2 +++ write.c 14 Aug 2003 18:39:33 -0000 1.3 @@ -230,3 +230,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 + |
From: Ruth K. <rk...@us...> - 2003-08-14 19:22:02
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv16191/include Added Files: cplant-yod.h Log Message: merge cplant branch into head |
From: Ruth K. <rk...@us...> - 2003-08-14 19:22:02
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv16191/tests Modified Files: Makefile.am test_copy.c test_getcwd.c test_list.c test_mounts.c test_path.c test_stats.c test_stdfd.c Log Message: merge cplant branch into head Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- Makefile.am 10 May 2003 14:43:58 -0000 1.9 +++ Makefile.am 14 Aug 2003 18:39:33 -0000 1.10 @@ -33,7 +33,15 @@ STDFD_DEV_CFLAGS= STDFD_DEV_LIB= endif -DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(STFD_DEV_NAME) +if WITH_CPLANT_YOD +YOD_DRIVER_NAME=yod +YOD_DRIVER_CFLAGS= -DCPLANT_YOD +else +YOD_DRIVER_NAME= +YOD_DRIVER_CFLAGS= +endif + +DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(YOD_DRIVER_NAME) $(STFD_DEV_NAME) CMNSRC=drv_init_all.c drv_data.c @@ -41,10 +49,10 @@ BUILT_SOURCES=drv_data.c CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ - $(STDFD_DEV_CFLAGS) + $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) LIBS=$(NATIVE_DRIVER_LIB) $(INCORE_DRIVER_LIB) \ - $(STDFD_DEV_LIB) \ + $(STDFD_DEV_LIB) $(YOD_DRIVER_LIB) \ $(top_builddir)/src/libsysio.a test_copy_SOURCES=test_copy.c $(CMNSRC) Index: test_copy.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- test_copy.c 24 Mar 2003 22:09:49 -0000 1.5 +++ test_copy.c 14 Aug 2003 18:39:33 -0000 1.6 @@ -110,6 +110,7 @@ main(int argc, char * const argv[]) if (!(argc - optind)) usage(); +#ifndef CPLANT_YOD if (_sysio_init() != 0) { perror("init sysio"); exit(1); @@ -125,7 +126,7 @@ main(int argc, char * const argv[]) perror(root_driver); exit(1); } - +#endif (void )umask(022); /* @@ -143,7 +144,9 @@ main(int argc, char * const argv[]) err = copy_file(spath, dpath); +#ifndef CPLANT_YOD _sysio_shutdown(); +#endif return err; } Index: test_getcwd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_getcwd.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- test_getcwd.c 9 Mar 2003 16:58:41 -0000 1.1 +++ test_getcwd.c 14 Aug 2003 18:39:33 -0000 1.2 @@ -108,7 +108,7 @@ main(int argc, char *const argv[]) default: usage(); } - +#ifndef CPLANT_YOD /* * Init sysio lib. */ @@ -130,6 +130,7 @@ main(int argc, char *const argv[]) perror("_sysio_mount_root"); exit(1); } +#endif n = argc - optind; @@ -165,10 +166,12 @@ main(int argc, char *const argv[]) } } +#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); +#endif return 0; } Index: test_list.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_list.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_list.c 24 Mar 2003 22:09:49 -0000 1.4 +++ test_list.c 14 Aug 2003 18:39:33 -0000 1.5 @@ -109,6 +109,7 @@ main(int argc, char *const argv[]) usage(); } +#ifndef CPLANT_YOD /* * Init sysio lib. */ @@ -130,7 +131,7 @@ main(int argc, char *const argv[]) perror("_sysio_mount_root"); exit(1); } - +#endif n = argc - optind; /* @@ -165,10 +166,12 @@ main(int argc, char *const argv[]) } } +#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); +#endif return 0; } Index: test_mounts.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_mounts.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_mounts.c 9 Mar 2003 16:57:47 -0000 1.3 +++ test_mounts.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -103,6 +103,7 @@ main(int argc, char *const argv[]) usage(); } +#ifndef CPLANT_YOD /* * Init sysio lib. */ @@ -124,7 +125,7 @@ main(int argc, char *const argv[]) perror("_sysio_mount_root"); exit(1); } - +#endif n = argc - optind; @@ -160,10 +161,12 @@ main(int argc, char *const argv[]) } } +#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); +#endif return 0; } @@ -429,7 +432,7 @@ mountit(const char *arg) /* * Eat leading white. */ - while (*s && *s == ' ' && *s == '\t') + while (*s && *s == ' ' || *s == '\t') s++; /* * Get opts. @@ -438,7 +441,7 @@ mountit(const char *arg) while (*cp && *cp != ' ' && *cp != '\t') cp++; if (opts == cp) { - (void )fprintf(stderr, "%s: Missing target\n", arg); + (void )fprintf(stderr, "%s: Missing opts\n", arg); err = -1; goto out; } @@ -449,7 +452,7 @@ mountit(const char *arg) /* * Eat leading white. */ - while (*s && *s == ' ' && *s == '\t') + while (*s && *s == ' ' || *s == '\t') s++; /* * Get target @@ -464,6 +467,9 @@ mountit(const char *arg) if (*cp) *cp++ = '\0'; + err = mkdir(target, "0777"); + if (err && errno != EEXIST) + perror(target); err = mount(source, target, fstype, 0, opts); if (err) perror(arg); Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_path.c 9 Mar 2003 16:57:47 -0000 1.3 +++ test_path.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -109,6 +109,7 @@ main(int argc, char *const argv[]) usage(); } +#ifndef CPLANT_YOD /* * Init sysio lib. */ @@ -130,7 +131,7 @@ main(int argc, char *const argv[]) perror("_sysio_mount_root"); exit(1); } - +#endif n = argc - optind; @@ -166,10 +167,12 @@ main(int argc, char *const argv[]) } } +#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); +#endif return 0; } Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_stats.c 9 Mar 2003 16:57:47 -0000 1.3 +++ test_stats.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -99,6 +99,7 @@ main(int argc, char * const argv[]) usage(); } +#ifndef CPLANT_YOD if (_sysio_init() != 0) { perror("init sysio"); exit(1); @@ -114,16 +115,18 @@ main(int argc, char * const argv[]) perror(root_driver); exit(1); } - +#endif (void )umask(022); while (optind < argc) do_stats(argv[optind++]); +#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); +#endif return 0; } Index: test_stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stdfd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- test_stdfd.c 24 Mar 2003 22:09:49 -0000 1.2 +++ test_stdfd.c 14 Aug 2003 18:39:33 -0000 1.3 @@ -119,6 +119,7 @@ main(int argc, char *const argv[]) if (argc - optind != 1) usage(); +#ifndef CPLANT_YOD /* * Init sysio lib. */ @@ -200,6 +201,7 @@ main(int argc, char *const argv[]) goto out; } +#endif /* * Read from stdin, write to stdout and stderr. */ @@ -226,8 +228,9 @@ main(int argc, char *const argv[]) * Clean up. */ out: +#ifndef CPLANT_YOD _sysio_shutdown(); - +#endif return 0; } |
From: Sonja T. <so...@us...> - 2003-08-14 18:58:33
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv16559/libsysio/include Modified Files: Tag: libsysio_tests inode.h sysio.h Log Message: Trying to get these missing files in again...it turns out I am not very good at CVS commands.. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -u -w -b -B -p -r1.6 -r1.6.6.1 --- inode.h 23 Apr 2003 19:45:51 -0000 1.6 +++ inode.h 14 Aug 2003 18:42:22 -0000 1.6.6.1 @@ -129,6 +129,7 @@ struct inode_ops { struct inode { LIST_ENTRY(inode) i_link; /* FS i-nodes link */ unsigned i_immune : 1; /* immune from GC */ + unsigned i_zombie : 1; /* stale inode */ unsigned i_ref; /* soft ref counter */ ino_t i_num; /* i-num (deprecate!) */ mode_t i_mode; /* mode (see stat.h) */ @@ -146,6 +147,7 @@ struct inode { #define I_INIT(ino, fs, inum, mode, rdev, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ + (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ (ino)->i_num = (inum); \ (ino)->i_mode = (mode); \ @@ -407,6 +409,7 @@ extern struct inode *_sysio_i_find(struc ino_t ino, struct file_identifier *fid); extern void _sysio_i_gone(struct inode *ino); +extern void _sysio_i_undead(struct inode *ino); extern int _sysio_p_find_alias(struct pnode *parent, struct qstr *name, struct pnode **pnop); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7 retrieving revision 1.7.8.1 diff -u -w -b -B -p -r1.7 -r1.7.8.1 --- sysio.h 26 Mar 2003 00:06:04 -0000 1.7 +++ sysio.h 14 Aug 2003 18:42:22 -0000 1.7.8.1 @@ -124,9 +124,7 @@ extern void _sysio_shutdown(void); * but it's not illegal to have multiple externs, so long as they are the * same. It helps when building the library in a standalone fashion. */ -#if 0 extern int access(const char *path, int amode); -#endif extern int chdir(const char *path); extern int chmod(const char *path, mode_t mode); extern int chown(const char *path, uid_t owner, gid_t group); |
From: Sonja T. <so...@us...> - 2003-08-14 18:57:18
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv16559/libsysio/drivers/native Modified Files: Tag: libsysio_tests fs_native.c Log Message: Trying to get these missing files in again...it turns out I am not very good at CVS commands.. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11 retrieving revision 1.11.6.1 diff -u -w -b -B -p -r1.11 -r1.11.6.1 --- fs_native.c 23 Apr 2003 18:18:38 -0000 1.11 +++ fs_native.c 14 Aug 2003 18:42:22 -0000 1.11.6.1 @@ -151,6 +151,9 @@ do { struct native_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -310,8 +313,12 @@ native_i_new(struct filesys *fs, struct nino = malloc(sizeof(struct native_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -496,6 +503,27 @@ native_fsswop_mount(const char *source, return err; } +static int +native_i_invalid(struct inode *inop, struct intnl_stat stbuf) +{ + /* + * Validate passed in inode against stat struct info + */ + struct native_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev != stbuf.st_dev || + nino->ni_ident.ino != stbuf.st_ino || +#ifdef HAVE_GENERATION + nino->ni_ident.gen != stbuf.st_gen || +#endif + ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || + (((inop)->i_rdev != stbuf.st_rdev) && + (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) + return 1; + + return 0; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -525,11 +553,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct native_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!native_i_invalid(*inop, stbuf)) return 0; /* * Invalidate. @@ -540,23 +564,40 @@ native_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (native_i_invalid(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = native_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; @@ -965,7 +1006,7 @@ static int native_inop_unlink(struct pnode *pno) { char *path; - int err; + int err = 0; path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -983,7 +1024,8 @@ native_inop_unlink(struct pnode *pno) * (usually .NFSXXXXXX, where the X's are replaced by the PID and some * unique characters) in order to simulate the proper semantic. */ - err = syscall(SYS_unlink, path); + if (syscall(SYS_unlink, path) != 0) + err = -errno; free(path); return err; } |
From: Sonja T. <so...@us...> - 2003-08-14 18:57:17
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv16559/libsysio/src Modified Files: Tag: libsysio_tests Makefile.am file.c getdirentries.c inode.c lseek.c namei.c Added Files: Tag: libsysio_tests access.c Log Message: Trying to get these missing files in again...it turns out I am not very good at CVS commands.. --- 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 retrieving revision 1.5.8.1 diff -u -w -b -B -p -r1.5 -r1.5.8.1 --- Makefile.am 24 Mar 2003 22:09:06 -0000 1.5 +++ Makefile.am 14 Aug 2003 18:42:22 -0000 1.5.8.1 @@ -3,6 +3,6 @@ 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 + stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c include $(top_srcdir)/Rules.make Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.4 retrieving revision 1.4.12.1 diff -u -w -b -B -p -r1.4 -r1.4.12.1 --- file.c 9 Mar 2003 17:18:57 -0000 1.4 +++ file.c 14 Aug 2003 18:42:22 -0000 1.4.12.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 retrieving revision 1.1.12.1 diff -u -w -b -B -p -r1.1 -r1.1.12.1 --- getdirentries.c 9 Mar 2003 13:53:53 -0000 1.1 +++ getdirentries.c 14 Aug 2003 18:42:22 -0000 1.1.12.1 @@ -64,7 +64,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 retrieving revision 1.7.6.1 diff -u -w -b -B -p -r1.7 -r1.7.6.1 --- inode.c 23 Apr 2003 19:45:52 -0000 1.7 +++ inode.c 14 Aug 2003 18:42:22 -0000 1.7.6.1 @@ -265,6 +265,7 @@ _sysio_i_gone(struct inode *ino) if (ino->i_ref) abort(); + if (!ino->i_zombie) LIST_REMOVE(ino, i_link); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); @@ -272,6 +273,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: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -u -w -b -B -p -r1.4 -r1.4.6.1 --- lseek.c 27 Apr 2003 13:20:01 -0000 1.4 +++ lseek.c 14 Aug 2003 18:42:22 -0000 1.4.6.1 @@ -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; Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.5 retrieving revision 1.5.8.1 diff -u -w -b -B -p -r1.5 -r1.5.8.1 --- namei.c 24 Mar 2003 22:09:06 -0000 1.5 +++ namei.c 14 Aug 2003 18:42:22 -0000 1.5.8.1 @@ -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++; |
From: Ruth K. <rk...@us...> - 2003-08-14 18:55:11
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv16191/drivers/yod Added Files: Makefile.am fs_yod.c fs_yod.h Log Message: merge cplant branch into head |
From: Ruth K. <rk...@us...> - 2003-08-14 18:55:10
|
Update of /cvsroot/libsysio/libsysio/drivers In directory sc8-pr-cvs1:/tmp/cvs-serv16191/drivers Modified Files: Makefile.am Log Message: merge cplant branch into head Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- Makefile.am 24 Mar 2003 22:09:03 -0000 1.2 +++ Makefile.am 14 Aug 2003 18:39:33 -0000 1.3 @@ -11,4 +11,10 @@ else INCORE_DRIVER = endif -SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) +if WITH_CPLANT_YOD +YOD_DRIVER = yod +else +YOD_DRIVER = +endif + +SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) $(YOD_DRIVER) |
From: Ruth K. <rk...@us...> - 2003-08-14 18:55:10
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1:/tmp/cvs-serv16191/dev/stdfd Modified Files: Makefile.am stdfd.c Log Message: merge cplant branch into head Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- Makefile.am 24 Mar 2003 22:09:02 -0000 1.2 +++ Makefile.am 14 Aug 2003 18:39:32 -0000 1.3 @@ -5,3 +5,11 @@ EXTRA_DIST = stdfd.h libsysio_stdfd_a_SOURCES = stdfd.c include $(top_srcdir)/Rules.make + +if WITH_CPLANT_YOD +YOD_DRIVER_FLAGS = -DCPLANT_YOD $(YOD_DRIVER_INCLUDE) +else +YOD_DRIVER_FLAGS = +endif + +AM_CPPFLAGS += $(YOD_DRIVER_FLAGS) Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- stdfd.c 31 Jul 2003 22:21:36 -0000 1.3 +++ stdfd.c 14 Aug 2003 18:39:33 -0000 1.4 @@ -58,6 +58,16 @@ #include "stdfd.h" +#ifdef CPLANT_YOD +#include <sys/statfs.h> +#include "cplant-yod.h" +#define dowrite(f, b, n) write_yod(f, b, n) +#define doread(f, b, n) read_yod(f, b, n) +#else +#define dowrite(f, b, n) syscall(SYS_write, f, b, n) +#define doread(f, b, n) syscall(SYS_read, f, b, n) +#endif + /* * Pre-opened standard file descriptors driver. */ @@ -153,7 +163,7 @@ static ssize_t stdfd_read(int fd, char *buf, size_t nbytes) { - return syscall(SYS_read, fd, buf, nbytes); + return doread(fd, buf, nbytes); } static int @@ -171,7 +181,7 @@ stdfd_write(int fd, size_t nbytes) { - return syscall(SYS_write, fd, buf, nbytes); + return dowrite(fd, buf, nbytes); } static int |