.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
.B #include <unistd.h>
.P
-.BI "long syscall(SYS_keyctl, KEYCTL_READ, unsigned long " arg2 ,
-.BI " unsigned long " arg3 ", unsigned long " arg4 ,
-.BI " unsigned long " arg5 );
+.BI "long syscall(SYS_keyctl, KEYCTL_READ, key_serial_t " key ,
+.BI " char " buf "[_Nullable ." size "], size_t " size );
.fi
.SH DESCRIPTION
-.TP
-.BR KEYCTL_READ " (since Linux 2.6.10)"
Read the payload data of a key.
-.IP
+.P
The ID of the key whose payload is to be read is specified in
-.I arg2
-(cast to
-.IR key_serial_t ).
+.IR key .
This can be the ID of an existing key,
or any of the special key IDs listed for
.BR KEYCTL_GET_KEYRING_ID (2const).
.\" including KEY_SPEC_REQKEY_AUTH_KEY
-.IP
+.P
The payload is placed in the buffer pointed by
-.I arg3
-(cast to
-.IR "char\ *" );
+.IR buf ;
the size of that buffer must be specified in
-.I arg4
-(cast to
-.IR size_t ).
-.IP
+.IR size .
+.P
The returned data will be processed for presentation
according to the key type.
For example, a keyring will return an array of
The
.I user
key type will return its data as is.
-If a key type does not implement this function,
-the operation fails with the error
-.BR EOPNOTSUPP .
-.IP
+.P
If
-.I arg3
+.I buf
is not NULL,
as much of the payload data as will fit is copied into the buffer.
On a successful return,
To determine whether the buffer was of sufficient size,
check to see that the return value is less than or equal to
the value supplied in
-.IR arg4 .
-.IP
+.IR size .
+.P
The key must either grant the caller
.I read
permission, or grant the caller
.I search
permission when searched for from the process keyrings
(i.e., the key is possessed).
-.IP
-The
-.I arg5
-argument is ignored.
-.IP
-This operation is exposed by
-.I libkeyutils
-via the function
-.BR keyctl_read (3).
.SH RETURN VALUE
-.TP
-.B KEYCTL_READ
-The amount of data that is available in the key,
+On success,
+the amount of data that is available in the key,
irrespective of the provided buffer size.
.P
On error, \-1 is returned, and
.SH ERRORS
.TP
.B EOPNOTSUPP
-.I operation
-was
-.B KEYCTL_READ
-and the key type does not support reading
+The key type does not support reading
(e.g., the type is
.IR \[dq]login\[dq] ).
.SH VERSIONS