Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
NAME
ctprtmplsettransfer, ctprtmplsetfatal,
ctprtmplsetparam, ctprtmplsetsvcfmri,
ctprtmplsetsvcaux, ctprtmplgettransfer,
ctprtmplgetfatal, ctprtmplgetparam,
ctprtmplgetsvcfmri, ctprtmplgetsvcaux - process
contract template functions
SYNOPSIS
cc [ flag... ] file... -DLARGEFILE64SOURCE -lcontract [ library... ]
#include
#include
int ctprtmplsettransfer(int fd, ctidt ctid);
int ctprtmplsetfatal(int fd, uintt events);
int ctprtmplsetparam(int fd, uintt params);
int ctprtmplsetsvcfmri(int fd, const char *fmri);
int ctprtmplsetsvcaux(int fd, const char *aux);
int ctprtmplgettransfer(int fd, ctidt *ctidp);
int ctprtmplgetfatal(int fd, uintt *eventsp);
int ctprtmplgetparam(int fd, uintt *paramsp);
int ctprtmplgetsvcfmri(int fd, char *fmri, sizet size);
int ctprtmplgetsvcaux(int fd, char *aux, sizet size);
DESCRIPTION
These functions read and write process contract terms and
operate on process contract template file descriptors
obtained from the contract(4) file system.
The ctprtmplsettransfer() and ctprtmplgettransfer()
functions write and read the transfer contract term. The
SunOS 5.11 Last change: 25 Feb 2008 1
Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
value is the ID of an empty regent process contract owned by
the caller whose inherited contracts are to be transferred
to a newly created contract.
The ctprtmplsetfatal() and ctprtmplgetfatal() func-
tions write and read the fatal event set term. The value is
a collection of bits as described in process(4).
The ctprtmplsetparam() and ctprtmplgetparam() func-
tions write and read the parameter set term. The value is a
collection of bits as described in process(4).
The ctprtmplsetsvcfmri() and ctprtmplgetsvcfmri()
functions write and read the service FMRI value of a process
contract template. The ctprtmplsetsvcfmri() function
requires the caller to have the {PRIVCONTRACTIDENTITY}
privilege in its effective set.
The ctprtmplsetsvcaux() and ctprtmplgetsvcaux()
functions write and read the creator's auxiliary value of a
process contract template.
RETURN VALUES
Upon successful completion, ctprtmplsettransfer(),
ctprtmplsetfatal(), ctprtmplsetparam(),
ctprtmplsetsvcfmri(), ctprtmplsetsvcaux(),
ctprtmplgettransfer(), ctprtmplgetfatal(), and
ctprtmplgetparam() return 0. Otherwise, they return a
non-zero error value.
Upon successful completion, ctprtmplgetsvcfmri() and
ctprtmplgetsvcaux() return the size required to store
the value, which is the same value return by strcpy(3C) ] 1.
Insufficient buffer size can be checked by:
if (ctprtmplgetsvcfmri(fd, fmri, size) > size)
/* buffer is too small */
Otherwise, ctprtmplgetsvcfmri() and
ctprtmplgetsvcaux() return -1 and set errno to indicate
the error.
ERORS
SunOS 5.11 Last change: 25 Feb 2008 2
Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
The ctprtmplsetparam(), ctprtmplsetsvcfmri(),
ctprtmplsetsvcaux(), ctprtmplgetsvcfmri() and
ctprtmplgetsvcaux() functions will fail if:
EINVAL An invalid parameter was specified.
The ctprtmplsetfatal() function will fail if:
EINVAL An invalid event was specified.
The ctprtmplsettransfer() function will fail if:
ESRCH The ID specified by ctid does not correspond to
a process contract.
EACES The ID specified by ctid does not correspond to
a process contract owned by the calling pro-
cess.
ENOTEMPTY The ID specified by ctid does not correspond to
an empty process contract.
The ctprtmplsetsvcfmri() function will fail if:
EPERM The calling process does not have
{PRIVCONTRACTIDENTITY} in its effective set.
EXAMPLES
Example 1 Create and activate a process contract template.
The following example opens a new template, makes hardware
errors and signals fatal events, makes hardware errors crit-
ical events, and activates the template. It then forks a
process in the new contract using the requested terms.
#include
#include
#include
...
SunOS 5.11 Last change: 25 Feb 2008 3
Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
int fd;
fd = open("/system/contract/process/template", ORDWR);
(void) ctprtmplsetfatal(fd, CTPREVHWERCTPREVSIGNAL);
(void) cttmplsetcritical(fd, CTPREVHWER);
(void) cttmplactivate(fd);
close(fd);
if (fork()) {
/* parent - owns new process contract */
...
} else {
/* child - in new process contract */
...
}
...
Example 2 Clear the process contract template.
The following example opens the template file and requests
that the active template be cleared.
#include
#include
...
int fd;
fd = open("/system/contract/process/template", ORDWR);
(void) cttmplclear(fd);
close(fd);
...
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 25 Feb 2008 4
Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
MT-Level Safe
SEE ALSO
libcontract(3LIB), strcpy(3C), contract(4), process(4),
attributes(5), lfcompile(5)
SunOS 5.11 Last change: 25 Feb 2008 5
Contract Management Library Functions
ctprtmplsettransfer(3CONTRACT)
SunOS 5.11 Last change: 25 Feb 2008 6
|