2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
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
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.
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.
36 * $Id: diskutil.h,v 1.14 2005/02/07 06:41:42 cpressey Exp $
44 #include "functions.h"
56 #ifdef NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS
59 struct disk *disk_head;
60 struct disk *disk_tail;
61 struct disk *selected_disk;
62 struct slice *selected_slice;
63 long ram; /* amount of physical memory in MB */
69 struct slice *slice_head;
70 struct slice *slice_tail;
71 char *desc; /* from whereever we get the best */
72 int number; /* Position in kern.disks */
73 char *device; /* `ad0', `da1', and such */
74 char *serno; /* serial number */
75 int cylinders; /* geometry information */
77 int sectors; /* (sectors per track) */
78 long capacity; /* capacity in megabytes */
79 int we_formatted; /* did we format it ourselves? */
86 struct subpartition *subpartition_head;
87 struct subpartition *subpartition_tail;
88 char *desc; /* description (w/sysid string) */
89 int number; /* 1 - 4 (or more?) (from fdisk) */
90 unsigned long start; /* start sector (from fdisk) */
91 unsigned long size; /* size in sectors (from fdisk) */
92 int type; /* sysid of slice (from fdisk) */
93 int flags; /* flags (from fdisk) */
94 unsigned long capacity; /* capacity in megabytes */
99 struct subpartition *next;
100 struct subpartition *prev;
101 char letter; /* 'a' = root partition */
102 char *mountpoint; /* includes leading slash */
103 long capacity; /* in megabytes, -1 = "rest of disk" */
105 long fsize; /* fragment size */
106 long bsize; /* block size */
108 int tmpfsbacked; /* TMPFS Backed */
109 int type; /* FS type (UFS, HAMMER) */
110 int pfs; /* HAMMER pseudo file system */
113 #endif /* NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS */
117 struct storage *storage_new(void);
118 void storage_free(struct storage *);
119 void storage_set_memsize(struct storage *, unsigned long);
120 long storage_get_memsize(const struct storage *);
121 struct disk *storage_disk_first(const struct storage *);
122 void storage_set_selected_disk(struct storage *, struct disk *);
123 struct disk *storage_get_selected_disk(const struct storage *);
124 void storage_set_selected_slice(struct storage *, struct slice *);
125 struct slice *storage_get_selected_slice(const struct storage *);
126 int storage_get_tmpfs_status(const char *, struct storage *);
128 struct disk *disk_new(struct storage *, const char *);
129 struct disk *disk_find(const struct storage *, const char *);
130 struct disk *disk_next(const struct disk *);
131 void disks_free(struct storage *);
132 void disk_set_number(struct disk *, const int);
133 void disk_set_desc(struct disk *, const char *);
134 void disk_set_serno(struct disk *, const char *);
135 int disk_get_number(const struct disk *);
136 const char *disk_get_desc(const struct disk *);
137 const char *disk_get_device_name(const struct disk *);
138 const char *disk_get_serno(const struct disk *);
139 struct slice *disk_slice_first(const struct disk *);
140 void disk_set_formatted(struct disk *, int);
141 int disk_get_formatted(const struct disk *);
142 void disk_set_geometry(struct disk *, int, int, int);
143 void disk_get_geometry(const struct disk *, int *, int *, int *);
145 struct slice *slice_new(struct disk *, int, int, int,
146 unsigned long, unsigned long);
147 struct slice *slice_find(const struct disk *, int);
148 struct slice *slice_next(const struct slice *);
149 int slice_get_number(const struct slice *);
150 const char *slice_get_desc(const struct slice *);
151 const char *slice_get_device_name(const struct slice *);
152 unsigned long slice_get_capacity(const struct slice *);
153 unsigned long slice_get_start(const struct slice *);
154 unsigned long slice_get_size(const struct slice *);
155 int slice_get_type(const struct slice *);
156 int slice_get_flags(const struct slice *);
157 void slices_free(struct slice *);
158 struct subpartition *slice_subpartition_first(const struct slice *);
160 struct subpartition *subpartition_new(struct slice *, const char *, long,
161 int, long, long, int);
162 struct subpartition *subpartition_new_hammer(struct slice *, const char *, long);
163 int subpartition_count(const struct slice *);
164 struct subpartition *subpartition_find(const struct slice *, const char *, ...);
165 struct subpartition *subpartition_of(const struct slice *, const char *, ...);
166 struct subpartition *subpartition_find_capacity(const struct slice *, long);
167 void subpartitions_free(struct slice *);
168 struct subpartition *subpartition_next(const struct subpartition *);
169 int subpartition_get_pfs(const struct subpartition *);
170 const char *subpartition_get_mountpoint(const struct subpartition *);
171 const char *subpartition_get_device_name(const struct subpartition *);
172 char subpartition_get_letter(const struct subpartition *);
173 unsigned long subpartition_get_fsize(const struct subpartition *);
174 unsigned long subpartition_get_bsize(const struct subpartition *);
175 long subpartition_get_capacity(const struct subpartition *);
176 int subpartition_is_swap(const struct subpartition *);
177 int subpartition_is_softupdated(const struct subpartition *);
178 int subpartition_is_tmpfsbacked(const struct subpartition *);
180 long measure_activated_swap(const struct i_fn_args *);
181 long measure_activated_swap_from_slice(const struct i_fn_args *,
182 const struct disk *, const struct slice *);
183 long measure_activated_swap_from_disk(const struct i_fn_args *,
184 const struct disk *);
185 void *swapoff_all(const struct i_fn_args *);
187 int survey_storage(struct i_fn_args *);
189 #endif /* !__DISKUTIL_H_ */