X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fcopytool.c;h=b67a6324e74e54817f1fa9569fc800db7fedff05;hb=eea698c944283b755882d8f504d2fcc8ea371bd8;hp=a74fac3b58c117244314299cc5c61f2b8c783c81;hpb=b5b8aa49e102e57e834c62422ea6cfb2baf62b76;p=fs%2Flustre-release.git diff --git a/lustre/tests/copytool.c b/lustre/tests/copytool.c index a74fac3..b67a632 100644 --- a/lustre/tests/copytool.c +++ b/lustre/tests/copytool.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -47,25 +47,66 @@ */ #include +#include +#include #include #include #include -int main() { - void *ctdata; - int archive_nums[] = {1}; /* which archive numbers we care about */ +void *ctdata; + +void handler(int signal ) { + psignal(signal, "exiting"); + /* If we don't clean up upon interrupt, umount thinks there's a ref + * and doesn't remove us from mtab (EINPROGRESS). The lustre client + * does successfully unmount and the mount is actually gone, but the + * mtab entry remains. So this just makes mtab happier. */ + llapi_copytool_fini(&ctdata); + exit(1); +} + +int main(int argc, char **argv) { + int c, test = 0; + struct option long_opts[] = { + {"test", no_argument, 0, 't'}, + {0, 0, 0, 0} + }; + int archives[] = {1}; /* which archives we care about */ int rc; - rc = llapi_copytool_start(&ctdata, 0, ARRAY_SIZE(archive_nums), - archive_nums); + optind = 0; + while ((c = getopt_long(argc, argv, "t", long_opts, NULL)) != -1) { + switch (c) { + case 't': + test++; + break; + default: + fprintf(stderr, "error: %s: option '%s' unrecognized\n", + argv[0], argv[optind - 1]); + return EINVAL; + } + } + + if (optind != argc - 1) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return -EINVAL; + } + + rc = llapi_copytool_start(&ctdata, argv[optind], 0, + ARRAY_SIZE(archives), archives); if (rc < 0) { fprintf(stderr, "Can't start copytool interface: %s\n", strerror(-rc)); - return rc; + return -rc; } + if (test) + return -llapi_copytool_fini(&ctdata); + printf("Waiting for message from kernel (pid=%d)\n", getpid()); + signal(SIGINT, handler); + while(1) { struct hsm_action_list *hal; struct hsm_action_item *hai; @@ -101,7 +142,7 @@ int main() { llapi_copytool_fini(&ctdata); - return 0; + return -rc; }