1 '\" te 2 .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 6 .TH EXACCT 3PERL "Dec 1, 2002" 7 .SH NAME 8 Exacct \- exacct system calls and error handling 9 .SH SYNOPSIS 10 .LP 11 .nf 12 use Sun::Solaris::Exacct qw(:EXACCT_ALL); 13 my $ea_rec = getacct(P_PID, $$); 14 .fi 15 16 .SH DESCRIPTION 17 .sp 18 .LP 19 This module provides access to the \fBea_error\fR(3EXACCT) function and for all 20 the extended accounting system calls. Constants from the various 21 \fBlibexacct\fR(3LIB) header files are also provided. 22 .SS "Constants" 23 .sp 24 .LP 25 The \fBP_PID\fR, \fBP_TASKID\fR, \fBP_PROJID\fR and all the \fBEW_*\fR, 26 \fBEP_*\fR, \fBEXR_*\fR macros are provided as Perl constants. 27 .SS "Functions" 28 .sp 29 .ne 2 30 .na 31 \fB\fBgetacct($idtype, $id)\fR\fR 32 .ad 33 .sp .6 34 .RS 4n 35 The \fB$idtype\fR parameter must be either \fBP_TASKID\fR or \fBP_PID\fR and 36 \fB$id\fR must be a corresponding task or process ID. This function returns an 37 object of type \fBSun::Solaris::Exacct::Object\fR, representing the unpacked 38 accounting buffer returned by the underlying \fBgetacct\fR(2) system call. In 39 the event of error, \fBundef\fR is returned. 40 .RE 41 42 .sp 43 .ne 2 44 .na 45 \fB\fBputacct($idtype, $id, $record)\fR\fR 46 .ad 47 .sp .6 48 .RS 4n 49 The \fB$idtype\fR parameter must be either \fBP_TASKID\fR or \fBP_PID\fR and 50 \fB$id\fR must be a corresponding task or process ID. If $record is of type 51 Sun::Solaris::Exacct::Object, it is converted to the corresponding packed 52 \fBlibexacct\fR object and passed to the \fBputacct\fR(2) system call. If 53 \fB$record\fR is not of type \fBSun::Solaris::Exacct::Object\fR it is converted 54 to a string using the normal Perl conversion rules and stored as a raw buffer. 55 For predictable and endian-independent results, any raw buffers should be 56 constructed using the Perl \fBpack()\fR function. This function returns true on 57 success and false on failure. 58 .RE 59 60 .sp 61 .ne 2 62 .na 63 \fB\fBwracct($idtype, $id, $flags)\fR\fR 64 .ad 65 .sp .6 66 .RS 4n 67 The \fB$idtype\fR parameter must be either \fBP_TASKID\fR or \fBP_PID\fR and 68 \fB$id\fR must be a corresponding task or process ID. The \fB$flags\fR 69 parameter must be either \fBEW_INTERVAL\fR or \fBEW_PARTIAL\fR. The parameters 70 are passed directly to the underlying \fBwracct\fR(2) system call. This 71 function returns true on success and false on failure. 72 .RE 73 74 .sp 75 .ne 2 76 .na 77 \fB\fBea_error()\fR\fR 78 .ad 79 .sp .6 80 .RS 4n 81 This function provides access to the \fBea_error\fR(3EXACCT) function. It 82 returns a double-typed scalar that becomes one of the EXR_* constants. In a 83 string context it becomes a descriptive error message. This is the exacct 84 equivalent to the \fB$!(errno)\fR Perl variable. 85 .RE 86 87 .sp 88 .ne 2 89 .na 90 \fB\fBea_error_str()\fR\fR 91 .ad 92 .sp .6 93 .RS 4n 94 This function returns a double-typed scalar that in a numeric context will be 95 one of the EXR_* constants as returned by ea_error. In a string context it 96 describes the value returned by ea_error. If ea_error returns EXR_SYSCALL_FAIL, 97 the string value returned is the value returned by \fBstrerror\fR(3C). This 98 function is provided as a convenience so that repeated blocks of code like the 99 following can be avoided: 100 .sp 101 .in +2 102 .nf 103 if (ea_error() == EXR_SYSCALL_FAIL) { 104 print("error: $!\en"); 105 } else { 106 print("error: ", ea_error(), "\en"); 107 } 108 .fi 109 .in -2 110 111 .RE 112 113 .sp 114 .ne 2 115 .na 116 \fB\fBea_register_catalog($cat_pfx, $catalog_id, $export, @idlist)\fR\fR 117 .ad 118 .sp .6 119 .RS 4n 120 This convenience function is a wrapper around the 121 \fBSun::Solaris::Exacct::Catalog->register()\fR method. 122 .RE 123 124 .sp 125 .ne 2 126 .na 127 \fB\fBea_new_catalog($integer)\fR\fR 128 .ad 129 .br 130 .na 131 \fB\fBea_new_catalog($cat_obj)\fR\fR 132 .ad 133 .br 134 .na 135 \fB\fBea_new_catalog($type, $catalog, $id)\fR\fR 136 .ad 137 .sp .6 138 .RS 4n 139 These convenience functions are wrappers around the 140 \fBSun::Solaris::Exacct::Catalog->new()\fR method. See 141 \fBExacct::Catalog\fR(3PERL). 142 .RE 143 144 .sp 145 .ne 2 146 .na 147 \fB\fBea_new_file($name, $oflags, creator => $creator, aflags => $aflags, mode 148 => $mode)\fR\fR 149 .ad 150 .sp .6 151 .RS 4n 152 This convenience function is a wrapper around the 153 \fBSun::Solaris::Exacct::File->new()\fR method. See \fBExacct::File\fR(3PERL). 154 .RE 155 156 .sp 157 .ne 2 158 .na 159 \fB\fBea_new_item($catalog, $value)\fR\fR 160 .ad 161 .sp .6 162 .RS 4n 163 This convenience function is a wrapper around the 164 \fBSun::Solaris::Exacct::Object::Item->new()\fR method. See 165 \fBExacct::Object::Item\fR(3PERL). 166 .RE 167 168 .sp 169 .ne 2 170 .na 171 \fB\fBea_new_group($catalog, @objects)\fR\fR 172 .ad 173 .sp .6 174 .RS 4n 175 This convenience function is a wrapper around the 176 \fBSun::Solaris::Exacct::Object::Group->new()\fR method. See 177 \fBExacct::Object::Group\fR(3PERL). 178 .RE 179 180 .sp 181 .ne 2 182 .na 183 \fB\fBea_dump_object($object, $filehandle)\fR\fR 184 .ad 185 .sp .6 186 .RS 4n 187 This convenience function is a wrapper around the 188 \fBSun::Solaris::Exacct::Object->dump()\fR method. See 189 \fBExacct::Object\fR(3PERL). 190 .RE 191 192 .SS "Class methods" 193 .sp 194 .LP 195 None. 196 .SS "Object methods" 197 .sp 198 .LP 199 None. 200 .SS "Exports" 201 .sp 202 .LP 203 By default nothing is exported from this module. The following tags can be used 204 to selectively import constants and functions defined in this module: 205 .sp 206 .ne 2 207 .na 208 \fB\fB:SYSCALLS\fR\fR 209 .ad 210 .RS 21n 211 \fBgetacct()\fR, \fBputacct()\fR, and \fBwracct()\fR 212 .RE 213 214 .sp 215 .ne 2 216 .na 217 \fB\fB:LIBCALLS\fR\fR 218 .ad 219 .RS 21n 220 \fBea_error()\fR and \fBea_error_str()\fR 221 .RE 222 223 .sp 224 .ne 2 225 .na 226 \fB\fB:CONSTANTS\fR\fR 227 .ad 228 .RS 21n 229 \fBP_PID\fR, \fBP_TASKID\fR, \fBP_PROJID\fR, \fBEW_*\fR, \fBEP_*\fR, and 230 \fBEXR_*\fR 231 .RE 232 233 .sp 234 .ne 2 235 .na 236 \fB\fB:SHORTHAND\fR\fR 237 .ad 238 .RS 21n 239 \fBea_register_catalog()\fR, \fBea_new_catalog()\fR, \fBea_new_file()\fR, 240 \fBea_new_item()\fR, and \fBea_new_group()\fR 241 .RE 242 243 .sp 244 .ne 2 245 .na 246 \fB\fB:ALL\fR\fR 247 .ad 248 .RS 21n 249 \fB:SYSCALLS\fR, \fB:LIBCALLS\fR, \fB:CONSTANTS\fR, and \fB:SHORTHAND\fR 250 .RE 251 252 .sp 253 .ne 2 254 .na 255 \fB\fB:EXACCT_CONSTANTS\fR\fR 256 .ad 257 .RS 21n 258 \fB:CONSTANTS\fR, plus the \fB:CONSTANTS\fR tags for 259 \fBSun::Solaris::Catalog\fR, \fBSun::Solaris::File\fR, and 260 \fBSun::Solaris::Object\fR 261 .RE 262 263 .sp 264 .ne 2 265 .na 266 \fB\fB:EXACCT_ALL\fR\fR 267 .ad 268 .RS 21n 269 \fB:ALL\fR, plus the \fB:ALL\fR tags for \fBSun::Solaris::Catalog\fR, 270 \fBSun::Solaris::File\fR, and \fBSun::Solaris::Object\fR 271 .RE 272 273 .SH ATTRIBUTES 274 .sp 275 .LP 276 See \fBattributes\fR(5) for descriptions of the following attributes: 277 .sp 278 279 .sp 280 .TS 281 box; 282 c | c 283 l | l . 284 ATTRIBUTE TYPE ATTRIBUTE VALUE 285 _ 286 Interface Stability Evolving 287 .TE 288 289 .SH SEE ALSO 290 .sp 291 .LP 292 \fBgetacct\fR(2), \fBputacct\fR(2), \fBwracct\fR(2), \fBea_error\fR(3EXACCT), 293 \fBExacct::Catalog\fR(3PERL), \fBExacct::File\fR(3PERL), 294 \fBExacct::Object\fR(3PERL), \fBExacct::Object::Group\fR(3PERL), 295 \fBExacct::Object::Item\fR(3PERL), \fBlibexacct\fR(3LIB), \fBattributes\fR(5) 296 .SH NOTES 297 .sp 298 .LP 299 The modules described in the section 3PERL manual pages make extensive use of 300 the Perl "double-typed scalar" facility. This facility allows a scalar value to 301 behave either as an integer or as a string, depending upon context. It is the 302 same behavior as exhibited by the \fB$!\fR Perl variable (\fBerrno\fR). It is 303 useful because it avoids the need to map from an integer value to the 304 corresponding string to display a value. Some examples are provided below: 305 .sp 306 .in +2 307 .nf 308 # Assume $obj is a Sun::Solaris::Item 309 my $type = $obj->type(); 310 311 # Print "2 EO_ITEM" 312 printf("%d %s\en", $type, $type); 313 314 # Behave as an integer, $i == 2 315 my $i = 0 + $type; 316 317 # Behave as a string, $s = "abc EO_ITEM xyx" 318 my $s = "abc $type xyz"; 319 .fi 320 .in -2 321 322 .sp 323 .LP 324 Wherever a function or method is documented as returning a double-typed scalar, 325 the returned value exhibits this type of behavior.