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 <sys/param.h>
11 #include <afs/param.h>
13 #include <afs/afsint.h>
15 #if !defined(AFS_SGI_ENV)
18 #else /* AFS_OSF_ENV */
19 #ifdef AFS_VFSINCL_ENV
22 #include <sys/fs/ufs_fs.h>
26 #else /* AFS_VFSINCL_ENV */
27 #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV)
30 #endif /* AFS_VFSINCL_ENV */
31 #endif /* AFS_OSF_ENV */
32 #endif /* AFS_SGI_ENV */
33 #include <sys/errno.h>
34 #include <sys/types.h>
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)
57 #include "../sgiefs/efs.h"
58 #define ROOTINO EFS_ROOTINO
60 #ifdef AFS_LINUX22_ENV
66 #endif /* AFS_SGI_ENV */
67 #endif /* AFS_HPUX_ENV */
70 #include <netinet/in.h>
75 #endif /* ITIMER_REAL */
76 #include "partition.h"
77 #ifdef AFS_LINUX22_ENV
78 #include <asm/types.h>
79 #include <linux/ext2_fs.h>
80 #define ROOTINO EXT2_ROOT_INO /* Assuming we do this on ext2, of course. */
83 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
84 * returns pointer to static storage; copy it out quickly!
86 char *vol_DevName(adev, wpath)
89 static char pbuffer[128];
96 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
97 struct mntent *mntent;
105 struct vmount *vmountp;
109 if ((nmounts = getmount(&vmountp)) <= 0) {
112 for (; nmounts; nmounts--, vmountp = (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
113 char *part = vmt2dataptr(vmountp, VMT_STUB);
116 if (!(mntfile = fopen(MNTTAB, "r"))) {
119 while (!getmntent(mntfile, &mnt)) {
120 char *part = mnt.mnt_mountp;
122 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
123 #ifdef AFS_LINUX22_ENV
124 if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
125 if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
130 if ((mfd = setmntent(MOUNTED/*MNTTAB*/, "r")) == NULL) {
134 while (mntent = getmntent(mfd)) {
135 char *part = mntent->mnt_dir;
138 while (fsent = getfsent()) {
139 char *part = fsent->fs_file;
141 #endif /* AFS_SGI_ENV */
145 if (vmountp->vmt_flags & (MNT_READONLY|MNT_REMOVABLE|MNT_REMOTE)) continue; /* Ignore any "special" partitions */
148 /* Ignore non ufs or non read/write partitions */
149 if ((strcmp(mnt.mnt_fstype, "ufs") !=0) ||
150 (strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
153 #if defined(AFS_LINUX22_ENV)
154 if (strcmp(mntent->mnt_type, "ext2"))
157 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
158 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
160 if (strcmp(fsent->fs_type, "rw") != 0) continue; /* Ignore non read/write partitions */
161 #endif /* AFS_LINUX22_ENV */
162 #endif /* AFS_SGI_ENV */
165 /* Only keep track of "/vicepx" partitions since it can get hairy when NFS mounts are involved.. */
166 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
167 continue; /* Non /vicepx; ignore */
169 if (stat(part, &status) == -1) {
172 #ifndef AFS_SGI_XFS_IOPS_ENV
173 if ((status.st_ino != ROOTINO) /*|| ((status.st_mode & S_IFMT) != S_IFBLK)*/) {
177 if (status.st_dev == adev) {
179 strcpy(pbuffer, vmt2dataptr(vmountp, VMT_OBJECT));
182 strcpy(pbuffer, mnt.mnt_special);
184 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
185 strcpy(pbuffer, mntent->mnt_fsname);
187 strcpy(pbuffer, fsent->fs_spec);
189 #endif /* AFS_SGI_ENV */
192 strcpy(pbuf, pbuffer);
193 ptr = (char *)rindex(pbuf, '/');
200 ptr = (char *)rindex(pbuffer, '/');
202 strcpy(pbuffer, ptr+1);
210 (void) fclose(mntfile);
212 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
217 #endif /* AFS_SGI_ENV */
223 /* Search for the raw device name. Will put an "r" in front of each
224 * directory and file entry of the pathname until we find a character
227 char *afs_rawname(devfile)
230 static char rawname[100];
237 strcpy(rawname, devfile);
238 if (devfile[i] == '/') {
241 strcat(rawname, &devfile[i+1]);
244 code = stat(rawname, &statbuf);
245 if (!code && S_ISCHR(statbuf.st_mode))
248 while((--i>=0) && (devfile[i] != '/'));