]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/tools/fstype.c
Cleanup Python build so that Python is not dragged
[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 /*
11    Copyright (C) 2004 Kern Sibbald
12
13    This program is free software; you can redistribute it and/or
14    modify it under the terms of the GNU General Public License as
15    published by the Free Software Foundation; either version 2 of
16    the License, or (at your option) any later version.
17
18    This program is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21    General Public License for more details.
22
23    You should have received a copy of the GNU General Public
24    License along with this program; if not, write to the Free
25    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26    MA 02111-1307, USA.
27
28  */
29
30 #include "bacula.h"
31 #include "findlib/find.h"
32
33 /* Dummy functions */
34 int generate_daemon_event(JCR *jcr, const char *event) 
35    { return 1; }
36
37 static void usage()
38 {
39    fprintf(stderr, _(
40 "\n"
41 "Usage: fstype [-d debug_level] path ...\n"
42 "\n"
43 "       Print the file system type a given file/directory is on.\n"
44 "       The following options are supported:\n"
45 "\n"
46 "       -v     print both path and file system type.\n"
47 "       -?     print this message.\n"
48 "\n"));
49
50    exit(1);
51 }
52
53
54 int
55 main (int argc, char *const *argv)
56 {
57    char fs[1000];
58    int verbose = 0;
59    int status = 0;
60    int ch, i;
61
62    while ((ch = getopt(argc, argv, "v?")) != -1) {
63       switch (ch) {
64          case 'v':
65             verbose = 1;
66             break;
67          case '?':
68          default:
69             usage();
70
71       }
72    }
73    argc -= optind;
74    argv += optind;
75
76    if (argc < 1) {
77       usage();
78    }
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 }