/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72Q src/bos/usr/ccs/lib/libcorcfg/wparcfg.h 1.9.5.2 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2005,2019 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* @(#)90 1.9.5.2 src/bos/usr/ccs/lib/libcorcfg/wparcfg.h, libcor, bos72Q, q2019_13A4 2/4/19 06:28:48 */ #ifndef _WPARCFG_H #define _WPARCFG_H #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef enum { WPARTYPE_ERR, /* 0 - error */ WPARTYPE_SYS, /* 1 - system wpar */ WPARTYPE_APP, /* 2 - application wpar */ } wpartype_t; typedef struct corralentry { cid_t cid; cre_t ostype; ckey_t ckey; wpartype_t ctype; char cname[MAXCORRALNAMELEN + 1]; } corralentry_t, corrallist_t; typedef int accessop_t; #define CKREAD 1 /* Check readability */ #define CKWRITE 2 /* Check writability */ typedef int wparstate_t; #define CORRALSTATUS_ERROR -1 #define CORRALSTATUS_BROKEN 0x01 #define CORRALSTATUS_TRANSITIONAL 0x02 #define CORRALSTATUS_DEFINED 0x04 #define CORRALSTATUS_ACTIVE 0x08 #define CORRALSTATUS_LOADED 0x10 #define CORRALSTATUS_PAUSED 0x20 #define CORRALSTATUS_FROZEN 0x40 #define CORRALSTATUS_MOVING 0x80 #define CORRALSTATUS_MAINTENANCE 0x100 #define CORRALSTATUS_SERVICE 0x200 /* Flags for getwparstate */ #define WPARSTATE_PERSPECTIVE_OFF 0x01 extern int getcorralid(const char *, cid_t *); /* * getcorralid returns the id of the corral matching the input parameter. * * EAGAIN - The lock could not be acquired to read the corral database. * EIO - An I/O error occurred reading the corral database. * ENOENT - The corrals database does not exist. * EACCESS - The process does not have appropriate privileges to access the * corrals database. * ESRCH - No corral matching the name parameter could be found in the corral * database. */ extern char * getcorralname(cid_t, char *, int); /* * getcorralname returns the name of the corral matching the cid_t parameter * in the buffer supplied by the caller in the buf parameter. * bufsize specifies the length of the buffer pointed to by the buf parameter, * including space required for the trailing null character. If bufsize is * less than the length required to hold the name of the corral, then NULL * is returned and errno is set to ERANGE. * * Return value: * Upon completion, getcorralname() returns a pointer to the name of * the corral if successful, or a null pointer if an error occurred. * * Errors Codes: * * EAGAIN - The lock could not be acquired to read the corral database. * EIO - An I/O error occurred reading the corral database. * ENOENT - The corrals database does not exist. * EACCESS - The process does not have appropriate privileges to access the * corrals database. * ERANGE - Insufficient storage was supplied via buffer and bufsize to * contain the corral name string to be retured. Allocate a * buffer of size _CORRALNAME_MAX to avoid this error. * ESRCH - No id matching the cid_t parameter could be found in the * corral database. */ extern wpartype_t getcorraltype(corralentry_t); /* * getcorraltype() returns the type of the WPAR matching the input parameter. * If the parameter's key field is 0, only the name is used to match. If the * name field is empty (ie. the first character is '\0'), only the key field is * used to match. If both are set, then both must match. * Otherwise, WPARTYPE_ERR is returned and the errno global variable is set to * indicate the error. * * Return value: * Upon completion, getcorraltype() returns one of the wpartype_t values * defined in this file. On error, WPARTYPE_ERR is returned and errno is * set to one of the following values: * * Error Codes: * * ESRCH - No WPAR matching the name/key could be found in * the WPAR database. * EINVAL - Neither the cname nor the ckey field is set. * EAGAIN - The lock could not be acquired to read the WPAR database. * EIO - An I/O error occurred reading the WPAR database. * ENOENT - The WPAR database does not exist. * EACCESS - The process does not have appropriate privileges to access the * WPAR database. * EFORMAT - The format of the database is incorrect. */ extern corralentry_t *getcorralbykey(ckey_t, corralentry_t *); extern corralentry_t *getcorralbyname(char *, corralentry_t *); extern char * generate_cuuid(void); extern int sanity_check_on_uuid(char *); extern int getcorrallist(corrallist_t *, int *); /* * getcorrallist returns the list of corrals in the buffer supplied by the * caller in the buf parameter. * needed specifies the number of corrallist_t entries pointed to by the buf * parameter. * If needed is less than the number of corrals, needed is updated and -1 * is returned and errno is set to ERANGE. * * Return value: * Upon completion, getcorrallist() returns 0 if successful, -1 on failure * * Errors Codes: * * EAGAIN - The lock could not be acquired to read the corral database. * EIO - An I/O error occurred reading the corral database. * ENOENT - The corrals database does not exist. * EACCESS - The process does not have appropriate privileges to access the * corrals database. * ERANGE - Insufficient storage was supplied via buffer. */ extern int setcorralid (corralentry_t); /* * setcorralid sets the id of the corral matching the input parameter. * Upon successful completion, setcorralid() returns zero, and changes the * cid of the corral matching the name/key parameter into the cid value passed * as input. If the parameter's key field is 0, only the name is used to * match. If the name field is empty (ie. the first character is '\0'), * only the key field is used to match. If both are set, then both must match. * Otherwise, -1 is returned and the errno global variable is set to * indicate the error. * * Error Codes : * * EINVAL - Neither the cname nor the ckey field is set. * EACCESS - The process does not have appropriate privilege to * access the corrals database. * EAGAIN - The index file is busy or locked. * EIO - I/O error reading the index file. * ENOENT - The index file could not be found. * ESRCH - No corrals matching the name/key could be found in * the corrals database. */ extern int setcorralname (corralentry_t, char *); /* * setcorralname modifies the name of the corral matching the input parameter * to the new name passed as input. * Upon successful completion, setcorralname() returns zero, and changes the * existing name of the corral matching the name/key parameter into the * new name passed as input. * If the parameter's key field is 0, only the name is used to * match. If the name field is empty(ie. the first character is '\0'), * only the key field is used to match. If both are set, then both must match. * Otherwise, -1 is returned and the errno global variable is set to * indicate the error. * * Error Codes : * * EINVAL - Neither the cname nor the ckey field is set or the new * name is not in proper format. * ERANGE - Input name exceeds the maxium allowable character limit for * for corral. * EACCESS - The process does not have appropriate privilege to * access the corrals database. * EAGAIN - The index file is busy or locked. * EIO - I/O error reading the index file. * ENOENT - The index file could not be found. * ESRCH - No corrals matching the name/key could be found in * the corrals database. */ ckey_t putcorral (char *, wpartype_t); /* * putcorral puts a new entry corresponding to the name parameter in the * index file. * Upon successful completion, putcorral() returns the newly generated * unique key and adds an entry in the index file with the cid set to 0. * Otherwise, 0 is returned and the errno global variable is set to * indicate the error. * * Error Codes: * * EBUSY - Input name parameter is already in use. * EINVAL - Input name or type parameter is not proper. * ERANGE - Input name exceeds the max allowable character limit. * EACCESS - The process does not have appropriate privelege to access * the corrals database. * EIO - I/O error reading index file. * ENOENT - The index file could not be found. * EAGAIN - The index file is busy or locked. */ int delcorralbyname (char *); /* * delcorralbyname deletes an existing entry matching e name parameter * from the index file. * Upon successful completion, delcorralbyname() deletes the index * file entry matching the name parameter and returns 0. * Otherwise, -1 is returned and the errno global variable is set to * indicate the error. * * Error Codes: * * EAGAIN - The index file is busy or locked. * EINVAL - Input name parameter is not proper. * ERANGE - Input name exceeds the max allowable character limit. * EACCESS - The process does not have appropriate privileges to * access the database. * EIO - I/O error reading the index file. * ENOENT - The index file could not be found. * ESRCH - No corrals matching the name could be found in the database. * EBUSY - Corral matching the name is currently active. */ int delcorralbykey (ckey_t); /* * delcorralbykey deletes an entry matching the key parameter. * Upon successful completion, delcorralbykey() deletes the index * file entry matching the key parameter and returns 0. * Otherwise, -1 is returned and the errno global variable is set to * indicate the error. * * Error Codes: * * EAGAIN - The index file is busy or locked. * EINVAL - Input key parameter is not valid. * EACCESS - The process does not have appropriate privileges to * access the database. * EIO - I/O error reading the index file. * ENOENT - The index file could not be found. * ESRCH - No corrals matching the key could be found in the database. * EBUSY - Corral matching the key is currently active. */ int refreshindexfile(void); /* * Function: refreshindexfile() cycles through the index file, cleaning out any * bogus entries and validating and resetting all cids. Keys are only validated * for format - we don't refresh them based on any corral_t structures that may * exist in the kernel. * * Return value: * If everything went perfectly, zero is returned. If a fatal error * occurred, such that the index file was not rewritten (and may be * corrupted), -1 is returned. Otherwise, an error count is returned and * errno indicates the LAST failure. Error codes set by this function are * found below. Other error codes may be set by the corral_getid() syscall. * * Error Codes: * * EAGAIN - The index file is busy or locked. * EINVAL - An entry in the index file was invalid (the entry was removed) * ERANGE - A name in the index file was too long (the entry was removed) * EACCESS - The process does not have appropriate privileges to * access the database. * EIO - I/O error reading the index file. * ENOENT - The index file could not be found. */ extern int corlogevent(char*, char*); /* * Function: corlogevent() is a wrapper for corlogevent_pid. * API call used for C languages. See corlogevent_pid(). * * Parameters: char* * char* */ extern int corlogevent_pid(uint_t, pid_t, char*, char*, char*); /* * Function: corlogevent_pid() logs an event to the corral event log file. * API call used by Perl XSub and the executable wrapper * for shell languages. * * Parameters: uint_t * pid_t * char* * char* * char* * * Description: corlogevent_pid() will attempt to obtain a lock * on the event log file before writing to it. If corlogevent() * fails to obtain a lock within the timeout period, ENOLCK will * be returned. corlogevent() will generate and prefix a time stamp * to the message. * * Return Value: * Upon completion, corlogevent_pid() returns 0 if successful, -1 on failure. * * Errors Codes: * * ENOLCK - Unable to lock event log file. * EINVAL - Invalid or out of range argument. * EFAULT - Error generating timestamp. * * Additional error codes may be returned by branch functions. */ extern void print_cerrors(uint, char*); /* * Function: Wrapper to print_cerrors_pid(). * API call used fpr C language WPAR commands. * * Parameters: uint * char* */ extern void print_cerrors_pid(uint, pid_t, char*, char*); /* * Function: print_cerrors_pid() prints messages associated with errors detected * by corral system calls. * * Parameters: uint * pid_t * char* * char* * * Description: see function. * * Return Value: N/A * * Errors Codes: None */ extern int ckaccess(char *, accessop_t); /* * Function: ckaccess() determines whether the current process has read * (accessop_t CKREAD), write (CKWRITE), or read-write (CKREAD|CKWRITE) access * to the entity specified in the first parameter. * * Parameters: char* * accessop_t * * Description: see function. * * Return Value: * 0 if access is allowed * EINVAL if the entity is null or the op isn't in range. * ENOENT if accessop_t is CKREAD and the entity does not exist. * EBUSY if all possible writable test files already exist (writability could * not be determined) * EROFS or EACCES if access is otherwise not allowed. * * Error Codes: * * Same as return code * */ extern char *cfgname(char *, int, struct stat *); /* * Returns the full path to the configuration file for the specified WPAR. On * error, returns NULL and sets errno. It is the responsibility of the caller * to free() the returned string. * If the nocheck flag is unset (zero), the function will also stat() the * generated path. If the file doesn't exist or is not a regular file, the * function will return NULL. * If the sp pointer is not null, the result of the stat() will be stored in the * structure to which it points. The content of the structure is only * guaranteed if the function returns successfully. * * Parameters: char* * int * struct stat * * * Return Value: A newly-malloc()ed string representing the absolute path to the * WPAR's config file, or NULL on error. * * Error Codes: * EINVAL - Function called with an invalid cname, or nocheck is zero and the * generated path is not a regular file. * ENOENT - The nocheck parameter is zero and the generated path does not * exist. * EACCESS - The process does not have appropriate privileges to access the * WPAR database or the config file in question. * Other errnos from malloc(), stat(), get/setppriv(), etc. */ extern long corral_ownerid(char *); /* * Returns the UID of the owner of the named WPAR's config file, or -1 on error. * Return type is long to distinguish between a big uid (unsigned int > MAXINT) * and failure (-1). * * Parameters: char* * * Error Codes: * EINVAL - Function called with an invalid cname. * ENOENT - The config database for the named WPAR does not exist. * EACCESS - The process does not have appropriate privileges to access the * WPAR database or the config file in question. * Other errnos from malloc(), stat(), get/setppriv(), etc. */ extern wparstate_t getwparstate(char *, uint); /* * Function: getwparstate() determines the state of the named wpar. * * Parameters: char* * uint * * Return Value: * -1 on error * Otherwise, one of the wparstate_t values #defined above. * Note that the value returned is normally dependent on the perspective of * the caller with respect to administrative locking. If the caller is the * lock holder or a descendant thereof, getwparstate() will never report * CORRALSTATUS_TRANSITIONAL, but will report the underlying state. This * perspective can be disabled by setting the value of the flags parameter * to WPARSTATE_PERSPECTIVE_OFF, in which case getwparstate() will always * report as though the caller is unrelated to the lock holder. * * Error Codes: * * EINVAL - passed-in char* is null or empty or invalid flags passed * OR * errnos from the following operations: * getcorralbyname() * corlockstat() * corral_getinfo() */ extern void wpar_clear_index_cache(void); /* * Function: wpar_clear_index_cache() resets the internal cache state, causing the * next query operation (such as getcorralid(), getcorrallist(), etc.) to * regenerate the cache afresh from the index file and kernel state. * * Parameters: None * * Return: None * * Error Codes: None */ extern int mkdevexport(cid_t, char *, wdevtype_t); extern int rmdevexport(cid_t, char *, wdevtype_t); int wio_devimport(wdevimport_t *wimp, unsigned int devtype, unsigned int flag); int getKEsign(char *dd_name, char *path, uchar_t *hash); int mkKEexport(cid_t cid, /* WPAR ID */ char *dd_name, /* KE name */ unsigned int major, /* major */ uchar_t *hash, /* hash */ unsigned int type); /* type */ int rmKEexport(cid_t cid, char *dd_name, uchar_t * hash); int rmKEexports(cid_t cid); int qryKEexport(cid_t cid, char * dd_name, uchar_t *hash, wdevKEexport_t * out ); int qryKEexports(cid_t cid, wdevKEexport_t * out, int * size ); #if 0 /* WPAR device ODM routines */ int wdev_set_odmpath(char *path, char *oldpath); int wdev_odminit(void); int wdev_odmterm(void); int wdev_open_class(wdevclass_t class); int wdev_odmget(wdevodmqry_t qry, void *outbuf); #endif #ifdef __cplusplus } #endif #endif /* _WPARCFG_H */