Appendix B. Application Programming Interface for the Comprehensive System Accounting (CSA)

This appendix contains information about the application programming interface (API) for Comprehensive System Accounting (CSA).

Linux CSA Application Interface Library

The Linux CSA application interface library provides interfaces that allow a programmer access to CSA capabilities, as follows:

Application interface man page 

Description

 

csa_auth(3) 

Checks to determine if caller has the necessary capabilities.

csa_check(3) 

Checks a kernel, daemon, or record accounting state.

csa_halt(3) 

Stops all accounting methods.

csa_jastart(3) 

Startd job accounting.

csa_jastop(3) 

Stops job accounting.

csa_kdstat(3) 

Gets the kernel and daemon accounting status.

csa_rcdstat(3) 

Gets the record accounting status.

csa_start(3) 

Gets the user ID of a job.

csa_stop(3) 

Stops specified accounting method(s).

csa_wracct(3) 

Writes the accounting record to file.

csa_auth(3)

NAME

csa_auth -checks if caller has the necessary capabilities

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>
int csa_auth();

DESCRIPTION

The csa_auth library call is part of the csa_api library that allows processes to manipulate and obtain status about linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

RETURN VALUE

Upon successful verification of proper capabilities, csa_auth returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_auth function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_check(3)csa_kdstat(3), csa_rcdstat(3), csa_jastart (3), csa_jastop(3), and csa_wracct(3).

csa_check(3)

NAME

csa_check -checks if caller has the necessary capabilities

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_check( struct csa_check_req *check_req );

DESCRIPTION

The csa_check library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h heade file should be included to obtain the proper definitions.

csa_check checks the state of a specified accounting method.

The caller should provide as a parameter a pointer to a variable of data structure type csa_check_req, as follows:

/*
         * CSA_CHECK request and reply
         */
        struct csa_check_req {
            struct csa_am_stat ck_stat;
        };

        /*
         * CSA Accounting Method Status struct
         */
        struct csa_am_stat {
            int     am_id;          /* accounting method ID */
            int     am_status;      /* accounting method status */
            int64_t am_param;       /* accounting method parameter */
        };

The state of the inquired accounting method is returned in am_status.

RETURN VALUE

Upon successful completion, csa_check returns 0 and check_req->ck_status contains the status of the inquired accounting method. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_check function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_kdstat(3), csa_rcdstat (3), csa_jastart(3), csa_jastop(3) csa_wracct(3), and csa_auth(3).

csa_halt(3)

NAME

csa_halt -stops all accounting methods

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_halt();

DESCRIPTION

The csa_halt library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_halt stops all accounting methods.

RETURN VALUE

Upon successful verification of proper capabilities, csa_halt returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_halt function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_check(3)csa_kdstat(3), csa_rcdstat (3), csa_jastart(3), csa_jastop(3), csa_auth(3) and csa_wracct(3).

csa_jastart(3)

NAME

csa_jastart -starts job accounting

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_jastart( struct csa_job_req *job_req );

The csa_jastart library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_jastart starts job accounting.

The caller should provide as a parameter a pointer to a variable of data structure type csa_job_req, as follows:

/*
         * CSA_JASTART/CSA_JASTOP request
         */
        struct csa_job_req {
            char    job_path[ACCT_PATH+1];
        };

RETURN VALUE

Upon successful completion, csa_jastart returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_jastart function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_check(3),csa_kdstat (3), csa_rcdstat(3), csa_jastop(3) csa_wracct(3), and csa_auth(3).

csa_jastop(3)

NAME

csa_jastop -stops job accounting

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_jastop( struct csa_job_req *job_req );

DESCRIPTION

The csa_jastop library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h heade file should be included to obtain the proper definitions.

csa_jastop stops job accounting.

The caller should provide as a parameter a pointer to a variable of data structure type csa_job_req, as follows:

/*
         * CSA_JASTART/CSA_JASTOP request
         */
        struct csa_job_req {
            char    job_path[ACCT_PATH+1];
        };

RETURN VALUE

Upon successful completion, csa_jastop returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_jastop function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_check(3),csa_kdstat (3), csa_rcdstat(3), csa_jastart(3) csa_wracct(3), and csa_auth(3).

csa_kdstat(3)

NAME

csa_kdstat -gets the kernel and daemon accounting status

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_kdstat( struct csa_status_req *kdstat_req );

DESCRIPTION

The csa_kdstat library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h heade file should be included to obtain the proper definitions.

csa_kdstat gets the kernel and daemon accounting status.

The caller should provide as a parameter a pointer to a variable of data structure type csa_status_req, as follows:

/*
         * CSA_KDSTAT/CSA_RCDSTAT request
         */
        struct csa_status_req {
            int     st_num;         /* num of entries in kd_method array */
            char    st_path[ACCT_PATH+1];
            struct csa_am_stat st_stat[NUM_KDRCDS];
        };

        /*
         * CSA Accounting Method Status struct
         */
        struct csa_am_stat {
            int     am_id;          /* accounting method ID */
            int     am_status;      /* accounting method status */
            int64_t am_param;       /* accounting method parameter */
        };

