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