1994-05-24 10:09:53 +00:00
|
|
|
/*-
|
1997-02-10 02:22:35 +00:00
|
|
|
* Copyright (c) 1982, 1986, 1989, 1994, 1995
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @(#)cd9660_node.c 8.2 (Berkeley) 1/23/94
|
|
|
|
*/
|
|
|
|
|
2003-06-11 00:34:37 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mount.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/malloc.h>
|
|
|
|
#include <sys/stat.h>
|
2001-01-24 12:35:55 +00:00
|
|
|
#include <sys/mutex.h>
|
2000-10-04 01:29:17 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <isofs/cd9660/iso.h>
|
|
|
|
#include <isofs/cd9660/cd9660_node.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#include <isofs/cd9660/cd9660_mount.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Structures associated with iso_node caching.
|
|
|
|
*/
|
1998-02-09 06:11:36 +00:00
|
|
|
static struct iso_node **isohashtbl;
|
|
|
|
static u_long isohash;
|
Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.
Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()
For now they're functions, they will become in-line functions
after one of the next two steps in this process.
Return major/minor/makedev to macro-hood for userland.
Register a name in cdevsw[] for the "filedescriptor" driver.
In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.
In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).
A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.
Without DEVT_FASCIST I belive this patch is a no-op.
Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.
Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +00:00
|
|
|
#define INOHASH(device, inum) ((minor(device) + ((inum)>>12)) & isohash)
|
2001-01-24 12:35:55 +00:00
|
|
|
static struct mtx cd9660_ihash_mtx;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2002-03-20 07:51:46 +00:00
|
|
|
static void cd9660_ihashrem(struct iso_node *);
|
|
|
|
static unsigned cd9660_chars2ui(unsigned char *begin, int len);
|
1995-12-03 17:14:38 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Initialize hash links for inodes and dnodes.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_init(vfsp)
|
|
|
|
struct vfsconf *vfsp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
isohashtbl = hashinit(desiredvnodes, M_ISOFSMNT, &isohash);
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&cd9660_ihash_mtx, "cd9660_ihash", NULL, MTX_DEF);
|
1994-05-25 09:21:21 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2000-06-29 01:19:12 +00:00
|
|
|
int
|
|
|
|
cd9660_uninit(vfsp)
|
|
|
|
struct vfsconf *vfsp;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isohashtbl != NULL)
|
|
|
|
free(isohashtbl, M_ISOFSMNT);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Use the device/inum pair to find the incore inode, and return a pointer
|
|
|
|
* to it. If it is in core, but locked, wait for it.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2002-03-17 01:25:47 +00:00
|
|
|
int
|
|
|
|
cd9660_ihashget(dev, inum, flags, vpp)
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *dev;
|
1997-02-10 02:22:35 +00:00
|
|
|
ino_t inum;
|
2002-03-17 01:25:47 +00:00
|
|
|
int flags;
|
|
|
|
struct vnode **vpp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = curthread; /* XXX */
|
1997-02-10 02:22:35 +00:00
|
|
|
struct iso_node *ip;
|
|
|
|
struct vnode *vp;
|
2002-03-17 01:25:47 +00:00
|
|
|
int error;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-03-17 01:25:47 +00:00
|
|
|
*vpp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
loop:
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock(&cd9660_ihash_mtx);
|
1997-02-10 02:22:35 +00:00
|
|
|
for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
|
|
|
|
if (inum == ip->i_number && dev == ip->i_dev) {
|
|
|
|
vp = ITOV(ip);
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock(&vp->v_interlock);
|
|
|
|
mtx_unlock(&cd9660_ihash_mtx);
|
2002-03-17 01:25:47 +00:00
|
|
|
error = vget(vp, flags | LK_INTERLOCK, td);
|
|
|
|
if (error == ENOENT)
|
1997-02-10 02:22:35 +00:00
|
|
|
goto loop;
|
2002-03-17 01:25:47 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
*vpp = vp;
|
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock(&cd9660_ihash_mtx);
|
2002-03-17 01:25:47 +00:00
|
|
|
return (0);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Insert the inode into the hash table, and return it locked.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cd9660_ihashins(ip)
|
|
|
|
struct iso_node *ip;
|
|
|
|
{
|
|
|
|
struct iso_node **ipp, *iq;
|
|
|
|
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock(&cd9660_ihash_mtx);
|
1997-02-10 02:22:35 +00:00
|
|
|
ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((iq = *ipp) != NULL)
|
1997-02-10 02:22:35 +00:00
|
|
|
iq->i_prev = &ip->i_next;
|
|
|
|
ip->i_next = iq;
|
|
|
|
ip->i_prev = ipp;
|
1994-05-24 10:09:53 +00:00
|
|
|
*ipp = ip;
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock(&cd9660_ihash_mtx);
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2002-10-14 03:20:36 +00:00
|
|
|
vn_lock(ITOV(ip), LK_EXCLUSIVE | LK_RETRY, curthread);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Remove the inode from the hash table.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-11-18 14:40:36 +00:00
|
|
|
static void
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_ihashrem(ip)
|
2004-07-03 16:56:45 +00:00
|
|
|
struct iso_node *ip;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2004-07-03 16:56:45 +00:00
|
|
|
struct iso_node *iq;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock(&cd9660_ihash_mtx);
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((iq = ip->i_next) != NULL)
|
1997-02-10 02:22:35 +00:00
|
|
|
iq->i_prev = ip->i_prev;
|
|
|
|
*ip->i_prev = iq;
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
ip->i_next = NULL;
|
|
|
|
ip->i_prev = NULL;
|
|
|
|
#endif
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_unlock(&cd9660_ihash_mtx);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Last reference to an inode, write the inode out and if necessary,
|
|
|
|
* truncate and deallocate the file.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
cd9660_inactive(ap)
|
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1994-05-24 10:09:53 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = ap->a_td;
|
2004-07-03 16:56:45 +00:00
|
|
|
struct iso_node *ip = VTOI(vp);
|
1994-09-26 00:32:59 +00:00
|
|
|
int error = 0;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-09-25 02:42:43 +00:00
|
|
|
if (prtactive && vrefcnt(vp) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
vprint("cd9660_inactive: pushing active", vp);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
ip->i_flag = 0;
|
|
|
|
/*
|
|
|
|
* If we are done with the inode, reclaim it
|
|
|
|
* so that it can be reused immediately.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ip->inode.iso_mode == 0)
|
2005-01-28 13:08:21 +00:00
|
|
|
vrecycle(vp, td);
|
1994-05-24 10:09:53 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reclaim an inode so that it can be used for other purposes.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
cd9660_reclaim(ap)
|
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1994-05-24 10:09:53 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
2004-07-03 16:56:45 +00:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct iso_node *ip = VTOI(vp);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-09-25 02:42:43 +00:00
|
|
|
if (prtactive && vrefcnt(vp) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
vprint("cd9660_reclaim: pushing active", vp);
|
|
|
|
/*
|
|
|
|
* Remove the inode from its hash chain.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_ihashrem(ip);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Purge old data structures associated with the inode.
|
|
|
|
*/
|
2004-10-29 10:41:44 +00:00
|
|
|
if (ip->i_mnt->im_devvp)
|
|
|
|
vrele(ip->i_mnt->im_devvp);
|
1994-05-24 10:09:53 +00:00
|
|
|
FREE(vp->v_data, M_ISOFSNODE);
|
|
|
|
vp->v_data = NULL;
|
2005-01-28 14:42:17 +00:00
|
|
|
vnode_destroy_vobject(vp);
|
1994-05-25 09:21:21 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File attributes
|
|
|
|
*/
|
|
|
|
void
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_defattr(isodir, inop, bp, ftype)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct iso_directory_record *isodir;
|
|
|
|
struct iso_node *inop;
|
|
|
|
struct buf *bp;
|
1995-01-16 17:03:29 +00:00
|
|
|
enum ISO_FTYPE ftype;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
struct buf *bp2 = NULL;
|
|
|
|
struct iso_mnt *imp;
|
|
|
|
struct iso_extended_attributes *ap = NULL;
|
|
|
|
int off;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* high sierra does not have timezone data, flag is one byte ahead */
|
|
|
|
if (isonum_711(ftype == ISO_FTYPE_HIGH_SIERRA?
|
|
|
|
&isodir->date[6]: isodir->flags)&2) {
|
1994-05-24 10:09:53 +00:00
|
|
|
inop->inode.iso_mode = S_IFDIR;
|
|
|
|
/*
|
|
|
|
* If we return 2, fts() will assume there are no subdirectories
|
|
|
|
* (just links for the path and .), so instead we return 1.
|
|
|
|
*/
|
|
|
|
inop->inode.iso_links = 1;
|
|
|
|
} else {
|
|
|
|
inop->inode.iso_mode = S_IFREG;
|
|
|
|
inop->inode.iso_links = 1;
|
|
|
|
}
|
|
|
|
if (!bp
|
1997-02-10 02:22:35 +00:00
|
|
|
&& ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
|
1994-05-24 10:09:53 +00:00
|
|
|
&& (off = isonum_711(isodir->ext_attr_length))) {
|
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(ITOV(inop), (off_t)-(off << imp->im_bshift), NULL,
|
1997-02-10 02:22:35 +00:00
|
|
|
&bp2);
|
1994-05-24 10:09:53 +00:00
|
|
|
bp = bp2;
|
|
|
|
}
|
|
|
|
if (bp) {
|
1997-02-10 02:22:35 +00:00
|
|
|
ap = (struct iso_extended_attributes *)bp->b_data;
|
2004-07-03 16:56:45 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (isonum_711(ap->version) == 1) {
|
|
|
|
if (!(ap->perm[0]&0x40))
|
|
|
|
inop->inode.iso_mode |= VEXEC >> 6;
|
|
|
|
if (!(ap->perm[0]&0x10))
|
|
|
|
inop->inode.iso_mode |= VREAD >> 6;
|
|
|
|
if (!(ap->perm[0]&4))
|
|
|
|
inop->inode.iso_mode |= VEXEC >> 3;
|
|
|
|
if (!(ap->perm[0]&1))
|
|
|
|
inop->inode.iso_mode |= VREAD >> 3;
|
|
|
|
if (!(ap->perm[1]&0x40))
|
|
|
|
inop->inode.iso_mode |= VEXEC;
|
|
|
|
if (!(ap->perm[1]&0x10))
|
|
|
|
inop->inode.iso_mode |= VREAD;
|
|
|
|
inop->inode.iso_uid = isonum_723(ap->owner); /* what about 0? */
|
|
|
|
inop->inode.iso_gid = isonum_723(ap->group); /* what about 0? */
|
|
|
|
} else
|
|
|
|
ap = NULL;
|
|
|
|
}
|
|
|
|
if (!ap) {
|
|
|
|
inop->inode.iso_mode |= VREAD|VEXEC|(VREAD|VEXEC)>>3|(VREAD|VEXEC)>>6;
|
|
|
|
inop->inode.iso_uid = (uid_t)0;
|
|
|
|
inop->inode.iso_gid = (gid_t)0;
|
|
|
|
}
|
|
|
|
if (bp2)
|
|
|
|
brelse(bp2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Time stamps
|
|
|
|
*/
|
|
|
|
void
|
1995-01-16 17:03:29 +00:00
|
|
|
cd9660_deftstamp(isodir,inop,bp,ftype)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct iso_directory_record *isodir;
|
|
|
|
struct iso_node *inop;
|
|
|
|
struct buf *bp;
|
1995-01-16 17:03:29 +00:00
|
|
|
enum ISO_FTYPE ftype;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
struct buf *bp2 = NULL;
|
|
|
|
struct iso_mnt *imp;
|
|
|
|
struct iso_extended_attributes *ap = NULL;
|
|
|
|
int off;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (!bp
|
1997-02-10 02:22:35 +00:00
|
|
|
&& ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
|
1994-05-24 10:09:53 +00:00
|
|
|
&& (off = isonum_711(isodir->ext_attr_length))) {
|
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(ITOV(inop), (off_t)-(off << imp->im_bshift), NULL,
|
1997-02-10 02:22:35 +00:00
|
|
|
&bp2);
|
1994-05-24 10:09:53 +00:00
|
|
|
bp = bp2;
|
|
|
|
}
|
|
|
|
if (bp) {
|
1997-02-10 02:22:35 +00:00
|
|
|
ap = (struct iso_extended_attributes *)bp->b_data;
|
2004-07-03 16:56:45 +00:00
|
|
|
|
1997-02-11 16:55:33 +00:00
|
|
|
if (ftype != ISO_FTYPE_HIGH_SIERRA
|
|
|
|
&& isonum_711(ap->version) == 1) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (!cd9660_tstamp_conv17(ap->ftime,&inop->inode.iso_atime))
|
|
|
|
cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_atime);
|
|
|
|
if (!cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_ctime))
|
|
|
|
inop->inode.iso_ctime = inop->inode.iso_atime;
|
|
|
|
if (!cd9660_tstamp_conv17(ap->mtime,&inop->inode.iso_mtime))
|
|
|
|
inop->inode.iso_mtime = inop->inode.iso_ctime;
|
|
|
|
} else
|
|
|
|
ap = NULL;
|
|
|
|
}
|
|
|
|
if (!ap) {
|
1995-01-16 17:03:29 +00:00
|
|
|
cd9660_tstamp_conv7(isodir->date,&inop->inode.iso_ctime,ftype);
|
1994-05-24 10:09:53 +00:00
|
|
|
inop->inode.iso_atime = inop->inode.iso_ctime;
|
|
|
|
inop->inode.iso_mtime = inop->inode.iso_ctime;
|
|
|
|
}
|
|
|
|
if (bp2)
|
|
|
|
brelse(bp2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-01-16 17:03:29 +00:00
|
|
|
cd9660_tstamp_conv7(pi,pu,ftype)
|
1997-02-10 02:22:35 +00:00
|
|
|
u_char *pi;
|
|
|
|
struct timespec *pu;
|
|
|
|
enum ISO_FTYPE ftype;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
int crtime, days;
|
|
|
|
int y, m, d, hour, minute, second, tz;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
y = pi[0] + 1900;
|
|
|
|
m = pi[1];
|
|
|
|
d = pi[2];
|
|
|
|
hour = pi[3];
|
|
|
|
minute = pi[4];
|
|
|
|
second = pi[5];
|
1995-01-16 17:03:29 +00:00
|
|
|
if(ftype != ISO_FTYPE_HIGH_SIERRA)
|
|
|
|
tz = pi[6];
|
|
|
|
else
|
|
|
|
/* original high sierra misses timezone data */
|
|
|
|
tz = 0;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (y < 1970) {
|
1996-09-20 05:51:12 +00:00
|
|
|
pu->tv_sec = 0;
|
|
|
|
pu->tv_nsec = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
#ifdef ORIGINAL
|
|
|
|
/* computes day number relative to Sept. 19th,1989 */
|
|
|
|
/* don't even *THINK* about changing formula. It works! */
|
|
|
|
days = 367*(y-1980)-7*(y+(m+9)/12)/4-3*((y+(m-9)/7)/100+1)/4+275*m/9+d-100;
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Changed :-) to make it relative to Jan. 1st, 1970
|
|
|
|
* and to disambiguate negative division
|
|
|
|
*/
|
|
|
|
days = 367*(y-1960)-7*(y+(m+9)/12)/4-3*((y+(m+9)/12-1)/100+1)/4+275*m/9+d-239;
|
|
|
|
#endif
|
|
|
|
crtime = ((((days * 24) + hour) * 60 + minute) * 60) + second;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/* timezone offset is unreliable on some disks */
|
|
|
|
if (-48 <= tz && tz <= 52)
|
1995-02-21 18:41:30 +00:00
|
|
|
crtime -= tz * 15 * 60;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1996-09-20 05:51:12 +00:00
|
|
|
pu->tv_sec = crtime;
|
|
|
|
pu->tv_nsec = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
static u_int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_chars2ui(begin,len)
|
1997-02-10 02:22:35 +00:00
|
|
|
u_char *begin;
|
1994-05-24 10:09:53 +00:00
|
|
|
int len;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
u_int rc;
|
2004-07-03 16:56:45 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
for (rc = 0; --len >= 0;) {
|
|
|
|
rc *= 10;
|
|
|
|
rc += *begin++ - '0';
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
cd9660_tstamp_conv17(pi,pu)
|
1997-02-10 02:22:35 +00:00
|
|
|
u_char *pi;
|
1994-09-15 19:46:03 +00:00
|
|
|
struct timespec *pu;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
u_char buf[7];
|
2004-07-03 16:56:45 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* year:"0001"-"9999" -> -1900 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[0] = cd9660_chars2ui(pi,4) - 1900;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* month: " 1"-"12" -> 1 - 12 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[1] = cd9660_chars2ui(pi + 4,2);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* day: " 1"-"31" -> 1 - 31 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[2] = cd9660_chars2ui(pi + 6,2);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* hour: " 0"-"23" -> 0 - 23 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[3] = cd9660_chars2ui(pi + 8,2);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* minute:" 0"-"59" -> 0 - 59 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[4] = cd9660_chars2ui(pi + 10,2);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
/* second:" 0"-"59" -> 0 - 59 */
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[5] = cd9660_chars2ui(pi + 12,2);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/* difference of GMT */
|
|
|
|
buf[6] = pi[16];
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 17:03:29 +00:00
|
|
|
return cd9660_tstamp_conv7(buf, pu, ISO_FTYPE_DEFAULT);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
ino_t
|
|
|
|
isodirino(isodir, imp)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct iso_directory_record *isodir;
|
|
|
|
struct iso_mnt *imp;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
ino_t ino;
|
|
|
|
|
|
|
|
ino = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length))
|
|
|
|
<< imp->im_bshift;
|
|
|
|
return (ino);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|