xref: /titanic_51/usr/src/cmd/zoneadm/zoneadm.h (revision 3c7284bd3243d42a710edac3a15f6019b4c849be)
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.
25*3c7284bdSAlexander Eremin  * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
260b5de56dSgjelinek  */
270b5de56dSgjelinek 
280b5de56dSgjelinek #ifndef _ZONEADM_H
290b5de56dSgjelinek #define	_ZONEADM_H
300b5de56dSgjelinek 
310094b373Sjv227347 #include <sys/types.h>
320094b373Sjv227347 
330b5de56dSgjelinek #define	CMD_HELP	0
340b5de56dSgjelinek #define	CMD_BOOT	1
350b5de56dSgjelinek #define	CMD_HALT	2
360b5de56dSgjelinek #define	CMD_READY	3
37*3c7284bdSAlexander Eremin #define	CMD_SHUTDOWN	4
38*3c7284bdSAlexander Eremin #define	CMD_REBOOT	5
39*3c7284bdSAlexander Eremin #define	CMD_LIST	6
40*3c7284bdSAlexander Eremin #define	CMD_VERIFY	7
41*3c7284bdSAlexander Eremin #define	CMD_INSTALL	8
42*3c7284bdSAlexander Eremin #define	CMD_UNINSTALL	9
43*3c7284bdSAlexander Eremin #define	CMD_MOUNT	10
44*3c7284bdSAlexander Eremin #define	CMD_UNMOUNT	11
45*3c7284bdSAlexander Eremin #define	CMD_CLONE	12
46*3c7284bdSAlexander Eremin #define	CMD_MOVE	13
47*3c7284bdSAlexander Eremin #define	CMD_DETACH	14
48*3c7284bdSAlexander Eremin #define	CMD_ATTACH	15
49*3c7284bdSAlexander Eremin #define	CMD_MARK	16
50*3c7284bdSAlexander Eremin #define	CMD_APPLY	17
51*3c7284bdSAlexander Eremin #define	CMD_SYSBOOT	18
520b5de56dSgjelinek 
530b5de56dSgjelinek #define	CMD_MIN		CMD_HELP
54fbbfbc6eSjv227347 #define	CMD_MAX		CMD_SYSBOOT
550b5de56dSgjelinek 
560b5de56dSgjelinek #if !defined(TEXT_DOMAIN)		/* should be defined by cc -D */
570b5de56dSgjelinek #define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it wasn't */
580b5de56dSgjelinek #endif
590b5de56dSgjelinek 
600b5de56dSgjelinek #define	Z_ERR		1
610b5de56dSgjelinek #define	Z_USAGE		2
626cfd72c6Sgjelinek #define	Z_FATAL		3
630b5de56dSgjelinek 
640b5de56dSgjelinek #define	SW_CMP_NONE	0x0
650b5de56dSgjelinek #define	SW_CMP_SRC	0x01
660b5de56dSgjelinek #define	SW_CMP_SILENT	0x02
670b5de56dSgjelinek 
680b5de56dSgjelinek /*
690094b373Sjv227347  * This structure stores information about mounts of interest within an
700094b373Sjv227347  * installed zone.
710094b373Sjv227347  */
720094b373Sjv227347 typedef struct zone_mounts {
730094b373Sjv227347 	/* The zone's zonepath */
740094b373Sjv227347 	char		*zonepath;
750094b373Sjv227347 
760094b373Sjv227347 	/* The length of zonepath */
770094b373Sjv227347 	int		zonepath_len;
780094b373Sjv227347 
790094b373Sjv227347 	/*
800094b373Sjv227347 	 * This indicates the number of unexpected mounts that were encountered
810094b373Sjv227347 	 * in the zone.
820094b373Sjv227347 	 */
830094b373Sjv227347 	int		num_unexpected_mounts;
840094b373Sjv227347 
850094b373Sjv227347 	/*
860094b373Sjv227347 	 * This is the number of overlay mounts detected on the zone's root
870094b373Sjv227347 	 * directory.
880094b373Sjv227347 	 */
890094b373Sjv227347 	int		num_root_overlay_mounts;
900094b373Sjv227347 
910094b373Sjv227347 	/*
920094b373Sjv227347 	 * This is used to track important zone root mount information.  The
930094b373Sjv227347 	 * mnt_time field isn't used.  If root_mnttab is NULL, then the
940094b373Sjv227347 	 * associated zone doesn't have a mounted root filesystem.
950094b373Sjv227347 	 *
960094b373Sjv227347 	 * NOTE: mnt_mountp is non-NULL iff the zone's root filesystem is a
970094b373Sjv227347 	 * ZFS filesystem with a non-legacy mountpoint.  In this case, it
980094b373Sjv227347 	 * refers to a string containing the dataset's mountpoint.
990094b373Sjv227347 	 */
1000094b373Sjv227347 	struct mnttab	*root_mnttab;
1010094b373Sjv227347 } zone_mounts_t;
1020094b373Sjv227347 
1030094b373Sjv227347 /*
1040b5de56dSgjelinek  * zoneadm.c
1050b5de56dSgjelinek  */
1060b5de56dSgjelinek extern char *target_zone;
1070b5de56dSgjelinek 
1080094b373Sjv227347 extern int zfm_print(const struct mnttab *mntp, void *unused);
1090b5de56dSgjelinek extern int clone_copy(char *source_zonepath, char *zonepath);
1100b5de56dSgjelinek extern char *cmd_to_str(int cmd_num);
111c75cc341S extern int do_subproc(char *cmdbuf);
112ff17c8bfSgjelinek extern int subproc_status(const char *cmd, int status,
113ff17c8bfSgjelinek     boolean_t verbose_failure);
1140b5de56dSgjelinek extern void zerror(const char *fmt, ...);
1150b5de56dSgjelinek extern void zperror(const char *str, boolean_t zonecfg_error);
1160b5de56dSgjelinek extern void zperror2(const char *zone, const char *str);
1170b5de56dSgjelinek 
1180b5de56dSgjelinek /*
1190b5de56dSgjelinek  * zfs.c
1200b5de56dSgjelinek  */
121ff17c8bfSgjelinek extern int clone_snapshot_zfs(char *snap_name, char *zonepath,
122ff17c8bfSgjelinek     char *validatesnap);
123ff17c8bfSgjelinek extern int clone_zfs(char *source_zonepath, char *zonepath, char *presnapbuf,
124ff17c8bfSgjelinek     char *postsnapbuf);
1250b5de56dSgjelinek extern void create_zfs_zonepath(char *zonepath);
1260b5de56dSgjelinek extern int destroy_zfs(char *zonepath);
1270b5de56dSgjelinek extern boolean_t is_zonepath_zfs(char *zonepath);
1280b5de56dSgjelinek extern int move_zfs(char *zonepath, char *new_zonepath);
1290b5de56dSgjelinek extern int verify_datasets(zone_dochandle_t handle);
1300b5de56dSgjelinek extern int verify_fs_zfs(struct zone_fstab *fstab);
1310094b373Sjv227347 extern int zone_mounts_init(zone_mounts_t *mounts, const char *zonepath);
1320094b373Sjv227347 extern void zone_mounts_destroy(zone_mounts_t *mounts);
1330094b373Sjv227347 extern int zone_mount_rootfs(zone_mounts_t *mounts, const char *zonepath);
1340094b373Sjv227347 extern int zone_unmount_rootfs(zone_mounts_t *mounts, const char *zonepath,
1350094b373Sjv227347     boolean_t force);
13699653d4eSeschrock extern int init_zfs(void);
1370b5de56dSgjelinek 
1380b5de56dSgjelinek #endif	/* _ZONEADM_H */
139