2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Implement routines to determine drive type (Windows specific).
23 * Written by Robert Nelson, June 2006
32 #else /* Set up for testing a stand alone program */
37 #define SUPPORTEDOSES \
41 #define bstrncpy strncpy
42 #define Dmsg0(n,s) fprintf(stderr, s)
43 #define Dmsg1(n,s,a1) fprintf(stderr, s, a1)
44 #define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2)
48 * These functions should be implemented for each OS
50 * bool drivetype(const char *fname, char *dt, int dtlen);
53 #if defined (HAVE_WIN32)
56 bool drivetype(const char *fname, char *dt, int dtlen)
61 /* Copy Drive Letter, colon, and backslash to rootpath */
62 bstrncpy(rootpath, fname, 3);
65 type = GetDriveType(rootpath);
68 case DRIVE_REMOVABLE: bstrncpy(dt, "removable", dtlen); return true;
69 case DRIVE_FIXED: bstrncpy(dt, "fixed", dtlen); return true;
70 case DRIVE_REMOTE: bstrncpy(dt, "remote", dtlen); return true;
71 case DRIVE_CDROM: bstrncpy(dt, "cdrom", dtlen); return true;
72 case DRIVE_RAMDISK: bstrncpy(dt, "ramdisk", dtlen); return true;
74 case DRIVE_NO_ROOT_DIR:
81 #else /* No recognised OS */
83 bool drivetype(const char *fname, char *dt, int dtlen)
85 Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n");
87 Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n",
97 int main(int argc, char **argv)
104 p = (argc < 1) ? "drivetype" : argv[0];
105 printf("usage:\t%s path ...\n"
106 "\t%s prints the drive type and pathname of the paths.\n",
111 if (!drivetype(*argv, dt, sizeof(dt))) {
112 status = EXIT_FAILURE;
114 printf("%s\t%s\n", dt, *argv);