]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/tools/fstype.c
Fixed problems with encryption when combined with compression or sparse files. Unfor...
[bacula/bacula] / bacula / src / tools / fstype.c
1 /*
2  * Program for determining file system type
3  *
4  *   Written by Preben 'Peppe' Guldberg, December MMIV
5  *
6  *   Version $Id$
7  *
8  */
9 /*
10    Copyright (C) 2004-2006 Kern Sibbald
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    version 2 as amended with additional clauses defined in the
15    file LICENSE in the main source directory.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
20    the file LICENSE for additional details.
21
22  */
23
24 #include "bacula.h"
25 #include "findlib/find.h"
26
27 /* Dummy functions */
28 int generate_daemon_event(JCR *jcr, const char *event) 
29    { return 1; }
30
31 static void usage()
32 {
33    fprintf(stderr, _(
34 "\n"
35 "Usage: fstype [-v] path ...\n"
36 "\n"
37 "       Print the file system type a given file/directory is on.\n"
38 "       The following options are supported:\n"
39 "\n"
40 "       -v     print both path and file system type.\n"
41 "       -?     print this message.\n"
42 "\n"));
43
44    exit(1);
45 }
46
47
48 int
49 main (int argc, char *const *argv)
50 {
51    char fs[1000];
52    int verbose = 0;
53    int status = 0;
54    int ch, i;
55
56    setlocale(LC_ALL, "");
57    bindtextdomain("bacula", LOCALEDIR);
58    textdomain("bacula");
59
60    while ((ch = getopt(argc, argv, "v?")) != -1) {
61       switch (ch) {
62          case 'v':
63             verbose = 1;
64             break;
65          case '?':
66          default:
67             usage();
68
69       }
70    }
71    argc -= optind;
72    argv += optind;
73
74    if (argc < 1) {
75       usage();
76    }
77
78    OSDependentInit();
79
80    for (i = 0; i < argc; --argc, ++argv) {
81       if (fstype(*argv, fs, sizeof(fs))) {
82          if (verbose) {
83             printf("%s: %s\n", *argv, fs);
84          } else {
85             puts(fs);
86          }
87       } else {
88          fprintf(stderr, _("%s: unknown\n"), *argv);
89          status = 1;
90       }
91    }
92
93    exit(status);
94 }