10Sstevel@tonic-gate# 2*12388SJohn.Sonnenschein@Sun.COM# Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate# 4*12388SJohn.Sonnenschein@Sun.COM 50Sstevel@tonic-gate# 60Sstevel@tonic-gate# Sun::Solaris::Exacct documentation. 70Sstevel@tonic-gate# 80Sstevel@tonic-gate 90Sstevel@tonic-gate=head1 NAME 100Sstevel@tonic-gate 110Sstevel@tonic-gateSun::Solaris::Exacct - exacct system calls and error handling 120Sstevel@tonic-gate 130Sstevel@tonic-gate=head1 SYNOPSIS 140Sstevel@tonic-gate 150Sstevel@tonic-gate use Sun::Solaris::Exacct qw(:EXACCT_ALL); 160Sstevel@tonic-gate my $ea_rec = getacct(P_PID, $$); 170Sstevel@tonic-gate 180Sstevel@tonic-gateThis module provides access to the C<ea_error(3EXACCT)> function and for all the 190Sstevel@tonic-gateextended accounting system calls. Constants from the various C<libexacct(3LIB)> 200Sstevel@tonic-gateheader files are also provided. 210Sstevel@tonic-gate 220Sstevel@tonic-gate=head2 Constants 230Sstevel@tonic-gate 240Sstevel@tonic-gateThe C<P_PID>, C<P_TASKID>, C<P_PROJID> and all the C<EW_*>, C<EP_*>, C<EXR_*> 250Sstevel@tonic-gatemacros are provided as Perl constants. 260Sstevel@tonic-gate 270Sstevel@tonic-gate=head2 Functions 280Sstevel@tonic-gate 290Sstevel@tonic-gateB<C<getacct($idtype, $id)>> 300Sstevel@tonic-gate 310Sstevel@tonic-gateThe C<$idtype> parameter must be either C<P_TASKID> or C<P_PID> and C<$id> 320Sstevel@tonic-gatemust be a corresponding task or process ID. This function returns an object of 330Sstevel@tonic-gatetype C<Sun::Solaris::Exacct::Object>, representing the unpacked accounting 340Sstevel@tonic-gatebuffer returned by the underlying C<getacct(2)> system call. In the event of 350Sstevel@tonic-gateerror, C<undef> is returned. 360Sstevel@tonic-gate 370Sstevel@tonic-gateB<C<putacct($idtype, $id, $record)>> 380Sstevel@tonic-gate 390Sstevel@tonic-gateThe C<$idtype> parameter must be either C<P_TASKID> or C<P_PID> and C<$id> 400Sstevel@tonic-gatemust be a corresponding task or process ID. If C<$record> is of type 410Sstevel@tonic-gateC<Sun::Solaris::Exacct::Object>, it is converted to the corresponding packed 420Sstevel@tonic-gatelibexacct object and passed to the C<putacct(2)> system call. If C<$record> is 430Sstevel@tonic-gatenot of type C<Sun::Solaris::Exacct::Object> it is converted to a string using 440Sstevel@tonic-gatethe normal Perl conversion rules and stored as a raw buffer. For predictable 450Sstevel@tonic-gateand endian-independent results, any raw buffers should be constructed using 460Sstevel@tonic-gatethe Perl C<pack()> function. This function returns C<true> on success and 470Sstevel@tonic-gateC<false> on failure. 480Sstevel@tonic-gate 490Sstevel@tonic-gateB<C<wracct($idtype, $id, $flags)>> 500Sstevel@tonic-gate 510Sstevel@tonic-gateThe C<$idtype> parameter must be either C<P_TASKID> or C<P_PID> and $id must 520Sstevel@tonic-gatebe a corresponding task or process ID. The C<$flags> parameter must be either 530Sstevel@tonic-gateC<EW_INTERVAL> or C<EW_PARTIAL>. The parameters are passed directly to the 540Sstevel@tonic-gateunderlying C<wracct(2)> system call. This function returns C<true> on success 550Sstevel@tonic-gateand C<false> on failure. 560Sstevel@tonic-gate 570Sstevel@tonic-gateB<C<ea_error()>> 580Sstevel@tonic-gate 590Sstevel@tonic-gateThis function provides access to the C<ea_error(3EXACCT)> function. It returns 600Sstevel@tonic-gatea double-typed scalar that in a numeric context will be one of the C<EXR_*> 610Sstevel@tonic-gateconstants. In a string context it will be a descriptive error message. This is 620Sstevel@tonic-gatethe exacct equivalent to the C<$!> (C<errno>) Perl variable. 630Sstevel@tonic-gate 640Sstevel@tonic-gateB<C<ea_error_str()>> 650Sstevel@tonic-gate 660Sstevel@tonic-gateThis function returns a double-typed scalar that in a numeric context will be 670Sstevel@tonic-gateone of the C<EXR_*> constants as returned by C<ea_error>. In a string context 680Sstevel@tonic-gateit describes the value returned by C<ea_error>. If C<ea_error> returns 690Sstevel@tonic-gateC<EXR_SYSCALL_FAIL>, the string value returned is the value returned by 700Sstevel@tonic-gateC<strerror(3C)>. This function is provided as a convenience so that repeated 710Sstevel@tonic-gateblocks of code like the following can be avoided: 720Sstevel@tonic-gate 730Sstevel@tonic-gate if (ea_error() == EXR_SYSCALL_FAIL) { 740Sstevel@tonic-gate print("error: $!\n"); 750Sstevel@tonic-gate } else { 760Sstevel@tonic-gate print("error: ", ea_error(), "\n"); 770Sstevel@tonic-gate } 780Sstevel@tonic-gate 790Sstevel@tonic-gateB<C<ea_register_catalog($cat_pfx, $catalog_id, $export, @idlist)>> 800Sstevel@tonic-gate 810Sstevel@tonic-gateThis convenience function is a wrapper around the 820Sstevel@tonic-gateC<< Sun::Solaris::Exacct::Catalog->register() >> method. 830Sstevel@tonic-gate 840Sstevel@tonic-gateB<C<ea_new_catalog($integer)>> 850Sstevel@tonic-gate 860Sstevel@tonic-gateB<C<ea_new_catalog($cat_obj)>> 870Sstevel@tonic-gate 880Sstevel@tonic-gateB<C<ea_new_catalog($type, $catalog, $id)>> 890Sstevel@tonic-gate 900Sstevel@tonic-gateThese convenience functions are wrappers around the 910Sstevel@tonic-gateC<< Sun::Solaris::Exacct::Catalog->new() >> method. See 920Sstevel@tonic-gateC<Sun::Solaris::Exacct::Catalog(3)>. 930Sstevel@tonic-gate 940Sstevel@tonic-gateB<C<< ea_new_file($name, $oflags, creator => $creator, 950Sstevel@tonic-gate aflags => $aflags, mode => $mode) >>> 960Sstevel@tonic-gate 970Sstevel@tonic-gateThis convenience function is a wrapper around the 980Sstevel@tonic-gateC<< Sun::Solaris::Exacct::File->new() >> method. See 990Sstevel@tonic-gateC<Sun::Solaris::Exacct::File(3)>. 1000Sstevel@tonic-gate 1010Sstevel@tonic-gateB<C<ea_new_item($catalog, $value)>> 1020Sstevel@tonic-gate 1030Sstevel@tonic-gateThis convenience function is a wrapper around the 1040Sstevel@tonic-gateC<< Sun::Solaris::Exacct::Object::Item->new() >> method. See 1050Sstevel@tonic-gateC<Sun::Solaris::Exacct::Object::Item(3)>. 1060Sstevel@tonic-gate 1070Sstevel@tonic-gateB<C<ea_new_group($catalog, @objects)>> 1080Sstevel@tonic-gate 1090Sstevel@tonic-gateThis convenience function is a wrapper around the 1100Sstevel@tonic-gateC<< Sun::Solaris::Exacct::Object::Group->new() >> method. See 1110Sstevel@tonic-gateC<Exacct::Object::Group(3)>. 1120Sstevel@tonic-gate 1130Sstevel@tonic-gateB<C<ea_dump_object($object, $filehandle)>> 1140Sstevel@tonic-gate 1150Sstevel@tonic-gateThis convenience function is a wrapper around the 1160Sstevel@tonic-gateC<< Sun::Solaris::Exacct::Object->dump() >> method. See 1170Sstevel@tonic-gateC<Sun::Solaris::Exacct::Object(3)>. 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate=head2 Class methods 1200Sstevel@tonic-gate 1210Sstevel@tonic-gateNone. 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate=head2 Object methods 1240Sstevel@tonic-gate 1250Sstevel@tonic-gateNone. 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate=head2 Exports 1280Sstevel@tonic-gate 1290Sstevel@tonic-gateBy default nothing is exported from this module. The following tags can be 1300Sstevel@tonic-gateused to selectively import constants and functions defined in this module: 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate :SYSCALLS getacct(), putacct(), and wracct() 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate :LIBCALLS ea_error() and ea_error_str() 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate :CONSTANTS P_PID, P_TASKID, P_PROJID, EW_*, EP_*, and EXR_* 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate :SHORTHAND ea_register_catalog(), ea_new_catalog(), ea_new_file(), 1390Sstevel@tonic-gate ea_new_item(), and ea_new_group() 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate :ALL :SYSCALLS, :LIBCALLS, :CONSTANTS, and :SHORTHAND 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate :EXACCT_CONSTANTS :CONSTANTS, plus the :CONSTANTS tags for 1440Sstevel@tonic-gate Sun::Solaris::Catalog, Sun::Solaris::File, 1450Sstevel@tonic-gate and Sun::Solaris::Object 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate :EXACCT_ALL :ALL, plus the :ALL tags for Sun::Solaris::Catalog, 1480Sstevel@tonic-gate Sun::Solaris::File, and Sun::Solaris::Object 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate=head1 ATTRIBUTES 1510Sstevel@tonic-gate 1520Sstevel@tonic-gateSee C<attributes(5)> for descriptions of the following attributes: 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate ___________________________________________________________ 1550Sstevel@tonic-gate | ATTRIBUTE TYPE | ATTRIBUTE VALUE | 1560Sstevel@tonic-gate |_____________________________|_____________________________| 1570Sstevel@tonic-gate | Availability | CPAN (http://www.cpan.org) | 1580Sstevel@tonic-gate |_____________________________|_____________________________| 1590Sstevel@tonic-gate | Interface Stability | Evolving | 1600Sstevel@tonic-gate |_____________________________|_____________________________| 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate=head1 SEE ALSO 1640Sstevel@tonic-gate 1650Sstevel@tonic-gateC<getacct(2)>, C<putacct(2)>, C<wracct(2)>, C<ea_error(3EXACCT)>, 1660Sstevel@tonic-gateC<Sun::Solaris::Exacct::Catalog(3)>, C<Sun::Solaris::Exacct::File(3)>, 1670Sstevel@tonic-gateC<Sun::Solaris::Exacct::Object(3)>, C<Sun::Solaris::Exacct::Object::Group(3)>, 1680Sstevel@tonic-gateC<Sun::Solaris::Exacct::Object::Item(3)>, C<libexacct(3LIB)>, C<attributes(5)> 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate=head1 NOTES 1710Sstevel@tonic-gate 1720Sstevel@tonic-gateThe modules described in the C<Sun::Solaris::Exacct> manual pages make 1730Sstevel@tonic-gateextensive use of the Perl "double-typed scalar" facility. This facility allows 1740Sstevel@tonic-gatea scalar value to behave either as an integer or as a string, depending upon 1750Sstevel@tonic-gatecontext. It is the same behavior as exhibited by the C<$!> Perl variable 1760Sstevel@tonic-gate(C<errno>). It is useful because it avoids the need to map from an integer 1770Sstevel@tonic-gatevalue to the corresponding string to display a value. Some examples are 1780Sstevel@tonic-gateprovided below: 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate # Assume $obj is a Sun::Solaris::Exacct::Item 1810Sstevel@tonic-gate my $type = $obj->type(); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate # Print "2 EO_ITEM" 1840Sstevel@tonic-gate printf("%d %s\n", $type, $type); 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate # Behave as an integer, $i == 2 1870Sstevel@tonic-gate my $i = 0 + $type; 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate # Behave as a string, $s = "abc EO_ITEM xyx" 1900Sstevel@tonic-gate my $s = "abc $type xyz"; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gateWherever a function or method is documented as returning a double-typed 1930Sstevel@tonic-gatescalar, the returned value exhibits this type of behavior. 194