Path: blob/main/usr.sbin/bsdinstall/partedit/partedit.h
103755 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2011 Nathan Whitehorn4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _PARTEDIT_PARTEDIT_H29#define _PARTEDIT_PARTEDIT_H3031#include <sys/queue.h>32#include <inttypes.h>33#include <fstab.h>3435#include "opt_osname.h"3637struct gprovider;38struct gmesh;39struct ggeom;4041TAILQ_HEAD(pmetadata_head, partition_metadata);42extern struct pmetadata_head part_metadata;4344struct partition_metadata {45char *name; /* name of this partition, as in GEOM */4647struct fstab *fstab; /* fstab data for this partition */48char *newfs; /* shell command to initialize partition */4950int bootcode;5152TAILQ_ENTRY(partition_metadata) metadata;53};5455struct partition_metadata *get_part_metadata(const char *name, int create);56void delete_part_metadata(const char *name);5758int part_wizard(const char *fstype);59int scripted_editor(int argc, const char **argv);60char *boot_disk_select(struct gmesh *mesh);61int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,62int interactive);6364/* gpart operations */65void gpart_delete(struct gprovider *pp);66void gpart_destroy(struct ggeom *lg_geom);67void gpart_edit(struct gprovider *pp);68void gpart_create(struct gprovider *pp, const char *default_type,69const char *default_size, const char *default_mountpoint,70char **output, int interactive);71intmax_t gpart_max_free(struct ggeom *gp, intmax_t *start);72void gpart_revert(struct gprovider *pp);73void gpart_revert_all(struct gmesh *mesh);74void gpart_commit(struct gmesh *mesh);75int gpart_partition(const char *lg_name, const char *scheme);76void set_default_part_metadata(const char *name, const char *scheme,77const char *type, const char *mountpoint, const char *newfs);78void gpart_set_root(const char *lg_name, const char *attribute);79const char *choose_part_type(const char *def_scheme);8081/* machine-dependent bootability checks */82const char *default_scheme(void); /* Default partition scheme */83int is_scheme_bootable(const char *scheme); /* Non-zero if scheme boots */84int is_fs_bootable(const char *scheme, const char *fs); /* Ditto if FS boots */8586/* Size of boot partition in bytes. Zero if no boot partition */87size_t bootpart_size(const char *scheme);8889/*90* Type and mountpoint of boot partition for given scheme. If boot partition91* should not be mounted, set mountpoint to NULL or leave it unchanged.92* Note that mountpoint non-NULL implies partcode_path() will be ignored.93* Do *NOT* set both!94*/95const char *bootpart_type(const char *scheme, const char **mountpoint);9697/* Path to bootcode that goes in the scheme (e.g. disk MBR). NULL if none */98const char *bootcode_path(const char *scheme);99100/*101* Path to boot blocks to be dd'ed into the partition suggested by bootpart_*102* for the given scheme and root filesystem type. If the boot partition should103* be mounted rather than dd'ed to, return NULL here.104*/105const char *partcode_path(const char *scheme, const char *fs_type);106107#endif108109110