1CAP_COPY_EXT(3)            Linux Programmer's Manual           CAP_COPY_EXT(3)
2
3
4

NAME

6       cap_copy_ext, cap_size, cap_copy_int - capability state external repre‐
7       sentation translation
8

SYNOPSIS

10       #include <sys/capability.h>
11
12       ssize_t cap_size(cap_t cap_p);
13
14       ssize_t cap_copy_ext(void *ext_p, cap_t cap_p, ssize_t size);
15
16       cap_t cap_copy_int(const void *ext_p);
17
18       Link with -lcap.
19

DESCRIPTION

21       These functions translate between internal and external representations
22       of  a  capability state.  The external representation is an exportable,
23       contiguous, persistent representation of a capability  state  in  user-
24       managed  space.  The internal representation is managed by the capabil‐
25       ity functions in working storage.
26
27       cap_size() returns the total length  (in  bytes)  that  the  capability
28       state  in  working  storage identified by cap_p would require when con‐
29       verted by cap_copy_ext().  This function is used primarily to determine
30       the  amount of buffer space that must be provided to the cap_copy_ext()
31       function in order to hold  the  capability  data  record  created  from
32       cap_p.
33
34       cap_copy_ext() copies a capability state in working storage, identified
35       by cap_p, from system managed space to user-managed space  (pointed  to
36       by  ext_p)  and  returns  the length of the resulting data record.  The
37       size parameter represents the maximum size, in bytes, of the  resulting
38       data  record.  The cap_copy_ext() function will do any conversions nec‐
39       essary to convert the capability state from the undefined internal for‐
40       mat  to  an  exportable, contiguous, persistent data record.  It is the
41       responsibility of the user to allocate a buffer large  enough  to  hold
42       the  copied  data.   The buffer length required to hold the copied data
43       may be obtained by a call to the cap_size() function.
44
45       cap_copy_int() copies a capability state from a capability data  record
46       in  user-managed  space  to  a new capability state in working storage,
47       allocating any memory necessary, and returning a pointer to  the  newly
48       created  capability  state.   The  function  initializes the capability
49       state and then copies the capability state from the record  pointed  to
50       by  ext_p into the capability state, converting, if necessary, the data
51       from a contiguous, persistent format to an undefined, internal  format.
52       Once  copied into internal format, the object can be manipulated by the
53       capability state manipulation functions (see cap_clear(3)).  Note  that
54       the record pointed to by ext_p must have been obtained from a previous,
55       successful call to cap_copy_ext() for this function  to  work  success‐
56       fully.  The caller should free any releasable memory, when the capabil‐
57       ity state  in  working  storage  is  no  longer  required,  by  calling
58       cap_free() with the cap_t as an argument.
59

RETURN VALUE

61       cap_size() returns the length required to hold a capability data record
62       on success, and -1 on failure.
63
64       cap_copy_ext() returns the number of bytes placed in the  user  managed
65       space pointed to by ext_p on success, and -1 on failure.
66
67       cap_copy_int()  returns a pointer to the newly created capability state
68       in working storage on success, and NULL on failure.
69
70       On failure, errno is set to EINVAL, ENOMEM, or ERANGE.
71

CONFORMING TO

73       These functions are specified in the withdrawn POSIX.1e draft  specifi‐
74       cation.
75

SEE ALSO

77       libcap(3),     cap_clear(3),     cap_from_text(3),     cap_get_file(3),
78       cap_get_proc(3), cap_init(3), capabilities(7)
79
80
81
82                                  2008-05-11                   CAP_COPY_EXT(3)
Impressum