From 948b5d3958529e6a19dd6f7abe233fd6b45e14e1 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 15 May 2007 20:45:40 +0000 Subject: [PATCH] Branch b1_6 Fix compile warnings/error due to recent lustre-build.m4 commit of _GNU_SOURCE. Remove some obsolete tests that now had compile warnings. b=12348 --- lustre/tests/Makefile.am | 5 +- lustre/tests/directio.c | 2 + lustre/tests/fsx.c | 10 +-- lustre/tests/ll_sparseness_write.c | 2 + lustre/tests/multiop.c | 2 + lustre/tests/o_directory.c | 2 + lustre/tests/openclose.c | 2 + lustre/tests/opendevunlink.c | 2 + lustre/tests/opendirunlink.c | 2 + lustre/tests/openfile.c | 2 + lustre/tests/openfilleddirunlink.c | 2 + lustre/tests/runfailure-mds | 63 ----------------- lustre/tests/runfailure-net | 66 ----------------- lustre/tests/runfailure-ost | 51 -------------- lustre/tests/runregression-brw.sh | 111 ----------------------------- lustre/tests/runregression-net.sh | 99 -------------------------- lustre/tests/test_brw.c | 4 +- lustre/tests/testreq.c | 141 ------------------------------------- 18 files changed, 28 insertions(+), 540 deletions(-) delete mode 100755 lustre/tests/runfailure-mds delete mode 100755 lustre/tests/runfailure-net delete mode 100755 lustre/tests/runfailure-ost delete mode 100644 lustre/tests/runregression-brw.sh delete mode 100644 lustre/tests/runregression-net.sh delete mode 100644 lustre/tests/testreq.c diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index 0b4a915..652fec3 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -6,8 +6,7 @@ AM_CFLAGS = $(LLCFLAGS) noinst_DATA = noinst_SCRIPTS = leak_finder.pl llecho.sh llmount.sh llmountcleanup.sh test-framework.sh -noinst_SCRIPTS += runfailure-mds runvmstat runfailure-net -noinst_SCRIPTS += runfailure-ost runiozone runregression-net.sh runtests +noinst_SCRIPTS += runvmstat runiozone runtests noinst_SCRIPTS += sanity.sh rundbench noinst_SCRIPTS += cfg/local.sh @@ -19,7 +18,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(noinst_DATA) \ acl/inheritance.test if TESTS -noinst_PROGRAMS = openunlink testreq truncate directio openme writeme +noinst_PROGRAMS = openunlink truncate directio openme writeme noinst_PROGRAMS += tchmod toexcl fsx test_brw openclose createdestroy noinst_PROGRAMS += stat createmany chownmany statmany multifstat createtest mlink utime noinst_PROGRAMS += opendirunlink opendevunlink unlinkmany fchdir_test checkstat diff --git a/lustre/tests/directio.c b/lustre/tests/directio.c index 5cd7cd9..b68bd74 100644 --- a/lustre/tests/directio.c +++ b/lustre/tests/directio.c @@ -1,7 +1,9 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include #include diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index 6cf43ee..dc97fd9 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -438,21 +438,21 @@ assign_fd_policy(char *policy) } } -int +int get_fd(void) { struct test_file *tf = get_tf(); return tf->fd; } -static const char *basename(const char *path) +static const char *my_basename(const char *path) { char *c = strrchr(path, '/'); return c ? c++ : path; } -void +void open_test_files(char **argv, int argc) { struct test_file *tf; @@ -1334,14 +1334,14 @@ main(int argc, char **argv) open_test_files(argv, argc); - strncat(goodfile, dirpath ? basename(fname) : fname, 256); + strncat(goodfile, dirpath ? my_basename(fname) : fname, 256); strcat (goodfile, ".fsxgood"); fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fsxgoodfd < 0) { prterr(goodfile); exit(92); } - strncat(logfile, dirpath ? basename(fname) : fname, 256); + strncat(logfile, dirpath ? my_basename(fname) : fname, 256); strcat (logfile, ".fsxlog"); fsxlogf = fopen(logfile, "w"); if (fsxlogf == NULL) { diff --git a/lustre/tests/ll_sparseness_write.c b/lustre/tests/ll_sparseness_write.c index c53ca7e..7c11096 100644 --- a/lustre/tests/ll_sparseness_write.c +++ b/lustre/tests/ll_sparseness_write.c @@ -1,7 +1,9 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include #include diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index 63a6f08..60e7589 100755 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -1,7 +1,9 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE /* pull in O_DIRECTORY in bits/fcntl.h */ +#endif #include #include #include diff --git a/lustre/tests/o_directory.c b/lustre/tests/o_directory.c index d4b2c1b..b587cd0 100644 --- a/lustre/tests/o_directory.c +++ b/lustre/tests/o_directory.c @@ -3,7 +3,9 @@ */ /* for O_DIRECTORY */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/openclose.c b/lustre/tests/openclose.c index 22c859c..6ca7af7 100644 --- a/lustre/tests/openclose.c +++ b/lustre/tests/openclose.c @@ -3,7 +3,9 @@ */ /* for O_DIRECT */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/opendevunlink.c b/lustre/tests/opendevunlink.c index 9335eda..15ac708 100644 --- a/lustre/tests/opendevunlink.c +++ b/lustre/tests/opendevunlink.c @@ -2,7 +2,9 @@ * vim:expandtab:shiftwidth=8:tabstop=8: */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/opendirunlink.c b/lustre/tests/opendirunlink.c index 5e70f7d..f7ad30f 100644 --- a/lustre/tests/opendirunlink.c +++ b/lustre/tests/opendirunlink.c @@ -3,7 +3,9 @@ */ /* for O_DIRECTORY */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/openfile.c b/lustre/tests/openfile.c index 40d197f..6cba76b 100644 --- a/lustre/tests/openfile.c +++ b/lustre/tests/openfile.c @@ -7,7 +7,9 @@ #endif /* for O_DIRECTORY and O_DIRECT */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/openfilleddirunlink.c b/lustre/tests/openfilleddirunlink.c index 6c7707f..9b07c64 100644 --- a/lustre/tests/openfilleddirunlink.c +++ b/lustre/tests/openfilleddirunlink.c @@ -3,7 +3,9 @@ */ /* for O_DIRECTORY */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/runfailure-mds b/lustre/tests/runfailure-mds deleted file mode 100755 index f2942c3..0000000 --- a/lustre/tests/runfailure-mds +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`" -. $SRCDIR/common.sh - -. $SRCDIR/llmount.sh - -MNT="setup_mount" - -test_fail() { - echo $1 > /proc/sys/lustre/fail_loc - shift - echo "Running '$*'" - $* - - echo "Cleaning up and restarting MDS" - umount /mnt/lustre || fail "unable to unmount" - $OBDCTL <<- EOF - name2dev MDSDEV - cleanup - detach - quit - EOF - - echo 0 > /proc/sys/lustre/fail_loc - - $OBDCTL <<- EOF - newdev - attach mds MDSDEV - setup ${MDS} ${MDSFS} - quit - EOF - $MNT -} - -#set -vx - -touch /mnt/lustre/foo -chmod a+x /mnt/lustre/foo -sync - -# OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr -test_fail 0x10a chmod 000 /mnt/lustre/foo -ls -l /mnt/lustre/foo -[ ! -x /mnt/lustre/foo ] && fail "/mnt/lustre/foo is not executable!" - -# OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file -test_fail 0x10c touch /mnt/lustre/bar -ls /mnt/lustre/bar -[ $? -eq 0 ] && fail "/mnt/lustre/bar was created!" - -# OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink -test_fail 0x10e rm /mnt/lustre/foo -ls /mnt/lustre/foo -[ $? -eq 1 ] && fail "/mnt/lustre/foo has been removed!" - -# OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename -test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar -ls /mnt/lustre/foo /mnt/lustre/bar -[ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \ - fail "/mnt/lustre/foo has been renamed to bar!" - -echo "Done." diff --git a/lustre/tests/runfailure-net b/lustre/tests/runfailure-net deleted file mode 100755 index 4e9bdd7..0000000 --- a/lustre/tests/runfailure-net +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -fail() { - echo "ERROR: $1" 1>&2 - [ $2 ] && RC=$2 || RC=1 - exit $RC -} - -test_fail() { - oldtimeout=`cat /proc/sys/lustre/timeout` - echo $TIMEOUT > /proc/sys/lustre/timeout - echo $1 > /proc/sys/lustre/fail_loc - shift - $* & - sleep $TIMEOUT - sleep 2 # fudge - kill -9 $! - - echo $oldtimeout > /proc/sys/lustre/timeout - echo 0 > /proc/sys/lustre/fail_loc - umount -f /mnt/lustre || fail "cannot unmount /mnt/lustre" - mount -t lustre_lite -o "osc=$OSC,mdc=$MDC" none /mnt/lustre || \ - fail "cannot remount $OSC/$MDC on /mnt/lustre" -} - -set -vx - -LCTL=../utils/lctl -OSC=OSC_`hostname`_UUID -MDC=MDC_client1_UUID -TIMEOUT=5 # complete in finite time - -[ "`mount | grep /mnt/lustre`" ] || echo | sh llmount.sh || exit -1 - -# GETATTR_NET - ls will hang on the getattr -# test_fail 0x102 ls -l /mnt/lustre - -# READPAGE_NET - ls will hang reading in new pages (lost+found is not in cache) -test_fail 0x104 ls /mnt/lustre - -sleep 1 - -# REINT_NET - touch will hang on setattr -test_fail 0x107 touch /mnt/lustre - -# REINT_NET - touch will hang on create -test_fail 0x107 touch /mnt/lustre/tt - -# REINT_NET - mv will hang on rename -touch /mnt/lustre/foo -test_fail 0x107 mv /mnt/lustre/foo /mnt/lustre/bar - -# REINT_NET - rm will hang on unlink -touch /mnt/lustre/salmon -test_fail 0x107 rm /mnt/lustre/salmon - -# OPEN_NET - touch will hang on open -touch /mnt/lustre/foo -test_fail 0x113 cat /mnt/lustre/foo - -# CLOSE_NET - ls will hang on close -test_fail 0x115 ./testreq --close junk_file_handle - -echo 0 > /proc/sys/lustre/fail_loc - -echo "Done." diff --git a/lustre/tests/runfailure-ost b/lustre/tests/runfailure-ost deleted file mode 100755 index 0c68d5a..0000000 --- a/lustre/tests/runfailure-ost +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`" -. $SRCDIR/common.sh - -setup_opts "$@" - -set -vx - -test_fail() { - echo $1 > /proc/sys/lustre/fail_loc - shift - echo "Running '$*'" - $* & - sleep 1 - kill -9 $! - - echo 0 > /proc/sys/lustre/fail_loc - umount /mnt/lustre || fail "cannot unmount /mnt/lustre" - setup_mount || fail "cannot remount /mnt/lustre" -} - -[ "`mount | grep /mnt/lustre`" ] || . llsetup.sh "$@" || exit -1 - -# OBD_FAIL_OST_OPEN_NET: OST will discard open request packet -touch /mnt/lustre/foo -test_fail 0x208 cat /mnt/lustre/foo - -# OBD_FAIL_OST_CLOSE_NET: OST will discard close request packet -test_fail 0x209 cat /mnt/lustre/foo - -# OBD_FAIL_OST_CREATE_NET: OST will discard create request packet -test_fail 0x204 touch /mnt/lustre/bar - -# OBD_FAIL_OST_DESTROY_NET: OST will discard destroy request packet -test_fail 0x205 rm /mnt/lustre/foo - -# OBD_FAIL_OST_BRW_NET: OST will discard read request packet -echo foo >> /mnt/lustre/foo -test_fail 0x20a cat /mnt/lustre/foo - -# OBD_FAIL_OST_BRW_NET: OST will discard write request packet -test_fail 0x20a "echo bar >> /mnt/lustre/foo" - -# OBD_FAIL_OST_PUNCH_NET: OST will discard truncate request packet -test_fail 0x208 "echo bar > /mnt/lustre/foo" - -# OBD_FAIL_OST_STATFS_NET: OST will discard statfs request packet -test_fail 0x208 df /mnt/lustre - -echo "Done." diff --git a/lustre/tests/runregression-brw.sh b/lustre/tests/runregression-brw.sh deleted file mode 100644 index 666b253..0000000 --- a/lustre/tests/runregression-brw.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -SRCDIR="`dirname $0`/" -export PATH=/sbin:/usr/sbin:$SRCDIR/../utils:$PATH - -LOOPS=${LOOPS:-1} -COUNT=${COUNT:-100000} -COUNT_10=`expr $COUNT / 10` -COUNT_100=`expr $COUNT / 100` - -ENDRUN=endrun-`hostname` - -ECHONAME="`lctl device_list 2> /dev/null | awk '/ echo_client / { print $4 }' | tail -n 1`" - -if [ -z "$ECHONAME" ]; then - echo "$0: needs an ECHO_CLIENT set up first" 1>&2 - exit 1 -fi - -cleanup () { - lctl --device \$$ECHONAME destroy $OID -} - -runthreads() { - THR=$1 - DO=$2 - CNT=$3 - V=$4 - PGS=$5 - - case $DO in - test_getattr) - RW= - ;; - test_brw_write) - DO=test_brw - RW=w - ;; - test_brw_read) - DO=test_brw - RW=r - ;; - esac - - lctl --threads $THR v \$$ECHONAME $DO $CNT $RW $V $PGS $OID || exit 1 - - if [ -e $ENDRUN ]; then - rm $ENDRUN - echo "exiting because $ENDRUN file was found" - cleanup - fi -} - -[ -z "$OID" ] && OID=`lctl --device \\$$ECHONAME create 1 | awk '/is object id/ { print $6 }'` && echo "created object $OID" -[ -z "$OID" ] && echo "error creating object" 1>&2 && exit 1 - -# TODO: obdctl needs to check on the progress of each forked thread -# (IPC SHM, sockets?) to see if it hangs. -for i in `seq $LOOPS`; do - PG=1 - PGVW=${PGVW:-16} - PGVR=${PGVR:-16} - - # We use '--threads 1 X' instead of '--device X' so that - # obdctl can monitor the forked thread for progress (TODO). - debug_server_off - debug_client_off - runthreads 1 test_brw_write 1000 -30 $PG - runthreads 1 test_brw_read 1000 -30 $PG - - [ "$PGVW" ] && runthreads 1 test_brw_write 100 -30 $PGVW - [ "$PGVW" ] && runthreads 1 test_brw_read 1600 -30 $PG - [ "$PGVR" ] && runthreads 1 test_brw_read 100 -30 $PGVR - - runthreads 1 test_brw_write $COUNT -30 $PG - runthreads 1 test_brw_read $COUNT -30 $PG - - [ "$PGVW" ] && runthreads 1 test_brw_write $COUNT_10 -30 $PGVW - [ "$PGVR" ] && runthreads 1 test_brw_read $COUNT_10 -30 $PGVR - - runthreads 2 test_brw_write $COUNT -30 $PG - runthreads 2 test_brw_read $COUNT -30 $PG - - [ "$PGVW" ] && runthreads 2 test_brw_write $COUNT_10 -30 $PGVW - [ "$PGVR" ] && runthreads 2 test_brw_read $COUNT_10 -30 $PGVR - - runthreads 10 test_brw_write $COUNT_10 -30 $PG - runthreads 10 test_brw_read $COUNT_10 -30 $PG - - [ "$PGVW" ] && runthreads 10 test_brw_write $COUNT_100 -60 $PGVW - [ "$PGVR" ] && runthreads 10 test_brw_read $COUNT_100 -60 $PGVR - - runthreads 32 test_brw_write $COUNT_10 -30 $PG - runthreads 32 test_brw_read $COUNT_10 -30 $PG - - [ "$PGVW" ] && runthreads 32 test_brw_write $COUNT_100 -60 $PGVW - [ "$PGVR" ] && runthreads 32 test_brw_read $COUNT_100 -60 $PGVR - - runthreads 64 test_brw_write $COUNT_10 -30 $PG - runthreads 64 test_brw_read $COUNT_10 -30 $PG - - [ "$PGVW" ] && runthreads 64 test_brw_write $COUNT_100 -60 $PGVW - [ "$PGVR" ] && runthreads 64 test_brw_read $COUNT_100 -60 $PGVR - - runthreads 100 test_brw_write $COUNT_100 -60 $PG - runthreads 100 test_brw_read $COUNT_100 -60 $PG - - [ "$PGVW" ] && runthreads 100 test_brw_write $COUNT_100 -60 $PGVW - [ "$PGVR" ] && runthreads 100 test_brw_read $COUNT_100 -60 $PGVR -done - -cleanup diff --git a/lustre/tests/runregression-net.sh b/lustre/tests/runregression-net.sh deleted file mode 100644 index 58f33ef..0000000 --- a/lustre/tests/runregression-net.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh -SRCDIR="`dirname $0`/" -export PATH=/sbin:/usr/sbin:$SRCDIR/../utils:$PATH - -COUNT=${COUNT:-100000} -COUNT_10=`expr $COUNT / 10` -COUNT_100=`expr $COUNT / 100` -COUNT_1000=`expr $COUNT / 1000` - -ENDRUN=endrun-`hostname` - -ECHONAME="`lctl device_list 2> /dev/null | awk '/ echo_client / { print $4 }' | tail -n 1`" - -if [ -z "$ECHONAME" ]; then - echo "$0: needs an ECHO_CLIENT set up first" 1>&2 - exit 1 -fi - -cleanup () { - lctl --device \$$ECHONAME destroy $OID -} - -runthreads() { - THR=$1 - DO=$2 - CNT=$3 - V=$4 - PGS=$5 - - case $DO in - test_getattr) - RW= - ;; - test_brw_write) - DO=test_brw - RW=w - ;; - test_brw_read) - DO=test_brw - RW=r - ;; - esac - - lctl --threads $THR v \$$ECHONAME $DO $CNT $RW $V $PGS $OID || exit 1 - - if [ -e $ENDRUN ]; then - rm $ENDRUN - echo "exiting because $ENDRUN file was found" - cleanup - fi -} - -[ -z "$OID" ] && OID=`lctl --device \\$$ECHONAME create 1 | awk '/is object id/ { print $6 }'` && echo "created object $OID" -[ -z "$OID" ] && echo "error creating object" 1>&2 && exit 1 - -# TODO: obdctl needs to check on the progress of each forked thread -# (IPC SHM, sockets?) to see if it hangs. -for CMD in test_getattr test_brw_write test_brw_read; do - case $CMD in - test_getattr) - PG= - PGV= - ;; - test_brw_write) - PG=1 - PGV=${PGV:-16} - ;; - test_brw_read) - PG=1 - PGV=${PGV:-16} - ;; - esac - - # We use '--threads 1 X' instead of '--device X' so that - # obdctl can monitor the forked thread for progress (TODO). - runthreads 1 $CMD 1 1 $PG - runthreads 1 $CMD 100 1 $PG - - echo 0 > /proc/sys/lnet/debug - runthreads 1 $CMD $COUNT_100 -10 $PG - [ "$PGV" ] && runthreads 1 $CMD $COUNT_1000 -10 $PGV - - runthreads 1 $CMD $COUNT -30 $PG - [ "$PGV" ] && runthreads 1 $CMD $COUNT_10 -30 $PGV - - runthreads 2 $CMD $COUNT_100 -30 $PG - [ "$PGV" ] && runthreads 2 $CMD $COUNT_1000 -30 $PGV - - runthreads 2 $CMD $COUNT -30 $PG - [ "$PGV" ] && runthreads 2 $CMD $COUNT_10 -30 $PGV - - runthreads 10 $CMD $COUNT_10 -30 $PG - [ "$PGV" ] && runthreads 10 $CMD $COUNT_100 -30 $PGV - - runthreads 100 $CMD $COUNT_100 -30 $PG - [ "$PGV" ] && runthreads 100 $CMD $COUNT_1000 -30 $PGV -done - -lctl --device \$$ECHONAME destroy $OID diff --git a/lustre/tests/test_brw.c b/lustre/tests/test_brw.c index 0e5605e..fe18021 100644 --- a/lustre/tests/test_brw.c +++ b/lustre/tests/test_brw.c @@ -3,7 +3,9 @@ */ /* for O_DIRECT */ -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include #include diff --git a/lustre/tests/testreq.c b/lustre/tests/testreq.c deleted file mode 100644 index 0b19a44..0000000 --- a/lustre/tests/testreq.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define _GNU_SOURCE -#include -#undef _GNU_SOURCE - -#include -#include - -static void usage(char *argv0, int status) -{ - printf( -"Usage: %s [OPTION...]\n\ -\n\ ---getattr \n\ ---setattr \n\ ---readpage \n\ ---open \n\ ---close \n\ ---create \n", argv0); - - exit(status); -} - -int main(int argc, char **argv) -{ - int fd = 0; - int rc = 0; - int c = 0; - long cmd = 0; - unsigned long arg; - char *short_opts = "h", *name = argv[0]; - static struct option long_opts[] = { -#define OPT_GETATTR -2 - {"getattr", no_argument, NULL, OPT_GETATTR}, -#define OPT_READPAGE -3 - {"readpage", no_argument, NULL, OPT_READPAGE}, -#define OPT_SETATTR -4 - {"setattr", no_argument, NULL, OPT_SETATTR}, -#define OPT_CREATE -5 - {"create", no_argument, NULL, OPT_CREATE}, -#define OPT_OPEN -6 - {"open", no_argument, NULL, OPT_OPEN}, -#define OPT_CLOSE -7 - {"close", required_argument, NULL, OPT_CLOSE}, -#define OPT_HELP 'h' - {"help", no_argument, NULL, OPT_HELP}, - {0} - }; - - do { - c = getopt_long(argc, argv, short_opts, long_opts, NULL); - - switch (c) { - case OPT_HELP: - usage(argv[0], 0); - break; - case OPT_GETATTR: - cmd = IOC_REQUEST_GETATTR; - name = "getattr"; - arg = 2; - break; - case OPT_SETATTR: - cmd = IOC_REQUEST_SETATTR; - name = "setattr"; - arg = 2; - break; - case OPT_READPAGE: - cmd = IOC_REQUEST_READPAGE; - name = "readpage"; - arg = 2; - break; - case OPT_CREATE: - cmd = IOC_REQUEST_CREATE; - name ="create"; - arg = 2; - break; - case OPT_OPEN: - cmd = IOC_REQUEST_OPEN; - name = "open"; - arg = 2; - break; - case OPT_CLOSE: - cmd = IOC_REQUEST_CLOSE; - name = "close"; - arg = strtoul(optarg, NULL, 0); - break; - case '?': - usage(argv[0], 1); - } - } while (c != -1); - - if (cmd == 0) - usage(argv[0], 1); - - fd = open("/dev/request", O_RDONLY); - if (fd == -1) { - fprintf(stderr, "error opening /dev/request: %s\n", - strerror(errno)); - exit(1); - } - - fprintf(stderr, "Executing %s test (arg=%lu)...\n", name, arg); - if (cmd == IOC_REQUEST_OPEN) { - rc = ioctl(fd, cmd, &arg); - printf("%lu\n", arg); - } else - rc = ioctl(fd, cmd, arg); - fprintf(stderr, "result code: %d\n", rc); - - return 0; -} -- 1.8.3.1