11867Sgjelinek /* 21867Sgjelinek * CDDL HEADER START 31867Sgjelinek * 41867Sgjelinek * The contents of this file are subject to the terms of the 51867Sgjelinek * Common Development and Distribution License (the "License"). 61867Sgjelinek * You may not use this file except in compliance with the License. 71867Sgjelinek * 81867Sgjelinek * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91867Sgjelinek * or http://www.opensolaris.org/os/licensing. 101867Sgjelinek * See the License for the specific language governing permissions 111867Sgjelinek * and limitations under the License. 121867Sgjelinek * 131867Sgjelinek * When distributing Covered Code, include this CDDL HEADER in each 141867Sgjelinek * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151867Sgjelinek * If applicable, add the following below this CDDL HEADER, with the 161867Sgjelinek * fields enclosed by brackets "[]" replaced with your own identifying 171867Sgjelinek * information: Portions Copyright [yyyy] [name of copyright owner] 181867Sgjelinek * 191867Sgjelinek * CDDL HEADER END 201867Sgjelinek */ 211867Sgjelinek 221867Sgjelinek /* 239310Sgerald.jelinek@sun.com * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 241867Sgjelinek * Use is subject to license terms. 251867Sgjelinek */ 261867Sgjelinek 271867Sgjelinek #ifndef _ZONEADM_H 281867Sgjelinek #define _ZONEADM_H 291867Sgjelinek 30*11276SJordan.Vaughan@Sun.com #include <sys/types.h> 31*11276SJordan.Vaughan@Sun.com 321867Sgjelinek #define CMD_HELP 0 331867Sgjelinek #define CMD_BOOT 1 341867Sgjelinek #define CMD_HALT 2 351867Sgjelinek #define CMD_READY 3 361867Sgjelinek #define CMD_REBOOT 4 371867Sgjelinek #define CMD_LIST 5 381867Sgjelinek #define CMD_VERIFY 6 391867Sgjelinek #define CMD_INSTALL 7 401867Sgjelinek #define CMD_UNINSTALL 8 411867Sgjelinek #define CMD_MOUNT 9 421867Sgjelinek #define CMD_UNMOUNT 10 431867Sgjelinek #define CMD_CLONE 11 441867Sgjelinek #define CMD_MOVE 12 451867Sgjelinek #define CMD_DETACH 13 461867Sgjelinek #define CMD_ATTACH 14 472303Scarlsonj #define CMD_MARK 15 483247Sgjelinek #define CMD_APPLY 16 4910718SJordan.Vaughan@Sun.com #define CMD_SYSBOOT 17 501867Sgjelinek 511867Sgjelinek #define CMD_MIN CMD_HELP 5210718SJordan.Vaughan@Sun.com #define CMD_MAX CMD_SYSBOOT 531867Sgjelinek 541867Sgjelinek #if !defined(TEXT_DOMAIN) /* should be defined by cc -D */ 551867Sgjelinek #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 561867Sgjelinek #endif 571867Sgjelinek 581867Sgjelinek #define Z_ERR 1 591867Sgjelinek #define Z_USAGE 2 605829Sgjelinek #define Z_FATAL 3 611867Sgjelinek 621867Sgjelinek #define SW_CMP_NONE 0x0 631867Sgjelinek #define SW_CMP_SRC 0x01 641867Sgjelinek #define SW_CMP_SILENT 0x02 651867Sgjelinek 661867Sgjelinek /* 67*11276SJordan.Vaughan@Sun.com * This structure stores information about mounts of interest within an 68*11276SJordan.Vaughan@Sun.com * installed zone. 69*11276SJordan.Vaughan@Sun.com */ 70*11276SJordan.Vaughan@Sun.com typedef struct zone_mounts { 71*11276SJordan.Vaughan@Sun.com /* The zone's zonepath */ 72*11276SJordan.Vaughan@Sun.com char *zonepath; 73*11276SJordan.Vaughan@Sun.com 74*11276SJordan.Vaughan@Sun.com /* The length of zonepath */ 75*11276SJordan.Vaughan@Sun.com int zonepath_len; 76*11276SJordan.Vaughan@Sun.com 77*11276SJordan.Vaughan@Sun.com /* 78*11276SJordan.Vaughan@Sun.com * This indicates the number of unexpected mounts that were encountered 79*11276SJordan.Vaughan@Sun.com * in the zone. 80*11276SJordan.Vaughan@Sun.com */ 81*11276SJordan.Vaughan@Sun.com int num_unexpected_mounts; 82*11276SJordan.Vaughan@Sun.com 83*11276SJordan.Vaughan@Sun.com /* 84*11276SJordan.Vaughan@Sun.com * This is the number of overlay mounts detected on the zone's root 85*11276SJordan.Vaughan@Sun.com * directory. 86*11276SJordan.Vaughan@Sun.com */ 87*11276SJordan.Vaughan@Sun.com int num_root_overlay_mounts; 88*11276SJordan.Vaughan@Sun.com 89*11276SJordan.Vaughan@Sun.com /* 90*11276SJordan.Vaughan@Sun.com * This is used to track important zone root mount information. The 91*11276SJordan.Vaughan@Sun.com * mnt_time field isn't used. If root_mnttab is NULL, then the 92*11276SJordan.Vaughan@Sun.com * associated zone doesn't have a mounted root filesystem. 93*11276SJordan.Vaughan@Sun.com * 94*11276SJordan.Vaughan@Sun.com * NOTE: mnt_mountp is non-NULL iff the zone's root filesystem is a 95*11276SJordan.Vaughan@Sun.com * ZFS filesystem with a non-legacy mountpoint. In this case, it 96*11276SJordan.Vaughan@Sun.com * refers to a string containing the dataset's mountpoint. 97*11276SJordan.Vaughan@Sun.com */ 98*11276SJordan.Vaughan@Sun.com struct mnttab *root_mnttab; 99*11276SJordan.Vaughan@Sun.com } zone_mounts_t; 100*11276SJordan.Vaughan@Sun.com 101*11276SJordan.Vaughan@Sun.com /* 1021867Sgjelinek * zoneadm.c 1031867Sgjelinek */ 1041867Sgjelinek extern char *target_zone; 1051867Sgjelinek 106*11276SJordan.Vaughan@Sun.com extern int zfm_print(const struct mnttab *mntp, void *unused); 1071867Sgjelinek extern int clone_copy(char *source_zonepath, char *zonepath); 1081867Sgjelinek extern char *cmd_to_str(int cmd_num); 1099310Sgerald.jelinek@sun.com extern int do_subproc(char *cmdbuf); 1107089Sgjelinek extern int subproc_status(const char *cmd, int status, 1117089Sgjelinek boolean_t verbose_failure); 1121867Sgjelinek extern void zerror(const char *fmt, ...); 1131867Sgjelinek extern void zperror(const char *str, boolean_t zonecfg_error); 1141867Sgjelinek extern void zperror2(const char *zone, const char *str); 1151867Sgjelinek 1161867Sgjelinek /* 1171867Sgjelinek * zfs.c 1181867Sgjelinek */ 1197089Sgjelinek extern int clone_snapshot_zfs(char *snap_name, char *zonepath, 1207089Sgjelinek char *validatesnap); 1217089Sgjelinek extern int clone_zfs(char *source_zonepath, char *zonepath, char *presnapbuf, 1227089Sgjelinek char *postsnapbuf); 1231867Sgjelinek extern void create_zfs_zonepath(char *zonepath); 1241867Sgjelinek extern int destroy_zfs(char *zonepath); 1251867Sgjelinek extern boolean_t is_zonepath_zfs(char *zonepath); 1261867Sgjelinek extern int move_zfs(char *zonepath, char *new_zonepath); 1271867Sgjelinek extern int verify_datasets(zone_dochandle_t handle); 1281867Sgjelinek extern int verify_fs_zfs(struct zone_fstab *fstab); 129*11276SJordan.Vaughan@Sun.com extern int zone_mounts_init(zone_mounts_t *mounts, const char *zonepath); 130*11276SJordan.Vaughan@Sun.com extern void zone_mounts_destroy(zone_mounts_t *mounts); 131*11276SJordan.Vaughan@Sun.com extern int zone_mount_rootfs(zone_mounts_t *mounts, const char *zonepath); 132*11276SJordan.Vaughan@Sun.com extern int zone_unmount_rootfs(zone_mounts_t *mounts, const char *zonepath, 133*11276SJordan.Vaughan@Sun.com boolean_t force); 1342082Seschrock extern int init_zfs(void); 1351867Sgjelinek 1361867Sgjelinek #endif /* _ZONEADM_H */ 137