xref: /freebsd/sys/fs/ext2fs/ext2_extern.h (revision bb3c01ec7960a5eaff45916bd74446f96301c16d)
1e09c00caSUlf Lilleengen /*-
2e09c00caSUlf Lilleengen  *  modified for EXT2FS support in Lites 1.1
3e09c00caSUlf Lilleengen  *
4e09c00caSUlf Lilleengen  *  Aug 1995, Godmar Back (gback@cs.utah.edu)
5e09c00caSUlf Lilleengen  *  University of Utah, Department of Computer Science
6e09c00caSUlf Lilleengen  */
7e09c00caSUlf Lilleengen /*-
851369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
951369649SPedro F. Giffuni  *
10e09c00caSUlf Lilleengen  * Copyright (c) 1991, 1993, 1994
11e09c00caSUlf Lilleengen  *	The Regents of the University of California.  All rights reserved.
12e09c00caSUlf Lilleengen  *
13e09c00caSUlf Lilleengen  * Redistribution and use in source and binary forms, with or without
14e09c00caSUlf Lilleengen  * modification, are permitted provided that the following conditions
15e09c00caSUlf Lilleengen  * are met:
16e09c00caSUlf Lilleengen  * 1. Redistributions of source code must retain the above copyright
17e09c00caSUlf Lilleengen  *    notice, this list of conditions and the following disclaimer.
18e09c00caSUlf Lilleengen  * 2. Redistributions in binary form must reproduce the above copyright
19e09c00caSUlf Lilleengen  *    notice, this list of conditions and the following disclaimer in the
20e09c00caSUlf Lilleengen  *    documentation and/or other materials provided with the distribution.
21fca15474SPedro F. Giffuni  * 3. Neither the name of the University nor the names of its contributors
22e09c00caSUlf Lilleengen  *    may be used to endorse or promote products derived from this software
23e09c00caSUlf Lilleengen  *    without specific prior written permission.
24e09c00caSUlf Lilleengen  *
25e09c00caSUlf Lilleengen  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26e09c00caSUlf Lilleengen  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27e09c00caSUlf Lilleengen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28e09c00caSUlf Lilleengen  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29e09c00caSUlf Lilleengen  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30e09c00caSUlf Lilleengen  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31e09c00caSUlf Lilleengen  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32e09c00caSUlf Lilleengen  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33e09c00caSUlf Lilleengen  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34e09c00caSUlf Lilleengen  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35e09c00caSUlf Lilleengen  * SUCH DAMAGE.
36e09c00caSUlf Lilleengen  *
37e09c00caSUlf Lilleengen  *	@(#)ffs_extern.h	8.3 (Berkeley) 4/16/94
38e09c00caSUlf Lilleengen  * $FreeBSD$
39e09c00caSUlf Lilleengen  */
40e09c00caSUlf Lilleengen 
41e09c00caSUlf Lilleengen #ifndef _FS_EXT2FS_EXT2_EXTERN_H_
42e09c00caSUlf Lilleengen #define	_FS_EXT2FS_EXT2_EXTERN_H_
43e09c00caSUlf Lilleengen 
44e09c00caSUlf Lilleengen struct ext2fs_dinode;
459824e4adSPedro F. Giffuni struct ext2fs_direct_2;
466d4a4ed7SFedor Uporov struct ext2fs_direct_tail;
479824e4adSPedro F. Giffuni struct ext2fs_searchslot;
48e09c00caSUlf Lilleengen struct indir;
49e09c00caSUlf Lilleengen struct inode;
50e09c00caSUlf Lilleengen struct mount;
51e09c00caSUlf Lilleengen struct vfsconf;
52e09c00caSUlf Lilleengen struct vnode;
53e09c00caSUlf Lilleengen 
549824e4adSPedro F. Giffuni int	ext2_add_entry(struct vnode *, struct ext2fs_direct_2 *);
5570097aacSPedro F. Giffuni int	ext2_alloc(struct inode *, daddr_t, e4fs_daddr_t, int,
5670097aacSPedro F. Giffuni 	    struct ucred *, e4fs_daddr_t *);
57ffbde5eaSFedor Uporov e4fs_daddr_t ext2_alloc_meta(struct inode *ip);
58e09c00caSUlf Lilleengen int	ext2_balloc(struct inode *,
59da057ed2SPedro F. Giffuni 	    e2fs_lbn_t, int, struct ucred *, struct buf **, int);
60e09c00caSUlf Lilleengen int	ext2_blkatoff(struct vnode *, off_t, char **, struct buf **);
6170097aacSPedro F. Giffuni void	ext2_blkfree(struct inode *,  e4fs_daddr_t, long);
6270097aacSPedro F. Giffuni e4fs_daddr_t	ext2_blkpref(struct inode *, e2fs_lbn_t, int, e2fs_daddr_t *,
6370097aacSPedro F. Giffuni 	    e2fs_daddr_t);
64e09c00caSUlf Lilleengen int	ext2_bmap(struct vop_bmap_args *);
6570097aacSPedro F. Giffuni int	ext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *);
66b394cd1eSFedor Uporov int	ext4_bmapext(struct vnode *, int32_t, int64_t *, int *, int *);
673767ed5bSFedor Uporov int	ext2_bmap_seekdata(struct vnode *, off_t *);
68ffbde5eaSFedor Uporov void	ext2_clusteracct(struct m_ext2fs *, char *, int, e4fs_daddr_t, int);
69e09c00caSUlf Lilleengen void	ext2_dirbad(struct inode *ip, doff_t offset, char *how);
70512f29d1SFedor Uporov int	ext2_ei2i(struct ext2fs_dinode *, struct inode *);
7170097aacSPedro F. Giffuni int	ext2_getlbns(struct vnode *, daddr_t, struct indir *, int *);
7272530f91SFedor Uporov int	ext2_i2ei(struct inode *, struct ext2fs_dinode *);
735b63c125SPedro F. Giffuni void	ext2_itimes(struct vnode *vp);
74fafb835aSPedro F. Giffuni int	ext2_reallocblks(struct vop_reallocblks_args *);
75e09c00caSUlf Lilleengen int	ext2_reclaim(struct vop_reclaim_args *);
76e09c00caSUlf Lilleengen int	ext2_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *);
77e09c00caSUlf Lilleengen int	ext2_update(struct vnode *, int);
78e09c00caSUlf Lilleengen int	ext2_valloc(struct vnode *, int, struct ucred *, struct vnode **);
79e09c00caSUlf Lilleengen int	ext2_vfree(struct vnode *, ino_t, int);
80e09c00caSUlf Lilleengen int	ext2_vinit(struct mount *, struct vop_vector *, struct vnode **vpp);
81e09c00caSUlf Lilleengen int	ext2_lookup(struct vop_cachedlookup_args *);
82e09c00caSUlf Lilleengen int	ext2_readdir(struct vop_readdir_args *);
83ebc94b66SFedor Uporov #ifdef EXT2FS_PRINT_EXTENTS
84e09c00caSUlf Lilleengen void	ext2_print_inode(struct inode *);
8533587684SPedro F. Giffuni #endif
86e09c00caSUlf Lilleengen int	ext2_direnter(struct inode *,
87e09c00caSUlf Lilleengen 		struct vnode *, struct componentname *);
88e09c00caSUlf Lilleengen int	ext2_dirremove(struct vnode *, struct componentname *);
89e09c00caSUlf Lilleengen int	ext2_dirrewrite(struct inode *,
90e09c00caSUlf Lilleengen 		struct inode *, struct componentname *);
91e09c00caSUlf Lilleengen int	ext2_dirempty(struct inode *, ino_t, struct ucred *);
92e09c00caSUlf Lilleengen int	ext2_checkpath(struct inode *, struct inode *, struct ucred *);
93d23db91eSPedro F. Giffuni int	ext2_cg_has_sb(struct m_ext2fs *fs, int cg);
946e38bf94SFedor Uporov uint64_t	ext2_cg_number_gdb(struct m_ext2fs *fs, int cg);
95e09c00caSUlf Lilleengen int	ext2_inactive(struct vop_inactive_args *);
969824e4adSPedro F. Giffuni int	ext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *,
979824e4adSPedro F. Giffuni 	    struct componentname *);
989824e4adSPedro F. Giffuni int	ext2_htree_create_index(struct vnode *, struct componentname *,
999824e4adSPedro F. Giffuni 	    struct ext2fs_direct_2 *);
1009824e4adSPedro F. Giffuni int	ext2_htree_has_idx(struct inode *);
1019824e4adSPedro F. Giffuni int	ext2_htree_hash(const char *, int, uint32_t *, int, uint32_t *,
1029824e4adSPedro F. Giffuni 	    uint32_t *);
1039824e4adSPedro F. Giffuni int	ext2_htree_lookup(struct inode *, const char *, int, struct buf **,
1049824e4adSPedro F. Giffuni 	    int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *);
1059824e4adSPedro F. Giffuni int	ext2_search_dirblock(struct inode *, void *, int *, const char *, int,
1069824e4adSPedro F. Giffuni 	    int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *);
1073acd9182SFedor Uporov uint32_t	e2fs_gd_get_ndirs(struct ext2_gd *gd);
1086e38bf94SFedor Uporov uint64_t	e2fs_gd_get_b_bitmap(struct ext2_gd *);
1096e38bf94SFedor Uporov uint64_t	e2fs_gd_get_i_bitmap(struct ext2_gd *);
110512f29d1SFedor Uporov uint64_t	e2fs_gd_get_i_tables(struct ext2_gd *);
111512f29d1SFedor Uporov void	ext2_sb_csum_set_seed(struct m_ext2fs *);
112512f29d1SFedor Uporov int	ext2_sb_csum_verify(struct m_ext2fs *);
113512f29d1SFedor Uporov void	ext2_sb_csum_set(struct m_ext2fs *);
114512f29d1SFedor Uporov int	ext2_extattr_blk_csum_verify(struct inode *, struct buf *);
115512f29d1SFedor Uporov void	ext2_extattr_blk_csum_set(struct inode *, struct buf *);
116512f29d1SFedor Uporov int	ext2_dir_blk_csum_verify(struct inode *, struct buf *);
1176d4a4ed7SFedor Uporov struct ext2fs_direct_tail	*ext2_dirent_get_tail(struct inode *ip,
1186d4a4ed7SFedor Uporov     struct ext2fs_direct_2 *ep);
1196d4a4ed7SFedor Uporov void	ext2_dirent_csum_set(struct inode *, struct ext2fs_direct_2 *);
1206d4a4ed7SFedor Uporov int	ext2_dirent_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep);
1216d4a4ed7SFedor Uporov void	ext2_dx_csum_set(struct inode *, struct ext2fs_direct_2 *);
1226d4a4ed7SFedor Uporov int	ext2_dx_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep);
123512f29d1SFedor Uporov int	ext2_extent_blk_csum_verify(struct inode *, void *);
124512f29d1SFedor Uporov void	ext2_extent_blk_csum_set(struct inode *, void *);
1256d4a4ed7SFedor Uporov void	ext2_init_dirent_tail(struct ext2fs_direct_tail *);
126e49d64a7SFedor Uporov int	ext2_is_dirent_tail(struct inode *, struct ext2fs_direct_2 *);
127512f29d1SFedor Uporov int	ext2_gd_i_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *);
128512f29d1SFedor Uporov void	ext2_gd_i_bitmap_csum_set(struct m_ext2fs *, int, struct buf *);
129512f29d1SFedor Uporov int	ext2_gd_b_bitmap_csum_verify(struct m_ext2fs *, int, struct buf *);
130512f29d1SFedor Uporov void	ext2_gd_b_bitmap_csum_set(struct m_ext2fs *, int, struct buf *);
131512f29d1SFedor Uporov int	ext2_ei_csum_verify(struct inode *, struct ext2fs_dinode *);
132512f29d1SFedor Uporov void	ext2_ei_csum_set(struct inode *, struct ext2fs_dinode *);
133512f29d1SFedor Uporov int	ext2_gd_csum_verify(struct m_ext2fs *, struct cdev *);
134512f29d1SFedor Uporov void	ext2_gd_csum_set(struct m_ext2fs *);
1359824e4adSPedro F. Giffuni 
1369e880b87SJohn Baldwin /* Flags to low-level allocation routines.
1379e880b87SJohn Baldwin  * The low 16-bits are reserved for IO_ flags from vnode.h.
138*bb3c01ecSKirk McKusick  *
139*bb3c01ecSKirk McKusick  * The BA_CLRBUF flag specifies that the existing content of the block
140*bb3c01ecSKirk McKusick  * will not be completely overwritten by the caller, so buffers for new
141*bb3c01ecSKirk McKusick  * blocks must be cleared and buffers for existing blocks must be read.
142*bb3c01ecSKirk McKusick  * When BA_CLRBUF is not set the buffer will be completely overwritten
143*bb3c01ecSKirk McKusick  * and there is no reason to clear them or to spend I/O fetching existing
144*bb3c01ecSKirk McKusick  * data. The BA_CLRBUF flag is handled in the UFS_BALLOC() functions.
1459e880b87SJohn Baldwin  */
1469e880b87SJohn Baldwin #define	BA_CLRBUF	0x00010000	/* Clear invalid areas of buffer. */
1479e880b87SJohn Baldwin #define	BA_SEQMASK	0x7F000000	/* Bits holding seq heuristic. */
1489e880b87SJohn Baldwin #define	BA_SEQSHIFT	24
1499e880b87SJohn Baldwin #define	BA_SEQMAX	0x7F
150e09c00caSUlf Lilleengen 
151e09c00caSUlf Lilleengen extern struct vop_vector ext2_vnodeops;
152e09c00caSUlf Lilleengen extern struct vop_vector ext2_fifoops;
153e09c00caSUlf Lilleengen 
154e09c00caSUlf Lilleengen #endif	/* !_FS_EXT2FS_EXT2_EXTERN_H_ */
155