source: rtems/doc/new_chapters/confspace.t @ 6385cbd

4.104.114.84.95
Last change on this file since 6385cbd was 6385cbd, checked in by Wade A Smith <warm38@…>, on 09/21/98 at 22:04:07

Updated file based upon red-lines received.

  • Property mode set to 100644
File size: 41.1 KB
Line 
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
13The configuration space manager provides a portable
14interface for manipulating configuration data.
15The capabilities in this manager were defined in the POSIX
161003.1h/D3 proposed standard titled @b{Services for Reliable,
17Available, and Serviceable Systems}.
18
19The 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
61This section details the configuration space manager's directives.
62A subsection is dedicated to each of this manager's directives
63and describes the calling sequence, related constants, usage,
64and 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
75int 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
90The caller does not have the appropriate privilege.
91
92@item EACCES
93Search permission is denied for a component of the path prefix.
94
95@item EEXIST
96The file specified by the file argument does not exist
97
98@item ENAMETOOLONG
99A component of a pathname exceeded @code{NAME_MAX} characters,
100or an entire path name exceed @code{PATH_MAX} characters while
101@code{_POSIX_NO_TRUNC} is in effect.
102
103@item ENOENT
104A component of @code{cfgpath} does not exist.
105
106@item ENOTDIR
107A component of the file path prefix is not a directory.
108
109@item EBUSY
110The configuration space defined by file is already mounted.
111
112@item EINVAL
113The notification argument specifies an invalid log facility.
114
115@end table
116
117@subheading DESCRIPTION:
118
119The @code{cfg_mount()} function maps a configuration space defined
120by the file identified by the the @code{file} argument.  The
121distinguished node of the mapped configuration space is
122mounted in the active space at the point identified by the
123@code{cfgpath} configuration pathname.
124
125The @code{notification} argument specifies how changes to the
126mapped configuration space are communicated to the application.
127If the @code{notification} argument is NULL, no notification will be
128be performed for the mapped configuration space.  If the Event
129Logging option is defined, the notification argument defines the
130facility to which changes in the mapped configuration space are
131logged.  Otherwise, the @code{notification} argument specifies
132an implementation defined method of notifying the application
133of changes to the mapped configuration space.
134
135@subheading NOTES:
136
137The @code{_POSIX_CFG} feature flag is defined to indicate
138this 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
149int 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
162The caller does not have the appropriate privileges.
163
164@item EACCES
165Search permission is denied for a component of the path prefix.
166
167@item ENOENT
168A component of cfgpath does not exist.
169
170@item ENAMETOOLONG
171A component of a pathname exceeded @code{NAME_MAX} characters,
172or an entire path name exceed @code{PATH_MAX} characters while
173@code{_POSIX_NO_TRUNC} is in effect.
174
175@item EINVAL
176The requested node is not the distinguished node of a mounted
177configuration space.
178
179@item EBUSY
180One or more processes has an open configuration traversal
181stream for the configuration space whose distinguished node is
182referenced by the cfgpath argument.
183
184@item ELOOP
185A node appears more than once in the path specified by the
186@code{cfg_path} argument
187
188@item ELOOP
189More than @code{SYMLOOP_MAX} symbolic links were encountered during
190resolution of the cfgpath argument
191
192@end table
193
194@subheading DESCRIPTION:
195
196The @code{cfg_umount()} function unmaps the configuration space whose
197distinguished node is mapped in the active space at the location defined
198by @code{cfgpath} configuration pathname.  All system resources
199allocated for this configuration space should be deallocated.
200
201@subheading NOTES:
202
203The @code{_POSIX_CFG} feature flag is defined to indicate
204this 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
215int 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
230A component of a pathname exceeded @code{NAME_MAX} characters,
231or an entire path name exceed @code{PATH_MAX} characters while
232@code{_POSIX_NO_TRUNC} is in effect.
233
234@item ENOENT
235A component of the path prefix does not exist.
236
237@item EACCES
238Search permission is denied for a component of the path prefix.
239
240@item ELOOP
241Too many symbolic links were encountered in translating the
242pathname.
243
244@item EPERM
245The calling process does not have the appropriate privilege.
246
247@item EEXIST
248The named node exists.
249
250@item EINVAL
251The value of @code{mode} is invalid.
252
253@item EINVAL
254The value of @code{type} is invalid.
255
256@item ELOOP
257A node appears more than once in the path specified by the
258@cdoe{cfg_path} argument
259
260@item ELOOP
261More than @code{SYMLOOP_MAX} symbolic links were encountered during
262resolution of the cfgpath argument.
263
264@item EROFS
265The named @code{node} resides on a read-only configuration space.
266
267@end table
268
269@subheading DESCRIPTION:
270
271The @code{cfg_mknod()} function creates a new node in the configuration
272space which contains the pathname prefix of @code{cfgpath}.  The node
273name is defined by the pathname suffix of @code{cfgpath}. The node
274permissions are specified by the value of @code{mode}.  The node type
275is specified by the value of @code{type}.
276
277@subheading NOTES:
278
279The @code{_POSIX_CFG} feature flag is defined to indicate
280this 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
291int 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
305A component of a pathname exceeded @code{NAME_MAX} characters,
306or an entire path name exceed @code{PATH_MAX} characters while
307@code{_POSIX_NO_TRUNC} is in effect.
308
309@item ENOENT
310A component of cfgpath does not exist.
311
312@item EACCES
313Search permission is denied for a component of the path prefix.
314
315@item EPERM
316The calling process does not have the appropriate privileges.
317
318@item ELOOP
319A node appears more than once in the path specified by the
320cfg_path argument
321
322@item ELOOP
323More than @code{SYMLOOP_MAX} symbolic links were encountered during
324resolution of the cfgpath argument.
325
326@end table
327
328@subheading DESCRIPTION:
329
330The @code{cfg_get} function stores the value attribute of the
331configuration node identified by @code{cfgpath}, into the buffer
332described by the @code{value} pointer.
333
334@subheading NOTES:
335
336The @code{_POSIX_CFG} feature flag is defined to indicate
337this 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
348int 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
362A component of a pathname exceeded @code{NAME_MAX} characters,
363or an entire path name exceed @code{PATH_MAX} characters while
364@code{_POSIX_NO_TRUNC} is in effect.
365
366@item ENOENT
367A component of cfgpath does not exist
368
369@item EACCES
370Search permission is denied for a component of the path prefix.
371
372@item EPERM
373The calling process does not have the appropriate privilege.
374
375@item ELOOP
376A node appears more than once in the path specified by the
377cfg-path argument.
378
379@item ELOOP
380More than @code{SYMLOOP_MAX} symbolic links were encountered during
381resolution of the cfgpath argument.
382
383@end table
384
385@subheading DESCRIPTION:
386
387The @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
393The @code{_POSIX_CFG} feature flag is defined to indicate
394this 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
405int 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
419A component of a pathname exceeded @code{NAME_MAX} characters,
420or an entire path name exceed @code{PATH_MAX} characters while
421@code{_POSIX_NO_TRUNC} is in effect.
422
423@item ENOENT
424A component of either path prefix does not exist.
425
426@item EACCES
427A component of either path prefix denies search permission.
428
429@item EACCES
430The requested link requires writing in a node with a mode that
431denies write permission.
432
433@item ENOENT
434The node named by src does not exist.
435
436@item EEXIST
437The node named by dest does exist.
438
439@item EPERM
440The calling process does not have the appropriate privilege to
441modify the node indicated by the src argument.
442
443@item EXDEV
444The link named by dest and the node named by src are from different
445configuration spaces.
446
447@item ENOSPC
448The node in which the entry for the new link is being placed
449cannot be extended because there is no space left on the
450configuration space containing the node.
451
452@item EIO
453An I/O error occurred while reading from or writing to the
454configuration space to make the link entry.
455
456@item EROFS
457The requested link requires writing in a node on a read-only
458configuration space.
459
460@item ELOOP
461A node appears more than once in the path specified by the
462cfg-path argument.
463
464@item ELOOP
465More than @code{SYMLOOP_MAX} symbolic links were encountered during
466resolution of the cfgpath argument.
467
468@end table
469
470@subheading DESCRIPTION:
471
472The @code{src} and @code{dest}arguments point to pathnames which
473name existing nodes.  The @code{cfg_link} function atomically creates
474a link between specified nodes, and increment by one the link count
475of the node specified by the @code{src} argument.
476
477If the @code{cfg_link} function fails, no link is created, and the
478link count of the node remains unchanged by this function call.
479
480This implementation may require that the calling process has permission
481to access the specified nodes.
482
483@subheading NOTES:
484
485The @code{_POSIX_CFG} feature flag is defined to indicate
486this 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
497int 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
510A component of a pathname exceeded @code{NAME_MAX} characters,
511or an entire path name exceed @code{PATH_MAX} characters.
512
513@item ENOENT
514The named  node does not exist.
515
516@item EACCES
517Search permission is denied on the node containing the link to
518be removed.
519
520@item EACCES
521Write permission is denied on the node containing the link to
522be removed.
523
524@item ENOENT
525A component of cfgpath does not exist.
526
527@item EPERM
528The calling process does not have the appropriate privilege to
529modify the node indicated by the path prefix of the cfgpath
530argument.
531
532@item EBUSY
533The node to be unlinked is the distinguished node of a mounted
534configuration space.
535
536@item EIO
537An I/O error occurred while deleting the link entry or deallocating
538the node.
539
540@item EROFS
541The named node resides in a read-only configuration space.
542
543@item ELOOP
544A node appears more than once in the path specified by the
545cfg-path argument.
546
547@item ELOOP
548More than @code{SYMLOOP_MAX} symbolic links were encountered during
549resolution of the cfgpath argument.
550
551@end table
552
553@subheading DESCRIPTION:
554
555The @code{cfg_unlink} function removes the link between the node
556specified by the @code{cfgpath} path prefix and the parent node
557specified by @code{cfgpath}, and decrements the link count
558of the @code{cfgpath} node.
559
560When the link count of the node becomes zero, the space occupied
561by the node is freed and the node is no longer be accessible.
562
563@subheading NOTES:
564
565The @code{_POSIX_CFG} feature flag is defined to indicate
566this 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
577int 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
593Search permission is denied for any component of a pathname.
594
595@item ELOOP
596A loop exists in symbolic links encountered during resolution
597of a pathname.
598
599@item ENAMETOOLONG
600The length of a pathname exceeds @code{PATH_MAX}, or a pathname
601component is longer than @code{NAME_MAX} while @code{_POSIX_NO_TRUNC}
602
603@item ENOENT
604The pathname argument is an empty string or the named node
605does not exist.
606
607@item EINVAL
608Either both or neither of CFG_LOGICAL and CFG_PHYSICAL are
609specified by the options argument
610
611@item ENOMEM
612Not enough memory is available to create the necessary structures.
613
614@item ELOOP
615More than @code{SYMLOOP_MAX} symbolic links were encountered during
616resolution of the pathnames argument.
617
618@item ENAMETOOLONG
619As a result of encountering a symbolic link in resolution of the
620pathname specified by the pathnames argument, the length of
621the substituted pathname string exceeded @code{PATH_MAX}.
622
623@end table
624
625@subheading DESCRIPTION:
626
627The @code{cfg_open} function opens a configuration traversal stream
628rooted in the configuration nodes name by the @code{pathnames} argument.
629It stores a pointer to a CFG object that represents that stream at
630the location identified the @code{cfgstream} pointer.  The @code{pathnames}
631argument is an array of character pointers to NULL-terminated strings.
632The last member of this array is a NULL pointer.
633
634The value of @code{options} is the bitwise inclusive OR of values from the
635following lists.  Applications supply exactly one of the first two values
636below in @code{options}.
637
638@table @b
639
640@item CFG_LOGICAL
641When symbolic links referencing existing nodes are
642encountered during the traversal, the @code{cfg_info}
643field of the returned CFGENT structure describes the
644target node pointed to by the link instead of the
645link itself, unless the target node does not exist.
646If the target node has children, the pre-order return,
647followed by the return of structures referencing all of
648its descendants, followed by a post-order return, is done.
649                   
650@item CFG_PHYSICAL
651When symbolic links are encountered during the traversal,
652the @code{cfg_info} field is used to describe the symbolic
653link.
654
655@end table
656                   
657
658Any combination of the remaining flags can be specified in the value of
659@code{options}
660
661@table @b
662
663@item CFG_COMFOLLOW
664When symbolic links referencing existing nodes are
665specified in the @code{pathnames} argument, the
666@code{cfg_info} field of the returned CFGENT structure
667describes the target node pointed to by the link
668instead of the link itself, unless the target node does
669not exist.  If the target node has children, the
670pre-order return, followed by the return of structures
671referencing all its descendants, followed by a post-order
672return, shall be done.
673
674@item CFG_XDEV
675The configuration space functions do not return a
676CFGENT structure for any node in a different configuration
677space than the configuration space of the nodes identified
678by the CFGENT structures for the @code{pathnames} argument.
679
680@end table
681
682The @code{cfg_open} argument @code{compar} is either a NULL or point
683to a function that is called with two pointers to pointers to CFGENT
684structures that returns less than, equal to , or greater than zero if
685the node referenced by the first argument is considered to be respectively
686less than, equal to, or greater than the node referenced by the second.
687The CFGENT structure fields provided to the comparison routine is as
688described with the exception that the contents of the @code{cfg_path} and
689@code{cfg_pathlen} fields are unspecified.
690
691This comparison routine is used to determine the order in which nodes in
692directories encountered during the traversal are returned, and the order
693of traversal when more than one node is specified in the @code{pathnames}
694argument to @code{cfg_open}.  If a comparison routine is specified, the
695order of traversal is from the least to the greatest.  If the @code{compar}
696argument is NULL, the order of traversal shall be as listed in the
697@code{pathnames} argument.
698
699@subheading NOTES:
700
701The @code{_POSIX_CFG} feature flag is defined to indicate
702this 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
713int 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
727Search permission is denied for any component of a pathname.
728
729@item EBADF
730The cfgp argument does not refer to an open configuration
731space.
732
733@item ELOOP
734A loop exists in symbolic links encountered during resolution
735of a pathname.
736
737@item ENOENT
738A named node does not exist.
739
740@item ENOMEM
741Not enough memory is available to create the necessary structures.
742
743@item ELOOP
744More than @code{SYMLOOP_MAX} symbolic links were encountered during
745resolution of the cfgpath argument.
746
747@item ENAMETOOLONG
748As a result of encountering a symbolic link in resolution of the
749pathname specified by the pathnames argument, the length of the
750substituted pathname string exceeded @code{PATH_MATH}.
751
752@end table
753
754@subheading DESCRIPTION:
755
756The @code{cfg_read} function returns a pointer to a CFGENT structure
757representing a node in the configuration space to which @code{cfgp}
758refers.  The returned pointer is stored at the location indicated
759by the @code{node} argument.
760
761The child nodes of each node in the configuration tree is returned
762by @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
764as specified by the routine, from least to greatest.  Otherwise
765the order of return is unspecified.
766
767Structures referencing nodes with children is returned by the
768function @code{cfg_read} at least twice [unless the application
769specifies otherwise with @code{cfg_mark}]-once immediately before
770the structures representing their descendants, are returned
771(pre-order), and once immediately after structures representing all
772of their descendants, if any, are returned (post-order).  The
773CFGENT structure returned in post-order (with the exception of the
774@code{cfg_info} field) is identical to that returned in pre-order.
775Structures referencing nodes of other types is returned at least
776once.
777
778The fields of the CFGENT structure contains the following
779information:
780
781@table @b
782
783@item cfg_parent
784A pointer to the structure returned by the
785@code{cfg_read} function for the node that contains
786the entry for the current node.  A @code{cfg_parent}
787structure is provided for the node(s) specified by
788the @code{pathnames} argument to the @code{cfg_open}
789function, but the contents of other than its
790@code{cfg_number}, @code{cfg_pointer}, @code{cfg_parent},
791and @code{cfg_parent}, and @code{cfg_level} fields are
792unspecified.  Its @code{cfg_link} field is unspecified.
793
794@item cfg_link
795Upon return from the @code{cfg_children} function, the
796@code{cfg_link} field points to the next CFGENT structure
797in a NULL-terminated linked list of CFGENT structures. 
798Otherwise, the content of the @code{cfg_link} field is
799unspecified.
800
801@item cfg_cycle
802If the structure being returned by @code{cfg_read}
803represents a node that appears in the @code{cfg_parent}
804linked list tree, the @code{cfg_cycle} field shall point
805to the structure representing that entry from the
806@code{cfg_parent} linked list.  Otherwise the content of
807the @code{cfg_cycle} field is unspecified.
808
809@item cfg_number
810The @code{cfg_number} field is provided for use by the
811application program.  It is initialized to zero for
812each new node returned by the @code{cfg_read} function,
813but is not further modified by the configuration space
814routines.
815
816@item cfg_pointer
817The @code{cfg_pointer} field is provided for use by the
818application program.  It is initialized to NULL for
819each new node returned by the @code{cfg_read} function,
820but is not further modified by the configuration
821space routines.
822
823@item cfg_path
824A pathname for the node including and relative to the
825argument supplied to the @code{cfg_open} routine for this
826configuration space.  This pathname may be longer than
827@code{PATH_MAX} bytes.  This pathname is NULL-terminated.
828
829@item cfg_name
830The nodename of the node.
831
832@item cfg_pathlen
833The length of the string pointed at by the @code{cfg_path}
834field when returned by @code{cfg_read}.
835
836@item cfg_namelen
837The length of the string pointed at by the @code{cfg_name}
838field.
839
840@item cfg_level
841The depth of the current entry in the configuration space.
842The @code{cfg_level} field of the @code{cfg_parent}
843structure for each of the node(s) specified in the
844@code{pathnames} argument to the @code{cfg_open} function
845is set to 0, and this number is incremented for each
846node level descendant.
847
848@item cfg_info
849This field contains one of the values listed below.  If
850an object can have more than one info value, the first
851appropriate value listed below is returned.
852
853@table @b
854
855@item CFG_D
856The structure represents a node with children in
857pre-order.
858
859@item CFG_DC
860The structure represents a node that is a parent
861of the node most recently returned by @code{cfg_read}.
862The @code{cfg_cycle} field references the structure
863previously returned by @code{cfg_read} that is the
864same as the returned structure.
865
866@item CFG_DEFAULT
867The structure represents a node that is not
868represented by one of the other node types
869
870@item CFG_DNR
871The structure represents a node, not of type symlink,
872that is unreadable.  The variable @code{cfg_errno}
873is set to the appropriate value.
874
875@item CFG_DP
876The structure represents a node with children in
877post-order.  This value occurs only if CFG_D
878has previously been returned for this entry.
879
880@item CFG_ERR
881The structure represents a node for which an error has
882occurred.  The variable @code{cfg_errno} is set to the
883appropriate value.
884
885@item CFG_F
886The structure represents a node without children.
887
888@item CFG_SL
889The structure represents a node of type symbolic link.
890
891@item CFG_SLNONET
892The structure represents a node of type symbolic link
893with a target node for which node characteristic
894information cannot be obtained.
895
896@end table
897
898@end table
899
900Structures returned by @code{cfg_read} with a @code{cfg_info} field equal
901to CFG_D is accessible until a subsequent call, on the same
902configuration traversal stream, to @code{cfg_close}, or to @code{cfg_read}
903after they have been returned by the @code{cfg_read} function in
904post-order.  Structures returned by @code{cfg_read} with an
905@code{cfg_info} field not equal to CFG_D is accessible until a subsequent
906call, on the same configuration traversal stream, to @code{cfg_close}
907or @code{cfg_read}.
908
909The content of the @code{cfg_path} field is specified only for the
910structure most recently returned by @code{cfg_read}.
911
912The specified fields in structures in the list representing nodes for
913which structures have previously been returned by @code{cfg_children},
914is identical to those returned by @code{cfg_children}, except that
915the contents of the @code{cfg_path} and @code{cfg_pathlen} fields are
916unspecified.
917         
918@subheading NOTES:
919
920The @code{_POSIX_CFG} feature flag is defined to indicate
921this 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
932int 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
947Search permission is denied for any component of a pathname
948
949@item EBADF
950The cfgp argument does not refer to an open configuration space.
951
952@item ELOOP
953A loop exists in symbolic links encountered during resolution of
954a pathname.
955
956@item ENAMETOOLONG
957The length of a pathname exceeds @code{PATH_MAX}, or a pathname
958component is longer than @code{NAME_MAX} while @code{_POSIX_NO_TRUNC} is
959in effect.
960
961@item EINVAL
962The specified value of the options argument is invalid.
963
964@item ENOENT
965The named node does not exist.
966
967@item ENOMEM
968Not enough memory is available to create the necessary structures.
969
970@end table
971
972@subheading DESCRIPTION:
973
974The first @code{cfg_children} call after a @code{cfg_read} returns
975information about the first node without children under the node
976returned by @code{cfg_read}.  Subsequent calls to @code{cfg_children}
977without the intervening @code{cfg_read} shall return information
978about the remaining nodes without children under that same node.
979
980If @code{cfg_read} has not yet been called for the configuration
981traversal stream represented by @code{cfgp}, @code{cfg_children}
982returns a pointer to the first entry in a list of the nodes
983represented by the @code{pathnames} argument to @code{cfg_open}.
984
985In either case, the list is NULL-terminated, ordered by the
986user-specified comparison function, if any, and linked through the
987cfg_link field.
988
989@subheading NOTES:
990
991The @code{_POSIX_CFG} feature flag is defined to indicate
992this 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
1003int 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
1018The specified combination of the cfgp and f arguments is not
1019supported by the implementation.
1020
1021@item EINVAL
1022The specified value of the options argument is invalid.
1023
1024@end table
1025
1026@subheading DESCRIPTION:
1027
1028The @code{cfg_mark} function modifies the subsequent behavior of
1029the cfg functions with regard to the node referenced by the structure
1030pointed to by the argument @code{f} or the configuration space referenced
1031by the structure pointed to by the argument @code{cfgp}.
1032
1033Exactly one of the @code{f} argument and the @code{cfgp} argument is NULL.
1034
1035The value of the @code{options} argument is exactly one of the flags
1036specified in the following list:
1037
1038@table @b
1039
1040@item CFG_AGAIN
1041If the @code{cfgp} argument is non-NULL, or the @code{f}
1042argument is NULL, or the structure referenced by @code{f}
1043is not the one most recently returned by @code{cfg_read},
1044@code{cfg_mark} returns an error.  Otherwise, the next
1045call to the @code{cfg_read} function returns the structure
1046referenced by @code{f} with the @code{cfg_info} field
1047reinitialized.  Subsequent behavior of the @code{cfg}
1048functions are based on the reinitialized value of
1049@code{cfg_info}.
1050
1051@item CFG_SKIP
1052If the @code{cfgp} argument is non-NULL, or the @code{f}
1053argument is NULL, or the structure referenced by @code{f}
1054is not one of those specified as accessible, or the structure
1055referenced by @code{f} is not for a node of type pre-order
1056node, @code{cfg_mark} returns an error.  Otherwise, no
1057more structures for the node referenced by @code{f} or its
1058descendants are returned by the @code{cfg_read} function.
1059
1060@item CFG_FOLLOW
1061If the @code{cfgp} argument is non-NULL, or the @code{f}
1062argument is NULL, or the structure referenced by @code{f}
1063is not one of those specified as accessible, or the structure
1064referenced by @code{f} is not for a node of type symbolic link,
1065@code{cfg_mark} returns an error.  Otherwise, the next
1066call to the @code{cfg_read} function returns the structure
1067referenced by @code{f} with the @code{cfg_info} field reset
1068to reflect the target of the symbolic link instead of the
1069symbolic link itself.  If the target of the link is node with
1070children, the pre-order return, followed by the return of
1071structures referencing all of its descendants, followed by a
1072post-order return, shall be done.
1073
1074@end table
1075
1076If the target of the symbolic link does not exist, the fields
1077of the structure by @code{cfg_read} shall be unmodified, except
1078that the @code{cfg_info} field shall be reset to @code{CFG_SLNONE}.
1079
1080@subheading NOTES:
1081
1082The @code{_POSIX_CFG} feature flag is defined to indicate
1083this 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
1094int 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
1107The cfgp argument does not refer to an open configuration space
1108traversal stream.
1109
1110@end table
1111
1112@subheading DESCRIPTION:
1113
1114The @code{cfg_close} function closes a configuration space transversal
1115stream represented by the CFG structure pointed at by the @code{cfgp}
1116argument.  All system resources allocated for this configuration space
1117traversal 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
1122The @code{_POSIX_CFG} feature flag is defined to indicate
1123this 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
1135struct 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
1148Invalid file descriptor
1149
1150@end table
1151
1152@subheading DESCRIPTION:
1153
1154The @code{cfg_readdir} function returns a pointer to a structure @code{dirent}
1155representing the next directory entry from the directory stream pointed to
1156by @code{dirp}.  On end-of-file, NULL is returned.
1157
1158The @code{cfg_readdir} function may (or may not) return entries for . or .. Your
1159program should tolerate reading dot and dot-dot but not require them.
1160
1161The 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
1163a call for another directory.
1164
1165@subheading NOTES:
1166
1167If 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},
1169the 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
1182int 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
1197Search permission is denied for a directory in a file's path prefix
1198@item EEXIST
1199The named file already exists.
1200@item EINTR
1201Function was interrupted by a signal.
1202@item EISDIR
1203Attempt to open a directory for writing or to rename a file to be a
1204directory.
1205@item EMFILE
1206Too many file descriptors are in use by this process.
1207@item ENAMETOOLONG
1208Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1209effect.
1210@item ENFILE
1211Too many files are currently open in the system.
1212@item ENOENT
1213A file or directory does not exist.
1214@item ENOSPC
1215No space left on disk.
1216@item ENOTDIR
1217A component of the specified pathname was not a directory when a directory
1218was expected.
1219@item ENXIO
1220No such device.  This error may also occur when a device is not ready, for
1221example, a tape drive is off-line.
1222@item EROFS
1223Read-only file system.
1224@end table
1225
1226@subheading DESCRIPTION:
1227
1228The @code{open} function establishes a connection between a file and a file
1229descriptor.  The file descriptor is a small integer that is used by I/O
1230functions to reference the file.  The @code{path} argument points to the
1231pathname for the file.
1232
1233The @code{oflag} argument is the bitwise inclusive OR of the values of
1234symbolic constants.  The programmer must specify exactly one of the following
1235three symbols:
1236
1237@table @b
1238@item O_RDONLY
1239Open for reading only.
1240
1241@item O_WRONLY
1242Open for writing only.
1243
1244@item O_RDWR
1245Open for reading and writing.
1246
1247@end table
1248
1249Any combination of the following symbols may also be used.
1250
1251@table @b
1252@item O_APPEND
1253Set the file offset to the end-of-file prior to each write.
1254
1255@item O_CREAT
1256If the file does not exist, allow it to be created.  This flag indicates
1257that the @code{mode} argument is present in the call to @code{open}.
1258
1259@item O_EXCL
1260This flag may be used only if O_CREAT is also set.  It causes the call
1261to @code{open} to fail if the file already exists.
1262
1263@item O_NOCTTY
1264If @code{path} identifies a terminal, this flag prevents that teminal from
1265becoming the controlling terminal for thi9s process.  See Chapter 8 for a
1266description of terminal I/O.
1267
1268@item O_NONBLOCK
1269Do no wait for the device or file to be ready or available.  After the file
1270is open, the @code{read} and @code{write} calls return immediately.  If the
1271process 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
1275This flag should be used only on ordinary files opened for writing.  It
1276causes the file to be tuncated to zero length..
1277
1278@end table
1279
1280Upon successful completion, @code{open} returns a non-negative file
1281descriptor.
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
1295mode_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
1308The @code{cfg_umask} function sets the process file creation mask to @code{cmask}.
1309The 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.
1311Bit positions that are set in @code{cmask} are cleared in the mode of the
1312created file.
1313
1314The file creation mask is inherited across @code{fork} and @code{exec} calls.
1315This makes it possible to alter the default permission bits of created files.
1316
1317@subheading NOTES:
1318
1319The @code{cmask} argument should have only permission bits set.  All other
1320bits 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
1331int 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
1345Search permission is denied for a directory in a file's path prefix
1346@item EEXIST
1347The named file already exists.
1348@item EMLINK
1349The number of links would exceed @code{LINK_MAX}.
1350@item ENAMETOOLONG
1351Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1352effect.
1353@item ENOENT
1354A file or directory does not exist.
1355@item ENOSPC
1356No space left on disk.
1357@item ENOTDIR
1358A component of the specified pathname was not a directory when a directory
1359was expected.
1360@item EPERM
1361Operation is not permitted.  Process does not have the appropriate priviledges
1362or permissions to perform the requested operations.
1363@item EROFS
1364Read-only file system.
1365@item EXDEV
1366Attempt to link a file to another file system.
1367
1368@end table
1369
1370@subheading DESCRIPTION:
1371
1372The @code{link} function atomically creates a new link for an existing file
1373and increments the link count for the file.
1374
1375If the @code{link} function fails, no directories are modified.
1376
1377The @code{existing} argument should not be a directory.
1378
1379The 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
1392int 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
1405Search permission is denied for a directory in a file's path prefix
1406@item EBUSY
1407The directory is in use.
1408@item ENAMETOOLONG
1409Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1410effect.
1411@item ENOENT
1412A file or directory does not exist.
1413@item ENOTDIR
1414A component of the specified pathname was not a directory when a directory
1415was expected.
1416@item EPERM
1417Operation is not permitted.  Process does not have the appropriate priviledges
1418or permissions to perform the requested operations.
1419@item EROFS
1420Read-only file system.
1421
1422@end table
1423
1424@subheading DESCRIPTION:
1425
1426The @code{unlink} function removes the link named by @{code} and decrements the
1427link count of the file referenced by the link.  When the link count goes to zero
1428and no process has the file open, the space occupied by the file is freed and the
1429file 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
1443int 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
1457Search permission is denied for a directory in a file's path prefix
1458@item EEXIST
1459The name file already exist. 
1460@item EMLINK
1461The number of links would exceed LINK_MAX
1462@item ENAMETOOLONG
1463Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1464effect.
1465@item ENOENT
1466A file or directory does not exist.
1467@item ENOSPC
1468No space left on disk.
1469@item ENOTDIR
1470A component of the specified pathname was not a directory when a directory
1471was expected.
1472@item EROFS
1473Read-only file system.
1474
1475@end table
1476
1477@subheading DESCRIPTION:
1478
1479The @code{cfg_mkdir} function creates a new diectory named @code{path}.  The
1480permission bits (modified by the file creation mask) are set from @code{mode}.
1481The owner and group IDs for the directory are set from the effective user ID
1482and group ID.
1483
1484The new directory may (or may not) contain entries for. and .. but is otherwise
1485empty.
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
1499int 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
1513Search permission is denied for a directory in a file's path prefix
1514@item ENAMETOOLONG
1515Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1516effect.
1517@item ENOENT
1518A file or directory does not exist.
1519@item ENOTDIR
1520A component of the specified pathname was not a directory when a directory
1521was expected.
1522@item EPERM
1523Operation is not permitted.  Process does not have the appropriate priviledges
1524or permissions to perform the requested operations.
1525@item EROFS
1526Read-only file system.
1527
1528@end table
1529
1530@subheading DESCRIPTION:
1531
1532Set the file permission bits, the set user ID bit, and the set group ID bit
1533for the file named by @code{path} to @code{mode}.  If the effective user ID
1534does not match the owner of the file and the calling process does not have
1535the 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
1550int 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
1565Search permission is denied for a directory in a file's path prefix
1566@item EINVAL
1567Invalid argument
1568@item ENAMETOOLONG
1569Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
1570effect.
1571@item ENOENT
1572A file or directory does not exist.
1573@item ENOTDIR
1574A component of the specified pathname was not a directory when a directory
1575was expected.
1576@item EPERM
1577Operation is not permitted.  Process does not have the appropriate priviledges
1578or permissions to perform the requested operations.
1579@item EROFS
1580Read-only file system.
1581
1582@end table
1583
1584@subheading DESCRIPTION:
1585
1586The user ID and group ID of the file named by @code{path} are set to
1587@code{owner} and @code{path}, respectively.
1588
1589For regular files, the set group ID (S_ISGID) and set user ID (S_ISUID)
1590bits are cleared.
1591
1592Some systems consider it a security violation to allow the owner of a file to
1593be changed,  If users are billed for disk space usage, loaning a file to
1594another user could result in incorrect billing.  The @code{cfg_chown} function
1595may be restricted to privileged users for some or all files.  The group ID can
1596still be changed to one of the supplementary group IDs.
1597
1598@subheading NOTES:
1599
1600This function may be restricted for some file.  The @code{pathconf} function
1601can be used to test the _PC_CHOWN_RESTRICTED flag.
1602
1603
Note: See TracBrowser for help on using the repository browser.