1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright 2015 Joyent, Inc. 13.\" 14.Dd May 11, 2016 15.Dt PR_IOCTL 3PROC 16.Os 17.Sh NAME 18.Nm pr_ioctl 19.Nd inject ioctl system call into victim process 20.Sh SYNOPSIS 21.Lb libproc 22.In libproc.h 23.Ft int 24.Fo pr_ioctl 25.Fa "struct ps_prochandle *P" 26.Fa "int fd" 27.Fa "int code" 28.Fa "void *buf" 29.Fa "size_t size" 30.Fc 31.Sh DESCRIPTION 32The 33.Fn pr_ioctl 34function injects the 35.Xr ioctl 2 36system call into the target process 37.Fa P 38by means of the agent LWP. 39If the process handle 40.Fa P 41is the value 42.Dv NULL 43then this will be equivalent to calling 44.Xr ioctl 2 45on the currently running process. 46.Pp 47The arguments 48.Fa fd , 49.Fa code , 50and 51.Fa buf 52have the same meaning as in 53.Xr ioctl 2 . 54See 55.Xr ioctl 2 56for the full description and purpose of the 57.Sy ioctl 58system call and its arguments. 59.Pp 60Unlike the traditional 61.Xr ioctl 2 62system call, the 63.Fn pr_ioctl 64function needs to know the maximum size of the buffer 65.Fa buf 66such that it can be properly injected into the address space of the 67target process. 68.Pp 69The 70.Fn pr_ioctl 71function only works on active processes. 72Process handles that correspond to core files, zombie processes, or ELF objects 73do not support system call injection. 74.Sh RETURN VALUES 75Upon successful completion, the 76.Fn pr_ioctl 77function's return value is that described in 78.Xr ioctl 2 . 79Otherwise, 80.Sy -1 81is returned and 82.Sy errno 83is set to 84.Er ENOSYS 85to indicate that the system call could not be injected. 86.Sh ERRORS 87For the full list of errors see the 88.Sy ERRORS 89section in 90.Xr ioctl 2 . 91.Pp 92The 93.Fn pr_ioctl 94function will fail if: 95.Bl -tag -width Er 96.It Er ENOSYS 97An error occurred while trying to invoke the agent LWP and inject a 98system call in the process handle 99.Fa P 100or the process handle 101.Fa P 102does not support system call injection. 103.El 104.Sh INTERFACE STABILITY 105.Sy Uncommitted 106.Sh MT-LEVEL 107See 108.Sy LOCKING 109in 110.Xr libproc 3LIB . 111.Sh SEE ALSO 112.Xr ioctl 2 , 113.Xr libproc 3LIB , 114.Xr proc 5 115