1994-05-24 10:09:53 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1989, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley
|
|
|
|
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
|
|
|
|
* Support code is derived from software contributed to Berkeley
|
|
|
|
* by Atsushi Murai (amurai@spec.co.jp).
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: @(#)ufs_lookup.c 7.33 (Berkeley) 5/19/91
|
|
|
|
*
|
|
|
|
* @(#)cd9660_lookup.c 8.2 (Berkeley) 1/23/94
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-09-15 19:46:03 +00:00
|
|
|
#include <sys/systm.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/namei.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
|
|
|
#include <isofs/cd9660/iso.h>
|
|
|
|
#include <isofs/cd9660/cd9660_node.h>
|
|
|
|
#include <isofs/cd9660/iso_rrip.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a component of a pathname into a pointer to a locked inode.
|
|
|
|
* This is a very central and rather complicated routine.
|
|
|
|
* If the file system is not maintained in a strict tree hierarchy,
|
|
|
|
* this can result in a deadlock situation (see comments in code below).
|
|
|
|
*
|
|
|
|
* The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on
|
|
|
|
* whether the name is to be looked up, created, renamed, or deleted.
|
|
|
|
* When CREATE, RENAME, or DELETE is specified, information usable in
|
|
|
|
* creating, renaming, or deleting a directory entry may be calculated.
|
|
|
|
* If flag has LOCKPARENT or'ed into it and the target of the pathname
|
|
|
|
* exists, lookup returns both the target and its parent directory locked.
|
|
|
|
* When creating or renaming and LOCKPARENT is specified, the target may
|
|
|
|
* not be ".". When deleting and LOCKPARENT is specified, the target may
|
|
|
|
* be "."., but the caller must check to ensure it does an vrele and iput
|
|
|
|
* instead of two iputs.
|
|
|
|
*
|
|
|
|
* Overall outline of ufs_lookup:
|
|
|
|
*
|
|
|
|
* search for name in directory, to found or notfound
|
|
|
|
* notfound:
|
|
|
|
* if creating, return locked directory, leaving info on available slots
|
|
|
|
* else return error
|
|
|
|
* found:
|
|
|
|
* if at end of path and deleting, return information to allow delete
|
|
|
|
* if at end of path and rewriting (RENAME and LOCKPARENT), lock target
|
|
|
|
* inode and return info to allow rewrite
|
|
|
|
* if not at end, add name to cache; if at end and neither creating
|
|
|
|
* nor deleting, add name to cache
|
|
|
|
*
|
|
|
|
* NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_lookup(ap)
|
1997-08-26 07:32:51 +00:00
|
|
|
struct vop_cachedlookup_args /* {
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
register struct vnode *vdp; /* vnode for directory being searched */
|
|
|
|
register struct iso_node *dp; /* inode for directory being searched */
|
|
|
|
register struct iso_mnt *imp; /* file system that directory is in */
|
|
|
|
struct buf *bp; /* a buffer of directory entries */
|
1994-05-25 09:21:21 +00:00
|
|
|
struct iso_directory_record *ep = 0;/* the current directory entry */
|
1994-05-24 10:09:53 +00:00
|
|
|
int entryoffsetinblock; /* offset of ep in bp's buffer */
|
1994-05-25 09:21:21 +00:00
|
|
|
int saveoffset = 0; /* offset of last directory entry in dir */
|
1994-05-24 10:09:53 +00:00
|
|
|
int numdirpasses; /* strategy for directory search */
|
|
|
|
doff_t endsearch; /* offset to end directory search */
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *pdp; /* saved dp during symlink work */
|
|
|
|
struct vnode *tdp; /* returned by cd9660_vget_internal */
|
|
|
|
u_long bmask; /* block offset mask */
|
1994-05-24 10:09:53 +00:00
|
|
|
int lockparent; /* 1 => lockparent flag is set */
|
|
|
|
int wantparent; /* 1 => wantparent or lockparent flag */
|
|
|
|
int error;
|
|
|
|
ino_t ino = 0;
|
|
|
|
int reclen;
|
|
|
|
u_short namelen;
|
1995-01-16 17:03:29 +00:00
|
|
|
int isoflags;
|
1994-05-24 10:09:53 +00:00
|
|
|
char altname[NAME_MAX];
|
|
|
|
int res;
|
|
|
|
int assoc, len;
|
|
|
|
char *name;
|
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
int flags = cnp->cn_flags;
|
|
|
|
int nameiop = cnp->cn_nameiop;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = cnp->cn_thread;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
bp = NULL;
|
|
|
|
*vpp = NULL;
|
|
|
|
vdp = ap->a_dvp;
|
|
|
|
dp = VTOI(vdp);
|
|
|
|
imp = dp->i_mnt;
|
|
|
|
lockparent = flags & LOCKPARENT;
|
|
|
|
wantparent = flags & (LOCKPARENT|WANTPARENT);
|
2000-10-03 04:39:50 +00:00
|
|
|
cnp->cn_flags &= ~PDIRUNLOCK;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* We now have a segment name to search for, and a directory to search.
|
|
|
|
*/
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
len = cnp->cn_namelen;
|
|
|
|
name = cnp->cn_nameptr;
|
|
|
|
/*
|
|
|
|
* A leading `=' means, we are looking for an associated file
|
|
|
|
*/
|
1994-09-26 00:32:59 +00:00
|
|
|
if ((assoc = (imp->iso_ftype != ISO_FTYPE_RRIP && *name == ASSOCCHAR)))
|
|
|
|
{
|
1994-05-24 10:09:53 +00:00
|
|
|
len--;
|
|
|
|
name++;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* If there is cached information on a previous search of
|
|
|
|
* this directory, pick up where we last left off.
|
|
|
|
* We cache only lookups as these are the most common
|
|
|
|
* and have the greatest payoff. Caching CREATE has little
|
|
|
|
* benefit as it usually must search the entire directory
|
|
|
|
* to determine that the entry does not exist. Caching the
|
|
|
|
* location of the last DELETE or RENAME has not reduced
|
|
|
|
* profiling time and hence has been removed in the interest
|
|
|
|
* of simplicity.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
bmask = imp->im_bmask;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (nameiop != LOOKUP || dp->i_diroff == 0 ||
|
|
|
|
dp->i_diroff > dp->i_size) {
|
|
|
|
entryoffsetinblock = 0;
|
|
|
|
dp->i_offset = 0;
|
|
|
|
numdirpasses = 1;
|
|
|
|
} else {
|
|
|
|
dp->i_offset = dp->i_diroff;
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((entryoffsetinblock = dp->i_offset & bmask) &&
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
(error = cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)))
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
numdirpasses = 2;
|
1997-03-08 16:09:38 +00:00
|
|
|
nchstats.ncs_2passes++;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
endsearch = dp->i_size;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
searchloop:
|
|
|
|
while (dp->i_offset < endsearch) {
|
|
|
|
/*
|
|
|
|
* If offset is on a block boundary,
|
|
|
|
* read the next directory block.
|
|
|
|
* Release previous if it exists.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((dp->i_offset & bmask) == 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bp != NULL)
|
|
|
|
brelse(bp);
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error =
|
|
|
|
cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
entryoffsetinblock = 0;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Get pointer to next entry.
|
|
|
|
*/
|
|
|
|
ep = (struct iso_directory_record *)
|
1997-02-10 02:22:35 +00:00
|
|
|
((char *)bp->b_data + entryoffsetinblock);
|
|
|
|
|
|
|
|
reclen = isonum_711(ep->length);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (reclen == 0) {
|
|
|
|
/* skip to next block, if any */
|
|
|
|
dp->i_offset =
|
1997-02-10 02:22:35 +00:00
|
|
|
(dp->i_offset & ~bmask) + imp->logical_block_size;
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (reclen < ISO_DIRECTORY_RECORD_SIZE)
|
|
|
|
/* illegal entry, stop */
|
|
|
|
break;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (entryoffsetinblock + reclen > imp->logical_block_size)
|
|
|
|
/* entries are not allowed to cross boundaries */
|
|
|
|
break;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
namelen = isonum_711(ep->name_len);
|
1995-01-16 17:03:29 +00:00
|
|
|
isoflags = isonum_711(imp->iso_ftype == ISO_FTYPE_HIGH_SIERRA?
|
|
|
|
&ep->date[6]: ep->flags);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (reclen < ISO_DIRECTORY_RECORD_SIZE + namelen)
|
|
|
|
/* illegal entry, stop */
|
|
|
|
break;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for a name match.
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
switch (imp->iso_ftype) {
|
|
|
|
default:
|
1995-01-16 17:03:29 +00:00
|
|
|
if (!(isoflags & 4) == !assoc) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if ((len == 1
|
|
|
|
&& *name == '.')
|
|
|
|
|| (flags & ISDOTDOT)) {
|
|
|
|
if (namelen == 1
|
|
|
|
&& ep->name[0] == ((flags & ISDOTDOT) ? 1 : 0)) {
|
|
|
|
/*
|
|
|
|
* Save directory entry's inode number and
|
1997-02-10 02:22:35 +00:00
|
|
|
* release directory buffer.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
dp->i_ino = isodirino(ep, imp);
|
1994-05-24 10:09:53 +00:00
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
if (namelen != 1
|
|
|
|
|| ep->name[0] != 0)
|
|
|
|
goto notfound;
|
1999-04-18 10:58:03 +00:00
|
|
|
} else if (!(res = isofncmp(name, len, ep->name, namelen, imp->joliet_level))) {
|
1997-02-11 16:16:02 +00:00
|
|
|
if (isoflags & 2)
|
1997-02-10 02:22:35 +00:00
|
|
|
ino = isodirino(ep, imp);
|
1994-05-24 10:09:53 +00:00
|
|
|
else
|
|
|
|
ino = dbtob(bp->b_blkno)
|
|
|
|
+ entryoffsetinblock;
|
|
|
|
saveoffset = dp->i_offset;
|
|
|
|
} else if (ino)
|
|
|
|
goto foundino;
|
|
|
|
#ifdef NOSORTBUG /* On some CDs directory entries are not sorted correctly */
|
|
|
|
else if (res < 0)
|
|
|
|
goto notfound;
|
|
|
|
else if (res > 0 && numdirpasses == 2)
|
|
|
|
numdirpasses++;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ISO_FTYPE_RRIP:
|
|
|
|
if (isonum_711(ep->flags)&2)
|
1997-02-10 02:22:35 +00:00
|
|
|
ino = isodirino(ep, imp);
|
1994-05-24 10:09:53 +00:00
|
|
|
else
|
|
|
|
ino = dbtob(bp->b_blkno) + entryoffsetinblock;
|
|
|
|
dp->i_ino = ino;
|
|
|
|
cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp);
|
|
|
|
if (namelen == cnp->cn_namelen
|
|
|
|
&& !bcmp(name,altname,namelen))
|
|
|
|
goto found;
|
|
|
|
ino = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dp->i_offset += reclen;
|
|
|
|
entryoffsetinblock += reclen;
|
|
|
|
}
|
|
|
|
if (ino) {
|
|
|
|
foundino:
|
|
|
|
dp->i_ino = ino;
|
|
|
|
if (saveoffset != dp->i_offset) {
|
1997-02-10 02:22:35 +00:00
|
|
|
if (lblkno(imp, dp->i_offset) !=
|
|
|
|
lblkno(imp, saveoffset)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bp != NULL)
|
|
|
|
brelse(bp);
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error = cd9660_blkatoff(vdp,
|
|
|
|
(off_t)saveoffset, NULL, &bp)) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
entryoffsetinblock = saveoffset & bmask;
|
|
|
|
ep = (struct iso_directory_record *)
|
|
|
|
((char *)bp->b_data + entryoffsetinblock);
|
1994-05-24 10:09:53 +00:00
|
|
|
dp->i_offset = saveoffset;
|
|
|
|
}
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
notfound:
|
|
|
|
/*
|
|
|
|
* If we started in the middle of the directory and failed
|
|
|
|
* to find our target, we must check the beginning as well.
|
|
|
|
*/
|
|
|
|
if (numdirpasses == 2) {
|
|
|
|
numdirpasses--;
|
|
|
|
dp->i_offset = 0;
|
|
|
|
endsearch = dp->i_diroff;
|
|
|
|
goto searchloop;
|
|
|
|
}
|
|
|
|
if (bp != NULL)
|
|
|
|
brelse(bp);
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Insert name into cache (as non-existent) if appropriate.
|
|
|
|
*/
|
|
|
|
if (cnp->cn_flags & MAKEENTRY)
|
|
|
|
cache_enter(vdp, *vpp, cnp);
|
|
|
|
if (nameiop == CREATE || nameiop == RENAME)
|
1995-11-12 10:16:53 +00:00
|
|
|
return (EROFS);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (ENOENT);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
found:
|
|
|
|
if (numdirpasses == 2)
|
1997-03-08 16:09:38 +00:00
|
|
|
nchstats.ncs_pass2++;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Found component in pathname.
|
|
|
|
* If the final component of path name, save information
|
|
|
|
* in the cache as to where the entry was found.
|
|
|
|
*/
|
|
|
|
if ((flags & ISLASTCN) && nameiop == LOOKUP)
|
|
|
|
dp->i_diroff = dp->i_offset;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Step through the translation in the name. We do not `iput' the
|
|
|
|
* directory because we may need it again if a symbolic link
|
|
|
|
* is relative to the current directory. Instead we save it
|
|
|
|
* unlocked as "pdp". We must get the target inode before unlocking
|
|
|
|
* the directory to insure that the inode will not be removed
|
|
|
|
* before we get it. We prevent deadlock by always fetching
|
|
|
|
* inodes from the root, moving down the directory tree. Thus
|
|
|
|
* when following backward pointers ".." we must unlock the
|
|
|
|
* parent directory before getting the requested directory.
|
|
|
|
* There is a potential race condition here if both the current
|
|
|
|
* and parent directories are removed before the `iget' for the
|
|
|
|
* inode associated with ".." returns. We hope that this occurs
|
|
|
|
* infrequently since we cannot avoid this race condition without
|
|
|
|
* implementing a sophisticated deadlock detection algorithm.
|
|
|
|
* Note also that this simple deadlock detection scheme will not
|
|
|
|
* work if the file system has any hard links other than ".."
|
|
|
|
* that point backwards in the directory structure.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
pdp = vdp;
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* If ino is different from dp->i_ino,
|
|
|
|
* it's a relocated directory.
|
|
|
|
*/
|
|
|
|
if (flags & ISDOTDOT) {
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(pdp, 0, td); /* race to get the inode */
|
1997-02-10 02:22:35 +00:00
|
|
|
error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
|
|
|
|
dp->i_ino != ino, ep);
|
|
|
|
brelse(bp);
|
|
|
|
if (error) {
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
2000-10-03 04:39:50 +00:00
|
|
|
if (lockparent && (flags & ISLASTCN)) {
|
2001-09-12 08:38:13 +00:00
|
|
|
if ((error = vn_lock(pdp, LK_EXCLUSIVE, td)) != 0) {
|
2000-10-03 04:39:50 +00:00
|
|
|
cnp->cn_flags |= PDIRUNLOCK;
|
|
|
|
vput(tdp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
cnp->cn_flags |= PDIRUNLOCK;
|
1997-02-10 02:22:35 +00:00
|
|
|
*vpp = tdp;
|
1994-05-24 10:09:53 +00:00
|
|
|
} else if (dp->i_number == dp->i_ino) {
|
1997-02-10 02:22:35 +00:00
|
|
|
brelse(bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
VREF(vdp); /* we want ourself, ie "." */
|
|
|
|
*vpp = vdp;
|
|
|
|
} else {
|
1997-02-10 02:22:35 +00:00
|
|
|
error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
|
|
|
|
dp->i_ino != ino, ep);
|
|
|
|
brelse(bp);
|
|
|
|
if (error)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
2000-10-03 04:39:50 +00:00
|
|
|
if (!lockparent || !(flags & ISLASTCN)) {
|
|
|
|
cnp->cn_flags |= PDIRUNLOCK;
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(pdp, 0, td);
|
2000-10-03 04:39:50 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
*vpp = tdp;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Insert name into cache if appropriate.
|
|
|
|
*/
|
|
|
|
if (cnp->cn_flags & MAKEENTRY)
|
|
|
|
cache_enter(vdp, *vpp, cnp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Return buffer with the contents of block "offset" from the beginning of
|
|
|
|
* directory "ip". If "res" is non-zero, fill it in with a pointer to the
|
1994-05-24 10:09:53 +00:00
|
|
|
* remaining space in the directory.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
cd9660_blkatoff(vp, offset, res, bpp)
|
|
|
|
struct vnode *vp;
|
|
|
|
off_t offset;
|
|
|
|
char **res;
|
|
|
|
struct buf **bpp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct iso_node *ip;
|
|
|
|
register struct iso_mnt *imp;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct buf *bp;
|
1997-02-10 02:22:35 +00:00
|
|
|
daddr_t lbn;
|
|
|
|
int bsize, error;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
ip = VTOI(vp);
|
1997-02-10 02:22:35 +00:00
|
|
|
imp = ip->i_mnt;
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
lbn = lblkno(imp, offset);
|
1997-02-10 02:22:35 +00:00
|
|
|
bsize = blksize(imp, ip, lbn);
|
|
|
|
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
brelse(bp);
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
*bpp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
if (res)
|
|
|
|
*res = (char *)bp->b_data + blkoff(imp, offset);
|
|
|
|
*bpp = bp;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|