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>
24 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
25 #include <ufs/ufs/dinode.h>
26 #include <ufs/ffs/fs.h>
31 #else /* AFS_VFSINCL_ENV */
32 #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_FBSD_ENV)
35 #endif /* AFS_VFSINCL_ENV */
36 #endif /* AFS_OSF_ENV */
37 #endif /* AFS_SGI_ENV */
38 #include <sys/errno.h>
39 #include <sys/types.h>
51 #if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
53 #include <sys/mnttab.h>
54 #include <sys/mntent.h>
59 #if defined(AFS_SGI_ENV)
62 #ifdef AFS_SGI_EFS_IOPS_ENV
63 #define ROOTINO EFS_ROOTINO
64 #include "../sgiefs/efs.h"
67 #ifdef AFS_LINUX22_ENV
73 #endif /* AFS_SGI_ENV */
74 #endif /* AFS_HPUX_ENV */
77 #include <netinet/in.h>
82 #endif /* ITIMER_REAL */
83 #include "partition.h"
84 #ifdef AFS_LINUX22_ENV
85 #include <asm/types.h>
86 #include <linux/ext2_fs.h>
87 #define ROOTINO EXT2_ROOT_INO /* Assuming we do this on ext2, of course. */
90 /* ensure that we don't have a "/" instead of a "/dev/rxd0a" type of device.
91 * returns pointer to static storage; copy it out quickly!
93 char *vol_DevName(adev, wpath)
96 static char pbuffer[128];
103 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
104 struct mntent *mntent;
112 struct vmount *vmountp;
116 if ((nmounts = getmount(&vmountp)) <= 0) {
119 for (; nmounts; nmounts--, vmountp = (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
120 char *part = vmt2dataptr(vmountp, VMT_STUB);
123 if (!(mntfile = fopen(MNTTAB, "r"))) {
126 while (!getmntent(mntfile, &mnt)) {
127 char *part = mnt.mnt_mountp;
129 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
130 #ifdef AFS_LINUX22_ENV
131 if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
132 if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
137 if ((mfd = setmntent(MOUNTED/*MNTTAB*/, "r")) == NULL) {
141 while (mntent = getmntent(mfd)) {
142 char *part = mntent->mnt_dir;
145 while (fsent = getfsent()) {
146 char *part = fsent->fs_file;
148 #endif /* AFS_SGI_ENV */
152 if (vmountp->vmt_flags & (MNT_READONLY|MNT_REMOVABLE|MNT_REMOTE)) continue; /* Ignore any "special" partitions */
155 /* Ignore non ufs or non read/write partitions */
156 if ((strcmp(mnt.mnt_fstype, "ufs") !=0) ||
157 (strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
160 #if defined(AFS_LINUX22_ENV)
161 if (strcmp(mntent->mnt_type, "ext2"))
164 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
165 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
167 if (strcmp(fsent->fs_type, "rw") != 0) continue; /* Ignore non read/write partitions */
168 #endif /* AFS_LINUX22_ENV */
169 #endif /* AFS_SGI_ENV */
172 /* Only keep track of "/vicepx" partitions since it can get hairy when NFS mounts are involved.. */
173 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
174 continue; /* Non /vicepx; ignore */
176 if (stat(part, &status) == -1) {
179 #ifndef AFS_SGI_XFS_IOPS_ENV
180 if ((status.st_ino != ROOTINO) /*|| ((status.st_mode & S_IFMT) != S_IFBLK)*/) {
184 if (status.st_dev == adev) {
186 strcpy(pbuffer, vmt2dataptr(vmountp, VMT_OBJECT));
189 strcpy(pbuffer, mnt.mnt_special);
191 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
192 strcpy(pbuffer, mntent->mnt_fsname);
194 strcpy(pbuffer, fsent->fs_spec);
196 #endif /* AFS_SGI_ENV */
199 strcpy(pbuf, pbuffer);
200 ptr = (char *)rindex(pbuf, '/');
207 ptr = (char *)rindex(pbuffer, '/');
209 strcpy(pbuffer, ptr+1);
217 (void) fclose(mntfile);
219 #if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
224 #endif /* AFS_SGI_ENV */
230 /* Search for the raw device name. Will put an "r" in front of each
231 * directory and file entry of the pathname until we find a character
234 char *afs_rawname(devfile)
237 static char rawname[100];
244 strcpy(rawname, devfile);
245 if (devfile[i] == '/') {
248 strcat(rawname, &devfile[i+1]);
251 code = stat(rawname, &statbuf);
252 if (!code && S_ISCHR(statbuf.st_mode))
255 while((--i>=0) && (devfile[i] != '/'));