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 November 27, 2023
15.Dt PR_CREAT 3PROC
16.Os
17.Sh NAME
18.Nm pr_creat
19.Nd inject creat system call into victim process
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo pr_creat
26.Fa "struct ps_prochandle *P"
27.Fa "const char *filename"
28.Fa "mode_t mode"
29.Fc
30.Sh DESCRIPTION
31The
32.Fn pr_creat
33function injects the
34.Xr creat 2
35system call into the target process
36.Fa P
37by means of the agent LWP.
38If the process handle
39.Fa P
40is
41.Dv NULL
42then this is equivalent to calling
43.Xr creat 2
44on the currently running process.
45.Pp
46The arguments
47.Fa filename
48and
49.Fa mode
50have the same meaning as in
51.Xr creat 2 .
52See
53.Xr creat 2
54for the full description and purpose of the
55.Sy creat
56system call and its arguments.
57.Pp
58The
59.Fn pr_creat
60function only works on active processes.
61Process handles that correspond to core files, zombie processes, or ELF objects
62do not support system call injection.
63.Sh RETURN VALUES
64Upon successful completion, the
65.Fn pr_creat
66function's return value is that described in
67.Xr creat 2 .
68Otherwise,
69.Sy -1
70is returned and
71.Sy errno
72is set to
73.Er ENOSYS
74to indicate that the system call could not be injected.
75.Sh ERRORS
76For the full list of errors see the
77.Sy ERRORS
78section in
79.Xr creat 2 .
80.Pp
81The
82.Fn pr_creat
83function will fail if:
84.Bl -tag -width Er
85.It Er ENOSYS
86An error occurred while trying to invoke the agent LWP and inject a
87system call in the process handle
88.Fa P
89or the process handle
90.Fa P
91does not support system call injection.
92.El
93.Sh INTERFACE STABILITY
94.Sy Uncommitted
95.Sh MT-LEVEL
96See
97.Sy LOCKING
98in
99.Xr libproc 3LIB .
100.Sh SEE ALSO
101.Xr creat 2 ,
102.Xr libproc 3LIB ,
103.Xr proc 5
104