/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2001, 2002 Scott Long <[email protected]>4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#define UDF_HASHTBLSIZE 1002930struct udf_node {31struct vnode *i_vnode;32struct udf_mnt *udfmp;33ino_t hash_id;34long diroff;35struct file_entry *fentry;36};3738struct udf_mnt {39int im_flags;40struct mount *im_mountp;41struct g_consumer *im_cp;42struct bufobj *im_bo;43struct cdev *im_dev;44struct vnode *im_devvp;45int bsize;46int bshift;47int bmask;48uint32_t part_start;49uint32_t part_len;50uint64_t root_id;51struct long_ad root_icb;52int p_sectors;53int s_table_entries;54struct udf_sparing_table *s_table;55void *im_d2l; /* disk->local iconv handle */56#if 057void *im_l2d; /* local->disk iconv handle */58#endif59};6061struct udf_dirstream {62struct udf_node *node;63struct udf_mnt *udfmp;64struct buf *bp;65uint8_t *data;66uint8_t *buf;67int fsize;68int off;69int this_off;70int offset;71int size;72int error;73int fid_fragment;74};7576struct ifid {77u_short ifid_len;78u_short ifid_pad;79int ifid_ino;80long ifid_start;81};8283#define VFSTOUDFFS(mp) ((struct udf_mnt *)((mp)->mnt_data))84#define VTON(vp) ((struct udf_node *)((vp)->v_data))8586/*87* The block layer refers to things in terms of 512 byte blocks by default.88* btodb() is expensive, so speed things up.89* XXX Can the block layer be forced to use a different block size?90*/91#define RDSECTOR(devvp, sector, size, bp) \92bread(devvp, sector << (udfmp->bshift - DEV_BSHIFT), size, NOCRED, bp)9394MALLOC_DECLARE(M_UDFFENTRY);9596static __inline int97udf_readdevblks(struct udf_mnt *udfmp, daddr_t sector, int size, struct buf **bp)98{99if (size < 0 || size + udfmp->bmask < size)100return (ERANGE);101return (RDSECTOR(udfmp->im_devvp, sector,102(size + udfmp->bmask) & ~udfmp->bmask, bp));103}104105/*106* Produce a suitable file number from an ICB. The passed in ICB is expected107* to be in little endian (meaning that it hasn't been swapped for big108* endian machines yet).109* XXX If the fileno resolves to 0, we might be in big trouble.110* XXX Assumes the ICB is a long_ad. This struct is compatible with short_ad,111* but not ext_ad.112*/113static __inline ino_t114udf_getid(struct long_ad *icb)115{116return (le32toh(icb->loc.lb_num));117}118119int udf_allocv(struct mount *, struct vnode **, struct thread *);120int udf_checktag(struct desc_tag *, uint16_t);121int udf_vget(struct mount *, ino_t, int, struct vnode **);122123extern uma_zone_t udf_zone_trans;124extern uma_zone_t udf_zone_node;125extern uma_zone_t udf_zone_ds;126127extern struct vop_vector udf_fifoops;128129130