]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/tools/drivetype.c
Convert to pure GPL v2 license.
[bacula/bacula] / bacula / src / tools / drivetype.c
1 /*
2  * Program for determining drive type
3  *
4  *   Written by Robert Nelson, June 2006
5  *
6  *   Version $Id$
7  *
8  */
9 /*
10    Bacula® - The Network Backup Solution
11
12    Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
13
14    The main author of Bacula is Kern Sibbald, with contributions from
15    many others, a complete list can be found in the file AUTHORS.
16    This program is Free Software; you can redistribute it and/or
17    modify it under the terms of version two of the GNU General Public
18    License as published by the Free Software Foundation and included
19    in the file LICENSE.
20
21    This program is distributed in the hope that it will be useful, but
22    WITHOUT ANY WARRANTY; without even the implied warranty of
23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24    General Public License for more details.
25
26    You should have received a copy of the GNU General Public License
27    along with this program; if not, write to the Free Software
28    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29    02110-1301, USA.
30
31    Bacula® is a registered trademark of John Walker.
32    The licensor of Bacula is the Free Software Foundation Europe
33    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34    Switzerland, email:ftf@fsfeurope.org.
35 */
36
37 #include "bacula.h"
38 #include "findlib/find.h"
39
40 /* Dummy functions */
41 int generate_daemon_event(JCR *jcr, const char *event) 
42    { return 1; }
43
44 static void usage()
45 {
46    fprintf(stderr, _(
47 "\n"
48 "Usage: drivetype [-v] path ...\n"
49 "\n"
50 "       Print the drive type a given file/directory is on.\n"
51 "       The following options are supported:\n"
52 "\n"
53 "       -v     print both path and file system type.\n"
54 "       -?     print this message.\n"
55 "\n"));
56
57    exit(1);
58 }
59
60
61 int
62 main (int argc, char *const *argv)
63 {
64    char dt[100];
65    int verbose = 0;
66    int status = 0;
67    int ch, i;
68
69    setlocale(LC_ALL, "");
70    bindtextdomain("bacula", LOCALEDIR);
71    textdomain("bacula");
72
73    while ((ch = getopt(argc, argv, "v?")) != -1) {
74       switch (ch) {
75          case 'v':
76             verbose = 1;
77             break;
78          case '?':
79          default:
80             usage();
81
82       }
83    }
84    argc -= optind;
85    argv += optind;
86
87    if (argc < 1) {
88       usage();
89    }
90
91    OSDependentInit();
92  
93    for (i = 0; i < argc; --argc, ++argv) {
94       if (drivetype(*argv, dt, sizeof(dt))) {
95          if (verbose) {
96             printf("%s: %s\n", *argv, dt);
97          } else {
98             puts(dt);
99          }
100       } else {
101          fprintf(stderr, _("%s: unknown\n"), *argv);
102          status = 1;
103       }
104    }
105
106    exit(status);
107 }