1218799Snwhitehorn/*-
2218799Snwhitehorn * Copyright (c) 2011 Nathan Whitehorn
3218799Snwhitehorn * All rights reserved.
4218799Snwhitehorn *
5218799Snwhitehorn * Redistribution and use in source and binary forms, with or without
6218799Snwhitehorn * modification, are permitted provided that the following conditions
7218799Snwhitehorn * are met:
8218799Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9218799Snwhitehorn *    notice, this list of conditions and the following disclaimer.
10218799Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
11218799Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
12218799Snwhitehorn *    documentation and/or other materials provided with the distribution.
13218799Snwhitehorn *
14218799Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15218799Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16218799Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17218799Snwhitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18218799Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19218799Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20218799Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21218799Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22218799Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23218799Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24218799Snwhitehorn * SUCH DAMAGE.
25218799Snwhitehorn *
26218799Snwhitehorn * $FreeBSD$
27218799Snwhitehorn */
28218799Snwhitehorn
29218799Snwhitehorn#ifndef _PARTEDIT_PARTEDIT_H
30218799Snwhitehorn#define _PARTEDIT_PARTEDIT_H
31218799Snwhitehorn
32218799Snwhitehorn#include <sys/queue.h>
33218799Snwhitehorn#include <inttypes.h>
34218799Snwhitehorn#include <fstab.h>
35218799Snwhitehorn
36218799Snwhitehornstruct gprovider;
37218799Snwhitehornstruct gmesh;
38218799Snwhitehornstruct ggeom;
39218799Snwhitehorn
40218799SnwhitehornTAILQ_HEAD(pmetadata_head, partition_metadata);
41218799Snwhitehornextern struct pmetadata_head part_metadata;
42218799Snwhitehorn
43218799Snwhitehornstruct partition_metadata {
44218799Snwhitehorn	char *name;		/* name of this partition, as in GEOM */
45218799Snwhitehorn
46218799Snwhitehorn	struct fstab *fstab;	/* fstab data for this partition */
47218799Snwhitehorn	char *newfs;		/* shell command to initialize partition */
48218799Snwhitehorn
49218799Snwhitehorn	int bootcode;
50218799Snwhitehorn
51218799Snwhitehorn	TAILQ_ENTRY(partition_metadata) metadata;
52218799Snwhitehorn};
53218799Snwhitehorn
54218799Snwhitehornstruct partition_metadata *get_part_metadata(const char *name, int create);
55218799Snwhitehornvoid delete_part_metadata(const char *name);
56218799Snwhitehorn
57218799Snwhitehornint part_wizard(void);
58248240Snwhitehornint scripted_editor(int argc, const char **argv);
59248240Snwhitehornint wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive);
60218799Snwhitehorn
61218799Snwhitehorn/* gpart operations */
62218799Snwhitehornvoid gpart_delete(struct gprovider *pp);
63226212Snwhitehornvoid gpart_destroy(struct ggeom *lg_geom);
64218799Snwhitehornvoid gpart_edit(struct gprovider *pp);
65218799Snwhitehornvoid gpart_create(struct gprovider *pp, char *default_type, char *default_size,
66218799Snwhitehorn    char *default_mountpoint, char **output, int interactive);
67218799Snwhitehornintmax_t gpart_max_free(struct ggeom *gp, intmax_t *start);
68218799Snwhitehornvoid gpart_revert(struct gprovider *pp);
69218799Snwhitehornvoid gpart_revert_all(struct gmesh *mesh);
70218799Snwhitehornvoid gpart_commit(struct gmesh *mesh);
71218799Snwhitehornint gpart_partition(const char *lg_name, const char *scheme);
72218799Snwhitehornvoid set_default_part_metadata(const char *name, const char *scheme,
73219892Snwhitehorn    const char *type, const char *mountpoint, const char *newfs);
74218799Snwhitehorn
75218799Snwhitehorn/* machine-dependent bootability checks */
76218799Snwhitehornconst char *default_scheme(void);
77218799Snwhitehornint is_scheme_bootable(const char *part_type);
78218799Snwhitehornsize_t bootpart_size(const char *part_type);
79218799Snwhitehornconst char *bootcode_path(const char *part_type);
80218799Snwhitehornconst char *partcode_path(const char *part_type);
81218799Snwhitehorn
82218799Snwhitehorn#endif
83