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>
20 #include <rx/rx_queue.h>
21 #include <afs/afsint.h>
23 #if !defined(AFS_SGI_ENV)
24 # ifdef AFS_VFSINCL_ENV
27 # include <sys/fs/ufs_fs.h>
31 # else /* AFS_VFSINCL_ENV */
32 # if !defined(AFS_AIX_ENV)
35 # endif /* AFS_VFSINCL_ENV */
36 #endif /* AFS_SGI_ENV */
46 # if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
48 # include <sys/mnttab.h>
49 # include <sys/mntent.h>
54 # if defined(AFS_SGI_ENV)
59 # endif /* AFS_SGI_ENV */
60 # endif /* AFS_HPUX_ENV */
67 #include "partition.h"
69 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
70 * returns pointer to static storage; copy it out quickly!
73 vol_DevName(dev_t adev, char *wpath)
75 static char pbuffer[128];
81 # if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
82 struct mntent *mntent;
87 #endif /* AFS_SUN5_ENV */
91 struct vmount *vmountp;
95 if ((nmounts = getmount(&vmountp)) <= 0) {
100 (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
101 char *part = vmt2dataptr(vmountp, VMT_STUB);
104 if (!(mntfile = fopen(MNTTAB, "r"))) {
107 while (!getmntent(mntfile, &mnt)) {
108 char *part = mnt.mnt_mountp;
110 # if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
111 if ((mfd = setmntent(MOUNTED /*MNTTAB*/, "r")) == NULL) {
114 while ((mntent = getmntent(mfd))) {
115 char *part = mntent->mnt_dir;
118 while ((fsent = getfsent())) {
119 char *part = fsent->fs_file;
121 # endif /* AFS_SGI_ENV */
125 if (vmountp->vmt_flags & (MNT_READONLY | MNT_REMOVABLE | MNT_REMOTE))
126 continue; /* Ignore any "special" partitions */
129 /* Ignore non ufs or non read/write partitions */
130 if ((strcmp(mnt.mnt_fstype, "ufs") != 0)
131 || (strncmp(mnt.mnt_mntopts, "ro,ignore", 9) == 0))
134 # if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
135 if (!hasmntopt(mntent, MNTOPT_RW))
138 if (strcmp(fsent->fs_type, "rw") != 0)
139 continue; /* Ignore non read/write partitions */
140 # endif /* AFS_SGI_ENV */
143 /* Only keep track of "/vicepx" partitions since it can get hairy when NFS mounts are involved.. */
144 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
145 continue; /* Non /vicepx; ignore */
147 if (stat(part, &status) == -1) {
150 #if !defined(AFS_SGI_XFS_IOPS_ENV)
151 if ((status.st_ino !=
152 ROOTINO) /*|| ((status.st_mode & S_IFMT) != S_IFBLK) */ ) {
156 if (status.st_dev == adev) {
158 strcpy(pbuffer, vmt2dataptr(vmountp, VMT_OBJECT));
161 strcpy(pbuffer, mnt.mnt_special);
163 # if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
164 strcpy(pbuffer, mntent->mnt_fsname);
166 strcpy(pbuffer, fsent->fs_spec);
168 # endif /* AFS_SGI_ENV */
171 strcpy(pbuf, pbuffer);
172 ptr = (char *)strrchr(pbuf, OS_DIRSEPC);
179 ptr = (char *)strrchr(pbuffer, OS_DIRSEPC);
181 strcpy(pbuffer, ptr + 1);
188 (void)fclose(mntfile);
190 # if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
197 #endif /* AFS_SGI_ENV */
201 /* Search for the raw device name. Will put an "r" in front of each
202 * directory and file entry of the pathname until we find a character
206 afs_rawname(char *devfile)
208 static char rawname[100];
214 strcpy(rawname, devfile);
215 if (devfile[i] == OS_DIRSEPC) {
216 rawname[i + 1] = 'r';
218 strcat(rawname, &devfile[i + 1]);
221 code = stat(rawname, &statbuf);
222 if (!code && S_ISCHR(statbuf.st_mode))
225 while ((--i >= 0) && (devfile[i] != OS_DIRSEPC));
231 #endif /* AFS_NAMEI_ENV */