1*5c2921b0SApple OSS Distributions /*
2*5c2921b0SApple OSS Distributions * Copyright (c) 2014 Apple Inc. All rights reserved.
3*5c2921b0SApple OSS Distributions *
4*5c2921b0SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@
5*5c2921b0SApple OSS Distributions *
6*5c2921b0SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*5c2921b0SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*5c2921b0SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*5c2921b0SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at
10*5c2921b0SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this
11*5c2921b0SApple OSS Distributions * file.
12*5c2921b0SApple OSS Distributions *
13*5c2921b0SApple OSS Distributions * The Original Code and all software distributed under the License are
14*5c2921b0SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15*5c2921b0SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16*5c2921b0SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17*5c2921b0SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18*5c2921b0SApple OSS Distributions * Please see the License for the specific language governing rights and
19*5c2921b0SApple OSS Distributions * limitations under the License.
20*5c2921b0SApple OSS Distributions *
21*5c2921b0SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@
22*5c2921b0SApple OSS Distributions */
23*5c2921b0SApple OSS Distributions #include <sys/stackshot.h>
24*5c2921b0SApple OSS Distributions #include <mach/mach.h>
25*5c2921b0SApple OSS Distributions #include <mach/mach_vm.h>
26*5c2921b0SApple OSS Distributions #include <stdint.h>
27*5c2921b0SApple OSS Distributions #include <stdlib.h>
28*5c2921b0SApple OSS Distributions #include <errno.h>
29*5c2921b0SApple OSS Distributions
30*5c2921b0SApple OSS Distributions /*
31*5c2921b0SApple OSS Distributions * System call entry point
32*5c2921b0SApple OSS Distributions */
33*5c2921b0SApple OSS Distributions int __stack_snapshot_with_config(int stackshot_config_version, user_addr_t stackshot_config, size_t stackshot_config_size);
34*5c2921b0SApple OSS Distributions
35*5c2921b0SApple OSS Distributions /*
36*5c2921b0SApple OSS Distributions * stackshot_config_create: create and initialize the arguments for a stackshot
37*5c2921b0SApple OSS Distributions *
38*5c2921b0SApple OSS Distributions * Outputs: NULL if malloc fails
39*5c2921b0SApple OSS Distributions * a pointer to a new stackshot_config_t on success
40*5c2921b0SApple OSS Distributions */
41*5c2921b0SApple OSS Distributions stackshot_config_t *
stackshot_config_create(void)42*5c2921b0SApple OSS Distributions stackshot_config_create(void)
43*5c2921b0SApple OSS Distributions {
44*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
45*5c2921b0SApple OSS Distributions
46*5c2921b0SApple OSS Distributions s_config = malloc(sizeof(stackshot_config_t));
47*5c2921b0SApple OSS Distributions if (s_config == NULL) {
48*5c2921b0SApple OSS Distributions return NULL;
49*5c2921b0SApple OSS Distributions }
50*5c2921b0SApple OSS Distributions
51*5c2921b0SApple OSS Distributions s_config->sc_pid = -1;
52*5c2921b0SApple OSS Distributions s_config->sc_flags = 0;
53*5c2921b0SApple OSS Distributions s_config->sc_delta_timestamp = 0;
54*5c2921b0SApple OSS Distributions s_config->sc_buffer = 0;
55*5c2921b0SApple OSS Distributions s_config->sc_size = 0;
56*5c2921b0SApple OSS Distributions s_config->sc_pagetable_mask = 0;
57*5c2921b0SApple OSS Distributions
58*5c2921b0SApple OSS Distributions return s_config;
59*5c2921b0SApple OSS Distributions }
60*5c2921b0SApple OSS Distributions
61*5c2921b0SApple OSS Distributions /*
62*5c2921b0SApple OSS Distributions * stackshot_config_set_pid: set the PID to be traced
63*5c2921b0SApple OSS Distributions *
64*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to the stackshot_config_t we want to update
65*5c2921b0SApple OSS Distributions * pid - process id of process to be traced, or -1 for the entire system
66*5c2921b0SApple OSS Distributions *
67*5c2921b0SApple OSS Distributions * Outputs: EINVAL if the passed stackshot_config pointer is NULL
68*5c2921b0SApple OSS Distributions * 0 on success
69*5c2921b0SApple OSS Distributions */
70*5c2921b0SApple OSS Distributions int
stackshot_config_set_pid(stackshot_config_t * stackshot_config,int pid)71*5c2921b0SApple OSS Distributions stackshot_config_set_pid(stackshot_config_t *stackshot_config, int pid)
72*5c2921b0SApple OSS Distributions {
73*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
74*5c2921b0SApple OSS Distributions
75*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
76*5c2921b0SApple OSS Distributions return EINVAL;
77*5c2921b0SApple OSS Distributions }
78*5c2921b0SApple OSS Distributions
79*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
80*5c2921b0SApple OSS Distributions s_config->sc_pid = pid;
81*5c2921b0SApple OSS Distributions
82*5c2921b0SApple OSS Distributions return 0;
83*5c2921b0SApple OSS Distributions }
84*5c2921b0SApple OSS Distributions
85*5c2921b0SApple OSS Distributions /*
86*5c2921b0SApple OSS Distributions * stackshot_config_set_flags: set the flags to be passed for the stackshot
87*5c2921b0SApple OSS Distributions *
88*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to the stackshot_config_t we want to update
89*5c2921b0SApple OSS Distributions * flags - flags to pass to stackshot
90*5c2921b0SApple OSS Distributions *
91*5c2921b0SApple OSS Distributions * Outputs: EINVAL if the passed stackshot_config pointer is NULL
92*5c2921b0SApple OSS Distributions * 0 on success
93*5c2921b0SApple OSS Distributions */
94*5c2921b0SApple OSS Distributions int
stackshot_config_set_flags(stackshot_config_t * stackshot_config,uint64_t flags)95*5c2921b0SApple OSS Distributions stackshot_config_set_flags(stackshot_config_t *stackshot_config, uint64_t flags)
96*5c2921b0SApple OSS Distributions {
97*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
98*5c2921b0SApple OSS Distributions
99*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
100*5c2921b0SApple OSS Distributions return EINVAL;
101*5c2921b0SApple OSS Distributions }
102*5c2921b0SApple OSS Distributions
103*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
104*5c2921b0SApple OSS Distributions s_config->sc_flags = flags;
105*5c2921b0SApple OSS Distributions
106*5c2921b0SApple OSS Distributions return 0;
107*5c2921b0SApple OSS Distributions }
108*5c2921b0SApple OSS Distributions
109*5c2921b0SApple OSS Distributions /*
110*5c2921b0SApple OSS Distributions * stackshot_capture_with_config: take a stackshot with the provided config
111*5c2921b0SApple OSS Distributions *
112*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to the stackshot_config_t we want to use
113*5c2921b0SApple OSS Distributions *
114*5c2921b0SApple OSS Distributions * Outputs: EINVAL if the passed stackshot_config pointer is NULL, a caller is trying
115*5c2921b0SApple OSS Distributions * to reuse a config without deallocating its buffer or if there is a
116*5c2921b0SApple OSS Distributions * problem with the arguments
117*5c2921b0SApple OSS Distributions * EFAULT if there was a problem with accessing the arguments from the kernel
118*5c2921b0SApple OSS Distributions * EPERM if the caller is not privileged
119*5c2921b0SApple OSS Distributions * ENOTSUP if the caller is passing a stackshot config version that is not
120*5c2921b0SApple OSS Distributions * supported by the kernel (indicates libsyscall:kernel mismatch),
121*5c2921b0SApple OSS Distributions * or if the caller is requesting unsupported flags
122*5c2921b0SApple OSS Distributions * ENOMEM if the kernel is unable to allocate memory
123*5c2921b0SApple OSS Distributions * ENOSPC if the caller doesn't have enough space in their address space for
124*5c2921b0SApple OSS Distributions * the kernel to remap the buffer
125*5c2921b0SApple OSS Distributions * ENOENT if the caller is requesting an existing buffer that doesn't exist
126*5c2921b0SApple OSS Distributions * or the target PID isn't found
127*5c2921b0SApple OSS Distributions * 0 on success
128*5c2921b0SApple OSS Distributions */
129*5c2921b0SApple OSS Distributions int
stackshot_capture_with_config(stackshot_config_t * stackshot_config)130*5c2921b0SApple OSS Distributions stackshot_capture_with_config(stackshot_config_t *stackshot_config)
131*5c2921b0SApple OSS Distributions {
132*5c2921b0SApple OSS Distributions int ret;
133*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
134*5c2921b0SApple OSS Distributions
135*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
136*5c2921b0SApple OSS Distributions return EINVAL;
137*5c2921b0SApple OSS Distributions }
138*5c2921b0SApple OSS Distributions
139*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
140*5c2921b0SApple OSS Distributions if (s_config->sc_buffer != 0) {
141*5c2921b0SApple OSS Distributions return EINVAL;
142*5c2921b0SApple OSS Distributions }
143*5c2921b0SApple OSS Distributions
144*5c2921b0SApple OSS Distributions s_config->sc_out_buffer_addr = (uintptr_t)&s_config->sc_buffer;
145*5c2921b0SApple OSS Distributions s_config->sc_out_size_addr = (uintptr_t)&s_config->sc_size;
146*5c2921b0SApple OSS Distributions ret = __stack_snapshot_with_config(STACKSHOT_CONFIG_TYPE, (uintptr_t)s_config, sizeof(stackshot_config_t));
147*5c2921b0SApple OSS Distributions
148*5c2921b0SApple OSS Distributions if (ret != 0) {
149*5c2921b0SApple OSS Distributions ret = errno;
150*5c2921b0SApple OSS Distributions s_config->sc_buffer = 0;
151*5c2921b0SApple OSS Distributions s_config->sc_size = 0;
152*5c2921b0SApple OSS Distributions }
153*5c2921b0SApple OSS Distributions
154*5c2921b0SApple OSS Distributions return ret;
155*5c2921b0SApple OSS Distributions }
156*5c2921b0SApple OSS Distributions
157*5c2921b0SApple OSS Distributions /*
158*5c2921b0SApple OSS Distributions * stackshot_config_get_stackshot_buffer: get a pointer to the buffer containing the stackshot
159*5c2921b0SApple OSS Distributions *
160*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
161*5c2921b0SApple OSS Distributions *
162*5c2921b0SApple OSS Distributions * Outputs: NULL if the passed stackshot_config is NULL or if its buffer is NULL
163*5c2921b0SApple OSS Distributions * a pointer to the buffer containing the stackshot on success
164*5c2921b0SApple OSS Distributions */
165*5c2921b0SApple OSS Distributions void *
stackshot_config_get_stackshot_buffer(stackshot_config_t * stackshot_config)166*5c2921b0SApple OSS Distributions stackshot_config_get_stackshot_buffer(stackshot_config_t *stackshot_config)
167*5c2921b0SApple OSS Distributions {
168*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
169*5c2921b0SApple OSS Distributions
170*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
171*5c2921b0SApple OSS Distributions return NULL;
172*5c2921b0SApple OSS Distributions }
173*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
174*5c2921b0SApple OSS Distributions
175*5c2921b0SApple OSS Distributions return (void *)s_config->sc_buffer;
176*5c2921b0SApple OSS Distributions }
177*5c2921b0SApple OSS Distributions
178*5c2921b0SApple OSS Distributions /*
179*5c2921b0SApple OSS Distributions * stackshot_config_get_stackshot_size: get the size of the stackshot buffer
180*5c2921b0SApple OSS Distributions *
181*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
182*5c2921b0SApple OSS Distributions *
183*5c2921b0SApple OSS Distributions * Outputs: -1 if the passed stackshot config is NULL or there is no buffer
184*5c2921b0SApple OSS Distributions * the length of the stackshot buffer on success
185*5c2921b0SApple OSS Distributions */
186*5c2921b0SApple OSS Distributions uint32_t
stackshot_config_get_stackshot_size(stackshot_config_t * stackshot_config)187*5c2921b0SApple OSS Distributions stackshot_config_get_stackshot_size(stackshot_config_t * stackshot_config)
188*5c2921b0SApple OSS Distributions {
189*5c2921b0SApple OSS Distributions if (stackshot_config == NULL || (void *)stackshot_config->sc_buffer == NULL) {
190*5c2921b0SApple OSS Distributions return -1;
191*5c2921b0SApple OSS Distributions }
192*5c2921b0SApple OSS Distributions
193*5c2921b0SApple OSS Distributions return stackshot_config->sc_size;
194*5c2921b0SApple OSS Distributions }
195*5c2921b0SApple OSS Distributions
196*5c2921b0SApple OSS Distributions /*
197*5c2921b0SApple OSS Distributions * stackshot_config_set_size_hint: set the size of the stackshot buffer
198*5c2921b0SApple OSS Distributions *
199*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
200*5c2921b0SApple OSS Distributions * suggested_size - hint for size allocation of stackshot
201*5c2921b0SApple OSS Distributions *
202*5c2921b0SApple OSS Distributions * Outputs: -1 if the passed stackshot config is NULL or there is existing stackshot buffer set.
203*5c2921b0SApple OSS Distributions * the length of the stackshot buffer on success.
204*5c2921b0SApple OSS Distributions */
205*5c2921b0SApple OSS Distributions int
stackshot_config_set_size_hint(stackshot_config_t * stackshot_config,uint32_t suggested_size)206*5c2921b0SApple OSS Distributions stackshot_config_set_size_hint(stackshot_config_t *stackshot_config, uint32_t suggested_size)
207*5c2921b0SApple OSS Distributions {
208*5c2921b0SApple OSS Distributions if (stackshot_config == NULL || (void *)stackshot_config->sc_buffer != NULL) {
209*5c2921b0SApple OSS Distributions return -1;
210*5c2921b0SApple OSS Distributions }
211*5c2921b0SApple OSS Distributions
212*5c2921b0SApple OSS Distributions stackshot_config->sc_size = suggested_size;
213*5c2921b0SApple OSS Distributions
214*5c2921b0SApple OSS Distributions return 0;
215*5c2921b0SApple OSS Distributions }
216*5c2921b0SApple OSS Distributions
217*5c2921b0SApple OSS Distributions /*
218*5c2921b0SApple OSS Distributions * stackshot_config_set_delta_timestamp: set the timestamp to use as the basis for the delta stackshot
219*5c2921b0SApple OSS Distributions *
220*5c2921b0SApple OSS Distributions * This timestamp will be used along with STACKSHOT_COLLECT_DELTA_SNAPSHOT flag to collect delta stackshots
221*5c2921b0SApple OSS Distributions *
222*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
223*5c2921b0SApple OSS Distributions * delta_timestamp - timestamp in MachAbsoluteTime units to be used as the basis for a delta stackshot
224*5c2921b0SApple OSS Distributions *
225*5c2921b0SApple OSS Distributions * Outputs: -1 if the passed stackshot config is NULL or there is existing stackshot buffer set.
226*5c2921b0SApple OSS Distributions * 0 on success
227*5c2921b0SApple OSS Distributions */
228*5c2921b0SApple OSS Distributions int
stackshot_config_set_delta_timestamp(stackshot_config_t * stackshot_config,uint64_t delta_timestamp)229*5c2921b0SApple OSS Distributions stackshot_config_set_delta_timestamp(stackshot_config_t *stackshot_config, uint64_t delta_timestamp)
230*5c2921b0SApple OSS Distributions {
231*5c2921b0SApple OSS Distributions if (stackshot_config == NULL || (void *)stackshot_config->sc_buffer != NULL) {
232*5c2921b0SApple OSS Distributions return -1;
233*5c2921b0SApple OSS Distributions }
234*5c2921b0SApple OSS Distributions
235*5c2921b0SApple OSS Distributions stackshot_config->sc_delta_timestamp = delta_timestamp;
236*5c2921b0SApple OSS Distributions
237*5c2921b0SApple OSS Distributions return 0;
238*5c2921b0SApple OSS Distributions }
239*5c2921b0SApple OSS Distributions
240*5c2921b0SApple OSS Distributions /*
241*5c2921b0SApple OSS Distributions * stackshot_config_set_pagetable_mask: set the level mask for pagetable dumping
242*5c2921b0SApple OSS Distributions *
243*5c2921b0SApple OSS Distributions * Each bit of the mask corresponds to a level in the paging structure. Bit 0
244*5c2921b0SApple OSS Distributions * corresponds to Level 0, bit 1 to level 1, and so on. It is undefined what
245*5c2921b0SApple OSS Distributions * happens when a bit is set that's higher than the current maximum level of
246*5c2921b0SApple OSS Distributions * pagetable structures.
247*5c2921b0SApple OSS Distributions *
248*5c2921b0SApple OSS Distributions * When using this setter, you must also pass STACKSHOT_PAGE_TABLES as a flag
249*5c2921b0SApple OSS Distributions * before invoking stackshot, otherwise this setter is a no-operation.
250*5c2921b0SApple OSS Distributions *
251*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
252*5c2921b0SApple OSS Distributions * level_mask - the pagetable level mask, as described above
253*5c2921b0SApple OSS Distributions *
254*5c2921b0SApple OSS Distributions * Outputs: -1 if the passed stackshot config is NULL or there is existing stackshot buffer set.
255*5c2921b0SApple OSS Distributions * 0 on success
256*5c2921b0SApple OSS Distributions */
257*5c2921b0SApple OSS Distributions int
stackshot_config_set_pagetable_mask(stackshot_config_t * stackshot_config,uint32_t pagetable_mask)258*5c2921b0SApple OSS Distributions stackshot_config_set_pagetable_mask(stackshot_config_t *stackshot_config, uint32_t pagetable_mask)
259*5c2921b0SApple OSS Distributions {
260*5c2921b0SApple OSS Distributions if (stackshot_config == NULL || (void *)stackshot_config->sc_buffer != NULL) {
261*5c2921b0SApple OSS Distributions return -1;
262*5c2921b0SApple OSS Distributions }
263*5c2921b0SApple OSS Distributions
264*5c2921b0SApple OSS Distributions stackshot_config->sc_pagetable_mask = pagetable_mask;
265*5c2921b0SApple OSS Distributions
266*5c2921b0SApple OSS Distributions return 0;
267*5c2921b0SApple OSS Distributions }
268*5c2921b0SApple OSS Distributions
269*5c2921b0SApple OSS Distributions
270*5c2921b0SApple OSS Distributions /*
271*5c2921b0SApple OSS Distributions * stackshot_config_dealloc_buffer: dealloc the stackshot buffer and reset the size so that a
272*5c2921b0SApple OSS Distributions * stackshot_config_t can be used again
273*5c2921b0SApple OSS Distributions *
274*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
275*5c2921b0SApple OSS Distributions *
276*5c2921b0SApple OSS Distributions * Outputs: EINVAL if the passed stackshot_config is NULL or if its buffer is NULL
277*5c2921b0SApple OSS Distributions * 0 otherwise
278*5c2921b0SApple OSS Distributions */
279*5c2921b0SApple OSS Distributions int
stackshot_config_dealloc_buffer(stackshot_config_t * stackshot_config)280*5c2921b0SApple OSS Distributions stackshot_config_dealloc_buffer(stackshot_config_t *stackshot_config)
281*5c2921b0SApple OSS Distributions {
282*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
283*5c2921b0SApple OSS Distributions
284*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
285*5c2921b0SApple OSS Distributions return EINVAL;
286*5c2921b0SApple OSS Distributions }
287*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
288*5c2921b0SApple OSS Distributions
289*5c2921b0SApple OSS Distributions if (s_config->sc_size && s_config->sc_buffer) {
290*5c2921b0SApple OSS Distributions mach_vm_deallocate(mach_task_self(), (mach_vm_offset_t)s_config->sc_buffer, (mach_vm_size_t)s_config->sc_size);
291*5c2921b0SApple OSS Distributions }
292*5c2921b0SApple OSS Distributions
293*5c2921b0SApple OSS Distributions s_config->sc_buffer = 0;
294*5c2921b0SApple OSS Distributions s_config->sc_size = 0;
295*5c2921b0SApple OSS Distributions
296*5c2921b0SApple OSS Distributions return 0;
297*5c2921b0SApple OSS Distributions }
298*5c2921b0SApple OSS Distributions
299*5c2921b0SApple OSS Distributions /*
300*5c2921b0SApple OSS Distributions * stackshot_config_dealloc: dealloc the stackshot buffer and the stackshot config
301*5c2921b0SApple OSS Distributions *
302*5c2921b0SApple OSS Distributions * Inputs: stackshot_config - a pointer to a stackshot_config_t
303*5c2921b0SApple OSS Distributions *
304*5c2921b0SApple OSS Distributions * Outputs: EINVAL if the passed stackshot_cofnig is NULL
305*5c2921b0SApple OSS Distributions * 0 otherwise
306*5c2921b0SApple OSS Distributions */
307*5c2921b0SApple OSS Distributions int
stackshot_config_dealloc(stackshot_config_t * stackshot_config)308*5c2921b0SApple OSS Distributions stackshot_config_dealloc(stackshot_config_t *stackshot_config)
309*5c2921b0SApple OSS Distributions {
310*5c2921b0SApple OSS Distributions stackshot_config_t *s_config;
311*5c2921b0SApple OSS Distributions
312*5c2921b0SApple OSS Distributions if (stackshot_config == NULL) {
313*5c2921b0SApple OSS Distributions return EINVAL;
314*5c2921b0SApple OSS Distributions }
315*5c2921b0SApple OSS Distributions s_config = (stackshot_config_t *) stackshot_config;
316*5c2921b0SApple OSS Distributions
317*5c2921b0SApple OSS Distributions if (s_config->sc_size && s_config->sc_buffer) {
318*5c2921b0SApple OSS Distributions mach_vm_deallocate(mach_task_self(), (mach_vm_offset_t)s_config->sc_buffer, (mach_vm_size_t)s_config->sc_size);
319*5c2921b0SApple OSS Distributions }
320*5c2921b0SApple OSS Distributions
321*5c2921b0SApple OSS Distributions s_config->sc_buffer = 0;
322*5c2921b0SApple OSS Distributions s_config->sc_size = 0;
323*5c2921b0SApple OSS Distributions
324*5c2921b0SApple OSS Distributions free(s_config);
325*5c2921b0SApple OSS Distributions return 0;
326*5c2921b0SApple OSS Distributions }
327