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"
53 #ifdef NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS
56 struct disk *disk_head;
57 struct disk *disk_tail;
58 struct disk *selected_disk;
59 struct slice *selected_slice;
60 unsigned long ram; /* amount of physical memory in MB */
66 struct slice *slice_head;
67 struct slice *slice_tail;
68 char *desc; /* from whereever we get the best */
69 char *device; /* `ad0', `da1', and such */
70 int cylinders; /* geometry information */
72 int sectors; /* (sectors per track) */
73 long capacity; /* capacity in megabytes */
74 int we_formatted; /* did we format it ourselves? */
81 struct subpartition *subpartition_head;
82 struct subpartition *subpartition_tail;
83 char *desc; /* description (w/sysid string) */
84 int number; /* 1 - 4 (or more?) (from fdisk) */
85 unsigned long start; /* start sector (from fdisk) */
86 unsigned long size; /* size in sectors (from fdisk) */
87 int type; /* sysid of slice (from fdisk) */
88 int flags; /* flags (from fdisk) */
89 unsigned long capacity; /* capacity in megabytes */
94 struct subpartition *next;
95 struct subpartition *prev;
96 char letter; /* 'a' = root partition */
97 char *mountpoint; /* includes leading slash */
98 long capacity; /* in megabytes, -1 = "rest of disk" */
100 long fsize; /* fragment size */
101 long bsize; /* block size */
103 int mfsbacked; /* Memory File System Backed */
106 #endif /* NEEDS_DISKUTIL_STRUCTURE_DEFINITIONS */
110 struct storage *storage_new(void);
111 void storage_free(struct storage *);
112 void storage_set_memsize(struct storage *, unsigned long);
113 unsigned long storage_get_memsize(const struct storage *);
114 struct disk *storage_disk_first(const struct storage *);
115 void storage_set_selected_disk(struct storage *, struct disk *);
116 struct disk *storage_get_selected_disk(const struct storage *);
117 void storage_set_selected_slice(struct storage *, struct slice *);
118 struct slice *storage_get_selected_slice(const struct storage *);
119 int storage_get_mfs_status(const char *, struct storage *);
121 struct disk *disk_new(struct storage *, const char *);
122 struct disk *disk_find(const struct storage *, const char *);
123 struct disk *disk_next(const struct disk *);
124 void disks_free(struct storage *);
125 void disk_set_desc(struct disk *, const char *);
126 const char *disk_get_desc(const struct disk *);
127 const char *disk_get_device_name(const struct disk *);
128 const char *disk_get_raw_device_name(const struct disk *);
129 struct slice *disk_slice_first(const struct disk *);
130 void disk_set_formatted(struct disk *, int);
131 int disk_get_formatted(const struct disk *);
132 void disk_set_geometry(struct disk *, int, int, int);
133 void disk_get_geometry(const struct disk *, int *, int *, int *);
135 struct slice *slice_new(struct disk *, int, int, int,
136 unsigned long, unsigned long);
137 struct slice *slice_find(const struct disk *, int);
138 struct slice *slice_next(const struct slice *);
139 int slice_get_number(const struct slice *);
140 const char *slice_get_desc(const struct slice *);
141 const char *slice_get_device_name(const struct slice *);
142 const char *slice_get_raw_device_name(const struct slice *);
143 unsigned long slice_get_capacity(const struct slice *);
144 unsigned long slice_get_start(const struct slice *);
145 unsigned long slice_get_size(const struct slice *);
146 int slice_get_type(const struct slice *);
147 int slice_get_flags(const struct slice *);
148 void slices_free(struct slice *);
149 struct subpartition *slice_subpartition_first(const struct slice *);
151 struct subpartition *subpartition_new(struct slice *, const char *, long,
152 int, long, long, int);
153 int subpartition_count(const struct slice *);
154 struct subpartition *subpartition_find(const struct slice *, const char *, ...);
155 struct subpartition *subpartition_of(const struct slice *, const char *, ...);
156 struct subpartition *subpartition_find_capacity(const struct slice *, long);
157 void subpartitions_free(struct slice *);
158 struct subpartition *subpartition_next(const struct subpartition *);
159 const char *subpartition_get_mountpoint(const struct subpartition *);
160 const char *subpartition_get_device_name(const struct subpartition *);
161 const char *subpartition_get_raw_device_name(const struct subpartition *);
162 char subpartition_get_letter(const struct subpartition *);
163 unsigned long subpartition_get_fsize(const struct subpartition *);
164 unsigned long subpartition_get_bsize(const struct subpartition *);
165 unsigned long subpartition_get_capacity(const struct subpartition *);
166 int subpartition_is_swap(const struct subpartition *);
167 int subpartition_is_softupdated(const struct subpartition *);
168 int subpartition_is_mfsbacked(const struct subpartition *);
170 long measure_activated_swap(const struct i_fn_args *);
171 long measure_activated_swap_from_slice(const struct i_fn_args *,
172 const struct disk *, const struct slice *);
173 long measure_activated_swap_from_disk(const struct i_fn_args *,
174 const struct disk *);
176 int survey_storage(struct i_fn_args *);
178 #endif /* !__DISKUTIL_H_ */