2 Bacula® - The Network Backup Solution
4 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
17 * Implement routines to determine drive type (Windows specific).
19 * Written by Robert Nelson, June 2006
29 #else /* Set up for testing a stand alone program */
34 #define SUPPORTEDOSES \
38 #define bstrncpy strncpy
39 #define Dmsg0(n,s) fprintf(stderr, s)
40 #define Dmsg1(n,s,a1) fprintf(stderr, s, a1)
41 #define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2)
45 * These functions should be implemented for each OS
47 * bool drivetype(const char *fname, char *dt, int dtlen);
50 #if defined (HAVE_WIN32)
53 bool drivetype(const char *fname, char *dt, int dtlen)
58 /* Copy Drive Letter, colon, and backslash to rootpath */
59 bstrncpy(rootpath, fname, 3);
62 type = GetDriveType(rootpath);
65 case DRIVE_REMOVABLE: bstrncpy(dt, "removable", dtlen); return true;
66 case DRIVE_FIXED: bstrncpy(dt, "fixed", dtlen); return true;
67 case DRIVE_REMOTE: bstrncpy(dt, "remote", dtlen); return true;
68 case DRIVE_CDROM: bstrncpy(dt, "cdrom", dtlen); return true;
69 case DRIVE_RAMDISK: bstrncpy(dt, "ramdisk", dtlen); return true;
71 case DRIVE_NO_ROOT_DIR:
78 #else /* No recognised OS */
80 bool drivetype(const char *fname, char *dt, int dtlen)
82 Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n");
84 Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n",
94 int main(int argc, char **argv)
101 p = (argc < 1) ? "drivetype" : argv[0];
102 printf("usage:\t%s path ...\n"
103 "\t%s prints the drive type and pathname of the paths.\n",
108 if (!drivetype(*argv, dt, sizeof(dt))) {
109 status = EXIT_FAILURE;
111 printf("%s\t%s\n", dt, *argv);