X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fcopytool.c;h=b67a6324e74e54817f1fa9569fc800db7fedff05;hb=e296c2d9f5d8ff8a7efdcef75bc3e8d379307440;hp=c862426baab6392c18e0031c16fd9fa2b7b099c4;hpb=6e2be01b6bbc0fc7727ac0389ad01eb4c3eb3756;p=fs%2Flustre-release.git diff --git a/lustre/tests/copytool.c b/lustre/tests/copytool.c index c862426..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. */ /* @@ -48,18 +48,30 @@ #include #include +#include #include #include #include +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} }; - void *ctdata; - int archive_nums[] = {1}; /* which archive numbers we care about */ + int archives[] = {1}; /* which archives we care about */ int rc; optind = 0; @@ -71,23 +83,30 @@ int main(int argc, char **argv) { default: fprintf(stderr, "error: %s: option '%s' unrecognized\n", argv[0], argv[optind - 1]); - return -EINVAL; + return EINVAL; } } - rc = llapi_copytool_start(&ctdata, 0, ARRAY_SIZE(archive_nums), - archive_nums); + 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); + 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; @@ -123,7 +142,7 @@ int main(int argc, char **argv) { llapi_copytool_fini(&ctdata); - return 0; + return -rc; }