Print this page
2594 implement graceful shutdown for local zones in zoneadm


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 #ifndef _ZONEADMD_H
  27 #define _ZONEADMD_H
  28 
  29 #ifdef  __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #include <libdladm.h>
  34 
  35 /*
  36  * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
  37  * thing which could try to acquire a user-level lock unprotected by an atfork
  38  * handler) between fork(2) and exec(2).  See the pthread_atfork(3THR) man
  39  * page for details.  In particular, we want to avoid calls to zerror() in
  40  * such situations, as it calls setlocale(3c) which is susceptible to such
  41  * problems.  So instead we have the child use one of the special exit codes
  42  * below when needed, and the parent look out for such possibilities and call
  43  * zerror() there.
  44  *
  45  * Since 0, 1 and 2 are generally used for success, general error, and usage,
  46  * we start with 3.
  47  */
  48 #define ZEXIT_FORK              3
  49 #define ZEXIT_EXEC              4
  50 #define ZEXIT_ZONE_ENTER        5
  51 
  52 #define DEVFSADM        "devfsadm"
  53 #define DEVFSADM_PATH   "/usr/sbin/devfsadm"
  54 
  55 #define EXEC_PREFIX     "exec "
  56 #define EXEC_LEN        (strlen(EXEC_PREFIX))
  57 
  58 #define CLUSTER_BRAND_NAME      "cluster"
  59 #define LABELED_BRAND_NAME      "labeled"
  60 




  61 /* 0755 is the default directory mode. */
  62 #define DEFAULT_DIR_MODE \
  63         (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
  64 #define DEFAULT_DIR_USER -1     /* user ID for chown: -1 means don't change */
  65 #define DEFAULT_DIR_GROUP -1    /* grp ID for chown: -1 means don't change */
  66 
  67 
  68 typedef struct zlog {
  69         FILE *logfile;  /* file to log to */
  70 
  71         /*
  72          * The following are used if logging to a buffer.
  73          */
  74         char *log;      /* remaining log */
  75         size_t loglen;  /* size of remaining log */
  76         char *buf;      /* underlying storage */
  77         size_t buflen;  /* total len of 'buf' */
  78         char *locale;   /* locale to use for gettext() */
  79 } zlog_t;
  80 




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  25  */
  26 
  27 #ifndef _ZONEADMD_H
  28 #define _ZONEADMD_H
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 #include <libdladm.h>
  35 
  36 /*
  37  * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
  38  * thing which could try to acquire a user-level lock unprotected by an atfork
  39  * handler) between fork(2) and exec(2).  See the pthread_atfork(3THR) man
  40  * page for details.  In particular, we want to avoid calls to zerror() in
  41  * such situations, as it calls setlocale(3c) which is susceptible to such
  42  * problems.  So instead we have the child use one of the special exit codes
  43  * below when needed, and the parent look out for such possibilities and call
  44  * zerror() there.
  45  *
  46  * Since 0, 1 and 2 are generally used for success, general error, and usage,
  47  * we start with 3.
  48  */
  49 #define ZEXIT_FORK              3
  50 #define ZEXIT_EXEC              4
  51 #define ZEXIT_ZONE_ENTER        5
  52 
  53 #define DEVFSADM        "devfsadm"
  54 #define DEVFSADM_PATH   "/usr/sbin/devfsadm"
  55 
  56 #define EXEC_PREFIX     "exec "
  57 #define EXEC_LEN        (strlen(EXEC_PREFIX))
  58 
  59 #define CLUSTER_BRAND_NAME      "cluster"
  60 #define LABELED_BRAND_NAME      "labeled"
  61 
  62 #define SHUTDOWN_WAIT           60
  63 #define SHUTDOWN_DEFAULT        "/sbin/init 0"
  64 #define SHUTDOWN_FMRI   "svc:/system/zones:default"
  65 
  66 /* 0755 is the default directory mode. */
  67 #define DEFAULT_DIR_MODE \
  68         (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
  69 #define DEFAULT_DIR_USER -1     /* user ID for chown: -1 means don't change */
  70 #define DEFAULT_DIR_GROUP -1    /* grp ID for chown: -1 means don't change */
  71 
  72 
  73 typedef struct zlog {
  74         FILE *logfile;  /* file to log to */
  75 
  76         /*
  77          * The following are used if logging to a buffer.
  78          */
  79         char *log;      /* remaining log */
  80         size_t loglen;  /* size of remaining log */
  81         char *buf;      /* underlying storage */
  82         size_t buflen;  /* total len of 'buf' */
  83         char *locale;   /* locale to use for gettext() */
  84 } zlog_t;
  85