Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
#include <zone.h> zoneid_t getzoneid(void);
zoneid_t getzoneidbyname(const char *name);
ssize_t getzonenamebyid(zoneid_t id, char *buf, size_t buflen);
The getzoneid() function returns the zone ID of the calling process.
The getzoneidbyname() function returns the zone ID corresponding to the named zone, if that zone is currently active. If name is NULL, the function returns the zone ID of the calling process.
The getzonenamebyid() function stores the name of the zone with ID specified by id in the location specified by buf. The bufsize argument specifies the size in bytes of the buffer. If the buffer is too small to hold the complete null-terminated name, the first bufsize bytes of the name are stored in the buffer. A buffer of size {ZONENAME_MAX} is sufficient to hold any zone name. If buf is NULL or bufsize is 0, the name is not copied into the buffer.
On successful completion, getzoneid() and getzoneidbyname() return a non-negative zone ID. Otherwise, getzoneidbyname() returns -1 and sets errno to indicate the error.
On successful completion, the getzonenamebyid() function returns the buffer size required to hold the full null-terminated name. Otherwise, it returns -1 and sets errno to indicate the error.
The getzoneidbyname() function will fail if: EFAULT
The name argument is non-null and points to an illegal address.
A zone with the indicated name is not active.
The length of the name argument exceeds {ZONENAME_MAX}.
The getzonenamebyid() function will fail if: EINVAL
A zone with the specified ID is not active.
The buf argument points to an illegal address.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Evolving |
MT-Level Safe |
Intro(2), chroot(2), malloc(3C), attributes(5), zones(5)