From 70cbd6f689988237075d01258d9469daa16de060 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Thu, 15 Mar 2001 18:55:20 +0000 Subject: [PATCH 1/1] dux-advfs-client-support-20010315 necessary changes to allow a cache in an advfs --- src/afs/DUX/osi_file.c | 90 +++++++++++++++++++++++++++++++++++++------------ src/afs/DUX/osi_inode.c | 1 + src/afsd/afsd.c | 6 ++++ 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/src/afs/DUX/osi_file.c b/src/afs/DUX/osi_file.c index 080f234..7391e87 100644 --- a/src/afs/DUX/osi_file.c +++ b/src/afs/DUX/osi_file.c @@ -23,36 +23,82 @@ extern struct mount *afs_cacheVfsp; void *osi_UFSOpen(ainode) afs_int32 ainode; { + static struct vnode *tags_vnode = NULL; struct inode *ip; register struct osi_file *afile = NULL; extern int cacheDiskType; afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if(cacheDiskType != AFS_FCACHE_TYPE_UFS) osi_Panic("UFSOpen called for non-UFS cache\n"); - } - if (!afs_osicred_initialized) { - /* valid for alpha_osf, SunOS, Ultrix */ - bzero((char *)&afs_osi_cred, sizeof(struct AFS_UCRED)); - afs_osi_cred.cr_ref++; - afs_osicred_initialized = 1; - } + afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, &dummy); - AFS_GLOCK(); - if (code) { - osi_FreeSmallSpace(afile); - osi_Panic("UFSOpen: igetinode failed"); + + switch(afs_cacheVfsp->m_stat.f_type) { + case MOUNT_UFS: + code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, &dummy); + if (code) { + osi_FreeSmallSpace(afile); + osi_Panic("UFSOpen: igetinode failed"); + } + IN_UNLOCK(ip); + afile->vnode = ITOV(ip); + afile->size = VTOI(afile->vnode)->i_size; + afile->offset = 0; + afile->proc = NULL; + afile->inum = ainode; /* for hint validity checking */ + break; + case MOUNT_MSFS: { + char path[1024]; + struct nameidata nd, *ndp = &nd; + struct utask_nd utnd = { NULL, NULL }; + struct vattr attr; + + bzero(&nd, sizeof(nd)); + ndp->ni_utnd = &utnd; + ndp->ni_nameiop = LOOKUP; + ndp->ni_cred = &afs_osi_cred; + ndp->ni_segflg = UIO_SYSSPACE; + + /* get hold of a vnode for the .tags directory, so we can + lookup files relative to it */ + if(tags_vnode == NULL) { + ndp->ni_cdir = afs_cacheVfsp->m_vnodecovered; + strcpy(path, afs_cacheVfsp->m_stat.f_mntonname); + strcat(path, "/.tags"); + ndp->ni_dirp = path; + if((code = namei(ndp))) + osi_Panic("failed to lookup %s (%d)", path, code); + tags_vnode = ndp->ni_vp; + } + sprintf(path, "%d", ainode); + ndp->ni_dirp = path; + ndp->ni_cdir = tags_vnode; + if((code = namei(ndp))) + osi_Panic("failed to lookup %s (%d)", path, code); + + /* XXX this sucks, chances are we're going to do this again right + away, but apparently we can't just set the size to 0 */ + VOP_GETATTR(ndp->ni_vp, &attr, &afs_osi_cred, code); + if(code) + osi_Panic("failed to stat %s (%d)", path, code); + + afile->vnode = ndp->ni_vp; + afile->size = attr.va_size; + afile->offset = 0; + afile->proc = NULL; + afile->inum = ainode; /* for hint validity checking */ + break; } - IN_UNLOCK(ip); - afile->vnode = ITOV(ip); - afile->size = VTOI(afile->vnode)->i_size; - afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ - return (void *)afile; + default: + osi_Panic("UFSOpen called for unknown cache-type (%d)", + afs_cacheVfsp->m_stat.f_type); + } + + AFS_GLOCK(); + return afile; } afs_osi_Stat(afile, astat) @@ -121,7 +167,9 @@ osi_UFSTruncate(afile, asize) void osi_DisableAtimes(avp) struct vnode *avp; { - struct inode *ip = VTOI(avp); + struct inode *ip; + assert(avp->v_tag == VT_UFS); + ip = VTOI(avp); ip->i_flag &= ~IACC; } diff --git a/src/afs/DUX/osi_inode.c b/src/afs/DUX/osi_inode.c index 6bdf32b..9e77761 100644 --- a/src/afs/DUX/osi_inode.c +++ b/src/afs/DUX/osi_inode.c @@ -103,6 +103,7 @@ getinode(fs, dev, inode, ipp, perror) } vp = (struct vnode *) fake_vnode; fake_inode_init(vp, fs); + assert(vp->v_tag == VT_UFS); code = iget(VTOI(vp), inode, &ip, 0); if (code != 0) { *perror = BAD_IGET; diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 0ca577e..8c82c21 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -601,6 +601,12 @@ int SweepAFSCache(vFilesFound) } else if ((strcmp(currp->d_name, ".") == 0) || (strcmp(currp->d_name, "..") == 0) || +#ifdef AFS_DECOSF_ENV + /* these are magic AdvFS files */ + (strcmp(currp->d_name, ".tags") == 0) || + (strcmp(currp->d_name, "quota.user") == 0) || + (strcmp(currp->d_name, "quota.group") == 0) || +#endif (strcmp(currp->d_name, "lost+found") == 0)) { /* * Don't do anything - this file is legit, and is to be left alone. -- 1.9.4