1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-1998. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Configuration Space Manager |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The configuration space manager provides a portable |
---|
14 | interface for manipulating configuration data. |
---|
15 | The capabilities in this manager were defined in the POSIX |
---|
16 | 1003.1h/D3 proposed standard titled @b{Services for Reliable, |
---|
17 | Available, and Serviceable Systems}. |
---|
18 | |
---|
19 | The directives provided by the configuration space manager are: |
---|
20 | |
---|
21 | @itemize @bullet |
---|
22 | @item @code{cfg_mount} - Mount a Configuration Space |
---|
23 | @item @code{cfg_unmount} - Unmount a Configuration Space |
---|
24 | @item @code{cfg_mknod} - Create a Configuration Node |
---|
25 | @item @code{cfg_get} - Get Configuration Node Value |
---|
26 | @item @code{cfg_set} - Set Configuration Node Value |
---|
27 | @item @code{cfg_link} - Create a Configuration Link |
---|
28 | @item @code{cfg_unlink} - Remove a Configuration Link |
---|
29 | @item @code{cfg_open} - Open a Configuration Space |
---|
30 | @item @code{cfg_read} - Read a Configuration Space |
---|
31 | @item @code{cfg_children} - Get Node Entries |
---|
32 | @item @code{cfg_mark} - Set Configuration Space Option |
---|
33 | @item @code{cfg_readdir} - Reads a directory |
---|
34 | @item @code{cfg_umask} - Sets a file creation mask |
---|
35 | @item @code{cfg_chmod} - Changes file mode |
---|
36 | @item @code{cfg_chown} - Changes the owner and/or group of a file |
---|
37 | @end itemize |
---|
38 | |
---|
39 | @section Background |
---|
40 | |
---|
41 | @subsection Configuration Nodes |
---|
42 | |
---|
43 | @subsection Configuration Space |
---|
44 | |
---|
45 | @subsection Format of a Configuration Space File |
---|
46 | |
---|
47 | @section Operations |
---|
48 | |
---|
49 | @subsection Mount and Unmounting |
---|
50 | |
---|
51 | @subsection Creating a Configuration Node |
---|
52 | |
---|
53 | @subsection Removing a Configuration Node |
---|
54 | |
---|
55 | @subsection Manipulating a Configuration Node |
---|
56 | |
---|
57 | @subsection Traversing a Configuration Space |
---|
58 | |
---|
59 | @section Directives |
---|
60 | |
---|
61 | This section details the configuration space manager's directives. |
---|
62 | A subsection is dedicated to each of this manager's directives |
---|
63 | and describes the calling sequence, related constants, usage, |
---|
64 | and status codes. |
---|
65 | |
---|
66 | @page |
---|
67 | @subsection cfg_mount - Mount a Configuration Space |
---|
68 | |
---|
69 | @subheading CALLING SEQUENCE: |
---|
70 | |
---|
71 | @ifset is-C |
---|
72 | @example |
---|
73 | #include <cfg.h> |
---|
74 | |
---|
75 | int cfg_mount( |
---|
76 | const char *file, |
---|
77 | const char *cfgpath, |
---|
78 | log_facility_t notification, |
---|
79 | ); |
---|
80 | @end example |
---|
81 | @end ifset |
---|
82 | |
---|
83 | @ifset is-Ada |
---|
84 | @end ifset |
---|
85 | |
---|
86 | @subheading STATUS CODES: |
---|
87 | |
---|
88 | @table @b |
---|
89 | @item EPERM |
---|
90 | The caller does not have the appropriate privilege. |
---|
91 | |
---|
92 | @item EACCES |
---|
93 | Search permission is denied for a component of the path prefix. |
---|
94 | |
---|
95 | @item EEXIST |
---|
96 | The file specified by the file argument does not exist |
---|
97 | |
---|
98 | @item ENAMETOOLONG |
---|
99 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
100 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
101 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
102 | |
---|
103 | @item ENOENT |
---|
104 | A component of @code{cfgpath} does not exist. |
---|
105 | |
---|
106 | @item ENOTDIR |
---|
107 | A component of the file path prefix is not a directory. |
---|
108 | |
---|
109 | @item EBUSY |
---|
110 | The configuration space defined by file is already mounted. |
---|
111 | |
---|
112 | @item EINVAL |
---|
113 | The notification argument specifies an invalid log facility. |
---|
114 | |
---|
115 | @end table |
---|
116 | |
---|
117 | @subheading DESCRIPTION: |
---|
118 | |
---|
119 | The @code{cfg_mount()} function maps a configuration space defined |
---|
120 | by the file identified by the the @code{file} argument. The |
---|
121 | distinguished node of the mapped configuration space is |
---|
122 | mounted in the active space at the point identified by the |
---|
123 | @code{cfgpath} configuration pathname. |
---|
124 | |
---|
125 | The @code{notification} argument specifies how changes to the |
---|
126 | mapped configuration space are communicated to the application. |
---|
127 | If the @code{notification} argument is NULL, no notification will be |
---|
128 | be performed for the mapped configuration space. If the Event |
---|
129 | Logging option is defined, the notification argument defines the |
---|
130 | facility to which changes in the mapped configuration space are |
---|
131 | logged. Otherwise, the @code{notification} argument specifies |
---|
132 | an implementation defined method of notifying the application |
---|
133 | of changes to the mapped configuration space. |
---|
134 | |
---|
135 | @subheading NOTES: |
---|
136 | |
---|
137 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
138 | this service is available. |
---|
139 | |
---|
140 | @page |
---|
141 | @subsection cfg_unmount - Unmount a Configuration Space |
---|
142 | |
---|
143 | @subheading CALLING SEQUENCE: |
---|
144 | |
---|
145 | @ifset is-C |
---|
146 | @example |
---|
147 | #include <cfg.h> |
---|
148 | |
---|
149 | int cfg_unmount( |
---|
150 | const char *cfgpath |
---|
151 | ); |
---|
152 | @end example |
---|
153 | @end ifset |
---|
154 | |
---|
155 | @ifset is-Ada |
---|
156 | @end ifset |
---|
157 | |
---|
158 | @subheading STATUS CODES: |
---|
159 | |
---|
160 | @table @b |
---|
161 | @item EPERM |
---|
162 | The caller does not have the appropriate privileges. |
---|
163 | |
---|
164 | @item EACCES |
---|
165 | Search permission is denied for a component of the path prefix. |
---|
166 | |
---|
167 | @item ENOENT |
---|
168 | A component of cfgpath does not exist. |
---|
169 | |
---|
170 | @item ENAMETOOLONG |
---|
171 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
172 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
173 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
174 | |
---|
175 | @item EINVAL |
---|
176 | The requested node is not the distinguished node of a mounted |
---|
177 | configuration space. |
---|
178 | |
---|
179 | @item EBUSY |
---|
180 | One or more processes has an open configuration traversal |
---|
181 | stream for the configuration space whose distinguished node is |
---|
182 | referenced by the cfgpath argument. |
---|
183 | |
---|
184 | @item ELOOP |
---|
185 | A node appears more than once in the path specified by the |
---|
186 | @code{cfg_path} argument |
---|
187 | |
---|
188 | @item ELOOP |
---|
189 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
190 | resolution of the cfgpath argument |
---|
191 | |
---|
192 | @end table |
---|
193 | |
---|
194 | @subheading DESCRIPTION: |
---|
195 | |
---|
196 | The @code{cfg_umount()} function unmaps the configuration space whose |
---|
197 | distinguished node is mapped in the active space at the location defined |
---|
198 | by @code{cfgpath} configuration pathname. All system resources |
---|
199 | allocated for this configuration space should be deallocated. |
---|
200 | |
---|
201 | @subheading NOTES: |
---|
202 | |
---|
203 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
204 | this service is available. |
---|
205 | |
---|
206 | @page |
---|
207 | @subsection cfg_mknod - Create a Configuration Node |
---|
208 | |
---|
209 | @subheading CALLING SEQUENCE: |
---|
210 | |
---|
211 | @ifset is-C |
---|
212 | @example |
---|
213 | #include <cfg.h> |
---|
214 | |
---|
215 | int cfg_mknod( |
---|
216 | const char *cfgpath, |
---|
217 | mode_t mode, |
---|
218 | cfg_type_t type |
---|
219 | ); |
---|
220 | @end example |
---|
221 | @end ifset |
---|
222 | |
---|
223 | @ifset is-Ada |
---|
224 | @end ifset |
---|
225 | |
---|
226 | @subheading STATUS CODES: |
---|
227 | |
---|
228 | @table @b |
---|
229 | @item ENAMETOOLONG |
---|
230 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
231 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
232 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
233 | |
---|
234 | @item ENOENT |
---|
235 | A component of the path prefix does not exist. |
---|
236 | |
---|
237 | @item EACCES |
---|
238 | Search permission is denied for a component of the path prefix. |
---|
239 | |
---|
240 | @item ELOOP |
---|
241 | Too many symbolic links were encountered in translating the |
---|
242 | pathname. |
---|
243 | |
---|
244 | @item EPERM |
---|
245 | The calling process does not have the appropriate privilege. |
---|
246 | |
---|
247 | @item EEXIST |
---|
248 | The named node exists. |
---|
249 | |
---|
250 | @item EINVAL |
---|
251 | The value of @code{mode} is invalid. |
---|
252 | |
---|
253 | @item EINVAL |
---|
254 | The value of @code{type} is invalid. |
---|
255 | |
---|
256 | @item ELOOP |
---|
257 | A node appears more than once in the path specified by the |
---|
258 | @cdoe{cfg_path} argument |
---|
259 | |
---|
260 | @item ELOOP |
---|
261 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
262 | resolution of the cfgpath argument. |
---|
263 | |
---|
264 | @item EROFS |
---|
265 | The named @code{node} resides on a read-only configuration space. |
---|
266 | |
---|
267 | @end table |
---|
268 | |
---|
269 | @subheading DESCRIPTION: |
---|
270 | |
---|
271 | The @code{cfg_mknod()} function creates a new node in the configuration |
---|
272 | space which contains the pathname prefix of @code{cfgpath}. The node |
---|
273 | name is defined by the pathname suffix of @code{cfgpath}. The node |
---|
274 | permissions are specified by the value of @code{mode}. The node type |
---|
275 | is specified by the value of @code{type}. |
---|
276 | |
---|
277 | @subheading NOTES: |
---|
278 | |
---|
279 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
280 | this service is available. |
---|
281 | |
---|
282 | @page |
---|
283 | @subsection cfg_get - Get Configuration Node Value |
---|
284 | |
---|
285 | @subheading CALLING SEQUENCE: |
---|
286 | |
---|
287 | @ifset is-C |
---|
288 | @example |
---|
289 | #include <cfg.h> |
---|
290 | |
---|
291 | int cfg_get( |
---|
292 | const char *cfgpath |
---|
293 | cfg_value_t *value |
---|
294 | ); |
---|
295 | @end example |
---|
296 | @end ifset |
---|
297 | |
---|
298 | @ifset is-Ada |
---|
299 | @end ifset |
---|
300 | |
---|
301 | @subheading STATUS CODES: |
---|
302 | |
---|
303 | @table @b |
---|
304 | @item ENAMETOOLONG |
---|
305 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
306 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
307 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
308 | |
---|
309 | @item ENOENT |
---|
310 | A component of cfgpath does not exist. |
---|
311 | |
---|
312 | @item EACCES |
---|
313 | Search permission is denied for a component of the path prefix. |
---|
314 | |
---|
315 | @item EPERM |
---|
316 | The calling process does not have the appropriate privileges. |
---|
317 | |
---|
318 | @item ELOOP |
---|
319 | A node appears more than once in the path specified by the |
---|
320 | cfg_path argument |
---|
321 | |
---|
322 | @item ELOOP |
---|
323 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
324 | resolution of the cfgpath argument. |
---|
325 | |
---|
326 | @end table |
---|
327 | |
---|
328 | @subheading DESCRIPTION: |
---|
329 | |
---|
330 | The @code{cfg_get} function stores the value attribute of the |
---|
331 | configuration node identified by @code{cfgpath}, into the buffer |
---|
332 | described by the @code{value} pointer. |
---|
333 | |
---|
334 | @subheading NOTES: |
---|
335 | |
---|
336 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
337 | this service is available. |
---|
338 | |
---|
339 | @page |
---|
340 | @subsection cfg_set - Set Configuration Node Value |
---|
341 | |
---|
342 | @subheading CALLING SEQUENCE: |
---|
343 | |
---|
344 | @ifset is-C |
---|
345 | @example |
---|
346 | #include <cfg.h> |
---|
347 | |
---|
348 | int cfg_set( |
---|
349 | const char *cfgpath |
---|
350 | cfg_value_t *value |
---|
351 | ); |
---|
352 | @end example |
---|
353 | @end ifset |
---|
354 | |
---|
355 | @ifset is-Ada |
---|
356 | @end ifset |
---|
357 | |
---|
358 | @subheading STATUS CODES: |
---|
359 | |
---|
360 | @table @b |
---|
361 | @item ENAMETOOLONG |
---|
362 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
363 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
364 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
365 | |
---|
366 | @item ENOENT |
---|
367 | A component of cfgpath does not exist |
---|
368 | |
---|
369 | @item EACCES |
---|
370 | Search permission is denied for a component of the path prefix. |
---|
371 | |
---|
372 | @item EPERM |
---|
373 | The calling process does not have the appropriate privilege. |
---|
374 | |
---|
375 | @item ELOOP |
---|
376 | A node appears more than once in the path specified by the |
---|
377 | cfg-path argument. |
---|
378 | |
---|
379 | @item ELOOP |
---|
380 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
381 | resolution of the cfgpath argument. |
---|
382 | |
---|
383 | @end table |
---|
384 | |
---|
385 | @subheading DESCRIPTION: |
---|
386 | |
---|
387 | The @code{cfg_set} function stores the value specified by the |
---|
388 | @code{value} argument in the configuration node defined by the |
---|
389 | @code{cfgpath} argument. |
---|
390 | |
---|
391 | @subheading NOTES: |
---|
392 | |
---|
393 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
394 | this service is available. |
---|
395 | |
---|
396 | @page |
---|
397 | @subsection cfg_link - Create a Configuration Link |
---|
398 | |
---|
399 | @subheading CALLING SEQUENCE: |
---|
400 | |
---|
401 | @ifset is-C |
---|
402 | @example |
---|
403 | #include <cfg.h> |
---|
404 | |
---|
405 | int cfg_link( |
---|
406 | const char *src |
---|
407 | const char *dest |
---|
408 | ); |
---|
409 | @end example |
---|
410 | @end ifset |
---|
411 | |
---|
412 | @ifset is-Ada |
---|
413 | @end ifset |
---|
414 | |
---|
415 | @subheading STATUS CODES: |
---|
416 | |
---|
417 | @table @b |
---|
418 | @item ENAMETOOLONG |
---|
419 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
420 | or an entire path name exceed @code{PATH_MAX} characters while |
---|
421 | @code{_POSIX_NO_TRUNC} is in effect. |
---|
422 | |
---|
423 | @item ENOENT |
---|
424 | A component of either path prefix does not exist. |
---|
425 | |
---|
426 | @item EACCES |
---|
427 | A component of either path prefix denies search permission. |
---|
428 | |
---|
429 | @item EACCES |
---|
430 | The requested link requires writing in a node with a mode that |
---|
431 | denies write permission. |
---|
432 | |
---|
433 | @item ENOENT |
---|
434 | The node named by src does not exist. |
---|
435 | |
---|
436 | @item EEXIST |
---|
437 | The node named by dest does exist. |
---|
438 | |
---|
439 | @item EPERM |
---|
440 | The calling process does not have the appropriate privilege to |
---|
441 | modify the node indicated by the src argument. |
---|
442 | |
---|
443 | @item EXDEV |
---|
444 | The link named by dest and the node named by src are from different |
---|
445 | configuration spaces. |
---|
446 | |
---|
447 | @item ENOSPC |
---|
448 | The node in which the entry for the new link is being placed |
---|
449 | cannot be extended because there is no space left on the |
---|
450 | configuration space containing the node. |
---|
451 | |
---|
452 | @item EIO |
---|
453 | An I/O error occurred while reading from or writing to the |
---|
454 | configuration space to make the link entry. |
---|
455 | |
---|
456 | @item EROFS |
---|
457 | The requested link requires writing in a node on a read-only |
---|
458 | configuration space. |
---|
459 | |
---|
460 | @item ELOOP |
---|
461 | A node appears more than once in the path specified by the |
---|
462 | cfg-path argument. |
---|
463 | |
---|
464 | @item ELOOP |
---|
465 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
466 | resolution of the cfgpath argument. |
---|
467 | |
---|
468 | @end table |
---|
469 | |
---|
470 | @subheading DESCRIPTION: |
---|
471 | |
---|
472 | The @code{src} and @code{dest}arguments point to pathnames which |
---|
473 | name existing nodes. The @code{cfg_link} function atomically creates |
---|
474 | a link between specified nodes, and increment by one the link count |
---|
475 | of the node specified by the @code{src} argument. |
---|
476 | |
---|
477 | If the @code{cfg_link} function fails, no link is created, and the |
---|
478 | link count of the node remains unchanged by this function call. |
---|
479 | |
---|
480 | This implementation may require that the calling process has permission |
---|
481 | to access the specified nodes. |
---|
482 | |
---|
483 | @subheading NOTES: |
---|
484 | |
---|
485 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
486 | this service is available. |
---|
487 | |
---|
488 | @page |
---|
489 | @subsection cfg_unlink - Remove a Configuration Link |
---|
490 | |
---|
491 | @subheading CALLING SEQUENCE: |
---|
492 | |
---|
493 | @ifset is-C |
---|
494 | @example |
---|
495 | #include <cfg.h> |
---|
496 | |
---|
497 | int cfg_unlink( |
---|
498 | const char *cfgpath |
---|
499 | ); |
---|
500 | @end example |
---|
501 | @end ifset |
---|
502 | |
---|
503 | @ifset is-Ada |
---|
504 | @end ifset |
---|
505 | |
---|
506 | @subheading STATUS CODES: |
---|
507 | |
---|
508 | @table @b |
---|
509 | @item ENAMETOOLONG |
---|
510 | A component of a pathname exceeded @code{NAME_MAX} characters, |
---|
511 | or an entire path name exceed @code{PATH_MAX} characters. |
---|
512 | |
---|
513 | @item ENOENT |
---|
514 | The named node does not exist. |
---|
515 | |
---|
516 | @item EACCES |
---|
517 | Search permission is denied on the node containing the link to |
---|
518 | be removed. |
---|
519 | |
---|
520 | @item EACCES |
---|
521 | Write permission is denied on the node containing the link to |
---|
522 | be removed. |
---|
523 | |
---|
524 | @item ENOENT |
---|
525 | A component of cfgpath does not exist. |
---|
526 | |
---|
527 | @item EPERM |
---|
528 | The calling process does not have the appropriate privilege to |
---|
529 | modify the node indicated by the path prefix of the cfgpath |
---|
530 | argument. |
---|
531 | |
---|
532 | @item EBUSY |
---|
533 | The node to be unlinked is the distinguished node of a mounted |
---|
534 | configuration space. |
---|
535 | |
---|
536 | @item EIO |
---|
537 | An I/O error occurred while deleting the link entry or deallocating |
---|
538 | the node. |
---|
539 | |
---|
540 | @item EROFS |
---|
541 | The named node resides in a read-only configuration space. |
---|
542 | |
---|
543 | @item ELOOP |
---|
544 | A node appears more than once in the path specified by the |
---|
545 | cfg-path argument. |
---|
546 | |
---|
547 | @item ELOOP |
---|
548 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
549 | resolution of the cfgpath argument. |
---|
550 | |
---|
551 | @end table |
---|
552 | |
---|
553 | @subheading DESCRIPTION: |
---|
554 | |
---|
555 | The @code{cfg_unlink} function removes the link between the node |
---|
556 | specified by the @code{cfgpath} path prefix and the parent node |
---|
557 | specified by @code{cfgpath}, and decrements the link count |
---|
558 | of the @code{cfgpath} node. |
---|
559 | |
---|
560 | When the link count of the node becomes zero, the space occupied |
---|
561 | by the node is freed and the node is no longer be accessible. |
---|
562 | |
---|
563 | @subheading NOTES: |
---|
564 | |
---|
565 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
566 | this service is available. |
---|
567 | |
---|
568 | @page |
---|
569 | @subsection cfg_open - Open a Configuration Space |
---|
570 | |
---|
571 | @subheading CALLING SEQUENCE: |
---|
572 | |
---|
573 | @ifset is-C |
---|
574 | @example |
---|
575 | #include <cfg.h> |
---|
576 | |
---|
577 | int cfg_open( |
---|
578 | const char *pathnames[], |
---|
579 | int options, |
---|
580 | int (*compar)(const CFGENT **f1, const CFGENT **f2), |
---|
581 | CFG **cfgstream |
---|
582 | ); |
---|
583 | @end example |
---|
584 | @end ifset |
---|
585 | |
---|
586 | @ifset is-Ada |
---|
587 | @end ifset |
---|
588 | |
---|
589 | @subheading STATUS CODES: |
---|
590 | |
---|
591 | @table @b |
---|
592 | @item EACCES |
---|
593 | Search permission is denied for any component of a pathname. |
---|
594 | |
---|
595 | @item ELOOP |
---|
596 | A loop exists in symbolic links encountered during resolution |
---|
597 | of a pathname. |
---|
598 | |
---|
599 | @item ENAMETOOLONG |
---|
600 | The length of a pathname exceeds @code{PATH_MAX}, or a pathname |
---|
601 | component is longer than @code{NAME_MAX} while @code{_POSIX_NO_TRUNC} |
---|
602 | |
---|
603 | @item ENOENT |
---|
604 | The pathname argument is an empty string or the named node |
---|
605 | does not exist. |
---|
606 | |
---|
607 | @item EINVAL |
---|
608 | Either both or neither of CFG_LOGICAL and CFG_PHYSICAL are |
---|
609 | specified by the options argument |
---|
610 | |
---|
611 | @item ENOMEM |
---|
612 | Not enough memory is available to create the necessary structures. |
---|
613 | |
---|
614 | @item ELOOP |
---|
615 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
616 | resolution of the pathnames argument. |
---|
617 | |
---|
618 | @item ENAMETOOLONG |
---|
619 | As a result of encountering a symbolic link in resolution of the |
---|
620 | pathname specified by the pathnames argument, the length of |
---|
621 | the substituted pathname string exceeded @code{PATH_MAX}. |
---|
622 | |
---|
623 | @end table |
---|
624 | |
---|
625 | @subheading DESCRIPTION: |
---|
626 | |
---|
627 | The @code{cfg_open} function opens a configuration traversal stream |
---|
628 | rooted in the configuration nodes name by the @code{pathnames} argument. |
---|
629 | It stores a pointer to a CFG object that represents that stream at |
---|
630 | the location identified the @code{cfgstream} pointer. The @code{pathnames} |
---|
631 | argument is an array of character pointers to NULL-terminated strings. |
---|
632 | The last member of this array is a NULL pointer. |
---|
633 | |
---|
634 | The value of @code{options} is the bitwise inclusive OR of values from the |
---|
635 | following lists. Applications supply exactly one of the first two values |
---|
636 | below in @code{options}. |
---|
637 | |
---|
638 | @table @b |
---|
639 | |
---|
640 | @item CFG_LOGICAL |
---|
641 | When symbolic links referencing existing nodes are |
---|
642 | encountered during the traversal, the @code{cfg_info} |
---|
643 | field of the returned CFGENT structure describes the |
---|
644 | target node pointed to by the link instead of the |
---|
645 | link itself, unless the target node does not exist. |
---|
646 | If the target node has children, the pre-order return, |
---|
647 | followed by the return of structures referencing all of |
---|
648 | its descendants, followed by a post-order return, is done. |
---|
649 | |
---|
650 | @item CFG_PHYSICAL |
---|
651 | When symbolic links are encountered during the traversal, |
---|
652 | the @code{cfg_info} field is used to describe the symbolic |
---|
653 | link. |
---|
654 | |
---|
655 | @end table |
---|
656 | |
---|
657 | |
---|
658 | Any combination of the remaining flags can be specified in the value of |
---|
659 | @code{options} |
---|
660 | |
---|
661 | @table @b |
---|
662 | |
---|
663 | @item CFG_COMFOLLOW |
---|
664 | When symbolic links referencing existing nodes are |
---|
665 | specified in the @code{pathnames} argument, the |
---|
666 | @code{cfg_info} field of the returned CFGENT structure |
---|
667 | describes the target node pointed to by the link |
---|
668 | instead of the link itself, unless the target node does |
---|
669 | not exist. If the target node has children, the |
---|
670 | pre-order return, followed by the return of structures |
---|
671 | referencing all its descendants, followed by a post-order |
---|
672 | return, shall be done. |
---|
673 | |
---|
674 | @item CFG_XDEV |
---|
675 | The configuration space functions do not return a |
---|
676 | CFGENT structure for any node in a different configuration |
---|
677 | space than the configuration space of the nodes identified |
---|
678 | by the CFGENT structures for the @code{pathnames} argument. |
---|
679 | |
---|
680 | @end table |
---|
681 | |
---|
682 | The @code{cfg_open} argument @code{compar} is either a NULL or point |
---|
683 | to a function that is called with two pointers to pointers to CFGENT |
---|
684 | structures that returns less than, equal to , or greater than zero if |
---|
685 | the node referenced by the first argument is considered to be respectively |
---|
686 | less than, equal to, or greater than the node referenced by the second. |
---|
687 | The CFGENT structure fields provided to the comparison routine is as |
---|
688 | described with the exception that the contents of the @code{cfg_path} and |
---|
689 | @code{cfg_pathlen} fields are unspecified. |
---|
690 | |
---|
691 | This comparison routine is used to determine the order in which nodes in |
---|
692 | directories encountered during the traversal are returned, and the order |
---|
693 | of traversal when more than one node is specified in the @code{pathnames} |
---|
694 | argument to @code{cfg_open}. If a comparison routine is specified, the |
---|
695 | order of traversal is from the least to the greatest. If the @code{compar} |
---|
696 | argument is NULL, the order of traversal shall be as listed in the |
---|
697 | @code{pathnames} argument. |
---|
698 | |
---|
699 | @subheading NOTES: |
---|
700 | |
---|
701 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
702 | this service is available. |
---|
703 | |
---|
704 | @page |
---|
705 | @subsection cfg_read - Read a Configuration Space |
---|
706 | |
---|
707 | @subheading CALLING SEQUENCE: |
---|
708 | |
---|
709 | @ifset is-C |
---|
710 | @example |
---|
711 | #include <cfg.h> |
---|
712 | |
---|
713 | int cfg_read( |
---|
714 | CFG *cfgp, |
---|
715 | CFGENT **node |
---|
716 | ); |
---|
717 | @end example |
---|
718 | @end ifset |
---|
719 | |
---|
720 | @ifset is-Ada |
---|
721 | @end ifset |
---|
722 | |
---|
723 | @subheading STATUS CODES: |
---|
724 | |
---|
725 | @table @b |
---|
726 | @item EACCES |
---|
727 | Search permission is denied for any component of a pathname. |
---|
728 | |
---|
729 | @item EBADF |
---|
730 | The cfgp argument does not refer to an open configuration |
---|
731 | space. |
---|
732 | |
---|
733 | @item ELOOP |
---|
734 | A loop exists in symbolic links encountered during resolution |
---|
735 | of a pathname. |
---|
736 | |
---|
737 | @item ENOENT |
---|
738 | A named node does not exist. |
---|
739 | |
---|
740 | @item ENOMEM |
---|
741 | Not enough memory is available to create the necessary structures. |
---|
742 | |
---|
743 | @item ELOOP |
---|
744 | More than @code{SYMLOOP_MAX} symbolic links were encountered during |
---|
745 | resolution of the cfgpath argument. |
---|
746 | |
---|
747 | @item ENAMETOOLONG |
---|
748 | As a result of encountering a symbolic link in resolution of the |
---|
749 | pathname specified by the pathnames argument, the length of the |
---|
750 | substituted pathname string exceeded @code{PATH_MATH}. |
---|
751 | |
---|
752 | @end table |
---|
753 | |
---|
754 | @subheading DESCRIPTION: |
---|
755 | |
---|
756 | The @code{cfg_read} function returns a pointer to a CFGENT structure |
---|
757 | representing a node in the configuration space to which @code{cfgp} |
---|
758 | refers. The returned pointer is stored at the location indicated |
---|
759 | by the @code{node} argument. |
---|
760 | |
---|
761 | The child nodes of each node in the configuration tree is returned |
---|
762 | by @code{cfg_read}. If a comparison routine is specified to the |
---|
763 | @code{cfg_open} function, the order of return of the child nodes is |
---|
764 | as specified by the routine, from least to greatest. Otherwise |
---|
765 | the order of return is unspecified. |
---|
766 | |
---|
767 | Structures referencing nodes with children is returned by the |
---|
768 | function @code{cfg_read} at least twice [unless the application |
---|
769 | specifies otherwise with @code{cfg_mark}]-once immediately before |
---|
770 | the structures representing their descendants, are returned |
---|
771 | (pre-order), and once immediately after structures representing all |
---|
772 | of their descendants, if any, are returned (post-order). The |
---|
773 | CFGENT structure returned in post-order (with the exception of the |
---|
774 | @code{cfg_info} field) is identical to that returned in pre-order. |
---|
775 | Structures referencing nodes of other types is returned at least |
---|
776 | once. |
---|
777 | |
---|
778 | The fields of the CFGENT structure contains the following |
---|
779 | information: |
---|
780 | |
---|
781 | @table @b |
---|
782 | |
---|
783 | @item cfg_parent |
---|
784 | A pointer to the structure returned by the |
---|
785 | @code{cfg_read} function for the node that contains |
---|
786 | the entry for the current node. A @code{cfg_parent} |
---|
787 | structure is provided for the node(s) specified by |
---|
788 | the @code{pathnames} argument to the @code{cfg_open} |
---|
789 | function, but the contents of other than its |
---|
790 | @code{cfg_number}, @code{cfg_pointer}, @code{cfg_parent}, |
---|
791 | and @code{cfg_parent}, and @code{cfg_level} fields are |
---|
792 | unspecified. Its @code{cfg_link} field is unspecified. |
---|
793 | |
---|
794 | @item cfg_link |
---|
795 | Upon return from the @code{cfg_children} function, the |
---|
796 | @code{cfg_link} field points to the next CFGENT structure |
---|
797 | in a NULL-terminated linked list of CFGENT structures. |
---|
798 | Otherwise, the content of the @code{cfg_link} field is |
---|
799 | unspecified. |
---|
800 | |
---|
801 | @item cfg_cycle |
---|
802 | If the structure being returned by @code{cfg_read} |
---|
803 | represents a node that appears in the @code{cfg_parent} |
---|
804 | linked list tree, the @code{cfg_cycle} field shall point |
---|
805 | to the structure representing that entry from the |
---|
806 | @code{cfg_parent} linked list. Otherwise the content of |
---|
807 | the @code{cfg_cycle} field is unspecified. |
---|
808 | |
---|
809 | @item cfg_number |
---|
810 | The @code{cfg_number} field is provided for use by the |
---|
811 | application program. It is initialized to zero for |
---|
812 | each new node returned by the @code{cfg_read} function, |
---|
813 | but is not further modified by the configuration space |
---|
814 | routines. |
---|
815 | |
---|
816 | @item cfg_pointer |
---|
817 | The @code{cfg_pointer} field is provided for use by the |
---|
818 | application program. It is initialized to NULL for |
---|
819 | each new node returned by the @code{cfg_read} function, |
---|
820 | but is not further modified by the configuration |
---|
821 | space routines. |
---|
822 | |
---|
823 | @item cfg_path |
---|
824 | A pathname for the node including and relative to the |
---|
825 | argument supplied to the @code{cfg_open} routine for this |
---|
826 | configuration space. This pathname may be longer than |
---|
827 | @code{PATH_MAX} bytes. This pathname is NULL-terminated. |
---|
828 | |
---|
829 | @item cfg_name |
---|
830 | The nodename of the node. |
---|
831 | |
---|
832 | @item cfg_pathlen |
---|
833 | The length of the string pointed at by the @code{cfg_path} |
---|
834 | field when returned by @code{cfg_read}. |
---|
835 | |
---|
836 | @item cfg_namelen |
---|
837 | The length of the string pointed at by the @code{cfg_name} |
---|
838 | field. |
---|
839 | |
---|
840 | @item cfg_level |
---|
841 | The depth of the current entry in the configuration space. |
---|
842 | The @code{cfg_level} field of the @code{cfg_parent} |
---|
843 | structure for each of the node(s) specified in the |
---|
844 | @code{pathnames} argument to the @code{cfg_open} function |
---|
845 | is set to 0, and this number is incremented for each |
---|
846 | node level descendant. |
---|
847 | |
---|
848 | @item cfg_info |
---|
849 | This field contains one of the values listed below. If |
---|
850 | an object can have more than one info value, the first |
---|
851 | appropriate value listed below is returned. |
---|
852 | |
---|
853 | @table @b |
---|
854 | |
---|
855 | @item CFG_D |
---|
856 | The structure represents a node with children in |
---|
857 | pre-order. |
---|
858 | |
---|
859 | @item CFG_DC |
---|
860 | The structure represents a node that is a parent |
---|
861 | of the node most recently returned by @code{cfg_read}. |
---|
862 | The @code{cfg_cycle} field references the structure |
---|
863 | previously returned by @code{cfg_read} that is the |
---|
864 | same as the returned structure. |
---|
865 | |
---|
866 | @item CFG_DEFAULT |
---|
867 | The structure represents a node that is not |
---|
868 | represented by one of the other node types |
---|
869 | |
---|
870 | @item CFG_DNR |
---|
871 | The structure represents a node, not of type symlink, |
---|
872 | that is unreadable. The variable @code{cfg_errno} |
---|
873 | is set to the appropriate value. |
---|
874 | |
---|
875 | @item CFG_DP |
---|
876 | The structure represents a node with children in |
---|
877 | post-order. This value occurs only if CFG_D |
---|
878 | has previously been returned for this entry. |
---|
879 | |
---|
880 | @item CFG_ERR |
---|
881 | The structure represents a node for which an error has |
---|
882 | occurred. The variable @code{cfg_errno} is set to the |
---|
883 | appropriate value. |
---|
884 | |
---|
885 | @item CFG_F |
---|
886 | The structure represents a node without children. |
---|
887 | |
---|
888 | @item CFG_SL |
---|
889 | The structure represents a node of type symbolic link. |
---|
890 | |
---|
891 | @item CFG_SLNONET |
---|
892 | The structure represents a node of type symbolic link |
---|
893 | with a target node for which node characteristic |
---|
894 | information cannot be obtained. |
---|
895 | |
---|
896 | @end table |
---|
897 | |
---|
898 | @end table |
---|
899 | |
---|
900 | Structures returned by @code{cfg_read} with a @code{cfg_info} field equal |
---|
901 | to CFG_D is accessible until a subsequent call, on the same |
---|
902 | configuration traversal stream, to @code{cfg_close}, or to @code{cfg_read} |
---|
903 | after they have been returned by the @code{cfg_read} function in |
---|
904 | post-order. Structures returned by @code{cfg_read} with an |
---|
905 | @code{cfg_info} field not equal to CFG_D is accessible until a subsequent |
---|
906 | call, on the same configuration traversal stream, to @code{cfg_close} |
---|
907 | or @code{cfg_read}. |
---|
908 | |
---|
909 | The content of the @code{cfg_path} field is specified only for the |
---|
910 | structure most recently returned by @code{cfg_read}. |
---|
911 | |
---|
912 | The specified fields in structures in the list representing nodes for |
---|
913 | which structures have previously been returned by @code{cfg_children}, |
---|
914 | is identical to those returned by @code{cfg_children}, except that |
---|
915 | the contents of the @code{cfg_path} and @code{cfg_pathlen} fields are |
---|
916 | unspecified. |
---|
917 | |
---|
918 | @subheading NOTES: |
---|
919 | |
---|
920 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
921 | this service is available. |
---|
922 | |
---|
923 | @page |
---|
924 | @subsection cfg_children - Get Node Entries |
---|
925 | |
---|
926 | @subheading CALLING SEQUENCE: |
---|
927 | |
---|
928 | @ifset is-C |
---|
929 | @example |
---|
930 | #include <cfg.h> |
---|
931 | |
---|
932 | int cfg_children( |
---|
933 | CFG *cfgp, |
---|
934 | int options, |
---|
935 | CFGENT **children |
---|
936 | ); |
---|
937 | @end example |
---|
938 | @end ifset |
---|
939 | |
---|
940 | @ifset is-Ada |
---|
941 | @end ifset |
---|
942 | |
---|
943 | @subheading STATUS CODES: |
---|
944 | |
---|
945 | @table @b |
---|
946 | @item EACCES |
---|
947 | Search permission is denied for any component of a pathname |
---|
948 | |
---|
949 | @item EBADF |
---|
950 | The cfgp argument does not refer to an open configuration space. |
---|
951 | |
---|
952 | @item ELOOP |
---|
953 | A loop exists in symbolic links encountered during resolution of |
---|
954 | a pathname. |
---|
955 | |
---|
956 | @item ENAMETOOLONG |
---|
957 | The length of a pathname exceeds @code{PATH_MAX}, or a pathname |
---|
958 | component is longer than @code{NAME_MAX} while @code{_POSIX_NO_TRUNC} is |
---|
959 | in effect. |
---|
960 | |
---|
961 | @item EINVAL |
---|
962 | The specified value of the options argument is invalid. |
---|
963 | |
---|
964 | @item ENOENT |
---|
965 | The named node does not exist. |
---|
966 | |
---|
967 | @item ENOMEM |
---|
968 | Not enough memory is available to create the necessary structures. |
---|
969 | |
---|
970 | @end table |
---|
971 | |
---|
972 | @subheading DESCRIPTION: |
---|
973 | |
---|
974 | The first @code{cfg_children} call after a @code{cfg_read} returns |
---|
975 | information about the first node without children under the node |
---|
976 | returned by @code{cfg_read}. Subsequent calls to @code{cfg_children} |
---|
977 | without the intervening @code{cfg_read} shall return information |
---|
978 | about the remaining nodes without children under that same node. |
---|
979 | |
---|
980 | If @code{cfg_read} has not yet been called for the configuration |
---|
981 | traversal stream represented by @code{cfgp}, @code{cfg_children} |
---|
982 | returns a pointer to the first entry in a list of the nodes |
---|
983 | represented by the @code{pathnames} argument to @code{cfg_open}. |
---|
984 | |
---|
985 | In either case, the list is NULL-terminated, ordered by the |
---|
986 | user-specified comparison function, if any, and linked through the |
---|
987 | cfg_link field. |
---|
988 | |
---|
989 | @subheading NOTES: |
---|
990 | |
---|
991 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
992 | this service is available. |
---|
993 | |
---|
994 | @page |
---|
995 | @subsection cfg_mark - Set Configuration Space Options |
---|
996 | |
---|
997 | @subheading CALLING SEQUENCE: |
---|
998 | |
---|
999 | @ifset is-C |
---|
1000 | @example |
---|
1001 | #include <cfg.h> |
---|
1002 | |
---|
1003 | int cfg_mark( |
---|
1004 | CFG *cfgp, |
---|
1005 | CFGENT *f, |
---|
1006 | int options |
---|
1007 | ); |
---|
1008 | @end example |
---|
1009 | @end ifset |
---|
1010 | |
---|
1011 | @ifset is-Ada |
---|
1012 | @end ifset |
---|
1013 | |
---|
1014 | @subheading STATUS CODES: |
---|
1015 | |
---|
1016 | @table @b |
---|
1017 | @item EINVAL |
---|
1018 | The specified combination of the cfgp and f arguments is not |
---|
1019 | supported by the implementation. |
---|
1020 | |
---|
1021 | @item EINVAL |
---|
1022 | The specified value of the options argument is invalid. |
---|
1023 | |
---|
1024 | @end table |
---|
1025 | |
---|
1026 | @subheading DESCRIPTION: |
---|
1027 | |
---|
1028 | The @code{cfg_mark} function modifies the subsequent behavior of |
---|
1029 | the cfg functions with regard to the node referenced by the structure |
---|
1030 | pointed to by the argument @code{f} or the configuration space referenced |
---|
1031 | by the structure pointed to by the argument @code{cfgp}. |
---|
1032 | |
---|
1033 | Exactly one of the @code{f} argument and the @code{cfgp} argument is NULL. |
---|
1034 | |
---|
1035 | The value of the @code{options} argument is exactly one of the flags |
---|
1036 | specified in the following list: |
---|
1037 | |
---|
1038 | @table @b |
---|
1039 | |
---|
1040 | @item CFG_AGAIN |
---|
1041 | If the @code{cfgp} argument is non-NULL, or the @code{f} |
---|
1042 | argument is NULL, or the structure referenced by @code{f} |
---|
1043 | is not the one most recently returned by @code{cfg_read}, |
---|
1044 | @code{cfg_mark} returns an error. Otherwise, the next |
---|
1045 | call to the @code{cfg_read} function returns the structure |
---|
1046 | referenced by @code{f} with the @code{cfg_info} field |
---|
1047 | reinitialized. Subsequent behavior of the @code{cfg} |
---|
1048 | functions are based on the reinitialized value of |
---|
1049 | @code{cfg_info}. |
---|
1050 | |
---|
1051 | @item CFG_SKIP |
---|
1052 | If the @code{cfgp} argument is non-NULL, or the @code{f} |
---|
1053 | argument is NULL, or the structure referenced by @code{f} |
---|
1054 | is not one of those specified as accessible, or the structure |
---|
1055 | referenced by @code{f} is not for a node of type pre-order |
---|
1056 | node, @code{cfg_mark} returns an error. Otherwise, no |
---|
1057 | more structures for the node referenced by @code{f} or its |
---|
1058 | descendants are returned by the @code{cfg_read} function. |
---|
1059 | |
---|
1060 | @item CFG_FOLLOW |
---|
1061 | If the @code{cfgp} argument is non-NULL, or the @code{f} |
---|
1062 | argument is NULL, or the structure referenced by @code{f} |
---|
1063 | is not one of those specified as accessible, or the structure |
---|
1064 | referenced by @code{f} is not for a node of type symbolic link, |
---|
1065 | @code{cfg_mark} returns an error. Otherwise, the next |
---|
1066 | call to the @code{cfg_read} function returns the structure |
---|
1067 | referenced by @code{f} with the @code{cfg_info} field reset |
---|
1068 | to reflect the target of the symbolic link instead of the |
---|
1069 | symbolic link itself. If the target of the link is node with |
---|
1070 | children, the pre-order return, followed by the return of |
---|
1071 | structures referencing all of its descendants, followed by a |
---|
1072 | post-order return, shall be done. |
---|
1073 | |
---|
1074 | @end table |
---|
1075 | |
---|
1076 | If the target of the symbolic link does not exist, the fields |
---|
1077 | of the structure by @code{cfg_read} shall be unmodified, except |
---|
1078 | that the @code{cfg_info} field shall be reset to @code{CFG_SLNONE}. |
---|
1079 | |
---|
1080 | @subheading NOTES: |
---|
1081 | |
---|
1082 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
1083 | this service is available. |
---|
1084 | |
---|
1085 | @page |
---|
1086 | @subsection cfg_close - Close a Configuration Space |
---|
1087 | |
---|
1088 | @subheading CALLING SEQUENCE: |
---|
1089 | |
---|
1090 | @ifset is-C |
---|
1091 | @example |
---|
1092 | #include <cfg.h> |
---|
1093 | |
---|
1094 | int cfg_close( |
---|
1095 | CFG *cfgp |
---|
1096 | ); |
---|
1097 | @end example |
---|
1098 | @end ifset |
---|
1099 | |
---|
1100 | @ifset is-Ada |
---|
1101 | @end ifset |
---|
1102 | |
---|
1103 | @subheading STATUS CODES: |
---|
1104 | |
---|
1105 | @table @b |
---|
1106 | @item EBADF |
---|
1107 | The cfgp argument does not refer to an open configuration space |
---|
1108 | traversal stream. |
---|
1109 | |
---|
1110 | @end table |
---|
1111 | |
---|
1112 | @subheading DESCRIPTION: |
---|
1113 | |
---|
1114 | The @code{cfg_close} function closes a configuration space transversal |
---|
1115 | stream represented by the CFG structure pointed at by the @code{cfgp} |
---|
1116 | argument. All system resources allocated for this configuration space |
---|
1117 | traversal stream should be deallocated. Upon return, the value of |
---|
1118 | @code{cfgp} need not point to an accessible object of type CFG. |
---|
1119 | |
---|
1120 | @subheading NOTES: |
---|
1121 | |
---|
1122 | The @code{_POSIX_CFG} feature flag is defined to indicate |
---|
1123 | this service is available. |
---|
1124 | |
---|
1125 | @page |
---|
1126 | @subsection cfg_readdir - Reads a directory |
---|
1127 | |
---|
1128 | @subheading CALLING SEQUENCE: |
---|
1129 | |
---|
1130 | @ifset is-C |
---|
1131 | @example |
---|
1132 | #include <sys/types.h> |
---|
1133 | #include <dirent.h> |
---|
1134 | |
---|
1135 | struct dirent *cfg_readdir( |
---|
1136 | DIR *dirp |
---|
1137 | ); |
---|
1138 | @end example |
---|
1139 | @end ifset |
---|
1140 | |
---|
1141 | @ifset is-Ada |
---|
1142 | @end ifset |
---|
1143 | |
---|
1144 | @subheading STATUS CODES: |
---|
1145 | |
---|
1146 | @table @b |
---|
1147 | @item EBADF |
---|
1148 | Invalid file descriptor |
---|
1149 | |
---|
1150 | @end table |
---|
1151 | |
---|
1152 | @subheading DESCRIPTION: |
---|
1153 | |
---|
1154 | The @code{cfg_readdir} function returns a pointer to a structure @code{dirent} |
---|
1155 | representing the next directory entry from the directory stream pointed to |
---|
1156 | by @code{dirp}. On end-of-file, NULL is returned. |
---|
1157 | |
---|
1158 | The @code{cfg_readdir} function may (or may not) return entries for . or .. Your |
---|
1159 | program should tolerate reading dot and dot-dot but not require them. |
---|
1160 | |
---|
1161 | The data pointed to be @code{cfg_readdir} may be overwritten by another call to |
---|
1162 | @code{readdir} for the same directory stream. It will not be overwritten by |
---|
1163 | a call for another directory. |
---|
1164 | |
---|
1165 | @subheading NOTES: |
---|
1166 | |
---|
1167 | If ptr is not a pointer returned by @code{malloc}, @code{calloc}, or |
---|
1168 | @code{realloc} or has been deallocated with @code{free} or @code{realloc}, |
---|
1169 | the results are not portable and are probably disastrous. |
---|
1170 | |
---|
1171 | @page |
---|
1172 | @subsection open - Opens a file |
---|
1173 | |
---|
1174 | @subheading CALLING SEQUENCE: |
---|
1175 | |
---|
1176 | @ifset is-C |
---|
1177 | @example |
---|
1178 | #include <sys/types.h> |
---|
1179 | #include <sys/stat.h> |
---|
1180 | #include <fcntl.h> |
---|
1181 | |
---|
1182 | int open( |
---|
1183 | const char *path, |
---|
1184 | int oflag, |
---|
1185 | mode_t mode |
---|
1186 | ); |
---|
1187 | @end example |
---|
1188 | @end ifset |
---|
1189 | |
---|
1190 | @ifset is-Ada |
---|
1191 | @end ifset |
---|
1192 | |
---|
1193 | @subheading STATUS CODES: |
---|
1194 | |
---|
1195 | @table @b |
---|
1196 | @item EACCES |
---|
1197 | Search permission is denied for a directory in a file's path prefix |
---|
1198 | @item EEXIST |
---|
1199 | The named file already exists. |
---|
1200 | @item EINTR |
---|
1201 | Function was interrupted by a signal. |
---|
1202 | @item EISDIR |
---|
1203 | Attempt to open a directory for writing or to rename a file to be a |
---|
1204 | directory. |
---|
1205 | @item EMFILE |
---|
1206 | Too many file descriptors are in use by this process. |
---|
1207 | @item ENAMETOOLONG |
---|
1208 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1209 | effect. |
---|
1210 | @item ENFILE |
---|
1211 | Too many files are currently open in the system. |
---|
1212 | @item ENOENT |
---|
1213 | A file or directory does not exist. |
---|
1214 | @item ENOSPC |
---|
1215 | No space left on disk. |
---|
1216 | @item ENOTDIR |
---|
1217 | A component of the specified pathname was not a directory when a directory |
---|
1218 | was expected. |
---|
1219 | @item ENXIO |
---|
1220 | No such device. This error may also occur when a device is not ready, for |
---|
1221 | example, a tape drive is off-line. |
---|
1222 | @item EROFS |
---|
1223 | Read-only file system. |
---|
1224 | @end table |
---|
1225 | |
---|
1226 | @subheading DESCRIPTION: |
---|
1227 | |
---|
1228 | The @code{open} function establishes a connection between a file and a file |
---|
1229 | descriptor. The file descriptor is a small integer that is used by I/O |
---|
1230 | functions to reference the file. The @code{path} argument points to the |
---|
1231 | pathname for the file. |
---|
1232 | |
---|
1233 | The @code{oflag} argument is the bitwise inclusive OR of the values of |
---|
1234 | symbolic constants. The programmer must specify exactly one of the following |
---|
1235 | three symbols: |
---|
1236 | |
---|
1237 | @table @b |
---|
1238 | @item O_RDONLY |
---|
1239 | Open for reading only. |
---|
1240 | |
---|
1241 | @item O_WRONLY |
---|
1242 | Open for writing only. |
---|
1243 | |
---|
1244 | @item O_RDWR |
---|
1245 | Open for reading and writing. |
---|
1246 | |
---|
1247 | @end table |
---|
1248 | |
---|
1249 | Any combination of the following symbols may also be used. |
---|
1250 | |
---|
1251 | @table @b |
---|
1252 | @item O_APPEND |
---|
1253 | Set the file offset to the end-of-file prior to each write. |
---|
1254 | |
---|
1255 | @item O_CREAT |
---|
1256 | If the file does not exist, allow it to be created. This flag indicates |
---|
1257 | that the @code{mode} argument is present in the call to @code{open}. |
---|
1258 | |
---|
1259 | @item O_EXCL |
---|
1260 | This flag may be used only if O_CREAT is also set. It causes the call |
---|
1261 | to @code{open} to fail if the file already exists. |
---|
1262 | |
---|
1263 | @item O_NOCTTY |
---|
1264 | If @code{path} identifies a terminal, this flag prevents that teminal from |
---|
1265 | becoming the controlling terminal for thi9s process. See Chapter 8 for a |
---|
1266 | description of terminal I/O. |
---|
1267 | |
---|
1268 | @item O_NONBLOCK |
---|
1269 | Do no wait for the device or file to be ready or available. After the file |
---|
1270 | is open, the @code{read} and @code{write} calls return immediately. If the |
---|
1271 | process would be delayed in the read or write opermation, -1 is returned and |
---|
1272 | @code{errno} is set to @code{EAGAIN} instead of blocking the caller. |
---|
1273 | |
---|
1274 | @item O_TRUNC |
---|
1275 | This flag should be used only on ordinary files opened for writing. It |
---|
1276 | causes the file to be tuncated to zero length.. |
---|
1277 | |
---|
1278 | @end table |
---|
1279 | |
---|
1280 | Upon successful completion, @code{open} returns a non-negative file |
---|
1281 | descriptor. |
---|
1282 | |
---|
1283 | @subheading NOTES: |
---|
1284 | |
---|
1285 | @page |
---|
1286 | @subsection cfg_umask - Sets a file creation mask. |
---|
1287 | |
---|
1288 | @subheading CALLING SEQUENCE: |
---|
1289 | |
---|
1290 | @ifset is-C |
---|
1291 | @example |
---|
1292 | #include <sys/types.h> |
---|
1293 | #include <sys/stat.h> |
---|
1294 | |
---|
1295 | mode_t cfg_umask( |
---|
1296 | mode_t cmask |
---|
1297 | ); |
---|
1298 | @end example |
---|
1299 | @end ifset |
---|
1300 | |
---|
1301 | @ifset is-Ada |
---|
1302 | @end ifset |
---|
1303 | |
---|
1304 | @subheading STATUS CODES: |
---|
1305 | |
---|
1306 | @subheading DESCRIPTION: |
---|
1307 | |
---|
1308 | The @code{cfg_umask} function sets the process file creation mask to @code{cmask}. |
---|
1309 | The file creation mask is used during @code{open}, @code{creat}, @code{mkdir}, |
---|
1310 | @code{mkfifo} calls to turn off permission bits in the @code{mode} argument. |
---|
1311 | Bit positions that are set in @code{cmask} are cleared in the mode of the |
---|
1312 | created file. |
---|
1313 | |
---|
1314 | The file creation mask is inherited across @code{fork} and @code{exec} calls. |
---|
1315 | This makes it possible to alter the default permission bits of created files. |
---|
1316 | |
---|
1317 | @subheading NOTES: |
---|
1318 | |
---|
1319 | The @code{cmask} argument should have only permission bits set. All other |
---|
1320 | bits should be zero. |
---|
1321 | |
---|
1322 | @page |
---|
1323 | @subsection link - Creates a link to a file |
---|
1324 | |
---|
1325 | @subheading CALLING SEQUENCE: |
---|
1326 | |
---|
1327 | @ifset is-C |
---|
1328 | @example |
---|
1329 | #include <unistd.h> |
---|
1330 | |
---|
1331 | int link( |
---|
1332 | const char *existing, |
---|
1333 | const char *new |
---|
1334 | ); |
---|
1335 | @end example |
---|
1336 | @end ifset |
---|
1337 | |
---|
1338 | @ifset is-Ada |
---|
1339 | @end ifset |
---|
1340 | |
---|
1341 | @subheading STATUS CODES: |
---|
1342 | |
---|
1343 | @table @b |
---|
1344 | @item EACCES |
---|
1345 | Search permission is denied for a directory in a file's path prefix |
---|
1346 | @item EEXIST |
---|
1347 | The named file already exists. |
---|
1348 | @item EMLINK |
---|
1349 | The number of links would exceed @code{LINK_MAX}. |
---|
1350 | @item ENAMETOOLONG |
---|
1351 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1352 | effect. |
---|
1353 | @item ENOENT |
---|
1354 | A file or directory does not exist. |
---|
1355 | @item ENOSPC |
---|
1356 | No space left on disk. |
---|
1357 | @item ENOTDIR |
---|
1358 | A component of the specified pathname was not a directory when a directory |
---|
1359 | was expected. |
---|
1360 | @item EPERM |
---|
1361 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1362 | or permissions to perform the requested operations. |
---|
1363 | @item EROFS |
---|
1364 | Read-only file system. |
---|
1365 | @item EXDEV |
---|
1366 | Attempt to link a file to another file system. |
---|
1367 | |
---|
1368 | @end table |
---|
1369 | |
---|
1370 | @subheading DESCRIPTION: |
---|
1371 | |
---|
1372 | The @code{link} function atomically creates a new link for an existing file |
---|
1373 | and increments the link count for the file. |
---|
1374 | |
---|
1375 | If the @code{link} function fails, no directories are modified. |
---|
1376 | |
---|
1377 | The @code{existing} argument should not be a directory. |
---|
1378 | |
---|
1379 | The callder may (or may not) need permission to access the existing file. |
---|
1380 | |
---|
1381 | @subheading NOTES: |
---|
1382 | |
---|
1383 | @page |
---|
1384 | @subsection unlink - Removes a directory entry |
---|
1385 | |
---|
1386 | @subheading CALLING SEQUENCE: |
---|
1387 | |
---|
1388 | @ifset is-C |
---|
1389 | @example |
---|
1390 | #include <unistd.h> |
---|
1391 | |
---|
1392 | int unlink( |
---|
1393 | const char path |
---|
1394 | ); |
---|
1395 | @end example |
---|
1396 | @end ifset |
---|
1397 | |
---|
1398 | @ifset is-Ada |
---|
1399 | @end ifset |
---|
1400 | |
---|
1401 | @subheading STATUS CODES: |
---|
1402 | |
---|
1403 | @table @b |
---|
1404 | @item EACCES |
---|
1405 | Search permission is denied for a directory in a file's path prefix |
---|
1406 | @item EBUSY |
---|
1407 | The directory is in use. |
---|
1408 | @item ENAMETOOLONG |
---|
1409 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1410 | effect. |
---|
1411 | @item ENOENT |
---|
1412 | A file or directory does not exist. |
---|
1413 | @item ENOTDIR |
---|
1414 | A component of the specified pathname was not a directory when a directory |
---|
1415 | was expected. |
---|
1416 | @item EPERM |
---|
1417 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1418 | or permissions to perform the requested operations. |
---|
1419 | @item EROFS |
---|
1420 | Read-only file system. |
---|
1421 | |
---|
1422 | @end table |
---|
1423 | |
---|
1424 | @subheading DESCRIPTION: |
---|
1425 | |
---|
1426 | The @code{unlink} function removes the link named by @{code} and decrements the |
---|
1427 | link count of the file referenced by the link. When the link count goes to zero |
---|
1428 | and no process has the file open, the space occupied by the file is freed and the |
---|
1429 | file is no longer accessible. |
---|
1430 | |
---|
1431 | @subheading NOTES: |
---|
1432 | |
---|
1433 | @page |
---|
1434 | @subsection cfg_mkdir - Makes a directory |
---|
1435 | |
---|
1436 | @subheading CALLING SEQUENCE: |
---|
1437 | |
---|
1438 | @ifset is-C |
---|
1439 | @example |
---|
1440 | #include <sys/types.h> |
---|
1441 | #include <sys/stat.h> |
---|
1442 | |
---|
1443 | int cfg_mkdir( |
---|
1444 | const char *path, |
---|
1445 | mode_t mode |
---|
1446 | ); |
---|
1447 | @end example |
---|
1448 | @end ifset |
---|
1449 | |
---|
1450 | @ifset is-Ada |
---|
1451 | @end ifset |
---|
1452 | |
---|
1453 | @subheading STATUS CODES: |
---|
1454 | |
---|
1455 | @table @b |
---|
1456 | @item EACCES |
---|
1457 | Search permission is denied for a directory in a file's path prefix |
---|
1458 | @item EEXIST |
---|
1459 | The name file already exist. |
---|
1460 | @item EMLINK |
---|
1461 | The number of links would exceed LINK_MAX |
---|
1462 | @item ENAMETOOLONG |
---|
1463 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1464 | effect. |
---|
1465 | @item ENOENT |
---|
1466 | A file or directory does not exist. |
---|
1467 | @item ENOSPC |
---|
1468 | No space left on disk. |
---|
1469 | @item ENOTDIR |
---|
1470 | A component of the specified pathname was not a directory when a directory |
---|
1471 | was expected. |
---|
1472 | @item EROFS |
---|
1473 | Read-only file system. |
---|
1474 | |
---|
1475 | @end table |
---|
1476 | |
---|
1477 | @subheading DESCRIPTION: |
---|
1478 | |
---|
1479 | The @code{cfg_mkdir} function creates a new diectory named @code{path}. The |
---|
1480 | permission bits (modified by the file creation mask) are set from @code{mode}. |
---|
1481 | The owner and group IDs for the directory are set from the effective user ID |
---|
1482 | and group ID. |
---|
1483 | |
---|
1484 | The new directory may (or may not) contain entries for. and .. but is otherwise |
---|
1485 | empty. |
---|
1486 | |
---|
1487 | @subheading NOTES: |
---|
1488 | |
---|
1489 | @page |
---|
1490 | @subsection cfg_chmod - Changes file mode. |
---|
1491 | |
---|
1492 | @subheading CALLING SEQUENCE: |
---|
1493 | |
---|
1494 | @ifset is-C |
---|
1495 | @example |
---|
1496 | #include <sys/types.h> |
---|
1497 | #include <sys/stat.h> |
---|
1498 | |
---|
1499 | int cfg_chmod( |
---|
1500 | const char *path, |
---|
1501 | mode_t mode |
---|
1502 | ); |
---|
1503 | @end example |
---|
1504 | @end ifset |
---|
1505 | |
---|
1506 | @ifset is-Ada |
---|
1507 | @end ifset |
---|
1508 | |
---|
1509 | @subheading STATUS CODES: |
---|
1510 | |
---|
1511 | @table @b |
---|
1512 | @item EACCES |
---|
1513 | Search permission is denied for a directory in a file's path prefix |
---|
1514 | @item ENAMETOOLONG |
---|
1515 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1516 | effect. |
---|
1517 | @item ENOENT |
---|
1518 | A file or directory does not exist. |
---|
1519 | @item ENOTDIR |
---|
1520 | A component of the specified pathname was not a directory when a directory |
---|
1521 | was expected. |
---|
1522 | @item EPERM |
---|
1523 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1524 | or permissions to perform the requested operations. |
---|
1525 | @item EROFS |
---|
1526 | Read-only file system. |
---|
1527 | |
---|
1528 | @end table |
---|
1529 | |
---|
1530 | @subheading DESCRIPTION: |
---|
1531 | |
---|
1532 | Set the file permission bits, the set user ID bit, and the set group ID bit |
---|
1533 | for the file named by @code{path} to @code{mode}. If the effective user ID |
---|
1534 | does not match the owner of the file and the calling process does not have |
---|
1535 | the appropriate privileges, @code{cfg_chmod} returns -1 and sets @code{errno} to |
---|
1536 | @code{EPERM}. |
---|
1537 | |
---|
1538 | @subheading NOTES: |
---|
1539 | |
---|
1540 | @page |
---|
1541 | @subsection cfg_chown - Changes the owner and/or group of a file. |
---|
1542 | |
---|
1543 | @subheading CALLING SEQUENCE: |
---|
1544 | |
---|
1545 | @ifset is-C |
---|
1546 | @example |
---|
1547 | #include <sys/types.h> |
---|
1548 | #include <unistd.h> |
---|
1549 | |
---|
1550 | int cfg_chown( |
---|
1551 | const char *path, |
---|
1552 | uid_t owner, |
---|
1553 | gid_t group |
---|
1554 | ); |
---|
1555 | @end example |
---|
1556 | @end ifset |
---|
1557 | |
---|
1558 | @ifset is-Ada |
---|
1559 | @end ifset |
---|
1560 | |
---|
1561 | @subheading STATUS CODES: |
---|
1562 | |
---|
1563 | @table @b |
---|
1564 | @item EACCES |
---|
1565 | Search permission is denied for a directory in a file's path prefix |
---|
1566 | @item EINVAL |
---|
1567 | Invalid argument |
---|
1568 | @item ENAMETOOLONG |
---|
1569 | Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in |
---|
1570 | effect. |
---|
1571 | @item ENOENT |
---|
1572 | A file or directory does not exist. |
---|
1573 | @item ENOTDIR |
---|
1574 | A component of the specified pathname was not a directory when a directory |
---|
1575 | was expected. |
---|
1576 | @item EPERM |
---|
1577 | Operation is not permitted. Process does not have the appropriate priviledges |
---|
1578 | or permissions to perform the requested operations. |
---|
1579 | @item EROFS |
---|
1580 | Read-only file system. |
---|
1581 | |
---|
1582 | @end table |
---|
1583 | |
---|
1584 | @subheading DESCRIPTION: |
---|
1585 | |
---|
1586 | The user ID and group ID of the file named by @code{path} are set to |
---|
1587 | @code{owner} and @code{path}, respectively. |
---|
1588 | |
---|
1589 | For regular files, the set group ID (S_ISGID) and set user ID (S_ISUID) |
---|
1590 | bits are cleared. |
---|
1591 | |
---|
1592 | Some systems consider it a security violation to allow the owner of a file to |
---|
1593 | be changed, If users are billed for disk space usage, loaning a file to |
---|
1594 | another user could result in incorrect billing. The @code{cfg_chown} function |
---|
1595 | may be restricted to privileged users for some or all files. The group ID can |
---|
1596 | still be changed to one of the supplementary group IDs. |
---|
1597 | |
---|
1598 | @subheading NOTES: |
---|
1599 | |
---|
1600 | This function may be restricted for some file. The @code{pathconf} function |
---|
1601 | can be used to test the _PC_CHOWN_RESTRICTED flag. |
---|
1602 | |
---|
1603 | |
---|