1 /*
2  * Copyright (c) 2022 Tomohiro Kusumi <tkusumi@netbsd.org>
3  * Copyright (c) 2011-2022 The DragonFly Project.  All rights reserved.
4  *
5  * This code is derived from software contributed to The DragonFly Project
6  * by Matthew Dillon <dillon@dragonflybsd.org>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  * 3. Neither the name of The DragonFly Project nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific, prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 #ifndef NEWFS_HAMMER2_H_
37 #define NEWFS_HAMMER2_H_
38 
39 #include <vfs/hammer2/hammer2_disk.h>
40 
41 #include <uuid.h>
42 
43 #include "hammer2_subs.h"
44 
45 #define HAMMER2_LABEL_NONE	0
46 #define HAMMER2_LABEL_BOOT	1
47 #define HAMMER2_LABEL_ROOT	2
48 #define HAMMER2_LABEL_DATA	3
49 
50 #define MAXLABELS	HAMMER2_SET_COUNT
51 
52 typedef struct {
53 	int Hammer2Version;
54 	uuid_t Hammer2_FSType;	/* filesystem type id for HAMMER2 */
55 	uuid_t Hammer2_VolFSID;	/* unique filesystem id in volu header */
56 	uuid_t Hammer2_SupCLID;	/* PFS cluster id in super-root inode */
57 	uuid_t Hammer2_SupFSID;	/* PFS unique id in super-root inode */
58 	uuid_t Hammer2_PfsCLID[MAXLABELS];
59 	uuid_t Hammer2_PfsFSID[MAXLABELS];
60 	hammer2_off_t BootAreaSize;
61 	hammer2_off_t AuxAreaSize;
62 	hammer2_off_t FileSystemSize[HAMMER2_MAX_VOLUMES];
63 	int NFileSystemSizes;
64 	char *Label[MAXLABELS];
65 	int NLabels;
66 	int CompType; /* default LZ4 */
67 	int CheckType; /* default XXHASH64 */
68 	int DefaultLabelType;
69 	int DebugOpt;
70 } hammer2_mkfs_options_t;
71 
72 void hammer2_mkfs_init(hammer2_mkfs_options_t *opt);
73 void hammer2_mkfs_cleanup(hammer2_mkfs_options_t *opt);
74 
75 int64_t getsize(const char *str, int64_t minval, int64_t maxval, int pw);
76 
77 void hammer2_mkfs(int ac, char **av, hammer2_mkfs_options_t *opt);
78 
79 #endif /* !NEWFS_HAMMER2_H_ */
80