xref: /freebsd/usr.sbin/bsdinstall/partedit/partedit.h (revision 6e15678a470671d454dba52e195c4167b8d63c06)
12118f387SNathan Whitehorn /*-
22118f387SNathan Whitehorn  * Copyright (c) 2011 Nathan Whitehorn
32118f387SNathan Whitehorn  * All rights reserved.
42118f387SNathan Whitehorn  *
52118f387SNathan Whitehorn  * Redistribution and use in source and binary forms, with or without
62118f387SNathan Whitehorn  * modification, are permitted provided that the following conditions
72118f387SNathan Whitehorn  * are met:
82118f387SNathan Whitehorn  * 1. Redistributions of source code must retain the above copyright
92118f387SNathan Whitehorn  *    notice, this list of conditions and the following disclaimer.
102118f387SNathan Whitehorn  * 2. Redistributions in binary form must reproduce the above copyright
112118f387SNathan Whitehorn  *    notice, this list of conditions and the following disclaimer in the
122118f387SNathan Whitehorn  *    documentation and/or other materials provided with the distribution.
132118f387SNathan Whitehorn  *
142118f387SNathan Whitehorn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
152118f387SNathan Whitehorn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162118f387SNathan Whitehorn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
172118f387SNathan Whitehorn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
182118f387SNathan Whitehorn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
192118f387SNathan Whitehorn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
202118f387SNathan Whitehorn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
212118f387SNathan Whitehorn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
222118f387SNathan Whitehorn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
232118f387SNathan Whitehorn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
242118f387SNathan Whitehorn  * SUCH DAMAGE.
252118f387SNathan Whitehorn  *
262118f387SNathan Whitehorn  * $FreeBSD$
272118f387SNathan Whitehorn  */
282118f387SNathan Whitehorn 
292118f387SNathan Whitehorn #ifndef _PARTEDIT_PARTEDIT_H
302118f387SNathan Whitehorn #define _PARTEDIT_PARTEDIT_H
312118f387SNathan Whitehorn 
322118f387SNathan Whitehorn #include <sys/queue.h>
332118f387SNathan Whitehorn #include <inttypes.h>
342118f387SNathan Whitehorn #include <fstab.h>
352118f387SNathan Whitehorn 
362118f387SNathan Whitehorn struct gprovider;
372118f387SNathan Whitehorn struct gmesh;
382118f387SNathan Whitehorn struct ggeom;
392118f387SNathan Whitehorn 
402118f387SNathan Whitehorn TAILQ_HEAD(pmetadata_head, partition_metadata);
412118f387SNathan Whitehorn extern struct pmetadata_head part_metadata;
422118f387SNathan Whitehorn 
432118f387SNathan Whitehorn struct partition_metadata {
442118f387SNathan Whitehorn 	char *name;		/* name of this partition, as in GEOM */
452118f387SNathan Whitehorn 
462118f387SNathan Whitehorn 	struct fstab *fstab;	/* fstab data for this partition */
472118f387SNathan Whitehorn 	char *newfs;		/* shell command to initialize partition */
482118f387SNathan Whitehorn 
492118f387SNathan Whitehorn 	int bootcode;
502118f387SNathan Whitehorn 
512118f387SNathan Whitehorn 	TAILQ_ENTRY(partition_metadata) metadata;
522118f387SNathan Whitehorn };
532118f387SNathan Whitehorn 
542118f387SNathan Whitehorn struct partition_metadata *get_part_metadata(const char *name, int create);
552118f387SNathan Whitehorn void delete_part_metadata(const char *name);
562118f387SNathan Whitehorn 
57*6e15678aSNathan Whitehorn int part_wizard(const char *fstype);
585eca7e06SNathan Whitehorn int scripted_editor(int argc, const char **argv);
59*6e15678aSNathan Whitehorn int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
60*6e15678aSNathan Whitehorn     int interactive);
612118f387SNathan Whitehorn 
622118f387SNathan Whitehorn /* gpart operations */
632118f387SNathan Whitehorn void gpart_delete(struct gprovider *pp);
64f36a5e0fSNathan Whitehorn void gpart_destroy(struct ggeom *lg_geom);
652118f387SNathan Whitehorn void gpart_edit(struct gprovider *pp);
662118f387SNathan Whitehorn void gpart_create(struct gprovider *pp, char *default_type, char *default_size,
672118f387SNathan Whitehorn     char *default_mountpoint, char **output, int interactive);
682118f387SNathan Whitehorn intmax_t gpart_max_free(struct ggeom *gp, intmax_t *start);
692118f387SNathan Whitehorn void gpart_revert(struct gprovider *pp);
702118f387SNathan Whitehorn void gpart_revert_all(struct gmesh *mesh);
712118f387SNathan Whitehorn void gpart_commit(struct gmesh *mesh);
722118f387SNathan Whitehorn int gpart_partition(const char *lg_name, const char *scheme);
732118f387SNathan Whitehorn void set_default_part_metadata(const char *name, const char *scheme,
7450de5d07SNathan Whitehorn     const char *type, const char *mountpoint, const char *newfs);
752118f387SNathan Whitehorn 
762118f387SNathan Whitehorn /* machine-dependent bootability checks */
772118f387SNathan Whitehorn const char *default_scheme(void);
786b446ed5SNathan Whitehorn int is_scheme_bootable(const char *scheme);
79*6e15678aSNathan Whitehorn int is_fs_bootable(const char *scheme, const char *fs);
806b446ed5SNathan Whitehorn size_t bootpart_size(const char *scheme);
816b446ed5SNathan Whitehorn const char *bootpart_type(const char *scheme);
826b446ed5SNathan Whitehorn const char *bootcode_path(const char *scheme);
83*6e15678aSNathan Whitehorn const char *partcode_path(const char *scheme, const char *fs_type);
842118f387SNathan Whitehorn 
852118f387SNathan Whitehorn #endif
86