2 * Implement routines to determine drive type (Windows specific).
4 * Written by Robert Nelson, June 2006
9 Bacula® - The Network Backup Solution
11 Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
13 The main author of Bacula is Kern Sibbald, with contributions from
14 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation and included
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of John Walker.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
33 Switzerland, email:ftf@fsfeurope.org.
41 #else /* Set up for testing a stand alone program */
46 #define SUPPORTEDOSES \
50 #define bstrncpy strncpy
51 #define Dmsg0(n,s) fprintf(stderr, s)
52 #define Dmsg1(n,s,a1) fprintf(stderr, s, a1)
53 #define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2)
57 * These functions should be implemented for each OS
59 * bool drivetype(const char *fname, char *dt, int dtlen);
62 #if defined (HAVE_WIN32)
65 bool drivetype(const char *fname, char *dt, int dtlen)
70 /* Copy Drive Letter, colon, and backslash to rootpath */
71 bstrncpy(rootpath, fname, 3);
74 type = GetDriveType(rootpath);
77 case DRIVE_REMOVABLE: bstrncpy(dt, "removable", dtlen); return true;
78 case DRIVE_FIXED: bstrncpy(dt, "fixed", dtlen); return true;
79 case DRIVE_REMOTE: bstrncpy(dt, "remote", dtlen); return true;
80 case DRIVE_CDROM: bstrncpy(dt, "cdrom", dtlen); return true;
81 case DRIVE_RAMDISK: bstrncpy(dt, "ramdisk", dtlen); return true;
83 case DRIVE_NO_ROOT_DIR:
90 #else /* No recognised OS */
92 bool drivetype(const char *fname, char *dt, int dtlen)
94 Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n");
96 Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n",
106 int main(int argc, char **argv)
113 p = (argc < 1) ? "drivetype" : argv[0];
114 printf("usage:\t%s path ...\n"
115 "\t%s prints the drive type and pathname of the paths.\n",
120 if (!drivetype(*argv, dt, sizeof(dt))) {
121 status = EXIT_FAILURE;
123 printf("%s\t%s\n", dt, *argv);