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_STAT 3PROC 16.Os 17.Sh NAME 18.Nm pr_fstat , 19.Nm pr_fstat64 , 20.Nm pr_lstat , 21.Nm pr_lstat64 , 22.Nm pr_stat , 23.Nm pr_stat64 24.Nd inject stat system call into victim process 25.Sh LIBRARY 26.Lb libproc 27.Sh SYNOPSIS 28.In libproc.h 29.Ft int 30.Fo pr_fstat 31.Fa "struct ps_prochandle *P" 32.Fa "int fd" 33.Fa "struct stat *buf" 34.Fc 35.Ft int 36.Fo pr_fstat64 37.Fa "struct ps_prochandle *P" 38.Fa "int fd" 39.Fa "struct stat64 *buf" 40.Fc 41.Ft int 42.Fo pr_lstat 43.Fa "struct ps_prochandle *P" 44.Fa "const char *path" 45.Fa "struct stat *buf" 46.Fc 47.Ft int 48.Fo pr_lstat64 49.Fa "struct ps_prochandle *P" 50.Fa "const char *path" 51.Fa "struct stat64 *buf" 52.Fc 53.Ft int 54.Fo pr_stat 55.Fa "struct ps_prochandle *P" 56.Fa "const char *path" 57.Fa "struct stat *buf" 58.Fc 59.Ft int 60.Fo pr_stat64 61.Fa "struct ps_prochandle *P" 62.Fa "const char *path" 63.Fa "struct stat64 *buf" 64.Fc 65.Sh DESCRIPTION 66The 67.Fn pr_stat , 68.Fn pr_lstat , 69and 70.Fn pr_fast 71functions inject the 72.Xr stat 2 , 73.Xr lstat 2 , 74and 75.Xr fstat 2 76system calls respectively into the target process 77.Fa P 78by means of the agent LWP. 79If the process handle 80.Fa P 81is the value 82.Dv NULL 83then this will be equivalent to calling 84.Xr stat 2 , 85.Xr lstat 2 , 86or 87.Xr fstat 2 88on the currently running process. 89.Pp 90The arguments 91.Fa path , 92and 93.Fa buf 94to the 95.Fn pr_stat 96function have the same meaning as in 97.Xr stat 2 . 98See 99.Xr stat 2 100for the full description and purpose of the 101.Sy stat 102system call and its arguments. 103.Pp 104The arguments 105.Fa fd , 106and 107.Fa buf 108to the 109.Fn pr_fstat 110function have the same meaning as in 111.Xr fstat 2 , 112see 113.Xr fstat 2 114for the full description and purpose of the 115.Sy fstat 116system call and its arguments. 117.Pp 118The arguments 119.Fa path , 120and 121.Fa buf 122to the 123.Fn pr_lstat 124function have the same meaning as in 125.Xr lstat 2 , 126see 127.Xr lstat 2 128for the full description and purpose of the 129.Sy lstat 130system call and its arguments. 131.Pp 132The 133.Fn pr_stat , 134.Fn pr_lstat , 135and 136.Fn pr_fstat 137functions only work on active processes. 138Process handles that correspond to core files, zombie processes, or ELF objects 139do not support system call injection. 140.Pp 141The 142.Fn pr_stat64 , 143.Fn pr_fstat64 , 144and 145.Fn pr_lstat64 146functions are equivalent to 147.Fn pr_stat , 148.Fn pr_fstat , 149and 150.Fn pr_lstat 151respectively; however, rather than having the stat information be subject to the 152data model of the target process, they always provide 64-bit stat information. 153See 154.Xr lf64 7 155for more information. 156.Sh RETURN VALUES 157Upon successful completion, the 158.Fn pr_stat 159function's return value is that described in 160.Xr stat 2 . 161Otherwise, 162.Sy -1 163is returned and 164.Sy errno 165is set to 166.Er ENOSYS 167to indicate that the system call could not be injected. 168.Sh ERRORS 169For the full list of errors see the 170.Sy ERRORS 171section in 172.Xr stat 2 . 173.Pp 174The 175.Fn pr_stat 176function will fail if: 177.Bl -tag -width Er 178.It Er ENOSYS 179An error occurred while trying to invoke the agent LWP and inject a 180system call in the process handle 181.Fa P 182or the process handle 183.Fa P 184does not support system call injection. 185.El 186.Sh INTERFACE STABILITY 187.Sy Uncommitted 188.Sh MT-LEVEL 189See 190.Sy LOCKING 191in 192.Xr libproc 3LIB . 193.Sh SEE ALSO 194.Xr stat 2 , 195.Xr libproc 3LIB , 196.Xr proc 5 , 197.Xr lf64 7 198