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 <afsconfig.h>
15 #include <afs/param.h>
17 #include <afs/afsint.h>
19 #if !defined(AFS_SGI_ENV)
22 #else /* AFS_OSF_ENV */
23 #ifdef AFS_VFSINCL_ENV
26 #include <sys/fs/ufs_fs.h>
28 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
29 #include <ufs/ufs/dinode.h>
30 #include <ufs/ffs/fs.h>
35 #else /* AFS_VFSINCL_ENV */
36 #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_FBSD_ENV)
39 #endif /* AFS_VFSINCL_ENV */
40 #endif /* AFS_OSF_ENV */
41 #endif /* AFS_SGI_ENV */
42 #include <sys/errno.h>
43 #include <sys/types.h>
55 #if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
57 #include <sys/mnttab.h>
58 #include <sys/mntent.h>
63 #if defined(AFS_SGI_ENV)
66 #ifdef AFS_SGI_EFS_IOPS_ENV
67 #define ROOTINO EFS_ROOTINO
68 #include "../sgiefs/efs.h"
71 #ifdef AFS_LINUX22_ENV
77 #endif /* AFS_SGI_ENV */
78 #endif /* AFS_HPUX_ENV */
81 #include <netinet/in.h>
86 #endif /* ITIMER_REAL */
87 #include "partition.h"
88 #ifdef AFS_LINUX22_ENV
89 #include <asm/types.h>
90 #include <linux/ext2_fs.h>
91 #define ROOTINO EXT2_ROOT_INO /* Assuming we do this on ext2, of course. */
94 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
95 * returns pointer to static storage; copy it out quickly!
97 char *vol_DevName(adev, wpath)
100 static char pbuffer[128];
101 char pbuf[128], *ptr;
107 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
108 struct mntent *mntent;
116 struct vmount *vmountp;
120 if ((nmounts = getmount(&vmountp)) <= 0) {
123 for (; nmounts; nmounts--, vmountp = (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
124 char *part = vmt2dataptr(vmountp, VMT_STUB);
127 if (!(mntfile = fopen(MNTTAB, "r"))) {
130 while (!getmntent(mntfile, &mnt)) {
131 char *part = mnt.mnt_mountp;
133 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
134 #ifdef AFS_LINUX22_ENV
135 if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
136 if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
141 if ((mfd = setmntent(MOUNTED/*MNTTAB*/, "r")) == NULL) {
145 while (mntent = getmntent(mfd)) {
146 char *part = mntent->mnt_dir;
149 while (fsent = getfsent()) {
150 char *part = fsent->fs_file;
152 #endif /* AFS_SGI_ENV */
156 if (vmountp->vmt_flags & (MNT_READONLY|MNT_REMOVABLE|MNT_REMOTE)) continue; /* Ignore any "special" partitions */
159 /* Ignore non ufs or non read/write partitions */
160 if ((strcmp(mnt.mnt_fstype, "ufs") !=0) ||
161 (strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
164 #if defined(AFS_LINUX22_ENV)
165 if (strcmp(mntent->mnt_type, "ext2"))
168 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
169 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
171 if (strcmp(fsent->fs_type, "rw") != 0) continue; /* Ignore non read/write partitions */
172 #endif /* AFS_LINUX22_ENV */
173 #endif /* AFS_SGI_ENV */
176 /* Only keep track of "/vicepx" partitions since it can get hairy when NFS mounts are involved.. */
177 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
178 continue; /* Non /vicepx; ignore */
180 if (stat(part, &status) == -1) {
183 #ifndef AFS_SGI_XFS_IOPS_ENV
184 if ((status.st_ino != ROOTINO) /*|| ((status.st_mode & S_IFMT) != S_IFBLK)*/) {
188 if (status.st_dev == adev) {
190 strcpy(pbuffer, vmt2dataptr(vmountp, VMT_OBJECT));
193 strcpy(pbuffer, mnt.mnt_special);
195 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
196 strcpy(pbuffer, mntent->mnt_fsname);
198 strcpy(pbuffer, fsent->fs_spec);
200 #endif /* AFS_SGI_ENV */
203 strcpy(pbuf, pbuffer);
204 ptr = (char *)rindex(pbuf, '/');
211 ptr = (char *)rindex(pbuffer, '/');
213 strcpy(pbuffer, ptr+1);
221 (void) fclose(mntfile);
223 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
228 #endif /* AFS_SGI_ENV */
234 /* Search for the raw device name. Will put an "r" in front of each
235 * directory and file entry of the pathname until we find a character
238 char *afs_rawname(devfile)
241 static char rawname[100];
248 strcpy(rawname, devfile);
249 if (devfile[i] == '/') {
252 strcat(rawname, &devfile[i+1]);
255 code = stat(rawname, &statbuf);
256 if (!code && S_ISCHR(statbuf.st_mode))
259 while((--i>=0) && (devfile[i] != '/'));