1ea_open(3EXACCT)Extended Accounting File Access Library Functionesa_open(3EXACCT)
2
3
4
6 ea_open, ea_close - open or close exacct files
7
9 cc [ flag... ] file... -lexacct [ library... ]
10 #include <exacct.h>
11
12 int ea_open(ea_file_t *ef, char *name, char *creator, int aflags,
13 int oflags, mode_t mode);
14
15
16 int ea_close(ea_file_t *ef);
17
18
20 The ea_open() function provides structured access to exacct files. The
21 aflags argument contains the appropriate exacct flags necessary to
22 describe the file. The oflags and mode arguments contain the appropri‐
23 ate flags and mode to open the file; see <fcntl.h>. If ea_open() is
24 invoked with EO_HEAD specified in aflags, the resulting file is opened
25 with the object cursor located at the first object of the file. If
26 ea_open() is invoked with EO_TAIL specified in aflags, the resulting
27 file is opened with the object cursor positioned beyond the last object
28 in the file. If EO_NO_VALID_HDR is set in aflags along with EO_HEAD,
29 the initial header record will be returned as the first item read from
30 the file. When creating a file, the creator argument should be set
31 (system generated files use the value "SunOS"); when reading a file,
32 this argument should be set to NULL if no validation is required; oth‐
33 erwise it should be set to the expected value in the file.
34
35
36 The ea_close() function closes an open exacct file.
37
39 Upon successful completion, ea_open() and ea_close() return 0. Other‐
40 wise they return −1 and call ea_error(3EXACCT) to return the extended
41 accounting error value describing the error.
42
44 The ea_open() and ea_close() functions may fail if:
45
46 EXR_SYSCALL_FAIL A system call invoked by the function failed. The
47 errno variable contains the error value set by the
48 underlying call.
49
50
51
52 The ea_open() function may fail if:
53
54 EXR_CORRUPT_FILE The file referred to by name is not a valid exacct
55 file.
56
57
58 EXR_NO_CREATOR In the case of file creation, the creator argument
59 was NULL. In the case of opening an existing file,
60 a creator argument was not NULL and does not match
61 the creator item of the exacct file.
62
63
64 EXR_UNKN_VERSION The file referred to by name uses an exacct file
65 version that cannot be processed by this library.
66
67
69 The exacct file format can be used to represent data other than that in
70 the extended accounting format. By using a unique creator type in the
71 file header, application writers can develop their own format suited to
72 the needs of their application.
73
75 Example 1 Open and close exacct file.
76
77
78 The following example opens the extended accounting data file for pro‐
79 cesses. The exacct file is then closed.
80
81
82 #include <exacct.h>
83
84 ea_file_t ef;
85 if (ea_open(&ef, "/var/adm/exacct/proc", NULL, EO_HEAD,
86 O_RDONLY, 0) == -1)
87 exit(1);
88 (void) ea_close(&ef);
89
90
92 See attributes(5) for descriptions of the following attributes:
93
94
95
96
97 ┌──────────────────────────┬────────────────────────────────┐
98 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
99 ├──────────────────────────┼────────────────────────────────┤
100 │Interface Stability │ Evolving │
101 ├──────────────────────────┼────────────────────────────────┤
102 │MT-Level │ MT-Safe │
103 └──────────────────────────┴────────────────────────────────┘
104
106 ea_error(3EXACCT), ea_pack_object(3EXACCT), ea_set_item(3EXACCT),
107 libexacct(3LIB), attributes(5)
108
109
110
111SunOS 5.11 29 Nov 2001 ea_open(3EXACCT)