2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
18 #include <afs/ihandle.h>
19 #include <afs/partition.h>
21 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
22 * Overwrites abuffer with the corrected name.
25 EnsureDevice(char *abuffer)
31 char *dirName, dirn[100];
35 code = stat(abuffer, &tstat);
38 if (((tstat.st_mode & S_IFMT) == S_IFBLK)
39 || ((tstat.st_mode & S_IFMT) == S_IFCHR)) {
40 return 0; /* already a block or char device */
42 /* otherwise, assume we've got a normal file, and we look up its device */
43 dev = tstat.st_dev; /* remember device for this file */
45 /* now, look in /dev for the appropriate file */
46 dirp = opendir(dirName = AFS_DSKDEV);
47 while (dp = readdir(dirp)) {
48 strcpy(pbuffer, dirName);
50 strcat(pbuffer, dp->d_name);
51 if (stat(pbuffer, &tstat) != -1 && (tstat.st_mode & S_IFMT) == S_IFBLK
52 && (tstat.st_rdev == dev)) {
53 strcpy(abuffer, pbuffer);
60 return 1; /* failed */