[Libsysio-commit] cplant: libsysio/tests test_unlink.c Makefile.am drv_init_all.c sysio_stubs.c sysi
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2003-10-09 15:04:19
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv7240/tests Modified Files: Tag: cplant Makefile.am drv_init_all.c sysio_stubs.c sysio_tests.c test_copy.c test_driver.c test_driver.h test_getcwd.c test_list.c test_mounts.c test_path.c test_stats.c test_stats.pl test_stdfd.c test_stdfd.pl Added Files: Tag: cplant test_unlink.c Log Message: Merging redstorm changes --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef REDSTORM #include <getopt.h> #else #include <unistd.h> #endif #include <errno.h> #include <sys/types.h> #include <sys/queue.h> #if 0 #include <dirent.h> #endif #include "sysio.h" #include "mount.h" #include "test.h" /* * Unlink files. * * Usage: unlink [-a] [-m <fsname>] [-r <mntpath>] [path...] * * Without any path arguments, the program unlinks files named * by the ocmmand line args. */ static int unlinkit(const char *path); static void usage(void); static const char *root_driver = DEFAULT_DRIVER; static const char *mntpath = "/"; static unsigned mntflgs = 0; #ifdef AUTOMOUNT_FILE_NAME #define EXTRA_AUTOMOUNT_OPT "a" #else #define EXTRA_AUTOMOUNT_OPT #endif const char *opts = EXTRA_AUTOMOUNT_OPT "m:r:"; int main(int argc, char *const argv[]) { int i; int err; int n; /* * Parse command line arguments. */ while ((i = getopt(argc, argv, opts)) != -1) switch (i) { #ifdef AUTOMOUNT_FILE_NAME case 'a': mntflgs |= MOUNT_F_AUTO; break; #endif case 'm': root_driver = optarg; break; case 'r': mntpath = optarg; break; default: usage(); } /* * Init sysio lib. */ _sysio_init(); /* * Init native file system driver and request mount of specified * source directory. */ err = drv_init_all(); if (err) { errno = -err; perror("drv_init_all"); exit(1); } err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); if (err) { errno = -err; perror("_sysio_mount_root"); exit(1); } n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )unlinkit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) unlinkit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ _sysio_shutdown(); return 0; } static int unlinkit(const char *path) { if (unlink(path) != 0) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" " [<path> ...\n]"); exit(1); } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -u -w -b -B -p -r1.12.2.2 -r1.12.2.3 --- Makefile.am 20 Aug 2003 21:05:49 -0000 1.12.2.2 +++ Makefile.am 9 Oct 2003 15:04:10 -0000 1.12.2.3 @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd test_driver + test_getcwd test_stdfd test_unlink test_driver CLEANFILES=drv_data.c @@ -36,7 +36,6 @@ endif if WITH_CPLANT_YOD YOD_DRIVER_NAME=yod YOD_DRIVER_CFLAGS= -DCPLANT_YOD -YOD_DRIVER_LIB= $(top_builddir)/drivers/yod/libsysio_yod.a else YOD_DRIVER_NAME= YOD_DRIVER_CFLAGS= @@ -46,7 +46,7 @@ DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_D CMNSRC=drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c -#check_PROGRAMS=test_driver +check_PROGRAMS=test_driver if TEST_ALPHA_ARG TESTS_ENVIRONMENT=IS_ALPHA=yes else @@ -97,8 +97,13 @@ test_stdfd_CFLAGS=$(AM_CFLAGS) test_stdfd_LDADD=$(LIBS) test_stdfd_DEPENDENCIES=$(LIBS) +test_unlink_SOURCES=test_unlink.c $(CMNSRC) +test_unlink_CFLAGS=$(CFL) +test_unlink_LDADD=$(LIBS) +test_unlink_DEPENDENCIES=$(LIBS) + test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) -test_driver_CFLAGS=$(AM_CFLAGS) +test_driver_CFLAGS=$(CFL) test_driver_LDADD=$(LIBS) test_driver_DEPENDENCIES=$(LIBS) Index: drv_init_all.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/drv_init_all.c,v retrieving revision 1.1 retrieving revision 1.1.18.1 diff -u -w -b -B -p -r1.1 -r1.1.18.1 --- drv_init_all.c 22 Feb 2003 18:25:11 -0000 1.1 +++ drv_init_all.c 9 Oct 2003 15:04:10 -0000 1.1.18.1 @@ -1,3 +1,5 @@ +#include <stdio.h> + extern int (*drvinits[])(void); /* @@ -13,9 +15,10 @@ drv_init_all() f = drvinits; while (*f) { err = (**f++)(); - if (err) + if (err) { return err; } + } return 0; } Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.2 --- sysio_stubs.c 20 Aug 2003 21:05:49 -0000 1.2.6.1 +++ sysio_stubs.c 9 Oct 2003 15:04:10 -0000 1.2.6.2 @@ -22,7 +22,7 @@ * ################################################ */ -int do_setdebug(int argc, char **argv) +int test_do_setdebug(int argc, char **argv) { int level; @@ -43,7 +43,7 @@ int do_setdebug(int argc, char **argv) return SUCCESS; } -int do_printline(int argc, char **argv) +int test_do_printline(int argc, char **argv) { int on; @@ -64,7 +64,7 @@ int do_printline(int argc, char **argv) } /* -int do_setoutput(int argc, char **argv) +int test_do_setoutput(int argc, char **argv) { FILE *newfp; @@ -88,7 +88,7 @@ int do_setoutput(int argc, char **argv) */ -int do_fillbuff(int argc, char **argv) +int test_do_fillbuff(int argc, char **argv) { char *typestr, *buf; void *valptr; @@ -209,7 +209,7 @@ void print_partial(char *buf, int offset } } -int do_printbuf(int argc, char **argv) +int test_do_printbuf(int argc, char **argv) { int index, i, type, offset, len; struct buf_t *buf_st; @@ -288,10 +288,10 @@ int do_printbuf(int argc, char **argv) return SUCCESS; } -int do_mount(int argc, char **argv) +int test_do_mount(int argc, char **argv) { if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for do_mount\n", + DBG(2, fprintf(outfp, "Invalid number of args (%d) for test_do_mount\n", argc)); return INVALID_ARGS; } @@ -304,7 +304,7 @@ int do_mount(int argc, char **argv) return SUCCESS; } -int do_clear(int argc, char **argv) +int test_do_clear(int argc, char **argv) { int index; struct buf_t *buf; @@ -326,7 +326,7 @@ int do_clear(int argc, char **argv) return SUCCESS; } -int do_list(int argc, char **argv) +int test_do_list(int argc, char **argv) { char *buf; @@ -336,7 +336,7 @@ int do_list(int argc, char **argv) return INVALID_ARGS; } - DBG(5,fprintf(outfp, "In do_list with args %p\n", argv)); + DBG(5,fprintf(outfp, "In test_do_list with args %p\n", argv)); if (!argv) { buf = getcwd(NULL, 0); DBG(4, fprintf(outfp, "Calling list with dir of %s\n", buf)); @@ -354,7 +354,7 @@ int do_list(int argc, char **argv) * Initlizes sysio library. Will use default initlization * unless arguments are given */ -int do_init(int argc, char **argv) +int test_do_init(int argc, char **argv) { if (argc > 0) { char *rdriver; @@ -391,7 +391,7 @@ int do_init(int argc, char **argv) } } - DBG(5, fprintf(outfp, "In do_init\n")); + DBG(5, fprintf(outfp, "In test_do_init\n")); last_type = SINT; DBG(3, fprintf(outfp, "Using driver %s, path %s, flags %x\n", root_driver, mntpath, mntflgs)); @@ -408,7 +408,7 @@ int get_endian(int argc, char **argv) int x = 1; if ((argc) || (argv)) { - DBG(2, fprintf(outfp, "Expected no args for do_endian\n")); + DBG(2, fprintf(outfp, "Expected no args for test_do_endian\n")); return INVALID_ARGS; } @@ -460,7 +460,7 @@ int get_sizeof(int argc, char **argv) return SUCCESS; } -int do_exit(int argc, char **argv) +int test_do_exit(int argc, char **argv) { int val = 0; @@ -582,7 +582,7 @@ int cmp_bufs(int argc, char **argv) return res; } -int do_chdir(int argc, char **argv) +int test_do_chdir(int argc, char **argv) { if (argc != 1) { DBG(2, fprintf(outfp, "Number of args (%d) invalid for chdir\n", @@ -594,7 +594,7 @@ int do_chdir(int argc, char **argv) } -int do_chmod(int argc, char **argv) +int test_do_chmod(int argc, char **argv) { if (argc != 2) { DBG(2, fprintf(outfp, "Number of args (%d) invalid for chmod\n", @@ -605,7 +605,7 @@ int do_chmod(int argc, char **argv) return sysio_chmod(argv[0], argv[1]); } -int do_chown(int argc, char **argv) +int test_do_chown(int argc, char **argv) { if (argc != 2) { DBG(2, fprintf(outfp, "Number of args (%d) invalid for chown\n", @@ -616,7 +616,7 @@ int do_chown(int argc, char **argv) return sysio_chown(argv[0], argv[1]); } -int do_open(int argc, char **argv) +int test_do_open(int argc, char **argv) { char *name = argv[0]; int flags = O_RDWR; @@ -649,7 +649,7 @@ int do_open(int argc, char **argv) return SUCCESS; } -int do_close(int argc, char **argv) +int test_do_close(int argc, char **argv) { int fd; char *name = argv[0]; @@ -675,7 +675,7 @@ int do_close(int argc, char **argv) return SUCCESS; } -int do_dup(int argc, char **argv) +int test_do_dup(int argc, char **argv) { int fd; char *var_name = argv[0]; @@ -700,7 +700,7 @@ int do_dup(int argc, char **argv) return SUCCESS; } -int do_dup2(int argc, char **argv) +int test_do_dup2(int argc, char **argv) { int fd1, fd2; char *var_name1 = argv[0]; @@ -770,7 +770,7 @@ struct cmd_map* get_cmd(char *cmd_name, return NULL; } -int do_fcntl(int argc, char **argv) +int test_do_fcntl(int argc, char **argv) { struct cmd_map *cmd; @@ -806,7 +806,7 @@ int do_fcntl(int argc, char **argv) return SUCCESS; } -int do_fstat(int argc, char **argv) +int test_do_fstat(int argc, char **argv) { int fd, index; void *buf; @@ -841,7 +841,7 @@ int do_fstat(int argc, char **argv) return SUCCESS; } -int do_lstat(int argc, char **argv) +int test_do_lstat(int argc, char **argv) { char *name = argv[0]; int index; @@ -866,7 +866,7 @@ int do_lstat(int argc, char **argv) return sysio_lstat(name, buf); } -int do_fsync(int argc, char **argv) +int test_do_fsync(int argc, char **argv) { int fd; @@ -892,7 +892,7 @@ int do_fsync(int argc, char **argv) } -int do_fdatasync(int argc, char **argv) +int test_do_fdatasync(int argc, char **argv) { int fd; @@ -918,7 +918,7 @@ int do_fdatasync(int argc, char **argv) } -int do_ftruncate(int argc, char **argv) +int test_do_ftruncate(int argc, char **argv) { int fd; off_t length; @@ -948,7 +948,7 @@ int do_ftruncate(int argc, char **argv) return SUCCESS; } -int do_getcwd(int argc, char **argv) +int test_do_getcwd(int argc, char **argv) { char *buf; int size, index; @@ -985,7 +985,7 @@ int do_getcwd(int argc, char **argv) return SUCCESS; } -int do_lseek(int argc, char **argv) +int test_do_lseek(int argc, char **argv) { int fd, whence; off_t offset; @@ -1021,7 +1021,7 @@ int do_lseek(int argc, char **argv) return SUCCESS; } -int do_getdirentries(int argc, char **argv) +int test_do_getdirentries(int argc, char **argv) { int fd, nbytes; int bufindex; @@ -1084,7 +1084,7 @@ int do_getdirentries(int argc, char **ar return SUCCESS; } -int do_mkdir(int argc, char **argv) +int test_do_mkdir(int argc, char **argv) { if (argc !=2) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to mkdir\n", argc)); @@ -1095,7 +1095,7 @@ int do_mkdir(int argc, char **argv) return sysio_mkdir(argv[0], argv[1]); } -int do_creat(int argc, char **argv) +int test_do_creat(int argc, char **argv) { if (argc !=2) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to creat\n", argc)); @@ -1106,7 +1106,7 @@ int do_creat(int argc, char **argv) return sysio_creat(argv[0], argv[1]); } -int do_stat(int argc, char **argv) +int test_do_stat(int argc, char **argv) { int index; void *buf; @@ -1132,7 +1132,7 @@ int do_stat(int argc, char **argv) return sysio_stat(str, buf); } -int do_statvfs(int argc, char **argv) +int test_do_statvfs(int argc, char **argv) { int index; void *buf; @@ -1156,7 +1156,7 @@ int do_statvfs(int argc, char **argv) return sysio_statvfs(argv[0], buf); } -int do_fstatvfs(int argc, char **argv) +int test_do_fstatvfs(int argc, char **argv) { int index, fd; void *buf; @@ -1188,7 +1188,7 @@ int do_fstatvfs(int argc, char **argv) return sysio_fstatvfs(fd, buf); } -int do_truncate(int argc, char **argv) +int test_do_truncate(int argc, char **argv) { off_t length; @@ -1208,7 +1208,7 @@ int do_truncate(int argc, char **argv) return SUCCESS; } -int do_rmdir(int argc, char **argv) +int test_do_rmdir(int argc, char **argv) { if (argc != 1) { @@ -1225,7 +1225,7 @@ int do_rmdir(int argc, char **argv) return SUCCESS; } -int do_symlink(int argc, char **argv) +int test_do_symlink(int argc, char **argv) { if (argc != 2) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to symlink\n", argc)); @@ -1245,13 +1245,13 @@ int do_symlink(int argc, char **argv) struct cmd_map ioctl_cmds[] = { +#if 0 { "BLKROSET", BLKROSET, 3 }, { "BLKROGET", BLKROGET, 3 }, { "BLKRRPART", BLKRRPART, 3 }, { "BLKGETSIZE", BLKGETSIZE, 3 }, { "BLKRASET", BLKRASET, 3 }, { "BLKRAGET", BLKRAGET, 3 }, -#if 0 { "BLKSECTSET", BLKSECTSET, 3 }, { "BLKSECTGET", BLKSECTGET, 3 }, { "BLKSSZGET", BLKSSZGET, 3 }, @@ -1279,7 +1279,7 @@ int get_ioctl_cmd(char *cmd) return -1; } -int do_ioctl(int argc, char **argv) +int test_do_ioctl(int argc, char **argv) { int fd, cmd; @@ -1312,7 +1312,7 @@ int do_ioctl(int argc, char **argv) return SUCCESS; } -int do_unlink(int argc, char **argv) +int test_do_unlink(int argc, char **argv) { if (argc != 1) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to unlink\n", argc)); @@ -1330,7 +1330,7 @@ int do_unlink(int argc, char **argv) return SUCCESS; } -int do_umask(int argc, char **argv) +int test_do_umask(int argc, char **argv) { mode_t old_mask; @@ -1347,7 +1347,7 @@ int do_umask(int argc, char **argv) return SUCCESS; } -int do_iowait(int argc, char **argv) +int test_do_iowait(int argc, char **argv) { int err; ioid_t ioid; @@ -1375,7 +1375,7 @@ int do_iowait(int argc, char **argv) return SUCCESS; } -int do_iodone(int argc, char **argv) +int test_do_iodone(int argc, char **argv) { int err; ioid_t ioid; @@ -1403,7 +1403,7 @@ int do_iodone(int argc, char **argv) } -int do_ipread(int argc, char **argv) +int test_do_ipread(int argc, char **argv) { int fd, index, count, offset; char *buf; @@ -1449,7 +1449,7 @@ int do_ipread(int argc, char **argv) return SUCCESS; } -int do_iread(int argc, char **argv) +int test_do_iread(int argc, char **argv) { int fd, index, count; char *buf; @@ -1490,7 +1490,7 @@ int do_iread(int argc, char **argv) } -int do_ipreadv(int argc, char **argv) +int test_do_ipreadv(int argc, char **argv) { int fd, count, index; off_t offset; @@ -1545,7 +1545,7 @@ int do_ipreadv(int argc, char **argv) } -int do_preadv(int argc, char **argv) +int test_do_preadv(int argc, char **argv) { int fd, count, index; off_t offset; @@ -1600,7 +1600,7 @@ int do_preadv(int argc, char **argv) } -int do_pread(int argc, char **argv) +int test_do_pread(int argc, char **argv) { int fd, count, index, numbytes, offset; char *buf; @@ -1653,7 +1653,7 @@ int do_pread(int argc, char **argv) } -int do_ireadv(int argc, char **argv) +int test_do_ireadv(int argc, char **argv) { int fd, count, index; char *buf; @@ -1700,7 +1700,7 @@ int do_ireadv(int argc, char **argv) return SUCCESS; } -int do_readv(int argc, char **argv) +int test_do_readv(int argc, char **argv) { int fd, count, index; char *buf; @@ -1747,7 +1747,7 @@ int do_readv(int argc, char **argv) return SUCCESS; } -int do_read(int argc, char **argv) +int test_do_read(int argc, char **argv) { int fd, count, index, numbytes=0; char *buf; @@ -1800,7 +1800,7 @@ int do_read(int argc, char **argv) return SUCCESS; } -int do_ipwritev(int argc, char **argv) +int test_do_ipwritev(int argc, char **argv) { int fd, count, index, offset; char *buf; @@ -1854,7 +1854,7 @@ int do_ipwritev(int argc, char **argv) return SUCCESS; } -int do_ipwrite(int argc, char **argv) +int test_do_ipwrite(int argc, char **argv) { int fd, count, index, offset; char *buf; @@ -1901,7 +1901,7 @@ int do_ipwrite(int argc, char **argv) return SUCCESS; } -int do_pwritev(int argc, char **argv) +int test_do_pwritev(int argc, char **argv) { int fd, count, index, offset; char *buf; @@ -1956,7 +1956,7 @@ int do_pwritev(int argc, char **argv) return SUCCESS; } -int do_pwrite(int argc, char **argv) +int test_do_pwrite(int argc, char **argv) { int fd, count, index, offset; char *buf; @@ -2004,7 +2004,7 @@ int do_pwrite(int argc, char **argv) } -int do_iwritev(int argc, char **argv) +int test_do_iwritev(int argc, char **argv) { int fd, count, index; char *buf; @@ -2051,7 +2051,7 @@ int do_iwritev(int argc, char **argv) return SUCCESS; } -int do_iwrite(int argc, char **argv) +int test_do_iwrite(int argc, char **argv) { int fd, count, index; char *buf; @@ -2093,7 +2093,7 @@ int do_iwrite(int argc, char **argv) } -int do_write(int argc, char **argv) +int test_do_write(int argc, char **argv) { int fd, count, index, err; char *buf; @@ -2139,7 +2139,7 @@ int do_write(int argc, char **argv) } -int do_writev(int argc, char **argv) +int test_do_writev(int argc, char **argv) { int fd, count, index; char *buf; @@ -2186,7 +2186,7 @@ int do_writev(int argc, char **argv) return SUCCESS; } -int do_mknod(int argc, char **argv) +int test_do_mknod(int argc, char **argv) { int dev; @@ -2206,7 +2206,7 @@ int do_mknod(int argc, char **argv) return sysio_mknod(argv[0], argv[1], (dev_t) dev); } -int do_umount(int argc, char **argv) +int test_do_umount(int argc, char **argv) { int err; Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_tests.c,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.2 --- sysio_tests.c 20 Aug 2003 21:05:49 -0000 1.2.6.1 +++ sysio_tests.c 9 Oct 2003 15:04:10 -0000 1.2.6.2 @@ -44,6 +44,7 @@ int initilize_sysio(char *root_driver, c * source directory. */ err = drv_init_all(); + DBG(5, sprintf(output, "%sdrv_init_all: err %d\n", output, err)); if (err) { my_errno = err; my_perror("drv_init_all"); @@ -51,6 +52,7 @@ int initilize_sysio(char *root_driver, c return SUCCESS; } err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); + DBG(5, sprintf(output, "%ssysio_mount_root: err %d\n", output, err)); if (err) { my_errno = errno; my_perror("_sysio_mount_root"); @@ -70,6 +72,7 @@ int initilize_sysio(char *root_driver, c strcpy(wd, "/"); } if (chdir(wd) != 0) { + DBG(5, sprintf(output, "%schdir: errno %d\n", output, errno)); my_perror(wd); my_errno = errno; last_ret_val = errno; @@ -551,10 +555,10 @@ int sysio_chown(char *new_id, char *file 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; + DBG(3, sprintf(output, "Returning with errno set to %s (ret val is %d)\n", + strerror(my_errno), last_ret_val)); return SUCCESS; } @@ -574,6 +578,7 @@ int sysio_open3(char *path, int flags, c last_ret_val = open(path, flags, mode); my_errno = errno; + return SUCCESS; } Index: test_copy.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2 --- test_copy.c 28 Aug 2003 13:39:24 -0000 1.6.2.1 +++ test_copy.c 9 Oct 2003 15:04:10 -0000 1.6.2.2 @@ -46,7 +46,9 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#ifndef REDSTORM #include <getopt.h> +#endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.2 --- test_driver.c 20 Aug 2003 21:05:49 -0000 1.2.6.1 +++ test_driver.c 9 Oct 2003 15:04:10 -0000 1.2.6.2 @@ -39,68 +39,68 @@ struct queue_t { struct cmd_t cmd_list[] = { {"alloc", get_buffer, usage_get_buffer}, - {"chdir", do_chdir, usage_chdir}, - {"chmod", do_chmod, usage_chmod}, - {"chown", do_chown, usage_chown}, - {"clear", do_clear, usage_clear}, - {"close", do_close, usage_close}, + {"chdir", test_do_chdir, usage_chdir}, + {"chmod", test_do_chmod, usage_chmod}, + {"chown", test_do_chown, usage_chown}, + {"clear", test_do_clear, usage_clear}, + {"close", test_do_close, usage_close}, {"cmpstr", cmp_bufs, usage_cmpbufs}, - {"creat", do_creat, usage_creat}, - {"debug", do_setdebug, usage_setdebug}, - {"dup", do_dup, usage_dup}, - {"dup2", do_dup2, usage_dup2}, + {"creat", test_do_creat, usage_creat}, + {"debug", test_do_setdebug, usage_setdebug}, + {"dup", test_do_dup, usage_dup}, + {"dup2", test_do_dup2, usage_dup2}, {"endian", get_endian, usage_endian}, - {"exit", do_exit, usage_exit}, - {"fcntl", do_fcntl, usage_fcntl}, - {"fdatasync", do_fdatasync, usage_fdatasync}, - {"fill", do_fillbuff, usage_do_fillbuff}, + {"exit", test_do_exit, usage_exit}, + {"fcntl", test_do_fcntl, usage_fcntl}, + {"fdatasync", test_do_fdatasync, usage_fdatasync}, + {"fill", test_do_fillbuff, usage_do_fillbuff}, {"free", free_buffer, usage_free_buffer}, - {"fstat", do_fstat, usage_fstat}, - {"fstatvfs", do_fstatvfs, usage_fstatvfs}, - {"fsync", do_fsync, usage_fsync}, - {"ftruncate", do_ftruncate, usage_ftruncate}, - {"getcwd", do_getcwd, usage_getcwd}, - {"getdirentries", do_getdirentries, usage_getdirentries}, - {"init", do_init, usage_init}, - {"ioctl", do_ioctl, usage_ioctl}, - {"iodone", do_iodone, usage_iodone}, - {"iowait", do_iowait, usage_iowait}, - {"ipread", do_ipread, usage_ipread}, - {"ipreadv", do_ipreadv, usage_ipreadv}, - {"ipwrite", do_ipwrite, usage_ipwrite}, - {"ipwritev", do_ipwritev, usage_ipwritev}, - {"iread", do_iread, usage_iread}, - {"ireadv", do_ireadv, usage_ireadv}, - {"iwrite", do_iwrite, usage_iwrite}, - {"iwritev", do_iwritev, usage_iwritev}, - {"list", do_list, usage_list}, - {"lseek", do_lseek, usage_lseek}, - {"lstat", do_lstat, usage_lstat}, - {"mkdir", do_mkdir, usage_mkdir}, - {"mknod", do_mknod, usage_mknod}, - {"mount", do_mount, usage_mount}, - {"open", do_open, usage_open}, - {"printbuf", do_printbuf, usage_do_printbuf}, - {"printline", do_printline, usage_printline}, - {"pread", do_pread, usage_pread}, - {"preadv", do_preadv, usage_preadv}, - {"pwritev", do_pwritev, usage_pwritev}, - {"pwrite", do_pwrite, usage_pwrite}, - {"quit", do_exit, usage_exit}, - {"read", do_read, usage_read}, - {"readv", do_readv, usage_readv}, - {"rmdir", do_rmdir, usage_rmdir}, + {"fstat", test_do_fstat, usage_fstat}, + {"fstatvfs", test_do_fstatvfs, usage_fstatvfs}, + {"fsync", test_do_fsync, usage_fsync}, + {"ftruncate", test_do_ftruncate, usage_ftruncate}, + {"getcwd", test_do_getcwd, usage_getcwd}, + {"getdirentries", test_do_getdirentries, usage_getdirentries}, + {"init", test_do_init, usage_init}, + {"ioctl", test_do_ioctl, usage_ioctl}, + {"iodone", test_do_iodone, usage_iodone}, + {"iowait", test_do_iowait, usage_iowait}, + {"ipread", test_do_ipread, usage_ipread}, + {"ipreadv", test_do_ipreadv, usage_ipreadv}, + {"ipwrite", test_do_ipwrite, usage_ipwrite}, + {"ipwritev", test_do_ipwritev, usage_ipwritev}, + {"iread", test_do_iread, usage_iread}, + {"ireadv", test_do_ireadv, usage_ireadv}, + {"iwrite", test_do_iwrite, usage_iwrite}, + {"iwritev", test_do_iwritev, usage_iwritev}, + {"list", test_do_list, usage_list}, + {"lseek", test_do_lseek, usage_lseek}, + {"lstat", test_do_lstat, usage_lstat}, + {"mkdir", test_do_mkdir, usage_mkdir}, + {"mknod", test_do_mknod, usage_mknod}, + {"mount", test_do_mount, usage_mount}, + {"open", test_do_open, usage_open}, + {"printbuf", test_do_printbuf, usage_do_printbuf}, + {"printline", test_do_printline, usage_printline}, + {"pread", test_do_pread, usage_pread}, + {"preadv", test_do_preadv, usage_preadv}, + {"pwritev", test_do_pwritev, usage_pwritev}, + {"pwrite", test_do_pwrite, usage_pwrite}, + {"quit", test_do_exit, usage_exit}, + {"read", test_do_read, usage_read}, + {"readv", test_do_readv, usage_readv}, + {"rmdir", test_do_rmdir, usage_rmdir}, {"sizeof", get_sizeof, usage_sizeof}, - /* {"setoutput", do_setoutput, usage_setoutput}, */ - {"stat", do_stat, usage_stat}, - {"statvfs", do_statvfs, usage_statvfs}, - {"symlink", do_symlink, usage_symlink}, - {"truncate", do_truncate, usage_truncate}, - {"umask", do_umask, usage_umask}, - {"umount", do_umount, usage_umount}, - {"unlink", do_unlink, usage_unlink}, - {"write", do_write, usage_write}, - {"writev", do_writev, usage_writev}, + /* {"setoutput", test_do_setoutput, usage_setoutput}, */ + {"stat", test_do_stat, usage_stat}, + {"statvfs", test_do_statvfs, usage_statvfs}, + {"symlink", test_do_symlink, usage_symlink}, + {"truncate", test_do_truncate, usage_truncate}, + {"umask", test_do_umask, usage_umask}, + {"umount", test_do_umount, usage_umount}, + {"unlink", test_do_unlink, usage_unlink}, + {"write", test_do_write, usage_write}, + {"writev", test_do_writev, usage_writev}, {NULL, NULL, NULL} }; @@ -721,7 +721,11 @@ char *getline(char *prompt) if ((do_prompt) && (infp == stdin)) printf(prompt); + /* + fprintf(stderr, "getline: errno %x\n", errno); fseek(infp, 0, SEEK_CUR); + fprintf(stderr, "getline: errno %x\n", errno); + */ do { /* If we get an end of file, just wait */ if (feof(infp)) { @@ -817,6 +821,7 @@ int main(int argc, char *argv[]) do_prompt = 1; + errno = 0; /* Get the input/output streams */ for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "--input")) { @@ -892,6 +898,7 @@ int main(int argc, char *argv[]) err = run_cmd(tree); store_result((char *)(&cmd[0][1]), last_ret_val); } else { + tree = build_tree(cmd, &count, 0); err = run_cmd(tree); } Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -w -b -B -p -r1.2 -r1.2.6.1 --- test_driver.h 14 Aug 2003 21:16:33 -0000 1.2 +++ test_driver.h 9 Oct 2003 15:04:10 -0000 1.2.6.1 @@ -135,67 +135,67 @@ extern void my_perror(char *msg); extern char *get_str(char *var_name); /* Stub functions defined in sysio_stubs.c */ -extern int do_setdebug(int argc, char **argv); -extern int do_printline(int argc, char **argv); +extern int test_do_setdebug(int argc, char **argv); +extern int test_do_printline(int argc, char **argv); extern int cmp_bufs(int argc, char **argv); -extern int do_printbuf(int argc, char **argv); -extern int do_fillbuff(int argc, char **argv); -extern int do_mount(int argc, char **args); -extern int do_list(int argc, char **args); -extern int do_init(int argc, char **args); +extern int test_do_printbuf(int argc, char **argv); +extern int test_do_fillbuff(int argc, char **argv); +extern int test_do_mount(int argc, char **args); +extern int test_do_list(int argc, char **args); +extern int test_do_init(int argc, char **args); extern int get_endian(int argc, char **args); extern int get_sizeof(int argc, char **args); -extern int do_exit(int argc, char **args); +extern int test_do_exit(int argc, char **args); extern int get_buffer(int argc, char **args); extern int free_buffer(int argc, char **args); -extern int do_chdir(int argc, char **args); -extern int do_chmod(int argc, char **args); -extern int do_chown(int argc, char **args); -extern int do_open(int argc, char **args); -extern int do_close(int argc, char **args); -extern int do_clear(int argc, char **argv); -extern int do_dup(int argc, char **args); -extern int do_dup2(int argc, char **args); -extern int do_fcntl(int argc, char **args); -extern int do_fstat(int argc, char **argv); -extern int do_fsync(int argc, char **argv); -extern int do_ftruncate(int argc, char **argv); -extern int do_getcwd(int argc, char **argv); -extern int do_lseek(int argc, char **argv); -extern int do_lstat(int argc, char **argv); -extern int do_getdirentries(int argc, char **argv); -extern int do_mkdir(int argc, char **argv); -extern int do_creat(int argc, char **argv); -extern int do_stat(int argc, char **argv); -extern int do_statvfs(int argc, char **argv); -extern int do_fstatvfs(int argc, char **argv); -extern int do_truncate(int argc, char **argv); -extern int do_rmdir(int argc, char **argv); -extern int do_symlink(int argc, char **argv); -extern int do_unlink(int argc, char **argv); -extern int do_fdatasync(int argc, char **argv); -extern int do_ioctl(int argc, char **argv); -extern int do_umask(int argc, char **argv); -extern int do_iodone(int argc, char **argv); -extern int do_iowait(int argc, char **argv); -extern int do_ipreadv(int argc, char **argv); -extern int do_ipread(int argc, char **argv); -extern int do_preadv(int argc, char **argv); -extern int do_pread(int argc, char **argv); -extern int do_ireadv(int argc, char **argv); -extern int do_iread(int argc, char **argv); -extern int do_readv(int argc, char **argv); -extern int do_read(int argc, char **argv); -extern int do_ipwritev(int argc, char **argv); -extern int do_ipwrite(int argc, char **argv); -extern int do_pwritev(int argc, char **argv); -extern int do_pwrite(int argc, char **argv); -extern int do_iwritev(int argc, char **argv); -extern int do_iwrite(int argc, char **argv); -extern int do_writev(int argc, char **argv); -extern int do_write(int argc, char **argv); -extern int do_mknod(int argc, char **argv); -extern int do_umount(int argc, char **argv); +extern int test_do_chdir(int argc, char **args); +extern int test_do_chmod(int argc, char **args); +extern int test_do_chown(int argc, char **args); +extern int test_do_open(int argc, char **args); +extern int test_do_close(int argc, char **args); +extern int test_do_clear(int argc, char **argv); +extern int test_do_dup(int argc, char **args); +extern int test_do_dup2(int argc, char **args); +extern int test_do_fcntl(int argc, char **args); +extern int test_do_fstat(int argc, char **argv); +extern int test_do_fsync(int argc, char **argv); +extern int test_do_ftruncate(int argc, char **argv); +extern int test_do_getcwd(int argc, char **argv); +extern int test_do_lseek(int argc, char **argv); +extern int test_do_lstat(int argc, char **argv); +extern int test_do_getdirentries(int argc, char **argv); +extern int test_do_mkdir(int argc, char **argv); +extern int test_do_creat(int argc, char **argv); +extern int test_do_stat(int argc, char **argv); +extern int test_do_statvfs(int argc, char **argv); +extern int test_do_fstatvfs(int argc, char **argv); +extern int test_do_truncate(int argc, char **argv); +extern int test_do_rmdir(int argc, char **argv); +extern int test_do_symlink(int argc, char **argv); +extern int test_do_unlink(int argc, char **argv); +extern int test_do_fdatasync(int argc, char **argv); +extern int test_do_ioctl(int argc, char **argv); +extern int test_do_umask(int argc, char **argv); +extern int test_do_iodone(int argc, char **argv); +extern int test_do_iowait(int argc, char **argv); +extern int test_do_ipreadv(int argc, char **argv); +extern int test_do_ipread(int argc, char **argv); +extern int test_do_preadv(int argc, char **argv); +extern int test_do_pread(int argc, char **argv); +extern int test_do_ireadv(int argc, char **argv); +extern int test_do_iread(int argc, char **argv); +extern int test_do_readv(int argc, char **argv); +extern int test_do_read(int argc, char **argv); +extern int test_do_ipwritev(int argc, char **argv); +extern int test_do_ipwrite(int argc, char **argv); +extern int test_do_pwritev(int argc, char **argv); +extern int test_do_pwrite(int argc, char **argv); +extern int test_do_iwritev(int argc, char **argv); +extern int test_do_iwrite(int argc, char **argv); +extern int test_do_writev(int argc, char **argv); +extern int test_do_write(int argc, char **argv); +extern int test_do_mknod(int argc, char **argv); +extern int test_do_umount(int argc, char **argv); /* Functions defined in sysio_tests.c */ Index: test_getcwd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_getcwd.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -w -b -B -p -r1.2 -r1.2.2.1 --- test_getcwd.c 14 Aug 2003 18:39:33 -0000 1.2 +++ test_getcwd.c 9 Oct 2003 15:04:10 -0000 1.2.2.1 @@ -44,7 +44,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef REDSTORM #include <getopt.h> +#else +#include <unistd.h> +#endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> Index: test_list.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_list.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -w -b -B -p -r1.5 -r1.5.2.1 --- test_list.c 14 Aug 2003 18:39:33 -0000 1.5 +++ test_list.c 9 Oct 2003 15:04:10 -0000 1.5.2.1 @@ -44,7 +44,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef REDSTORM #include <getopt.h> +#else +#include <unistd.h> +#endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> @@ -203,10 +207,9 @@ listit(const char *path) while ((cc = getdirentries(fd, (char *)buf, n, &base)) > 0) { dp = buf; while (cc > 0) { - (void )printf("\t%s: ino %llu off %llu type %u\n", + (void )printf("\t%s: ino %llu type %u\n", dp->d_name, (unsigned long long )dp->d_ino, - (unsigned long long )dp->d_off, (int )dp->d_type); cc -= dp->d_reclen; dp = (void *)dp + dp->d_reclen; Index: test_mounts.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_mounts.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- test_mounts.c 14 Aug 2003 18:39:33 -0000 1.4 +++ test_mounts.c 9 Oct 2003 15:04:10 -0000 1.4.2.1 @@ -44,7 +44,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef REDSTORM #include <getopt.h> +#else +#include <unistd.h> +#endif #include <errno.h> #include <assert.h> Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- test_path.c 14 Aug 2003 18:39:33 -0000 1.4 +++ test_path.c 9 Oct 2003 15:04:10 -0000 1.4.2.1 @@ -44,7 +44,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef REDSTORM #include <getopt.h> +#else +#include <unistd.h> +#endif #include <errno.h> #include <assert.h> @@ -187,7 +191,7 @@ statit(const char *path) /* * Get file attrs. */ - err = stat(path, &stbuf); + err = lstat(path, &stbuf); if (err) { perror(path); return -1; Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.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 --- test_stats.c 20 Aug 2003 21:05:49 -0000 1.4.2.1 +++ test_stats.c 9 Oct 2003 15:04:10 -0000 1.4.2.2 @@ -46,13 +46,17 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#ifndef REDSTORM #include <getopt.h> +#endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> +#ifdef notdef #include <sys/statvfs.h> +#endif #include "sysio.h" #include "mount.h" @@ -72,6 +76,14 @@ unsigned mntflgs = 0; void usage(void); void do_stats(const char *path); +#ifdef AUTOMOUNT_FILE_NAME +#define EXTRA_AUTOMOUNT_OPT "a" +#else +#define EXTRA_AUTOMOUNT_OPT +#endif + +const char *opts = EXTRA_AUTOMOUNT_OPT "m:r:"; + int main(int argc, char * const argv[]) { @@ -81,7 +93,7 @@ main(int argc, char * const argv[]) /* * Parse command-line args. */ - while ((i = getopt(argc, argv, "i:m:")) != -1) + while ((i = getopt(argc, argv, opts)) != -1) switch (i) { #ifdef AUTOMOUNT_FILE_NAME @@ -147,7 +159,9 @@ do_stats(const char *path) int fd; int err; struct stat stbuf1, stbuf2; +#ifdef notdef struct statvfs stvfsbuf1, stvfsbuf2; +#endif fd = open(path, O_RDONLY); if (fd < 0) { @@ -157,10 +171,12 @@ do_stats(const char *path) err = fstat(fd, &stbuf1); if (!err) err = stat(path, &stbuf2); +#ifdef notdef if (!err) err = fstatvfs(fd, &stvfsbuf1); if (!err) err = statvfs(path, &stvfsbuf1); +#endif if (err) { perror(path); goto out; @@ -170,16 +186,11 @@ do_stats(const char *path) (void )fprintf(stderr, "%s: [f]stat info mismatch\n", path); goto out; } - if ( -#if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1) - stvfsbuf1.f_fsid.__val[0] != stvfsbuf2.f_fsid.__val[0] || - stvfsbuf1.f_fsid.__val[1] != stvfsbuf2.f_fsid.__val[1] -#else - stvfsbuf1.f_fsid != stvfsbuf2.f_fsid -#endif - ) { +#ifdef notdef + if (stvfsbuf1.f_fsid != stvfsbuf2.f_fsid) { (void )fprintf(stderr, "%s: [f]statvfs info mismatch\n", path); } +#endif printf("%s:" " dev %lu," " ino %lu," Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.pl,v retrieving revision 1.2.6.3 retrieving revision 1.2.6.4 diff -u -w -b -B -p -r1.2.6.3 -r1.2.6.4 Index: test_stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stdfd.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -w -b -B -p -r1.3 -r1.3.2.1 --- test_stdfd.c 14 Aug 2003 18:39:33 -0000 1.3 +++ test_stdfd.c 9 Oct 2003 15:04:10 -0000 1.3.2.1 @@ -49,7 +49,9 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#ifndef REDSTORM #include <getopt.h> +#endif #include <errno.h> #include <assert.h> #include <sys/queue.h> Index: test_stdfd.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stdfd.pl,v retrieving revision 1.2.6.2 retrieving revision 1.2.6.3 diff -u -w -b -B -p -r1.2.6.2 -r1.2.6.3 --- test_stdfd.pl 28 Aug 2003 13:38:08 -0000 1.2.6.2 +++ test_stdfd.pl 9 Oct 2003 15:04:10 -0000 1.2.6.3 @@ -133,7 +133,7 @@ $testdir =~ s/\/\w+.pl$//; if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init incore ".'"0777+0+0"'." 0\n"); - + helper::verify_cmd($cmdfh, $outfh, "init incore"); } |