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