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>
15 #include <afs/afsint.h>
16 #include <afs/ihandle.h>
17 #include <afs/partition.h>
19 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
20 * Overwrites abuffer with the corrected name.
23 EnsureDevice(char *abuffer)
29 char *dirName, dirn[100];
33 code = stat(abuffer, &tstat);
36 if (((tstat.st_mode & S_IFMT) == S_IFBLK)
37 || ((tstat.st_mode & S_IFMT) == S_IFCHR)) {
38 return 0; /* already a block or char device */
40 /* otherwise, assume we've got a normal file, and we look up its device */
41 dev = tstat.st_dev; /* remember device for this file */
43 /* now, look in /dev for the appropriate file */
44 dirp = opendir(dirName = AFS_DSKDEV);
45 while (dp = readdir(dirp)) {
46 strcpy(pbuffer, dirName);
48 strcat(pbuffer, dp->d_name);
49 if (stat(pbuffer, &tstat) != -1 && (tstat.st_mode & S_IFMT) == S_IFBLK
50 && (tstat.st_rdev == dev)) {
51 strcpy(abuffer, pbuffer);
58 return 1; /* failed */