1rctl_walk(3C) Standard C Library Functions rctl_walk(3C)
2
3
4
6 rctl_walk - visit registered rctls on current system
7
9 #include <rctl.h>
10
11 int rctl_walk(int (*callback)(const char *rctlname, void *walk_data),
12 void *init_data);
13
14
16 The rctl_walk() function provides a mechanism for the application
17 author to examine all active resource controls (rctls) on the current
18 system. The callback function provided by the application is given the
19 name of an rctl at each invocation and can use the walk_data to record
20 its own state. The callback function should return non-zero if it
21 encounters an error condition or attempts to terminate the walk prema‐
22 turely; otherwise the callback function should return 0.
23
25 Upon successful completion, rctl_walk() returns 0. It returns −1 if the
26 callback function returned a non-zero value or if the walk encountered
27 an error, in which case errno is set to indicate the error.
28
30 The rctl_walk() function will fail if:
31
32 ENOMEM There is insufficient memory available to set up the initial
33 data for the walk.
34
35
36
37 Other returned error values are presumably caused by the callback func‐
38 tion.
39
41 Example 1 Count the number of rctls available on the system.
42
43
44 The following example counts the number of resource controls on the
45 system.
46
47
48 #include <sys/types.h>
49 #include <rctl.h>
50 #include <stdio.h>
51
52 typedef struct wdata {
53 uint_t count;
54 } wdata_t;
55
56 wdata_t total_count;
57
58 int
59 simple_callback(const char *name, void *pvt)
60 {
61 wdata_t *w = (wdata_t *)pvt;
62 w->count++;
63 return (0);
64 }
65
66 ...
67
68 total_count.count = 0;
69 errno = 0;
70 if (rctl_walk(simple_callback, &total_count)) == 0)
71 (void) printf("count = %u\n", total_count.count);
72
73
75 See attributes(5) for descriptions of the following attributes:
76
77
78
79
80 ┌─────────────────────────────┬─────────────────────────────┐
81 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
82 ├─────────────────────────────┼─────────────────────────────┤
83 │Interface Stability │Evolving │
84 ├─────────────────────────────┼─────────────────────────────┤
85 │MT-Level │MT-Safe │
86 └─────────────────────────────┴─────────────────────────────┘
87
89 setrctl(2), attributes(5)
90
91
92
93SunOS 5.11 2001 rctl_walk(3C)