The inquired status are returned in the am_status field of st_stat array.

RETURN VALUE

Upon successful completion, csa_kdstat returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_kdstat function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_check(3),csa_jastop (3), csa_rcdstat(3), csa_jastart(3) csa_wracct(3), and csa_auth(3).

csa_rcdstat(3)

NAME

csa_rcdstat -gets the record accounting status

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_rcdstat( struct csa_status_req *rcdstat_req );

DESCRIPTION

The csa_rcdstat library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_rcdstat gets the record accounting status.

The caller should provide as a parameter a pointer to a variable of data structure type csa_status_req, as follows:

/*
         * CSA_KDSTAT/CSA_RCDSTAT request
         */
        struct csa_status_req {
            int     st_num;         /* num of entries in kd_method array */
            char    st_path[ACCT_PATH+1];
            struct csa_am_stat st_stat[NUM_KDRCDS];
        };

        /*
         * CSA Accounting Method Status struct
         */
        struct csa_am_stat {
            int     am_id;          /* accounting method ID */
            int     am_status;      /* accounting method status */
            int64_t am_param;       /* accounting method parameter */
        };

The inquired status are returned in the am_status field of st_stat array.

RETURN VALUE

Upon successful verification of proper capabilities, csa_rcdstat returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_rcdstat function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3), csa_halt(3), csa_check(3),csa_jastop (3), csa_kdstat(3), csa_jastart(3) csa_wracct(3), and csa_auth(3).

csa_start(3)

NAME

csa_start -starts specified accounting method(s)

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>




DESCRIPTION

The csa_start library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_start starts specified CSA accounting method(s).

The caller should provide as a parameter a pointer to a variable of data structure type struct csa_start_req, as follows:

/*
         * CSA_START request
         */
        struct csa_start_req {
            int    sr_num;         /* num of entries in sr_method array */
            char   sr_path[ACCT_PATH+1];  /* path name for accounting file */
            struct method_info {
                   int     sr_id;         /* Accounting Method type id */
                   int64_t param;         /* Entry parameter */
            } sr_method[NUM_KDRCDS];
        }

RETURN VALUE

Upon successful verification of proper capabilities, csa_start returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_start function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_stop(3), csa_halt(3), csa_check(3),csa_jastop(3), csa_kdstat (3), csa_rcdstat(3), csa_jastart(3) csa_wracct(3), and csa_auth(3).

csa_stop(3)

NAME

csa_stop -

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_stop( struct csa_stop_req *stop_req );

DESCRIPTION

The csa_stop library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_stops stops specified CSA accounting method(s).

The caller should provide as a parameter a pointer to a variable of data structure type csa_stop_req, as follows:

/*
         * CSA_STOP request
         */
        struct csa_stop_req {
            int     pr_num;         /* num of entries in pr_id[] array */
            int     pr_id[NUM_KDRCDS];   /* Accounting Method type id */
        };

RETURN VALUE

Upon successful verification of proper capabilities, csa_stop returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_stop function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_halt(3), csa_check(3),csa_jastop(3), csa_kdstat (3), csa_rcdstat(3), csa_jastart(3) csa_wracct(3), and csa_auth(3).

csa_wracct(3)

NAME

csa_wracct -writes an accounting record to a file

LIBRARY

Linux CSA Application Interface library (libcsa_api, -lcsa_api)

SYNOPSIS

#include <csa_api.h>

int csa_wracct( struct csa_wra_req *wra_req );

DESCRIPTION

The csa_wracct library call is part of the csa_api library that allows processes to manipulate and obtain status about Linux CSA accounting methods. When the csa_api library is to be used, the csa_api.h header file should be included to obtain the proper definitions.

csa_wracct writes an accounting record to a file.

The caller should provide as a parameter a pointer to a variable of data structure type csa_wra_req, as follows:

/*
         * CSA_WRACCT request
         */
        struct csa_wra_req {
            int             wra_did;        /* Daemon Index */
            int             wra_len;        /* Length of buffer (bytes) */
            uint64_t        wra_jid;        /* Job ID */
            char            *wra_buf;       /* Daemon accounting buffer */
        };

RETURN VALUE

Upon successful verification of proper capabilities, csa_wracct returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

Under the following conditions, the csa_wracct function fails and sets errno to:

[EACCESS] 

Search permission is denied on a component of the path prefix.

[EFAULT] 

The check_req argument points to an illegal address.

[EINVAL] 

An invalid argument was specified.

[EPERM] 

The process does not have appropriate capability to use this system call.

[ENOSYS] 

The CSA kernel module/driver is not installed.

[ENOENT] 

No job table entry is found when attempting to start or stop user job accounting.

SEE ALSO

csa_start(3), csa_stop(3)csa_halt(3), csa_check(3),csa_jastop (3), csa_kdstat(3), csa_rcdstat(3),csa_jastart(3), and csa_auth(3).