4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 * mmap() system call -- executed by subject process
39 pr_mmap(struct ps_prochandle
*Pr
,
40 void *addr
, size_t len
, int prot
, int flags
, int fd
, off_t off
)
42 sysret_t rval
; /* return value from mmap() */
43 argdes_t argd
[6]; /* arg descriptors for mmap() */
47 if (Pr
== NULL
) /* no subject process */
48 return (mmap(addr
, len
, prot
, flags
, fd
, off
));
50 adp
= &argd
[0]; /* addr argument */
51 adp
->arg_value
= (long)addr
;
52 adp
->arg_object
= NULL
;
53 adp
->arg_type
= AT_BYVAL
;
54 adp
->arg_inout
= AI_INPUT
;
57 adp
++; /* len argument */
58 adp
->arg_value
= (long)len
;
59 adp
->arg_object
= NULL
;
60 adp
->arg_type
= AT_BYVAL
;
61 adp
->arg_inout
= AI_INPUT
;
64 adp
++; /* prot argument */
65 adp
->arg_value
= (long)prot
;
66 adp
->arg_object
= NULL
;
67 adp
->arg_type
= AT_BYVAL
;
68 adp
->arg_inout
= AI_INPUT
;
71 adp
++; /* flags argument */
72 adp
->arg_value
= (long)flags
;
73 adp
->arg_object
= NULL
;
74 adp
->arg_type
= AT_BYVAL
;
75 adp
->arg_inout
= AI_INPUT
;
78 adp
++; /* fd argument */
79 adp
->arg_value
= (long)fd
;
80 adp
->arg_object
= NULL
;
81 adp
->arg_type
= AT_BYVAL
;
82 adp
->arg_inout
= AI_INPUT
;
85 adp
++; /* off argument */
86 adp
->arg_value
= (long)off
;
87 adp
->arg_object
= NULL
;
88 adp
->arg_type
= AT_BYVAL
;
89 adp
->arg_inout
= AI_INPUT
;
92 error
= Psyscall(Pr
, &rval
, SYS_mmap
, 6, &argd
[0]);
95 errno
= (error
> 0)? error
: ENOSYS
;
96 return ((void *)(-1));
98 return ((void *)rval
.sys_rval1
);
102 * munmap() system call -- executed by subject process
105 pr_munmap(struct ps_prochandle
*Pr
, void *addr
, size_t len
)
107 sysret_t rval
; /* return value from munmap() */
108 argdes_t argd
[2]; /* arg descriptors for munmap() */
112 if (Pr
== NULL
) /* no subject process */
113 return (munmap(addr
, len
));
115 adp
= &argd
[0]; /* addr argument */
116 adp
->arg_value
= (long)addr
;
117 adp
->arg_object
= NULL
;
118 adp
->arg_type
= AT_BYVAL
;
119 adp
->arg_inout
= AI_INPUT
;
122 adp
++; /* len argument */
123 adp
->arg_value
= (long)len
;
124 adp
->arg_object
= NULL
;
125 adp
->arg_type
= AT_BYVAL
;
126 adp
->arg_inout
= AI_INPUT
;
129 error
= Psyscall(Pr
, &rval
, SYS_munmap
, 2, &argd
[0]);
132 errno
= (error
> 0)? error
: ENOSYS
;
135 return (rval
.sys_rval1
);
139 * zmap() -- convenience function; mmap(MAP_ANON) executed by subject process.
142 pr_zmap(struct ps_prochandle
*Pr
, void *addr
, size_t len
, int prot
, int flags
)
144 return (pr_mmap(Pr
, addr
, len
, prot
, flags
| MAP_ANON
, -1, (off_t
)0));