xref: /illumos-gate/usr/src/man/man3contract/ct_dev_tmpl_set_aset.3contract (revision fc910014e8a32a65612105835a10995f2c13d942)
te
Copyright (c) 2007, 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]
CT_DEV_TMPL_SET_ASET 3CONTRACT "Aug 9, 2007"
NAME
ct_dev_tmpl_set_aset, ct_dev_tmpl_get_aset, ct_dev_tmpl_set_minor, ct_dev_tmpl_get_minor, ct_dev_tmpl_set_noneg, ct_dev_tmpl_clear_noneg, ct_dev_tmpl_get_noneg - device contract template functions
SYNOPSIS

cc [ flag.\|.\|. ] file.\|.\|. -D_LARGEFILE64_SOURCE  -lcontract  [ library.\|.\|. ]
#include <libcontract.h>
#include <sys/contract/device.h>

int ct_dev_tmpl_set_aset(int fd, uint_t aset);

int ct_dev_tmpl_get_aset(int fd, uint_t *asetp);

int ct_dev_tmpl_set_minor(int fd, char *minor);

int ct_dev_tmpl_get_minor(int fd, char *buf, size_t *buflenp);

int ct_dev_tmpl_set_noneg(int fd);

int ct_dev_tmpl_clear_noneg(int fd);

int ct_dev_tmpl_get_noneg(int fd, uint_t *nonegp);
PARAMETERS
aset

a bitset of one or more of device states

asetp

a pointer to a variable into which the current A-set is to be returned

buf

a buffer into which the minor path is to be returned

buflenp

a pointer to variable of type size_t in which the size of the buffer buf is passed in. If the buffer is too small the size of the buffer needed for a successful call is passed back to the caller.

fd

a file descriptor from an open of the device contract template file in the contract filesystem (ctfs)

minor

the devfs path (the /devices path without the "/devices" prefix) of a minor which is to be the subject of a contract

nonegp

a pointer to a uint_t variable for receiving the current setting of the "nonnegotiable" term in the template

DESCRIPTION

These functions read and write device contract terms and operate on device contract template file descriptors obtained from the contract(5) filesystem (ctfs).

The ct_dev_tmpl_set_aset() and ct_dev_tmpl_get_aset() functions write and read the "acceptable states" set (or A-set for short). This is the set of device states guaranteed by the contract. Any departure from these states will result in the breaking of the contract and a delivery of a critical contract event to the contract holder. The A-set value is a bitset of one or more of the following device states: CT_DEV_EV_ONLINE, CT_DEV_EV_DEGRADED, and CT_DEV_EV_OFFLINE.

The ct_dev_tmpl_set_minor() and ct_dev_tmpl_get_minor() functions write and read the minor term (the device resource that is to be the subject of the contract.) The value is a devfs path to a device minor node (minus the "/devices" prefix). For the ct_dev_tmpl_get_minor() function, a buffer at least PATH_MAX in size must be passed in. If the buffer is smaller than PATH_MAX, then the minimum size of the buffer required (PATH_MAX) for this function is passed back to the caller via the buflenp argument.

The ct_dev_tmpl_set_noneg() and ct_dev_tmpl_get_noneg() functions write and read the nonnegotiable term. If this term is set, synchronous negotiation events are automatically NACKed on behalf of the contract holder. For ct_dev_tmpl_get_noneg(), the variable pointed to by nonegp is set to 1 if the "noneg" term is set or to 0 otherwise. The ct_dev_tmpl_clear_noneg() term clears the nonnegotiable term from a template.

RETURN VALUES

Upon successful completion, these functions return 0. Otherwise, they return a non-zero error value.

ERRORS

The ct_dev_tmpl_set_aset() function will fail if: EINVAL

A template file descriptor or A-set is invalid

The ct_dev_tmpl_set_minor() function will fail if: EINVAL

One or more arguments is invalid.

ENXIO

The minor named by minor path does not exist.

The ct_dev_tmpl_set_noneg() function will fail if: EPERM

A process lacks sufficient privilege to NACK a device state change.

The ct_dev_tmpl_get_aset() and ct_dev_tmpl_get_minor() functions will fail if: EINVAL

One or more arguments is invalid.

ENOENT

The requested term is not set.

The ct_dev_tmpl_get_noneg() function will fail if: EINVAL

One or more arguments is invalid.

The ct_dev_tmpl_get_minor() function will fail if: EOVERFLOW

The supplied buffer is too small.

ATTRIBUTES

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
MT-Level Safe
SEE ALSO

libcontract (3LIB), contract (5), devices (5), attributes (7), lfcompile (7)