2 * Program for determining drive type
4 * Written by Robert Nelson, June 2006
8 Bacula® - The Network Backup Solution
10 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
12 The main author of Bacula is Kern Sibbald, with contributions from many
13 others, a complete list can be found in the file AUTHORS.
15 You may use this file and others of this release according to the
16 license defined in the LICENSE file, which includes the Affero General
17 Public License, v3.0 ("AGPLv3") and some additional permissions and
18 terms pursuant to its AGPLv3 Section 7.
20 Bacula® is a registered trademark of Kern Sibbald.
24 #include "findlib/find.h"
30 "Usage: drivetype [-v] path ...\n"
32 " Print the drive type a given file/directory is on.\n"
33 " The following options are supported:\n"
35 " -l print local fixed hard drive\n"
36 " -a display information on all drives\n"
37 " -v print both path and file system type.\n"
38 " -? print this message.\n"
44 int display_drive(char *drive, bool display_local, int verbose)
49 if (drivetype(drive, dt, sizeof(dt))) {
50 if (display_local) { /* in local mode, display only harddrive */
51 if (strcmp(dt, "fixed") == 0) {
52 printf("%s\n", drive);
55 printf("%s: %s\n", drive, dt);
59 } else if (!display_local) { /* local mode is used by FileSet scripts */
60 fprintf(stderr, _("%s: unknown\n"), drive);
67 main (int argc, char *const *argv)
72 bool display_local = false;
73 bool display_all = false;
77 setlocale(LC_ALL, "");
78 bindtextdomain("bacula", LOCALEDIR);
81 while ((ch = getopt(argc, argv, "alv?")) != -1) {
103 if (argc < 1 && display_all) {
104 /* Try all letters */
105 for (drive = 'A'; drive <= 'Z'; drive++) {
106 bsnprintf(buf, sizeof(buf), "%c:/", drive);
107 display_drive(buf, display_local, verbose);
116 for (i = 0; i < argc; --argc, ++argv) {
117 status += display_drive(*argv, display_local, verbose);