From f671a647e5480a709f09a66252995bf07e512e32 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 30 Jun 2008 21:50:56 +0200 Subject: a lot of love --- sktest.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sktest.c (limited to 'sktest.c') diff --git a/sktest.c b/sktest.c new file mode 100644 index 0000000..374b11c --- /dev/null +++ b/sktest.c @@ -0,0 +1,66 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +/*** + This file is part of SmartKit. + + Copyright 2008 Lennart Poettering + + libcanberra 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. + + libcanberra 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 libcanberra. If not, If not, see + . +***/ + +#include +#include + +#include "smart.h" + +int main(int argc, char *argv[]) { + int ret; + const char *device; + SkDisk *d; + SkSmartSelfTest test; + + if (argc < 3) { + g_printerr("%s [DEVICE] [short|extended|conveyance]\n", argv[0]); + return 1; + } + + device = argv[1]; + + if (!g_strcasecmp(argv[2], sk_smart_self_test_to_string(SK_SMART_SELF_TEST_SHORT))) + test = SK_SMART_SELF_TEST_SHORT; + else if (!g_strcasecmp(argv[2], sk_smart_self_test_to_string(SK_SMART_SELF_TEST_EXTENDED))) + test = SK_SMART_SELF_TEST_EXTENDED; + else if (!(g_strcasecmp(argv[2], sk_smart_self_test_to_string(SK_SMART_SELF_TEST_CONVEYANCE)))) + test = SK_SMART_SELF_TEST_CONVEYANCE; + else { + g_printerr("Unknown test '%s'.\n", argv[2]); + return 1; + } + + if ((ret = sk_disk_open(device, &d)) < 0) { + g_printerr("Failed to open disk %s: %s\n", device, g_strerror(errno)); + return 1; + } + + if ((ret = sk_disk_smart_self_test(d, test)) < 0) { + g_printerr("Failed to start sel-test: %s\n", g_strerror(errno)); + return 1; + + } + + sk_disk_free(d); + + return 0; +} -- cgit