User Tools

Site Tools


solaris:contract_open.3contract

contract_open


NAME

contract_open, contract_latest, contract_abandon_id, getctid - common contract functions

SYNOPSIS

cc [ flag… ] file… -D_LARGEFILE64_SOURCE -lcontract [ library… ]

#include<libcontract.h>

int contract_latest(cttype_t type, ctid_t *id)
int contract_open(ctid_t ctid, cttype_t type, const char *file, int oflag)
int contract_abandon_id(ctid_t ctid)
ctid_t getctid()

DESCRIPTION

These functions operate on contract control file descriptors obtained from the contract file system. For more information, see the contract(5) man page.

The contract_latest() function populates ctid_t with the contract ID of the latest contract created by the LWP of _type_. If the LWP has not created a _type_ contract, this function will return ESRCH. Acceptable values for _type_ are CT_TYPE_PROCESS or CT_TYPE_DEVICE.

The contract_open() function returns a file descriptor to the contract _file_ for the given _type_. For more information, see the STRUCTURE OF /system/contract/_type_/_id_ section in the contract(5) man page. The default flag for opening the file descriptor is O_CLOEXEC. The flag O_CREAT cannot be used. Acceptable values for _type_ are CT_TYPE_PROCESS, CT_TYPE_DEVICE, and CT_TYPE_ALL.

The contract_abandon_id() function abandons the contract _ctid_. It is a convenience wrapper on the ct_ctl_abandon() function. For more information, see the ct_ctl_abandon(3CONTRACT) man page.

The getctid() function returns the contract ID containing the current process.

RETURN VALUES

Upon successful completion, the contract_latest() and contract_abandon_id() functions return 0, else, they return a non-zero error value. On error, the contract_open() and getctid() functions return -1 and set errno.

ERRORS

The contract_latest() function will fail if:

EINVAL

The type argument is not a valid.

ESRCH

No contract of _type_ has been created by the LWP.

The contract_open() function will fail if:

ENOENT

The file /system/contract/<type>/_id_/_file_ does not exist.

ENAMETOOLONG

type, ID, and file arguments resulted in a ctfs name which is longer than PATH_MAX.

The contract_abandon_id() function will fail if:

ENOENT

No contract with id _ctid_ exists on the system.

EBUSY

The contract does not belong to the calling process.

The functions contract_latest(), contract_open(), contract_abandon_id(), and getctid() will fail if:

EINTR

A signal was caught during an underlying open() or read() operation.

ATTRIBUTES

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

SEE ALSO

libcontract(3LIB), contract(5), ct_ctl_abandon(3CONTRACT), attributes(7), lfcompile(7)


solaris/contract_open.3contract.txt · Last modified: 2023/07/19 08:58 by A User Not Logged in