12118f387SNathan Whitehorn /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 42118f387SNathan Whitehorn * Copyright (c) 2011 Nathan Whitehorn 52118f387SNathan Whitehorn * All rights reserved. 62118f387SNathan Whitehorn * 72118f387SNathan Whitehorn * Redistribution and use in source and binary forms, with or without 82118f387SNathan Whitehorn * modification, are permitted provided that the following conditions 92118f387SNathan Whitehorn * are met: 102118f387SNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 112118f387SNathan Whitehorn * notice, this list of conditions and the following disclaimer. 122118f387SNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 132118f387SNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 142118f387SNathan Whitehorn * documentation and/or other materials provided with the distribution. 152118f387SNathan Whitehorn * 162118f387SNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172118f387SNathan Whitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182118f387SNathan Whitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192118f387SNathan Whitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202118f387SNathan Whitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212118f387SNathan Whitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222118f387SNathan Whitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232118f387SNathan Whitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242118f387SNathan Whitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252118f387SNathan Whitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262118f387SNathan Whitehorn * SUCH DAMAGE. 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 36147585b4SBrad Davis #include "opt_osname.h" 37147585b4SBrad Davis 382118f387SNathan Whitehorn struct gprovider; 392118f387SNathan Whitehorn struct gmesh; 402118f387SNathan Whitehorn struct ggeom; 412118f387SNathan Whitehorn 422118f387SNathan Whitehorn TAILQ_HEAD(pmetadata_head, partition_metadata); 432118f387SNathan Whitehorn extern struct pmetadata_head part_metadata; 442118f387SNathan Whitehorn 452118f387SNathan Whitehorn struct partition_metadata { 462118f387SNathan Whitehorn char *name; /* name of this partition, as in GEOM */ 472118f387SNathan Whitehorn 482118f387SNathan Whitehorn struct fstab *fstab; /* fstab data for this partition */ 492118f387SNathan Whitehorn char *newfs; /* shell command to initialize partition */ 502118f387SNathan Whitehorn 512118f387SNathan Whitehorn int bootcode; 522118f387SNathan Whitehorn 532118f387SNathan Whitehorn TAILQ_ENTRY(partition_metadata) metadata; 542118f387SNathan Whitehorn }; 552118f387SNathan Whitehorn 562118f387SNathan Whitehorn struct partition_metadata *get_part_metadata(const char *name, int create); 572118f387SNathan Whitehorn void delete_part_metadata(const char *name); 582118f387SNathan Whitehorn 596e15678aSNathan Whitehorn int part_wizard(const char *fstype); 605eca7e06SNathan Whitehorn int scripted_editor(int argc, const char **argv); 615140034cSNathan Whitehorn char *boot_disk_select(struct gmesh *mesh); 626e15678aSNathan Whitehorn int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype, 636e15678aSNathan Whitehorn int interactive); 642118f387SNathan Whitehorn 652118f387SNathan Whitehorn /* gpart operations */ 662118f387SNathan Whitehorn void gpart_delete(struct gprovider *pp); 67f36a5e0fSNathan Whitehorn void gpart_destroy(struct ggeom *lg_geom); 682118f387SNathan Whitehorn void gpart_edit(struct gprovider *pp); 6952f39da1SNathan Whitehorn void gpart_create(struct gprovider *pp, const char *default_type, 7052f39da1SNathan Whitehorn const char *default_size, const char *default_mountpoint, 7152f39da1SNathan Whitehorn char **output, int interactive); 722118f387SNathan Whitehorn intmax_t gpart_max_free(struct ggeom *gp, intmax_t *start); 732118f387SNathan Whitehorn void gpart_revert(struct gprovider *pp); 742118f387SNathan Whitehorn void gpart_revert_all(struct gmesh *mesh); 752118f387SNathan Whitehorn void gpart_commit(struct gmesh *mesh); 762118f387SNathan Whitehorn int gpart_partition(const char *lg_name, const char *scheme); 772118f387SNathan Whitehorn void set_default_part_metadata(const char *name, const char *scheme, 7850de5d07SNathan Whitehorn const char *type, const char *mountpoint, const char *newfs); 797059fa6fSAllan Jude void gpart_set_root(const char *lg_name, const char *attribute); 807059fa6fSAllan Jude const char *choose_part_type(const char *def_scheme); 812118f387SNathan Whitehorn 822118f387SNathan Whitehorn /* machine-dependent bootability checks */ 8352f39da1SNathan Whitehorn const char *default_scheme(void); /* Default partition scheme */ 8452f39da1SNathan Whitehorn int is_scheme_bootable(const char *scheme); /* Non-zero if scheme boots */ 8552f39da1SNathan Whitehorn int is_fs_bootable(const char *scheme, const char *fs); /* Ditto if FS boots */ 8652f39da1SNathan Whitehorn 8752f39da1SNathan Whitehorn /* Size of boot partition in bytes. Zero if no boot partition */ 886b446ed5SNathan Whitehorn size_t bootpart_size(const char *scheme); 8952f39da1SNathan Whitehorn 9052f39da1SNathan Whitehorn /* 9152f39da1SNathan Whitehorn * Type and mountpoint of boot partition for given scheme. If boot partition 9252f39da1SNathan Whitehorn * should not be mounted, set mountpoint to NULL or leave it unchanged. 9352f39da1SNathan Whitehorn * Note that mountpoint non-NULL implies partcode_path() will be ignored. 9452f39da1SNathan Whitehorn * Do *NOT* set both! 9552f39da1SNathan Whitehorn */ 9652f39da1SNathan Whitehorn const char *bootpart_type(const char *scheme, const char **mountpoint); 9752f39da1SNathan Whitehorn 9852f39da1SNathan Whitehorn /* Path to bootcode that goes in the scheme (e.g. disk MBR). NULL if none */ 996b446ed5SNathan Whitehorn const char *bootcode_path(const char *scheme); 10052f39da1SNathan Whitehorn 10152f39da1SNathan Whitehorn /* 10252f39da1SNathan Whitehorn * Path to boot blocks to be dd'ed into the partition suggested by bootpart_* 10352f39da1SNathan Whitehorn * for the given scheme and root filesystem type. If the boot partition should 10452f39da1SNathan Whitehorn * be mounted rather than dd'ed to, return NULL here. 10552f39da1SNathan Whitehorn */ 1066e15678aSNathan Whitehorn const char *partcode_path(const char *scheme, const char *fs_type); 1072118f387SNathan Whitehorn 1082118f387SNathan Whitehorn #endif 109