Add HAMMER support to the installer
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / lib / libinstaller / diskutil.h
CommitLineData
337ad0df
DH
1/*
2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of the DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * diskutil.h
36 * $Id: diskutil.h,v 1.14 2005/02/07 06:41:42 cpressey Exp $
37 */
38
39#include <stdio.h>
40
41#ifndef __DISKUTIL_H_
42#define __DISKUTIL_H_
43
44#include "functions.h"
45
46/*** TYPES ***/
47
48struct storage;
49struct disk;
50struct slice;
51struct subpartition;
52
971d1cca
MS
53#define FS_HAMMER 0
54#define FS_UFS 1
55
337ad0df
DH
56#ifdef NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS
57
58struct storage {
59 struct disk *disk_head;
60 struct disk *disk_tail;
61 struct disk *selected_disk;
62 struct slice *selected_slice;
63 unsigned long ram; /* amount of physical memory in MB */
64};
65
66struct disk {
67 struct disk *next;
68 struct disk *prev;
69 struct slice *slice_head;
70 struct slice *slice_tail;
71 char *desc; /* from whereever we get the best */
72 char *device; /* `ad0', `da1', and such */
73 int cylinders; /* geometry information */
74 int heads;
75 int sectors; /* (sectors per track) */
76 long capacity; /* capacity in megabytes */
77 int we_formatted; /* did we format it ourselves? */
78};
79
80struct slice {
81 struct disk *parent;
82 struct slice *next;
83 struct slice *prev;
84 struct subpartition *subpartition_head;
85 struct subpartition *subpartition_tail;
86 char *desc; /* description (w/sysid string) */
87 int number; /* 1 - 4 (or more?) (from fdisk) */
88 unsigned long start; /* start sector (from fdisk) */
89 unsigned long size; /* size in sectors (from fdisk) */
90 int type; /* sysid of slice (from fdisk) */
91 int flags; /* flags (from fdisk) */
92 unsigned long capacity; /* capacity in megabytes */
93};
94
95struct subpartition {
96 struct slice *parent;
97 struct subpartition *next;
98 struct subpartition *prev;
99 char letter; /* 'a' = root partition */
100 char *mountpoint; /* includes leading slash */
101 long capacity; /* in megabytes, -1 = "rest of disk" */
102 int softupdates;
103 long fsize; /* fragment size */
104 long bsize; /* block size */
105 int is_swap;
106 int mfsbacked; /* Memory File System Backed */
971d1cca
MS
107 int type; /* FS type (UFS, HAMMER) */
108 int pfs; /* HAMMER pseudo file system */
337ad0df
DH
109};
110
111#endif /* NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS */
112
113/*** PROTOTYPES ***/
114
115struct storage *storage_new(void);
116void storage_free(struct storage *);
117void storage_set_memsize(struct storage *, unsigned long);
118unsigned long storage_get_memsize(const struct storage *);
119struct disk *storage_disk_first(const struct storage *);
120void storage_set_selected_disk(struct storage *, struct disk *);
121struct disk *storage_get_selected_disk(const struct storage *);
122void storage_set_selected_slice(struct storage *, struct slice *);
123struct slice *storage_get_selected_slice(const struct storage *);
124int storage_get_mfs_status(const char *, struct storage *);
125
126struct disk *disk_new(struct storage *, const char *);
127struct disk *disk_find(const struct storage *, const char *);
128struct disk *disk_next(const struct disk *);
129void disks_free(struct storage *);
130void disk_set_desc(struct disk *, const char *);
131const char *disk_get_desc(const struct disk *);
132const char *disk_get_device_name(const struct disk *);
133const char *disk_get_raw_device_name(const struct disk *);
134struct slice *disk_slice_first(const struct disk *);
135void disk_set_formatted(struct disk *, int);
136int disk_get_formatted(const struct disk *);
137void disk_set_geometry(struct disk *, int, int, int);
138void disk_get_geometry(const struct disk *, int *, int *, int *);
139
140struct slice *slice_new(struct disk *, int, int, int,
141 unsigned long, unsigned long);
142struct slice *slice_find(const struct disk *, int);
143struct slice *slice_next(const struct slice *);
144int slice_get_number(const struct slice *);
145const char *slice_get_desc(const struct slice *);
146const char *slice_get_device_name(const struct slice *);
147const char *slice_get_raw_device_name(const struct slice *);
148unsigned long slice_get_capacity(const struct slice *);
149unsigned long slice_get_start(const struct slice *);
150unsigned long slice_get_size(const struct slice *);
151int slice_get_type(const struct slice *);
152int slice_get_flags(const struct slice *);
153void slices_free(struct slice *);
154struct subpartition *slice_subpartition_first(const struct slice *);
155
156struct subpartition *subpartition_new(struct slice *, const char *, long,
157 int, long, long, int);
971d1cca 158struct subpartition *subpartition_new_hammer(struct slice *, const char *, long);
337ad0df
DH
159int subpartition_count(const struct slice *);
160struct subpartition *subpartition_find(const struct slice *, const char *, ...);
161struct subpartition *subpartition_of(const struct slice *, const char *, ...);
162struct subpartition *subpartition_find_capacity(const struct slice *, long);
163void subpartitions_free(struct slice *);
164struct subpartition *subpartition_next(const struct subpartition *);
971d1cca 165int subpartition_get_pfs(const struct subpartition *);
337ad0df
DH
166const char *subpartition_get_mountpoint(const struct subpartition *);
167const char *subpartition_get_device_name(const struct subpartition *);
168const char *subpartition_get_raw_device_name(const struct subpartition *);
169char subpartition_get_letter(const struct subpartition *);
170unsigned long subpartition_get_fsize(const struct subpartition *);
171unsigned long subpartition_get_bsize(const struct subpartition *);
172unsigned long subpartition_get_capacity(const struct subpartition *);
173int subpartition_is_swap(const struct subpartition *);
174int subpartition_is_softupdated(const struct subpartition *);
175int subpartition_is_mfsbacked(const struct subpartition *);
176
177long measure_activated_swap(const struct i_fn_args *);
178long measure_activated_swap_from_slice(const struct i_fn_args *,
179 const struct disk *, const struct slice *);
180long measure_activated_swap_from_disk(const struct i_fn_args *,
181 const struct disk *);
182
183int survey_storage(struct i_fn_args *);
184
185#endif /* !__DISKUTIL_H_ */