xref: /dragonfly/usr.sbin/makefs/ffs.h (revision f9993810)
1 /*	$NetBSD: ffs.h,v 1.2 2004/12/20 20:51:42 jmc Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-4-Clause
5  *
6  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
7  * All rights reserved.
8  *
9  * Written by Luke Mewburn for Wasabi Systems, Inc.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed for the NetBSD Project by
22  *      Wasabi Systems, Inc.
23  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
24  *    or promote products derived from this software without specific prior
25  *    written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  *
39  * $FreeBSD: head/usr.sbin/makefs/ffs.h 326276 2017-11-27 15:37:16Z pfg $
40  */
41 
42 #ifndef _FFS_H
43 #define _FFS_H
44 
45 #include <vfs/ufs/dinode.h>
46 #include <vfs/ufs/fs.h>
47 #include <stdbool.h>
48 
49 typedef struct {
50 	char	label[MAXVOLLEN];	/* volume name/label */
51 	int	bsize;		/* block size */
52 	int	fsize;		/* fragment size */
53 	int	cpg;		/* cylinders per group */
54 	int	cpgflg;		/* cpg was specified by user */
55 	int	density;	/* bytes per inode */
56 	bool	min_inodes;	/* allocate minimum number of inodes */
57 	int	ntracks;	/* number of tracks */
58 	int	nsectors;	/* number of sectors */
59 	int	rpm;		/* rpm */
60 	int	minfree;	/* free space threshold */
61 	int	optimization;	/* optimization (space or time) */
62 	int	maxcontig;	/* max contiguous blocks to allocate */
63 	int	rotdelay;	/* rotational delay between blocks */
64 	int	maxbpg;		/* maximum blocks per file in a cyl group */
65 	int	nrpos;		/* # of distinguished rotational positions */
66 	int	avgfilesize;	/* expected average file size */
67 	int	avgfpdir;	/* expected # of files per directory */
68 	int	version;	/* filesystem version (1 = FFS, 2 = UFS2) */
69 #ifndef __DragonFly__
70 	int	maxbsize;	/* maximum extent size */
71 #endif
72 	int	maxblkspercg;	/* max # of blocks per cylinder group */
73 	int	softupdates;	/* soft updates */
74 		/* XXX: support `old' file systems ? */
75 } ffs_opt_t;
76 
77 #ifdef __DragonFly__
78 #define	SBLOCK_UFS1		8192
79 #define	SBLOCKSIZE		SBSIZE
80 #define	FS_UFS1_MAGIC		FS_MAGIC
81 
82 #define	csum_total		csum
83 #define	ufs1_daddr_t		ufs_daddr_t
84 
85 #define	fs_old_cgmask		fs_cgmask
86 #define	fs_old_cgoffset		fs_cgoffset
87 #define	fs_old_cpc		fs_cpc
88 #define	fs_old_cpg		fs_cpg
89 #define	fs_old_flags		fs_flags
90 #define	fs_old_inodefmt		fs_inodefmt
91 #define	fs_old_interleave	fs_interleave
92 #define	fs_old_ncyl		fs_ncyl
93 #define	fs_old_npsect		fs_npsect
94 #define	fs_old_nrpos		fs_nrpos
95 #define	fs_old_nsect		fs_nsect
96 #define	fs_old_nspf		fs_nspf
97 #define	fs_old_postblformat	fs_postblformat
98 #define	fs_old_postbloff	fs_postbloff
99 #define	fs_old_rotbloff		fs_rotbloff
100 #define	fs_old_rotdelay		fs_rotdelay
101 #define	fs_old_rps		fs_rps
102 #define	fs_old_spc		fs_spc
103 #define	fs_old_trackskew	fs_trackskew
104 
105 #define	cg_old_boff		cg_boff
106 #define	cg_old_btotoff		cg_btotoff
107 #define	cg_old_ncyl		cg_ncyl
108 #define	cg_old_niblk		cg_niblk
109 #define	cg_old_time		cg_time
110 
111 typedef	__int64_t	makefs_daddr_t;	/* XXX swildner: ours is 32 bits?! */
112 
113 /*
114  * The size of a cylinder group is calculated by CGSIZE. The maximum size
115  * is limited by the fact that cylinder groups are at most one block.
116  * Its size is derived from the size of the maps maintained in the
117  * cylinder group and the (struct cg) size.
118  */
119 
120 /*
121  * XXX swildner: go with FreeBSD's CGSIZE macro until I've figured out
122  *               what's wrong with ours
123  */
124 #define	FBSD_CGSIZE(fs) \
125     /* base cg */	(sizeof(struct cg) + sizeof(int32_t) + \
126     /* old btotoff */	(fs)->fs_cpg * sizeof(int32_t) + \
127     /* old boff */	(fs)->fs_cpg * sizeof(u_int16_t) + \
128     /* inode map */	howmany((fs)->fs_ipg, NBBY) + \
129     /* block map */	howmany((fs)->fs_fpg, NBBY) +\
130     /* if present */	((fs)->fs_contigsumsize <= 0 ? 0 : \
131     /* cluster sum */	(fs)->fs_contigsumsize * sizeof(int32_t) + \
132     /* cluster map */	howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
133 #endif
134 
135 #endif /* _FFS_H */
136