1cfe60390STomohiro Kusumi /*- 2cfe60390STomohiro Kusumi * modified for EXT2FS support in Lites 1.1 3cfe60390STomohiro Kusumi * 4cfe60390STomohiro Kusumi * Aug 1995, Godmar Back (gback@cs.utah.edu) 5cfe60390STomohiro Kusumi * University of Utah, Department of Computer Science 6cfe60390STomohiro Kusumi */ 7cfe60390STomohiro Kusumi /*- 8cfe60390STomohiro Kusumi * SPDX-License-Identifier: BSD-3-Clause 9cfe60390STomohiro Kusumi * 10cfe60390STomohiro Kusumi * Copyright (c) 1991, 1993, 1994 11cfe60390STomohiro Kusumi * The Regents of the University of California. All rights reserved. 12cfe60390STomohiro Kusumi * 13cfe60390STomohiro Kusumi * Redistribution and use in source and binary forms, with or without 14cfe60390STomohiro Kusumi * modification, are permitted provided that the following conditions 15cfe60390STomohiro Kusumi * are met: 16cfe60390STomohiro Kusumi * 1. Redistributions of source code must retain the above copyright 17cfe60390STomohiro Kusumi * notice, this list of conditions and the following disclaimer. 18cfe60390STomohiro Kusumi * 2. Redistributions in binary form must reproduce the above copyright 19cfe60390STomohiro Kusumi * notice, this list of conditions and the following disclaimer in the 20cfe60390STomohiro Kusumi * documentation and/or other materials provided with the distribution. 21cfe60390STomohiro Kusumi * 3. Neither the name of the University nor the names of its contributors 22cfe60390STomohiro Kusumi * may be used to endorse or promote products derived from this software 23cfe60390STomohiro Kusumi * without specific prior written permission. 24cfe60390STomohiro Kusumi * 25cfe60390STomohiro Kusumi * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26cfe60390STomohiro Kusumi * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27cfe60390STomohiro Kusumi * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28cfe60390STomohiro Kusumi * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29cfe60390STomohiro Kusumi * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30cfe60390STomohiro Kusumi * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31cfe60390STomohiro Kusumi * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32cfe60390STomohiro Kusumi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33cfe60390STomohiro Kusumi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34cfe60390STomohiro Kusumi * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35cfe60390STomohiro Kusumi * SUCH DAMAGE. 36cfe60390STomohiro Kusumi * 37cfe60390STomohiro Kusumi * @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94 38cfe60390STomohiro Kusumi * $FreeBSD$ 39cfe60390STomohiro Kusumi */ 40cfe60390STomohiro Kusumi 41cfe60390STomohiro Kusumi #ifndef _FS_EXT2FS_EXT2_EXTERN_H_ 42cfe60390STomohiro Kusumi #define _FS_EXT2FS_EXT2_EXTERN_H_ 43cfe60390STomohiro Kusumi 44cfe60390STomohiro Kusumi struct ext2fs_dinode; 45cfe60390STomohiro Kusumi struct ext2fs_direct_2; 46cfe60390STomohiro Kusumi struct ext2fs_direct_tail; 47cfe60390STomohiro Kusumi struct ext2fs_searchslot; 48cfe60390STomohiro Kusumi struct indir; 49cfe60390STomohiro Kusumi struct inode; 50cfe60390STomohiro Kusumi struct mount; 51cfe60390STomohiro Kusumi struct vfsconf; 52cfe60390STomohiro Kusumi struct vnode; 53cfe60390STomohiro Kusumi 54cfe60390STomohiro Kusumi int ext2_add_entry(struct vnode *, struct ext2fs_direct_2 *); 55cfe60390STomohiro Kusumi int ext2_alloc(struct inode *, daddr_t, e4fs_daddr_t, int, 56cfe60390STomohiro Kusumi struct ucred *, e4fs_daddr_t *); 57cfe60390STomohiro Kusumi e4fs_daddr_t ext2_alloc_meta(struct inode *ip); 58cfe60390STomohiro Kusumi int ext2_balloc(struct inode *, 59cfe60390STomohiro Kusumi e2fs_lbn_t, int, struct ucred *, struct buf **, int); 60cfe60390STomohiro Kusumi int ext2_blkatoff(struct vnode *, off_t, char **, struct buf **); 61cfe60390STomohiro Kusumi void ext2_blkfree(struct inode *, e4fs_daddr_t, long); 62cfe60390STomohiro Kusumi e4fs_daddr_t ext2_blkpref(struct inode *, e2fs_lbn_t, int, e2fs_daddr_t *, 63cfe60390STomohiro Kusumi e2fs_daddr_t); 64cfe60390STomohiro Kusumi int ext2_bmap(struct vop_bmap_args *); 65cfe60390STomohiro Kusumi int ext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *); 66cfe60390STomohiro Kusumi int ext4_bmapext(struct vnode *, int32_t, daddr_t/*int64_t*/ *, int *, int *); 67cfe60390STomohiro Kusumi void ext2_clusteracct(struct m_ext2fs *, char *, int, e4fs_daddr_t, int); 68cfe60390STomohiro Kusumi void ext2_dirbad(struct inode *ip, doff_t offset, char *how); 69cfe60390STomohiro Kusumi int ext2_ei2i(struct ext2fs_dinode *, struct inode *); 70cfe60390STomohiro Kusumi int ext2_getlbns(struct vnode *, daddr_t, struct indir *, int *); 71cfe60390STomohiro Kusumi int ext2_i2ei(struct inode *, struct ext2fs_dinode *); 72cfe60390STomohiro Kusumi void ext2_itimes(struct vnode *vp); 73cfe60390STomohiro Kusumi int ext2_reallocblks(struct vop_reallocblks_args *); 74cfe60390STomohiro Kusumi int ext2_reclaim(struct vop_reclaim_args *); 75cfe60390STomohiro Kusumi int ext2_truncate(struct vnode *, off_t, int, struct ucred *); 76cfe60390STomohiro Kusumi int ext2_update(struct vnode *, int); 77cfe60390STomohiro Kusumi int ext2_valloc(struct vnode *, int, struct ucred *, struct vnode **); 78cfe60390STomohiro Kusumi int ext2_vfree(struct vnode *, ino_t, int); 79cfe60390STomohiro Kusumi int ext2_vinit(struct mount *, struct vnode **vpp); 80cfe60390STomohiro Kusumi int ext2_lookup(struct vop_old_lookup_args *); 81cfe60390STomohiro Kusumi int ext2_readdir(struct vop_readdir_args *); 82cfe60390STomohiro Kusumi #ifdef EXT2FS_PRINT_EXTENTS 83cfe60390STomohiro Kusumi void ext2_print_inode(struct inode *); 84cfe60390STomohiro Kusumi #endif 85cfe60390STomohiro Kusumi int ext2_direnter(struct inode *, 86cfe60390STomohiro Kusumi struct vnode *, struct componentname *); 87cfe60390STomohiro Kusumi int ext2_dirremove(struct vnode *, struct componentname *); 88cfe60390STomohiro Kusumi int ext2_dirrewrite(struct inode *, 89cfe60390STomohiro Kusumi struct inode *, struct componentname *); 90cfe60390STomohiro Kusumi int ext2_dirempty(struct inode *, ino_t, struct ucred *); 91cfe60390STomohiro Kusumi int ext2_checkpath(struct inode *, struct inode *, struct ucred *); 92cfe60390STomohiro Kusumi int ext2_cg_has_sb(struct m_ext2fs *fs, int cg); 93cfe60390STomohiro Kusumi uint64_t ext2_cg_number_gdb(struct m_ext2fs *fs, int cg); 94cfe60390STomohiro Kusumi int ext2_inactive(struct vop_inactive_args *); 95cfe60390STomohiro Kusumi int ext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *, 96cfe60390STomohiro Kusumi struct componentname *); 97cfe60390STomohiro Kusumi int ext2_htree_create_index(struct vnode *, struct componentname *, 98cfe60390STomohiro Kusumi struct ext2fs_direct_2 *); 99cfe60390STomohiro Kusumi int ext2_htree_has_idx(struct inode *); 100cfe60390STomohiro Kusumi int ext2_htree_hash(const char *, int, uint32_t *, int, uint32_t *, 101cfe60390STomohiro Kusumi uint32_t *); 102cfe60390STomohiro Kusumi int ext2_htree_lookup(struct inode *, const char *, int, struct buf **, 103cfe60390STomohiro Kusumi int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); 104cfe60390STomohiro Kusumi int ext2_search_dirblock(struct inode *, void *, int *, const char *, int, 105cfe60390STomohiro Kusumi int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); 106cfe60390STomohiro Kusumi uint32_t e2fs_gd_get_ndirs(struct ext2_gd *gd); 107cfe60390STomohiro Kusumi uint64_t e2fs_gd_get_b_bitmap(struct ext2_gd *); 108cfe60390STomohiro Kusumi uint64_t e2fs_gd_get_i_bitmap(struct ext2_gd *); 109cfe60390STomohiro Kusumi uint64_t e2fs_gd_get_i_tables(struct ext2_gd *); 110cfe60390STomohiro Kusumi void ext2_sb_csum_set_seed(struct m_ext2fs *); 111cfe60390STomohiro Kusumi int ext2_sb_csum_verify(struct m_ext2fs *); 112cfe60390STomohiro Kusumi void ext2_sb_csum_set(struct m_ext2fs *); 113cfe60390STomohiro Kusumi int ext2_dir_blk_csum_verify(struct inode *, struct buf *); 114cfe60390STomohiro Kusumi struct ext2fs_direct_tail *ext2_dirent_get_tail(struct inode *ip, 115cfe60390STomohiro Kusumi struct ext2fs_direct_2 *ep); 116cfe60390STomohiro Kusumi void ext2_dirent_csum_set(struct inode *, struct ext2fs_direct_2 *); 117cfe60390STomohiro Kusumi int ext2_dirent_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep); 118cfe60390STomohiro Kusumi void ext2_dx_csum_set(struct inode *, struct ext2fs_direct_2 *); 119cfe60390STomohiro Kusumi int ext2_dx_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep); 120cfe60390STomohiro Kusumi int ext2_extent_blk_csum_verify(struct inode *, void *); 121cfe60390STomohiro Kusumi void ext2_extent_blk_csum_set(struct inode *, void *); 122cfe60390STomohiro Kusumi void ext2_init_dirent_tail(struct ext2fs_direct_tail *); 123cfe60390STomohiro Kusumi int ext2_is_dirent_tail(struct inode *, struct ext2fs_direct_2 *); 124cfe60390STomohiro Kusumi int ext2_gd_i_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *); 125cfe60390STomohiro Kusumi void ext2_gd_i_bitmap_csum_set(struct m_ext2fs *, int, struct buf *); 126cfe60390STomohiro Kusumi int ext2_gd_b_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *); 127cfe60390STomohiro Kusumi void ext2_gd_b_bitmap_csum_set(struct m_ext2fs *, int, struct buf *); 128cfe60390STomohiro Kusumi int ext2_ei_csum_verify(struct inode *, struct ext2fs_dinode *); 129cfe60390STomohiro Kusumi void ext2_ei_csum_set(struct inode *, struct ext2fs_dinode *); 130cfe60390STomohiro Kusumi int ext2_gd_csum_verify(struct m_ext2fs *, struct cdev *); 131cfe60390STomohiro Kusumi void ext2_gd_csum_set(struct m_ext2fs *); 132cfe60390STomohiro Kusumi 133cfe60390STomohiro Kusumi struct vnode *ext2_ihashget(cdev_t, ino_t); 134cfe60390STomohiro Kusumi int ext2_ihashins(struct inode *); 135cfe60390STomohiro Kusumi void ext2_ihashrem(struct inode *); 136cfe60390STomohiro Kusumi void ext2_ihashinit(void); 137cfe60390STomohiro Kusumi void ext2_ihashuninit(void); 138ffd4f0afSTomohiro Kusumi int ext2_alloc_vnode(struct mount *, ino_t, struct vnode **); 139cfe60390STomohiro Kusumi 140cfe60390STomohiro Kusumi void ext2_free(void *, struct malloc_type *, const char *); 141cfe60390STomohiro Kusumi 142cfe60390STomohiro Kusumi /* Flags to low-level allocation routines. 143cfe60390STomohiro Kusumi * The low 16-bits are reserved for IO_ flags from vnode.h. 14405e28f52STomohiro Kusumi * 14505e28f52STomohiro Kusumi * The BA_CLRBUF flag specifies that the existing content of the block 14605e28f52STomohiro Kusumi * will not be completely overwritten by the caller, so buffers for new 14705e28f52STomohiro Kusumi * blocks must be cleared and buffers for existing blocks must be read. 14805e28f52STomohiro Kusumi * When BA_CLRBUF is not set the buffer will be completely overwritten 14905e28f52STomohiro Kusumi * and there is no reason to clear them or to spend I/O fetching existing 150*4c733efeSTomohiro Kusumi * data. The BA_CLRBUF flag is handled in the ext2_balloc() functions. 151cfe60390STomohiro Kusumi */ 152cfe60390STomohiro Kusumi #define BA_CLRBUF 0x00010000 /* Clear invalid areas of buffer. */ 153cfe60390STomohiro Kusumi #define BA_SEQMASK 0x7F000000 /* Bits holding seq heuristic. */ 154cfe60390STomohiro Kusumi #define BA_SEQSHIFT 24 155cfe60390STomohiro Kusumi #define BA_SEQMAX 0x7F 156cfe60390STomohiro Kusumi 157cfe60390STomohiro Kusumi extern struct vop_ops ext2_vnodeops; 158cfe60390STomohiro Kusumi extern struct vop_ops ext2_specops; 159cfe60390STomohiro Kusumi extern struct vop_ops ext2_fifoops; 160cfe60390STomohiro Kusumi 161cfe60390STomohiro Kusumi #endif /* !_FS_EXT2FS_EXT2_EXTERN_H_ */ 162