10b5de56dSgjelinek /* 20b5de56dSgjelinek * CDDL HEADER START 30b5de56dSgjelinek * 40b5de56dSgjelinek * The contents of this file are subject to the terms of the 50b5de56dSgjelinek * Common Development and Distribution License (the "License"). 60b5de56dSgjelinek * You may not use this file except in compliance with the License. 70b5de56dSgjelinek * 80b5de56dSgjelinek * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90b5de56dSgjelinek * or http://www.opensolaris.org/os/licensing. 100b5de56dSgjelinek * See the License for the specific language governing permissions 110b5de56dSgjelinek * and limitations under the License. 120b5de56dSgjelinek * 130b5de56dSgjelinek * When distributing Covered Code, include this CDDL HEADER in each 140b5de56dSgjelinek * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150b5de56dSgjelinek * If applicable, add the following below this CDDL HEADER, with the 160b5de56dSgjelinek * fields enclosed by brackets "[]" replaced with your own identifying 170b5de56dSgjelinek * information: Portions Copyright [yyyy] [name of copyright owner] 180b5de56dSgjelinek * 190b5de56dSgjelinek * CDDL HEADER END 200b5de56dSgjelinek */ 210b5de56dSgjelinek 220b5de56dSgjelinek /* 23c75cc341S * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240b5de56dSgjelinek * Use is subject to license terms. 250b5de56dSgjelinek */ 260b5de56dSgjelinek 270b5de56dSgjelinek #ifndef _ZONEADM_H 280b5de56dSgjelinek #define _ZONEADM_H 290b5de56dSgjelinek 30*0094b373Sjv227347 #include <sys/types.h> 31*0094b373Sjv227347 320b5de56dSgjelinek #define CMD_HELP 0 330b5de56dSgjelinek #define CMD_BOOT 1 340b5de56dSgjelinek #define CMD_HALT 2 350b5de56dSgjelinek #define CMD_READY 3 360b5de56dSgjelinek #define CMD_REBOOT 4 370b5de56dSgjelinek #define CMD_LIST 5 380b5de56dSgjelinek #define CMD_VERIFY 6 390b5de56dSgjelinek #define CMD_INSTALL 7 400b5de56dSgjelinek #define CMD_UNINSTALL 8 410b5de56dSgjelinek #define CMD_MOUNT 9 420b5de56dSgjelinek #define CMD_UNMOUNT 10 430b5de56dSgjelinek #define CMD_CLONE 11 440b5de56dSgjelinek #define CMD_MOVE 12 450b5de56dSgjelinek #define CMD_DETACH 13 460b5de56dSgjelinek #define CMD_ATTACH 14 47555afedfScarlsonj #define CMD_MARK 15 480209230bSgjelinek #define CMD_APPLY 16 49fbbfbc6eSjv227347 #define CMD_SYSBOOT 17 500b5de56dSgjelinek 510b5de56dSgjelinek #define CMD_MIN CMD_HELP 52fbbfbc6eSjv227347 #define CMD_MAX CMD_SYSBOOT 530b5de56dSgjelinek 540b5de56dSgjelinek #if !defined(TEXT_DOMAIN) /* should be defined by cc -D */ 550b5de56dSgjelinek #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 560b5de56dSgjelinek #endif 570b5de56dSgjelinek 580b5de56dSgjelinek #define Z_ERR 1 590b5de56dSgjelinek #define Z_USAGE 2 606cfd72c6Sgjelinek #define Z_FATAL 3 610b5de56dSgjelinek 620b5de56dSgjelinek #define SW_CMP_NONE 0x0 630b5de56dSgjelinek #define SW_CMP_SRC 0x01 640b5de56dSgjelinek #define SW_CMP_SILENT 0x02 650b5de56dSgjelinek 660b5de56dSgjelinek /* 67*0094b373Sjv227347 * This structure stores information about mounts of interest within an 68*0094b373Sjv227347 * installed zone. 69*0094b373Sjv227347 */ 70*0094b373Sjv227347 typedef struct zone_mounts { 71*0094b373Sjv227347 /* The zone's zonepath */ 72*0094b373Sjv227347 char *zonepath; 73*0094b373Sjv227347 74*0094b373Sjv227347 /* The length of zonepath */ 75*0094b373Sjv227347 int zonepath_len; 76*0094b373Sjv227347 77*0094b373Sjv227347 /* 78*0094b373Sjv227347 * This indicates the number of unexpected mounts that were encountered 79*0094b373Sjv227347 * in the zone. 80*0094b373Sjv227347 */ 81*0094b373Sjv227347 int num_unexpected_mounts; 82*0094b373Sjv227347 83*0094b373Sjv227347 /* 84*0094b373Sjv227347 * This is the number of overlay mounts detected on the zone's root 85*0094b373Sjv227347 * directory. 86*0094b373Sjv227347 */ 87*0094b373Sjv227347 int num_root_overlay_mounts; 88*0094b373Sjv227347 89*0094b373Sjv227347 /* 90*0094b373Sjv227347 * This is used to track important zone root mount information. The 91*0094b373Sjv227347 * mnt_time field isn't used. If root_mnttab is NULL, then the 92*0094b373Sjv227347 * associated zone doesn't have a mounted root filesystem. 93*0094b373Sjv227347 * 94*0094b373Sjv227347 * NOTE: mnt_mountp is non-NULL iff the zone's root filesystem is a 95*0094b373Sjv227347 * ZFS filesystem with a non-legacy mountpoint. In this case, it 96*0094b373Sjv227347 * refers to a string containing the dataset's mountpoint. 97*0094b373Sjv227347 */ 98*0094b373Sjv227347 struct mnttab *root_mnttab; 99*0094b373Sjv227347 } zone_mounts_t; 100*0094b373Sjv227347 101*0094b373Sjv227347 /* 1020b5de56dSgjelinek * zoneadm.c 1030b5de56dSgjelinek */ 1040b5de56dSgjelinek extern char *target_zone; 1050b5de56dSgjelinek 106*0094b373Sjv227347 extern int zfm_print(const struct mnttab *mntp, void *unused); 1070b5de56dSgjelinek extern int clone_copy(char *source_zonepath, char *zonepath); 1080b5de56dSgjelinek extern char *cmd_to_str(int cmd_num); 109c75cc341S extern int do_subproc(char *cmdbuf); 110ff17c8bfSgjelinek extern int subproc_status(const char *cmd, int status, 111ff17c8bfSgjelinek boolean_t verbose_failure); 1120b5de56dSgjelinek extern void zerror(const char *fmt, ...); 1130b5de56dSgjelinek extern void zperror(const char *str, boolean_t zonecfg_error); 1140b5de56dSgjelinek extern void zperror2(const char *zone, const char *str); 1150b5de56dSgjelinek 1160b5de56dSgjelinek /* 1170b5de56dSgjelinek * zfs.c 1180b5de56dSgjelinek */ 119ff17c8bfSgjelinek extern int clone_snapshot_zfs(char *snap_name, char *zonepath, 120ff17c8bfSgjelinek char *validatesnap); 121ff17c8bfSgjelinek extern int clone_zfs(char *source_zonepath, char *zonepath, char *presnapbuf, 122ff17c8bfSgjelinek char *postsnapbuf); 1230b5de56dSgjelinek extern void create_zfs_zonepath(char *zonepath); 1240b5de56dSgjelinek extern int destroy_zfs(char *zonepath); 1250b5de56dSgjelinek extern boolean_t is_zonepath_zfs(char *zonepath); 1260b5de56dSgjelinek extern int move_zfs(char *zonepath, char *new_zonepath); 1270b5de56dSgjelinek extern int verify_datasets(zone_dochandle_t handle); 1280b5de56dSgjelinek extern int verify_fs_zfs(struct zone_fstab *fstab); 129*0094b373Sjv227347 extern int zone_mounts_init(zone_mounts_t *mounts, const char *zonepath); 130*0094b373Sjv227347 extern void zone_mounts_destroy(zone_mounts_t *mounts); 131*0094b373Sjv227347 extern int zone_mount_rootfs(zone_mounts_t *mounts, const char *zonepath); 132*0094b373Sjv227347 extern int zone_unmount_rootfs(zone_mounts_t *mounts, const char *zonepath, 133*0094b373Sjv227347 boolean_t force); 13499653d4eSeschrock extern int init_zfs(void); 1350b5de56dSgjelinek 1360b5de56dSgjelinek #endif /* _ZONEADM_H */ 137