xref: /freebsd/sys/fs/ext2fs/ext2_mount.h (revision 29363fb446372cb3f10bc98664e9767c53fbb457)
1e09c00caSUlf Lilleengen /*-
2*51369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
3*51369649SPedro F. Giffuni  *
4e09c00caSUlf Lilleengen  * Copyright (c) 1982, 1986, 1989, 1993
5e09c00caSUlf Lilleengen  *	The Regents of the University of California.  All rights reserved.
6e09c00caSUlf Lilleengen  *
7e09c00caSUlf Lilleengen  * Redistribution and use in source and binary forms, with or without
8e09c00caSUlf Lilleengen  * modification, are permitted provided that the following conditions
9e09c00caSUlf Lilleengen  * are met:
10e09c00caSUlf Lilleengen  * 1. Redistributions of source code must retain the above copyright
11e09c00caSUlf Lilleengen  *    notice, this list of conditions and the following disclaimer.
12e09c00caSUlf Lilleengen  * 2. Redistributions in binary form must reproduce the above copyright
13e09c00caSUlf Lilleengen  *    notice, this list of conditions and the following disclaimer in the
14e09c00caSUlf Lilleengen  *    documentation and/or other materials provided with the distribution.
15fca15474SPedro F. Giffuni  * 3. Neither the name of the University nor the names of its contributors
16e09c00caSUlf Lilleengen  *    may be used to endorse or promote products derived from this software
17e09c00caSUlf Lilleengen  *    without specific prior written permission.
18e09c00caSUlf Lilleengen  *
19e09c00caSUlf Lilleengen  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20e09c00caSUlf Lilleengen  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21e09c00caSUlf Lilleengen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22e09c00caSUlf Lilleengen  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23e09c00caSUlf Lilleengen  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24e09c00caSUlf Lilleengen  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25e09c00caSUlf Lilleengen  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26e09c00caSUlf Lilleengen  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27e09c00caSUlf Lilleengen  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28e09c00caSUlf Lilleengen  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29e09c00caSUlf Lilleengen  * SUCH DAMAGE.
30e09c00caSUlf Lilleengen  */
31e09c00caSUlf Lilleengen 
32e09c00caSUlf Lilleengen #ifndef _FS_EXT2FS_EXT2_MOUNT_H_
33e09c00caSUlf Lilleengen #define	_FS_EXT2FS_EXT2_MOUNT_H_
34e09c00caSUlf Lilleengen 
35e09c00caSUlf Lilleengen #ifdef _KERNEL
36e09c00caSUlf Lilleengen 
37e09c00caSUlf Lilleengen #ifdef MALLOC_DECLARE
38e09c00caSUlf Lilleengen MALLOC_DECLARE(M_EXT2NODE);
39e09c00caSUlf Lilleengen #endif
40e09c00caSUlf Lilleengen 
41e09c00caSUlf Lilleengen struct vnode;
42e09c00caSUlf Lilleengen 
43e09c00caSUlf Lilleengen /* This structure describes the ext2fs specific mount structure data. */
44e09c00caSUlf Lilleengen struct ext2mount {
45e09c00caSUlf Lilleengen 	struct	mount *um_mountp;		/* filesystem vfs structure */
46e09c00caSUlf Lilleengen 	struct	cdev *um_dev;			/* device mounted */
47e09c00caSUlf Lilleengen 	struct	vnode *um_devvp;		/* block device mounted vnode */
48e09c00caSUlf Lilleengen 
49e09c00caSUlf Lilleengen 	struct	m_ext2fs *um_e2fs;		/* EXT2FS */
50e09c00caSUlf Lilleengen 
51e09c00caSUlf Lilleengen 	u_long	um_nindir;			/* indirect ptrs per block */
52e09c00caSUlf Lilleengen 	u_long	um_bptrtodb;			/* indir ptr to disk block */
53e09c00caSUlf Lilleengen 	u_long	um_seqinc;			/* inc between seq blocks */
54e09c00caSUlf Lilleengen 
55e09c00caSUlf Lilleengen 	struct mtx um_lock;			/* Protects ext2mount & fs */
56e09c00caSUlf Lilleengen 
57e09c00caSUlf Lilleengen 	struct g_consumer *um_cp;
58e09c00caSUlf Lilleengen 	struct bufobj *um_bo;
59e09c00caSUlf Lilleengen };
60e09c00caSUlf Lilleengen 
61e09c00caSUlf Lilleengen #define	EXT2_LOCK(aa)		mtx_lock(&(aa)->um_lock)
62e09c00caSUlf Lilleengen #define	EXT2_UNLOCK(aa)	mtx_unlock(&(aa)->um_lock)
63e09c00caSUlf Lilleengen #define	EXT2_MTX(aa)		(&(aa)->um_lock)
64e09c00caSUlf Lilleengen 
65e09c00caSUlf Lilleengen /* Convert mount ptr to ext2fsmount ptr. */
66e09c00caSUlf Lilleengen #define	VFSTOEXT2(mp)	((struct ext2mount *)((mp)->mnt_data))
67e09c00caSUlf Lilleengen 
68e09c00caSUlf Lilleengen /*
69e09c00caSUlf Lilleengen  * Macros to access file system parameters in the ufsmount structure.
70e09c00caSUlf Lilleengen  * Used by ufs_bmap.
71e09c00caSUlf Lilleengen  */
72e09c00caSUlf Lilleengen #define	MNINDIR(ump)			((ump)->um_nindir)
73e09c00caSUlf Lilleengen #define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
74e09c00caSUlf Lilleengen #define	is_sequential(ump, a, b)	((b) == (a) + ump->um_seqinc)
75e09c00caSUlf Lilleengen #endif	/* _KERNEL */
76e09c00caSUlf Lilleengen 
7745641afbSJohn Baldwin #endif	/* !_FS_EXT2FS_EXT2_MOUNT_H_ */
78