2002-04-14 16:52:14 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
2003-05-04 03:40:11 +00:00
|
|
|
#define UDF_HASHTBLSIZE 100
|
|
|
|
|
2002-04-14 16:52:14 +00:00
|
|
|
struct udf_node {
|
|
|
|
struct vnode *i_vnode;
|
|
|
|
struct udf_mnt *udfmp;
|
|
|
|
ino_t hash_id;
|
|
|
|
long diroff;
|
|
|
|
struct file_entry *fentry;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct udf_mnt {
|
|
|
|
int im_flags;
|
|
|
|
struct mount *im_mountp;
|
2004-10-29 10:40:58 +00:00
|
|
|
struct g_consumer *im_cp;
|
|
|
|
struct bufobj *im_bo;
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *im_dev;
|
2002-04-14 16:52:14 +00:00
|
|
|
struct vnode *im_devvp;
|
|
|
|
int bsize;
|
|
|
|
int bshift;
|
|
|
|
int bmask;
|
2002-04-15 19:49:15 +00:00
|
|
|
uint32_t part_start;
|
|
|
|
uint32_t part_len;
|
|
|
|
uint64_t root_id;
|
2002-04-14 16:52:14 +00:00
|
|
|
struct long_ad root_icb;
|
|
|
|
int p_sectors;
|
|
|
|
int s_table_entries;
|
|
|
|
struct udf_sparing_table *s_table;
|
2003-11-05 06:56:08 +00:00
|
|
|
void *im_d2l; /* disk->local iconv handle */
|
|
|
|
#if 0
|
|
|
|
void *im_l2d; /* local->disk iconv handle */
|
|
|
|
#endif
|
2002-04-14 16:52:14 +00:00
|
|
|
};
|
|
|
|
|
2002-08-15 00:43:43 +00:00
|
|
|
struct udf_dirstream {
|
|
|
|
struct udf_node *node;
|
|
|
|
struct udf_mnt *udfmp;
|
|
|
|
struct buf *bp;
|
|
|
|
uint8_t *data;
|
|
|
|
uint8_t *buf;
|
|
|
|
int fsize;
|
|
|
|
int off;
|
|
|
|
int this_off;
|
|
|
|
int offset;
|
|
|
|
int size;
|
|
|
|
int error;
|
|
|
|
int fid_fragment;
|
|
|
|
};
|
|
|
|
|
2007-02-15 22:08:35 +00:00
|
|
|
struct ifid {
|
|
|
|
u_short ifid_len;
|
|
|
|
u_short ifid_pad;
|
|
|
|
int ifid_ino;
|
|
|
|
long ifid_start;
|
|
|
|
};
|
|
|
|
|
2002-04-14 16:52:14 +00:00
|
|
|
#define VFSTOUDFFS(mp) ((struct udf_mnt *)((mp)->mnt_data))
|
|
|
|
#define VTON(vp) ((struct udf_node *)((vp)->v_data))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The block layer refers to things in terms of 512 byte blocks by default.
|
|
|
|
* btodb() is expensive, so speed things up.
|
|
|
|
* XXX Can the block layer be forced to use a different block size?
|
|
|
|
*/
|
|
|
|
#define RDSECTOR(devvp, sector, size, bp) \
|
|
|
|
bread(devvp, sector << (udfmp->bshift - DEV_BSHIFT), size, NOCRED, bp)
|
|
|
|
|
|
|
|
MALLOC_DECLARE(M_UDFFENTRY);
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
udf_readlblks(struct udf_mnt *udfmp, int sector, int size, struct buf **bp)
|
|
|
|
{
|
2003-05-04 07:40:29 +00:00
|
|
|
return (RDSECTOR(udfmp->im_devvp, sector,
|
|
|
|
(size + udfmp->bmask) & ~udfmp->bmask, bp));
|
2002-04-14 16:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
udf_readalblks(struct udf_mnt *udfmp, int lsector, int size, struct buf **bp)
|
|
|
|
{
|
|
|
|
daddr_t rablock, lblk;
|
|
|
|
int rasize;
|
|
|
|
|
|
|
|
lblk = (lsector + udfmp->part_start) << (udfmp->bshift - DEV_BSHIFT);
|
|
|
|
rablock = (lblk + 1) << udfmp->bshift;
|
|
|
|
rasize = size;
|
|
|
|
|
|
|
|
return (breadn(udfmp->im_devvp, lblk,
|
|
|
|
(size + udfmp->bmask) & ~udfmp->bmask,
|
|
|
|
&rablock, &rasize, 1, NOCRED, bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-06-23 19:36:09 +00:00
|
|
|
* Produce a suitable file number from an ICB. The passed in ICB is expected
|
|
|
|
* to be in little endian (meaning that it hasn't been swapped for big
|
|
|
|
* endian machines yet).
|
2002-04-14 16:52:14 +00:00
|
|
|
* XXX If the fileno resolves to 0, we might be in big trouble.
|
|
|
|
* XXX Assumes the ICB is a long_ad. This struct is compatible with short_ad,
|
|
|
|
* but not ext_ad.
|
|
|
|
*/
|
2003-05-04 07:40:29 +00:00
|
|
|
static __inline ino_t
|
2002-04-14 16:52:14 +00:00
|
|
|
udf_getid(struct long_ad *icb)
|
|
|
|
{
|
2004-06-23 19:36:09 +00:00
|
|
|
return (le32toh(icb->loc.lb_num));
|
2002-04-14 16:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int udf_allocv(struct mount *, struct vnode **, struct thread *);
|
2002-04-15 19:49:15 +00:00
|
|
|
int udf_checktag(struct desc_tag *, uint16_t);
|
2002-04-14 16:52:14 +00:00
|
|
|
int udf_vget(struct mount *, ino_t, int, struct vnode **);
|
|
|
|
|
|
|
|
extern uma_zone_t udf_zone_trans;
|
|
|
|
extern uma_zone_t udf_zone_node;
|
2002-08-15 00:43:43 +00:00
|
|
|
extern uma_zone_t udf_zone_ds;
|