extern struct osi_dev cacheDev;
extern struct vfs *afs_cacheVfsp;
-
-/* As of 6.2, we support either XFS or EFS clients. osi_UFSOpen
- * now vectors to the correct EFS or XFS function. If new functionality is
- * added which accesses the inode, that will also need EFS/XFS variants.
- */
-#ifdef AFS_SGI_EFS_IOPS_ENV
-vnode_t *
-afs_EFSIGetVnode(ino_t ainode)
-{
- struct inode *ip;
- int error;
-
- if ((error = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode, &ip))) {
- osi_Panic("afs_EFSIGetVnode: igetinode failed, error=%d", error);
- }
- /* We don't care about atimes on the cache files, so disable them. I'm not
- * sure that this is the right place to do this: it should be *after* readi
- * and getattr and stuff.
- */
- ip->i_flags &= ~(ISYN | IACC);
- iunlock(ip);
- return (EFS_ITOV(ip));
-}
-#endif /* AFS_SGI_EFS_IOPS_ENV */
-
vnode_t *
afs_XFSIGetVnode(ino_t ainode)
{
return code;
}
-#ifdef AFS_SGI_EFS_IOPS_ENV
-void
-osi_DisableAtimes(struct vnode *avp)
-{
- if (afs_CacheFSType == AFS_SGI_EFS_CACHE) {
- struct inode *ip = EFS_VTOI(avp);
- ip->i_flags &= ~IACC;
- }
-
-}
-#endif /* AFS_SGI_EFS_IOPS_ENV */
-
/* Generic read interface */
int
if (code == 0) {
code = asize - resid;
afile->offset += code;
-#ifdef AFS_SGI_EFS_IOPS_ENV
- osi_DisableAtimes(afile->vnode);
-#endif /* AFS_SGI_EFS_IOPS_ENV */
} else {
afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
ICL_TYPE_INT32, code);
int
icreate(struct icreateargs *uap, rval_t * rvp)
{
-#ifdef AFS_SGI_EFS_IOPS_ENV
- AFS_STATCNT(icreate);
- return (afs_syscall_icreate
- (uap->dev, uap->near_inode, uap->param1, uap->param2, uap->param3,
- uap->param4, rvp));
-#else
return ENOSYS;
-#endif
}
-#ifdef AFS_SGI_EFS_IOPS_ENV
-int
-afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp)
- afs_uint32 dev, near_inode, param1, param2, param3, param4;
- rval_t *rvp;
-{
- struct inode *ip, *newip;
- struct afsparms *ap;
- struct cred cr;
- int error;
-
- AFS_STATCNT(afs_syscall_icreate);
- if (!afs_suser(NULL))
- return EPERM;
-
- if (error = getinode(0, (dev_t) dev, 2, &ip))
- return error;
-
- cr.cr_uid = 0;
- cr.cr_gid = -2;
- if (error = efs_ialloc(ip, IFREG, 1, NODEV, &newip, &cr)) {
- iput(ip);
- return error;
- }
- iput(ip);
- osi_Assert(newip);
- newip->i_flags |= IACC | IUPD | ICHG;
-
- osi_Assert(newip->i_afs == NULL);
- newip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP);
- if (param2 == INODESPECIAL)
- newip->i_version = EFS_IVER_AFSSPEC;
- else
- newip->i_version = EFS_IVER_AFSINO;
- ap = (struct afsparms *)newip->i_afs;
- ap->vicep1 = param1; /* VOLid */
- ap->vicep2 = param2; /* Vnode # */
- ap->vicep3 = param3; /* SPEC:type INO:vnode uniq */
- ap->vicep4 = param4; /* SPEC:parentId INO:data version */
- rvp->r_val1 = newip->i_number;
- iput(newip);
- return 0;
-}
-#else /* !AFS_SGI_EFS_IOPS_ENV */
int
afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp)
afs_uint32 dev, near_inode, param1, param2, param3, param4;
{
return ENOSYS;
}
-#endif /* AFS_SGI_EFS_IOPS_ENV */
#ifdef AFS_SGI_XFS_IOPS_ENV
/* inode creation routines for icreatename64 entry point. Use for EFS/XFS
if (!vfsp)
return ENXIO;
-#ifdef AFS_SGI_EFS_IOPS_ENV
- if (vfsp->vfs_fstype == efs_fstype) {
- struct inode *ip;
- if (error = igetinode(vfsp, (dev_t) dev, inode, &ip))
- return error;
- vp = EFS_ITOV(ip);
- if (error = vfile_alloc((usrmod + 1) & (FMASK), &fp, &fd)) {
- iput(ip);
- return error;
- }
- iunlock(ip);
- } else
-#endif /* AFS_SGI_EFS_IOPS_ENV */
if (vfsp->vfs_fstype == xfs_fstype) {
struct xfs_inode *xip;
if (error = xfs_igetinode(vfsp, (dev_t) dev, inode, &xip))
* Only VICEMAGIC type inodes.
*/
#ifdef AFS_SGI_XFS_IOPS_ENV
-#ifdef AFS_SGI_EFS_IOPS_ENV
-/* efs_iincdec
- *
- * XFS/EFS iinc/idec code for EFS. Uses 32 bit inode numbers.
- */
-static int
-efs_iincdec(vfsp, inode, inode_p1, amount)
- struct vfs *vfsp;
- int inode, inode_p1, amount;
-{
- struct inode *ip;
- int error;
-
- if (error = igetinode(vfsp, NULL, inode, &ip))
- return error;
-
- if (!IS_VICEMAGIC(ip))
- error = EPERM;
- else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1)
- error = ENXIO;
- else {
- ip->i_nlink += amount;
- osi_Assert(ip->i_nlink >= 0);
- if (ip->i_nlink == 0) {
- CLEAR_VICEMAGIC(ip);
- afsidestroy(ip);
- }
- ip->i_flags |= ICHG;
- }
- /* XXX sync write?? */
- iput(ip);
- return error;
-}
-#endif /* AFS_SGI_EFS_IOPS_ENV */
/* xfs_iincdec
*
inode |= inode_lo;
return xfs_iincdec64(vfsp, inode, inode_p1, amount);
}
-#ifdef AFS_SGI_EFS_IOPS_ENV
- else if (vfsp->vfs_fstype == efs_fstype) {
- return efs_iincdec(vfsp, inode_lo, inode_p1, amount);
- }
-#endif /* AFS_SGI_EFS_IOPS_ENV */
return ENXIO;
}
/* libefs.h includes <assert.h>, which we don't want */
#define __ASSERT_H__
-#ifdef AFS_SGI_EFS_IOPS_ENV
-#include "sgiefs/libefs.h"
-extern int Log();
-
-/* afs_efs_figet() replaces the SGI library routine because we are malloc'ing
- * memory for all the inodes on all the cylinder groups without releasing
- * it when we're done. Using afs_efs_figet ensures more efficient use of
- * memory.
- */
-struct efs_dinode *
-afs_efs_figet(EFS_MOUNT * mp, struct efs_dinode *dinodeBuf, int *last_cgno,
- ino_t inum)
-{
- int cgno = EFS_ITOCG(mp->m_fs, inum);
-
-
- if (cgno != *last_cgno) {
- if (efs_readb
- (mp->m_fd, (char *)dinodeBuf, EFS_CGIMIN(mp->m_fs, cgno),
- mp->m_fs->fs_cgisize) != mp->m_fs->fs_cgisize) {
- Log("Unable to read inodes for cylinder group %d.\n", cgno);
- return NULL;
- }
- *last_cgno = cgno;
- }
-
- return dinodeBuf + (inum % (mp->m_fs->fs_cgisize * EFS_INOPBB));
-}
-
-
-int
-efs_ListViceInodes(char *devname, char *mountedOn, char *resultFile,
- int (*judgeInode) (), int judgeParam, int *forcep,
- int forceR, char *wpath, void *rock)
-{
- FILE *inodeFile = NULL;
- char dev[50], rdev[51];
- struct stat status;
- struct efs_dinode *p;
- struct ViceInodeInfo info;
- int ninodes = 0, err = 0;
- struct efs_dinode *dinodeBuf = NULL;
- int last_cgno;
- EFS_MOUNT *mp;
- ino_t imax, inum; /* total number of I-nodes in file system */
-
- *forcep = 0;
-
- partition = mountedOn;
- sprintf(dev, "/dev/dsk/%s", devname);
- sprintf(rdev, "/dev/rdsk/%s", devname);
-
-
- /*
- * open raw device
- */
- efs_init(Log);
- if ((stat(rdev, &status) == -1)
- || ((mp = efs_mount(rdev, O_RDONLY)) == NULL)) {
- sprintf(rdev, "/dev/r%s", devname);
- mp = efs_mount(rdev, O_RDONLY);
- }
- if (mp == NULL) {
- Log("Unable to open `%s' inode for reading\n", rdev);
- return -1;
- }
-
- inodeFile = fopen(resultFile, "w");
- if (inodeFile == NULL) {
- Log("Unable to create inode description file %s\n", resultFile);
- goto out;
- }
-
- /* Allocate space for one cylinder group's worth of inodes. */
- dinodeBuf = (struct efs_dinode *)malloc(mp->m_fs->fs_cgisize * BBSIZE);
- if (!dinodeBuf) {
- Log("Unable to malloc %lu bytes for inode buffer.\n",
- mp->m_fs->fs_cgisize * BBSIZE);
- goto out;
- }
-
- /*
- * calculate the maximum number of inodes possible
- */
- imax = mp->m_fs->fs_ncg * mp->m_fs->fs_ipcg;
-
- last_cgno = -1;
- for (inum = 2; inum < imax; ++inum) {
- p = afs_efs_figet(mp, dinodeBuf, &last_cgno, inum);
- if (!p) {
- Log("Unable to read all inodes from partition.\n");
- goto out;
- }
- if (!IS_DVICEMAGIC(p) || !((p->di_mode & IFMT) == IFREG)) {
- continue;
- }
-#if defined(AFS_SGI_EXMAG)
- /* volume ID */
- info.u.param[0] =
- dmag(p, 0) << 24 | dmag(p, 1) << 16 | dmag(p, 2) << 8 | dmag(p,
- 3) <<
- 0;
- if ((p)->di_version == EFS_IVER_AFSSPEC) {
- info.u.param[1] = INODESPECIAL;
- /* type */
- info.u.param[2] = dmag(p, 8);
- /* parentId */
- info.u.param[3] =
- dmag(p, 4) << 24 | dmag(p, 5) << 16 | dmag(p,
- 6) << 8 | dmag(p,
- 7)
- << 0;
- } else {
- /* vnode number */
- info.u.param[1] =
- dmag(p, 4) << 16 | dmag(p, 5) << 8 | dmag(p, 6) << 0;
- /* disk uniqifier */
- info.u.param[2] =
- dmag(p, 7) << 16 | dmag(p, 8) << 8 | dmag(p, 9) << 0;
- /* data version */
- info.u.param[3] =
- dmag(p, 10) << 16 | dmag(p, 11) << 8 | (p)->di_spare;
- }
-#else
- BOMB ! !
-#endif
- info.inodeNumber = inum;
- info.byteCount = p->di_size;
- info.linkCount = p->di_nlink;
-#ifdef notdef
- Log("Ino=%d, bytes=%d, linkCnt=%d, [%x,%x,%x,%x]\n", inum, p->di_size,
- p->di_nlink, info.u.param[0], info.u.param[1], info.u.param[2],
- info.u.param[3]);
-#endif
- if (judgeInode && (*judgeInode) (&info, judgeParam, rock) == 0)
- continue;
-
- if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
- Log("Error writing inode file for partition %s\n", partition);
- goto out;
- }
- ++ninodes;
- }
-
- if (fflush(inodeFile) == EOF) {
- Log("Unable to successfully flush inode file for %s\n", partition);
- err = -2;
- goto out1;
- }
- if (fsync(fileno(inodeFile)) == -1) {
- Log("Unable to successfully fsync inode file for %s\n", partition);
- err = -2;
- goto out1;
- }
- if (fclose(inodeFile) == EOF) {
- Log("Unable to successfully close inode file for %s\n", partition);
- err = -2;
- goto out1;
- }
-
- /*
- * Paranoia: check that the file is really the right size
- */
- if (stat(resultFile, &status) == -1) {
- Log("Unable to successfully stat inode file for %s\n", partition);
- err = -2;
- goto out1;
- }
- if (status.st_size != ninodes * sizeof(struct ViceInodeInfo)) {
- Log("Wrong size (%d instead of %d) in inode file for %s\n",
- status.st_size, ninodes * sizeof(struct ViceInodeInfo),
- partition);
- err = -2;
- goto out1;
- }
- efs_umount(mp);
- if (dinodeBuf) {
- free(dinodeBuf);
- }
- return 0;
-
- out:
- err = -1;
- out1:
- if (dinodeBuf) {
- free(dinodeBuf);
- }
- efs_umount(mp);
- if (inodeFile)
- fclose(inodeFile);
-
- return err;
-}
-#endif /* AFS_SGI_EFS_IOPS_ENV */
-
#ifdef AFS_SGI_XFS_IOPS_ENV
#include <dirent.h>
#include <afs/xfsattrs.h>
int ninodes = 0, err = 0;
struct efs_dinode *dinodeBuf = NULL;
int last_cgno;
-#ifdef AFS_SGI_EFS_IOPS_ENV
- EFS_MOUNT *mp;
-#endif
ino_t imax, inum; /* total number of I-nodes in file system */
*forcep = 0;
return xfs_ListViceInodes(devname, mountedOn, resultFile, judgeInode,
judgeParam, forcep, forceR, wpath, rock);
} else
-#endif
-#ifdef AFS_SGI_EFS_IOPS_ENV
- if (root_inode.st_ino == EFS_ROOTINO) {
- return efs_ListViceInodes(devname, mountedOn, resultFile, judgeInode,
- judgeParam, forcep, forceR, wpath, rock);
- } else
#endif
{
Log("%s is not root of a filesystem\n", mountedOn);