Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/ptools/common/ptools_common.c
+++ new/usr/src/cmd/ptools/common/ptools_common.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright (c) 2014 Joyent, Inc. All rights reserved.
14 14 */
15 15
16 16 #include <sys/feature_tests.h>
17 17 #include <stdio.h>
18 18 #include <stdarg.h>
19 19 #include <sys/types.h>
20 20 #include <zone.h>
21 21
22 22 /*
23 23 * Common routines for ptools.
24 24 */
25 25
26 26 int
27 27 proc_snprintf(char *_RESTRICT_KYWD s, size_t n,
28 28 const char *_RESTRICT_KYWD fmt, ...)
29 29 {
30 30 static boolean_t ptools_zroot_valid = B_FALSE;
31 31 static const char *ptools_zroot = NULL;
32 32 va_list args;
33 33 int ret, nret = 0;
34 34
35 35 if (ptools_zroot_valid == B_FALSE) {
36 36 ptools_zroot_valid = B_TRUE;
37 37 ptools_zroot = zone_get_nroot();
38 38 }
39 39
40 40 if (ptools_zroot != NULL) {
41 41 nret = snprintf(s, n, "%s", ptools_zroot);
42 42 if (nret > n)
43 43 return (nret);
44 44 }
45 45 va_start(args, fmt);
46 46 ret = vsnprintf(s + nret, n - nret, fmt, args);
47 47 va_end(args);
48 48
49 49 return (ret + nret);
50 50 }
|
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX