1/*-
2 * Copyright (c) 2011 Nathan Whitehorn
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#ifndef _PARTEDIT_PARTEDIT_H
30#define _PARTEDIT_PARTEDIT_H
31
32#include <sys/queue.h>
33#include <inttypes.h>
34#include <fstab.h>
35
36struct gprovider;
37struct gmesh;
38struct ggeom;
39
40TAILQ_HEAD(pmetadata_head, partition_metadata);
41extern struct pmetadata_head part_metadata;
42
43struct partition_metadata {
44	char *name;		/* name of this partition, as in GEOM */
45
46	struct fstab *fstab;	/* fstab data for this partition */
47	char *newfs;		/* shell command to initialize partition */
48
49	int bootcode;
50
51	TAILQ_ENTRY(partition_metadata) metadata;
52};
53
54struct partition_metadata *get_part_metadata(const char *name, int create);
55void delete_part_metadata(const char *name);
56
57int part_wizard(void);
58int scripted_editor(int argc, const char **argv);
59int wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive);
60
61/* gpart operations */
62void gpart_delete(struct gprovider *pp);
63void gpart_destroy(struct ggeom *lg_geom);
64void gpart_edit(struct gprovider *pp);
65void gpart_create(struct gprovider *pp, char *default_type, char *default_size,
66    char *default_mountpoint, char **output, int interactive);
67intmax_t gpart_max_free(struct ggeom *gp, intmax_t *start);
68void gpart_revert(struct gprovider *pp);
69void gpart_revert_all(struct gmesh *mesh);
70void gpart_commit(struct gmesh *mesh);
71int gpart_partition(const char *lg_name, const char *scheme);
72void set_default_part_metadata(const char *name, const char *scheme,
73    const char *type, const char *mountpoint, const char *newfs);
74
75/* machine-dependent bootability checks */
76const char *default_scheme(void);
77int is_scheme_bootable(const char *part_type);
78size_t bootpart_size(const char *part_type);
79const char *bootcode_path(const char *part_type);
80const char *partcode_path(const char *part_type);
81
82#endif
83