This appendix provides an overview of the site-defined policy feature and a summary of the policy subroutines sites may write:
Site-defined policy subroutines are loaded dynamically by DMF to provide custom decision-making at key points in its processing. Several DMF processes, including dmfdaemon, can call subroutines within sitelib.so.
You do not need to use this feature, in which case DMF will function as documented in the manuals and man pages. But if you wish, you can implement one or more of these subroutines in order to override DMF's default behavior.
If you use the site-defined policy feature, you must communicate the policy changes to your user community; otherwise, they will not be able to predict how the user commands will work. The man page for any command with a site-defined policy will state something like the following:
If your site is using the site-defined policy feature, the default behavior may be overridden. Please check with your administrator for any behavior differences due to site-defined policies.
You should also consider adding ERROR, WARN, and INFO messages into the reply stream for commands you customize so that you can routinely return messages to the user that explain what was changed in their request. Doing so will allows the users to understand why the behavior was different from what they expected.
The subroutines are written in C++ according to the subroutine prototypes in /usr/include/dmf/libdmfadm.H. They are placed in a shared-object library called /usr/lib/dmf/sitelib.so.
The parameters and return values of the subroutines and the name of the sitelib.so library are fixed and cannot be altered by the site. In general, the parameters provide all of the information DMF has that is relevant to the purpose of the subroutine, which is described in the comments preceding each subroutine.
The code within the subroutines performs whatever processing the site wishes. To assist in several common operations, such as extracting information from the DMF configuration file, optional helper subroutines are provided in /usr/include/dmf/libdmfadm.H.
The /usr/share/doc/dmf-*/info/sample directory contains the following files to demonstrate generating the sitelib.so library:
| Note: If you use these files as a base for implementing subroutines of your own, be sure to keep them in a different directory and/or rename them to avoid any conflict when DMF is upgraded and new sample files are installed. For example, you could rename the files sitelib.c and sitelib.mk. |
Do the following:
Copy sample_sitelib.C and its associated makefile sample_sitelib.mk from /usr/share/doc/dmf-*/info/sample to a directory of your own with names of your own choice.
For example, if you wanted to work in the /tmp/testdmf directory:
$ cp /usr/share/doc/dmf-*/info/sample_sitelib.C /tmp/testdmf/sitelib.C $ cp /usr/share/doc/dmf-*/info/sample_sitelib.mk /tmp/testdmf/sitelib.mk |
In the makefile, specify the stem from which the library filename and source code filename will be derived by editing the value for the SITELIB parameter. For example, to use a stem of sitelib (that is, sitelib.so for the library and sitelib.c for the source code file):
SITELIB=sitelib |
| Note: Although you can set the SITELIB value to something other than sitelib for testing purposes, when you actually want to run with DMF, it must be sitelib. |
Read the comments at the start of each subroutine and alter the supplied code to suit your requirements. As supplied, each subroutine is disabled. To enable one or more subroutines, modify the SiteFncMap variable at the bottom of the source file (in our example, sitelib.C).
| Note: The name of the SiteFncMap variable is fixed and cannot be altered. However, you can change the names of the site-defined subroutines such as SiteCreateContext(). |
Build the sitelib.so library by using the make(1) command:
$ make -f sitelib.mk |
Print a list of the subroutines that have been enabled and visually verify that it is what you expect:
# make -f sitelib.mk verbose |
Install the library on a DMF server, which requires you to be the root user:
$ su # make -f sitelib.mk install |
| Note: You do not need to install sitelib.so on a machine that functions only as a DMF client. |
For subroutines that affect the operation of the DMF daemon, library server, or MSP, you must wait for a minute or so for the new sitelib.so library to be noticed. You will see a message in the relevant log file when this happens.
Test your new library by monitoring the relevant logfile with tail -f while you present test cases to DMF. You may also find it useful to have a Resource Watcher configured and running or to use dmstat.
As you write your own custom subroutines, be aware of the following:
The sitelib.so file must be owned by root and must not be writable by anyone else, for security reasons. If these conditions are not met, DMF will ignore sitelib.so and use the default behavior.
The sitelib.so library should not use the stdin, stdout, or stderr files as this could cause problems for DMF, possibly endangering data. For information about sending messages to users or to log files, see “DmaSendLogFmtMessage()” and “DmaSendUserFmtMessage()”.
If you overwrite the sitelib.so file while it is in use (for example by copying a new version of your file over the top of the old one), DMF processes may abort or run improperly. The DMF daemon may or may not be able to restart them properly.
To update the file, you should do one of the following:
Use the mv(1) command to move the new file over the top of the old one, so that any existing DMF processes will continue to use the previous version of the file, which is now unlinked pending removal. The install target in the supplied makefile is also a safe way to update the file.
Delete the old file with rm(1) before installing the new one using cp, mv, or make install.
Shut down DMF while the update takes place.
This warning also applies to changes to the DMF configuration file.
Site-defined policy subroutines should not call subroutines in libdmfusr.so, such as DmuSettagByPathSync() . They are free to call member functions of classes defined in libdmfcom.H, such as DmuVolGroups_t::numVolGroups() .
At times, the site-defined subroutines may be called many times in rapid succession. They should therefore be as efficient as possible, avoiding any unnecessary processing, especially of system calls.
For example, when dmfsfree is invoked to prevent a filesystem from filling, site-defined subroutines may be called one or more times for every file in the filesystem as dmfsfree prepares its list of candidates prior to migrating and/or freeing some of them. If the functions are slow, DMF may not be able to react to the situation in time to prevent the filesystem from filling.
For IRIX systems, DMF processes that call routines in sitelib.so were compiled using MIPSpro compilers. Compiling the C++ routines that make up sitelib.so on IRIX systems with compilers other than MIPSpro compilers may result in incompatibilities causing load-time or run-time errors.
The data types described in this section are defined in libdmfadm.H. The information in this section is provided as a general description and overall usage outline. Other data types that are referenced in this file are defined in libdmfcom.H; see Appendix B, “DMF User Library libdmfusr.so”.
| Note: For the most current definitions of these types, see the libdmfadm.H file. |
The DmaContext_t object stores information for DMF in order to provide continuity from one subroutine call to the next. It is an opaque object that is created when a DMF process first loads sitelib.so and it exists until that process unloads it. This context is provided as a parameter for each of the site-defined policy subroutines.
Site-defined subroutines cannot directly access the information held in the context, but they can obtain information from it by using the following subroutines:
Site-defined subroutines can also store their own information in the context and retrieve it on subsequent calls by using the following subroutines:
The DmaFrom_t object specifies the type of policy statement being evaluated.
There are the following possible values:
| DmaFromAgeWeight | Indicates that an AGE_WEIGHT policy statement is being evaluated. | |
| DmaFromSpaceWeight | Indicates that a SPACE_WEIGHT policy statement is being evaluated. | |
| DmaFromVgSelect | Indicates that a SELECT_MSP or SELECT_VG policy statement is being evaluated. |
The DmaIdentity_t object provides information, if known, about the program calling the site-defined subroutine and the user whose request generated the call.
The public member fields and functions of this class are as follows:
| realm_type | |
Specifies the environment in which the type of data that is contained in the realm_data field is meaningful. The following settings are defined:
| |
| realm_data | |
Specifies user identity information that is specific to the environment defined by realm_type. Only the unix_1 member of the union is defined for the realm_type of DMF_REALM_UNIX. If the UID and/or GID values are 0xffffffff, the values are not reliable. | |
| logical_name | |
Specifies a character string containing the program name of the process. This may be an absolute or relative pathname. If the value is unknown, the program name was unavailable. | |
| product_name_and_revision | |
Specifies a character string containing the product name and revision (for example, DMF_3.1.0.0). | |
| locale_1 | |
Specifies a character string containing the locale value. See the locale(1) man page. | |
| host | |
Specifies a character string containing the host on which the DmaIdentity_t originated. | |
| pid | |
Specifies the process ID where the DmaIdentity_t originated. | |
| instance_id | |
Specifies a further refinement of the PID field. Because a process may create more than one DmaIdentity_t, this value is incremented by one for each new DmaIdentity_t. | |
| os_type | |
Specifies a character string containing a description of the operating system where the DmaIdentity_t originated. | |
| os_version | |
Specifies a character string containing a description of the operating system version where the DmaIdentity_t originated. | |
| cpu_type | |
Specifies a character string containing a description of the CPU type where the DmaIdentity_t originated. | |
| Note: Any of the descriptive character strings may be set to unknown if the field's true value cannot be determined. |
The DmaLogLevel_t object specifies the level of a message. The administrator may select a log level in the DMF configuration file; messages with a less severe level than what is specified in the configuration file will not appear in the log.
The SiteFncMap_t object specifies the site subroutine map. The various DMF processes that can call subroutines in sitelib.so look for a variable named SiteFncMap, of type SiteFncMap_t, in the sitelib.so library. It then uses the addresses provided in this variable to find the site-defined subroutines. If the variable is not found, DMF will not make any calls to subroutines in sitelib.so.
DMF looks for the variable named SiteFncMap, of type SiteFncMap_t, in the sitelib.so library. It then uses the addresses provided in this variable to find site-defined subroutines listed in this section. You can provide any number of these subroutines in the sitelib.so library.
The SiteCreateContext() subroutine provides the opportunity to create a site-specific setup. It is called when sitelib.so is loaded. If no such setup is required, it need not be implemented. If this subroutine returns anything other than DmuNoError, no other subroutines in sitelib.so, including SiteDestroyContext(), will be called by the current process, unless sitelib.so is changed and therefore reloaded.
This subroutine may not issue messages to the user because the user details are unknown at the time it is invoked. If it is invoked by a program with a log file, such as dmfdaemon, it can issue log messages by calling DmaSendLogFmtMessage(). You can call DmaGetContextFlags() to determine if it can issue log messages.
The prototype is as follows:
typedef DmuError_t (*SiteCreateContext_f)(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Refers to the context established when sitelib.so was loaded. |
The SiteDestroyContext() subroutine provides the opportunity for site-specific cleanup. It is called when sitelib.so is unloaded. If no such cleanup is required, it need not be implemented. This subroutine may not issue messages to the user because the user details are no longer valid at the time it is invoked. If it is invoked by a program with a log file, such as dmfdaemon, it can issue log messages by calling DmaSendLogFmtMessage(). You can call DmaGetContextFlags() to determine if it can issue log messages.
The prototype is as follows:
typedef void (*SiteDestroyContext_f)(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Refers to the context established when sitelib.so was loaded. |
The SiteKernRecall() subroutine allows sites some control over kernel requests to recall a file. It is invoked when DMF receives a kernel request to recall a file. For example, a read() system call for a file that is currently in OFL state would result in SiteKernRecall() being called. The dmget command or the equivalent libdmfusr.so library call would not result in a call to SiteKernRecall().
This subroutine may accept or reject the request or change its priority; no other changes are possible. If the subroutine returns a value other than DmuNoError, the request will be rejected. Changing the priority has no effect at this time.
| Note: offset and length pertain to the range of the file that the user's I/O request referenced, not the byte range that dmfdaemon will actually recall. |
The subroutine may not issue messages to the user, but it can issue messages to the DMF daemon log.
The prototype is as follows:
typedef DmuError_t (*SiteKernRecall_f) (
DmaContext_t dmacontext,
const DmuFullstat_t *fullstat,
const DmuFhandle_t *fhandle,
uint64_t offset,
uint64_t length,
DmaRecallType_t recall_type,
DmuPriority_t *operative_priority); |
The parameters are as follows:
| dmacontext | Refers to the context established when sitelib.so was loaded. | |
| fullstat | Specifies the DmuFullstat_t of the file being recalled | |
| fhandle | Specifies the DmuFhandle_t of the file being recalled | |
| offset | Pertains to the range of the file that the user's I/O request referenced. | |
| length | Pertains to the length of the file that the user's I/O request referenced. | |
| recall_type | Specifies the type of recall. | |
| operative_priority | (Deferred implementation.) |
The SitePutFile() subroutine allows sites some control over the DMF put requests. It is invoked when a dmput command is issued or when one of the following libdmfusr.so subroutines is called:
| DmuPutByPathAsync() |
| DmuPutByPathSync() |
| DmuPutByFhandleAsync() |
| DmuPutByFhandleSync() |
This subroutine is not called when automatic space management migrates a file.
| Caution: If SitePutFile() is implemented, it takes precedence over any when clause being used to control MSP or volume group selection, whether or not SiteWhen() has been implemented. |
If this subroutine returns a value other than DmuNoError , the put request will be rejected. The subroutine may not issue log messages, but it can issue messages to the user.
The prototype is as follows:
typedef DmuError_t (*SitePutFile_f) (
const DmaContext_t dmacontext,
const DmuFullstat_t *fstat,
const char *path,
const DmuFhandle_t *fhandle,
const int flags,
const DmuVolGroups_t *policy_volgrps,
const DmuPriority_t user_priority,
const int user_flags,
const DmuByteRanges_t *user_byteranges,
const DmuVolGroups_t *user_volgrps,
DmuPriority_t *operative_priority,
int *operative_flags,
DmuByteRanges_t *operative_byteranges,
DmuVolGroups_t *operative_volgrps); |
The parameters are as follows:
| dmacontext | Refers to the context established when sitelib.so was loaded. | |||||
| fstat | Specifies the DmuFullstat_t information of the target file for the put request. | |||||
| path | Specifies the pathname of the target file for the put request (if known) or NULL. | |||||
| fhandle | Specifies the DmuFhandle_t of the target file for the put request. | |||||
| flags | Specifies whether the SitePutFile() subroutine is called for the first time (0) or is replayed (nonzero). SitePutFile() can be called multiple times for the same request. For example, if dmfdaemon is not running, a dmput request will periodically try to establish a connection with it, and SitePutFile() may be called. If flags is 0, this is the first time that SitePutFile() has been called for a particular request. When a request is replayed, DMF reevaluates the parameters to SitePutFile() before calling it. | |||||
| policy_volgrps | Specifies an input parameter that contains the volume groups and MSPs that have been selected by the policy statements in the DMF configuration file. | |||||
| user_priority, user_flags, user_byteranges, user_volgrps | Contains information entered by the user as a dmput parameter (where supported) or as a parameter to one of the following libdmfusr.so subroutines:
| |||||
| operative_priority, operative_flags, operative_byteranges, operative_volgrps | Contains the information that will be used when the request is made to the dmfdaemon. These are all both input and output parameters. You can alter the operative_flags, operative_byteranges, and operative_volgrps values. (Currently, operative_priority is ignored. For compatibility with future releases of DMF, it is recommended that you do not alter the value of this parameter at this time.) |
The SiteWhen() subroutine provides the opportunity to supply the value for the sitefn variable in when clauses in the following parameters:
| AGE_WEIGHT |
| SPACE_WEIGHT |
| SELECT_MSP |
| SELECT_VG |
This subroutine is not supported in when clauses associated with a DCM cache.
| Caution: If SitePutFile() is implemented, it takes precedence over any when clause being used to control MSP or volume group selection, whether or not SiteWhen() has been implemented. |
For example,
SELECT_VG tp9840 when uid = archive or sitefn = 6 |
If this subroutine is unavailable, either because it was not implemented or because the sitelib.so library is not accessible, the expression using sitefn is evaluated as being false. Therefore, the example above would be treated as if it were the following:
SELECT_VG tp9840 when uid = archive or false |
Or more simply:
SELECT_VG tp9840 when uid = archive |
If a policy stanza contains multiple references to sitefn , it is possible that the subroutine is only called once and the value returned by that call may be used for several substitutions of sitefn. Therefore, a policy that contains the following will not necessarily call the subroutine three times:
AGE_WEIGHT -1 0 when sitefn < 10 AGE_WEIGHT 1 .1 SPACE_WEIGHT 1 1e-6 when sitefn != 11 SPACE_WEIGHT 2 1e-9 when sitefn > 19 SPACE_WEIGHT 3.14 1e-12 |
The subroutine can issue log messages in some circumstances and user messages in others. You can call DmaGetContextFlags() to determine what kind of messages are possible.
The prototype is as follows:
typedef int (*SiteWhen_f) (
const DmaContext_t dmacontext,
const DmuFullstat_t *fstat,
const DmuFhandle_t *fhandle,
DmaFrom_t fromtyp); |
The parameters are as follows:
| dmacontext | Refers to the context established when sitelib.so was loaded | |
| fstat | Specifies the DmuFullstat_t of the file being evaluated. | |
| fhandle | Specifies the DmuFhandle_t of the file being evaluated. | |
| fromtyp | Indicates what kind of policy is being evaluated. |
This section describes optional subroutines that may be called from sitelib.so and are present in the processes that load sitelib.so.
The DmaConfigStanzaExists() subroutine checks whether a specified stanza exists in the DMF configuration file.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
DmaBool_t
DmaConfigStanzaExists(
const DmaContext_t dmacontext,
const char *type,
const char *stanza); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| type | Specifies the type of the stanza being checked. | |
| stanza | Specifies the name of the stanza being checked. |
For example, if the DMF configuration file contained the following:
define /dmf1
TYPE filesystem
POLICIES space_policy vg_policy
enddef |
Then the following call would return true:
DmaConfigStanzaExists(dmacontext, "filesystem","/dmf1"); |
The DmaGetConfigBool() subroutine extracts parameter values of type DmaBool_t from the specified stanza in the DMF configuration file. If there is no such parameter definition or if it exists but with a missing or improper value, then the default is used.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
DmaBool_t
DmaGetConfigBool(
const DmaContext_t dmacontext,
const char *stanza,
const char *param,
DmaBool_t default_val); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| param | Specifies the name of the parameter for which DmaGetConfigBool() is searching. | |
| default_val | Specifies the value to use if param is not found in stanza or if param has a missing or invalid value. |
The DmaGetConfigFloat() subroutine extracts parameter values of type float from the specified stanza in the DMF configuration file. If there is no such parameter definition or if it exists but with a missing or invalid value, the default is used.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
float
DmaGetConfigFloat(
const DmaContext_t dmacontext,
const char *stanza,
const char *param,
float default_val,
float min,
float max); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| param | Specifies the name of the parameter for which DmaGetConfigFloat() is searching. | |
| default_val | Specifies the value to use if param is not found in stanza or if param has a missing or invalid value. | |
| min | Defines the minimum valid value. | |
| max | Defines the maximum valid value. |
The DmaGetConfigInt() subroutine extracts parameter values of type int64_t from the specified stanza in the DMF configuration file. If there is no such parameter definition or if it exists but with a missing or invalid value, then a default value is used.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
int64_t
DmaGetConfigInt(
const DmaContext_t dmacontext,
const char *stanza,
const char *param,
int64_t default_val,
int64_t min,
int64_t max); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| param | Specifies the name of the parameter for which DmaGetConfigInt() is searching. | |
| default_val | Specifies the value to use if param is not found in stanza or if param has a missing or invalid value. | |
| min | Defines the minimum valid value. | |
| max | Defines the maximum valid value. |
The DmaGetConfigList() subroutine returns a pointer to an array of words found in the parameter in the specified stanza. The items value points to a block of memory containing an array of string pointers are well as the strings themselves; the end of the array is marked by a NULL pointer. The block of memory has been allocated by the malloc() subroutine and can be released with the free() subroutine if desired. The caller is responsible for releasing this memory.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
DmaBool_t
DmaGetConfigList(
const DmaContext_t dmacontext,
const char *stanza,
const char *param,
char *** items); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| param | The name of the parameter for which DmaGetConfigList() is searching. | |
| items | Specifies an output value that points to a block of memory containing an array of string pointers as well as the strings themselves; the end of the array is marked by a NULL pointer. |
The DmaGetConfigStanza() subroutine return a pointer to an array of parameters and values for the specified stanza in the DMF configuration file. (That is, it provides the entire stanza, after comments have been removed.) The items value points to a block of memory containing an array of structures with string pointers as well as the strings themselves; the end of the array is marked by a NULL pointer. The block of memory has been allocated by the malloc() subroutine and can be released with the free() subroutine if desired. The caller is responsible for releasing this memory.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
DmaBool_t
DmaGetConfigStanza(
const DmaContext_t dmacontext,
const char *stanza,
DmaConfigData_t **items);
} |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| items | Specifies an output value that points to a block of memory containing an array of structures with string pointers as well as the strings themselves; the end of the array is marked by a NULL pointer. |
Extracts a string from the specified stanza in the DMF configuration file and returns it. If there is no such parameter definition, the default is used. If the parameter exists but with a missing value, the null string (which is a valid value) is returned.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
void
DmaGetConfigString(
const DmaContext_t dmacontext,
const char *stanza,
const char *param,
const char *default_val,
DmuStringImage_t &result); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| stanza | Specifies the name of the stanza being searched. | |
| param | Specifies the name of the parameter for which DmaGetConfigString() is searching. | |
| default_val | Specifies the value to use if param is not found in stanza. If param is found in stanza but has a missing value, the null string is returned. | |
| result | Specifies an output parameter, containing the result. |
The DmaGetContextFlags() determines if a given subroutine can issue log messages or issue user messages.
| Note: If DmaFlagContextValid() is not set in the return value, no use should be made of any other bits. |
DmaGetContextFlags() can return the following values, which may be OR'd together:
| DmaFlagContextValid | Indicates that the context is valid. | |
| DmaFlagLogAvail | Indicates that DmaSendLogFmtMessage may be called. | |
| DmaFlagMsgAvail | Indicates that DmaSendUserFmtMessage may be called. |
The prototype is as follows:
uint64_t
DmaGetContextFlags(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). |
The DmaGetCookie() subroutine returns the cookie that was stored in dmacontext by a call to DmaSetCookie() . If a NULL value is returned, either the context is invalid or the cookie was not set.
The prototype is as follows:
void *
DmaGetCookie(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). |
The DmaGetDaemonVolGroups() subroutine returns the volume groups and MSPs that the dmfdaemon is currently configured to use.
| Note: Values in the configuration file may change while DMF is running. |
The prototype is as follows:
const DmuVolGroups_t *
DmaGetDaemonVolGroups(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). |
The DmaGetProgramIdentity() subroutine returns a pointer to the program DmaIdentity_t object in the dmacontext parameter.
| Note: The program DmaIdentity_t object should not be confused with the user DmaIdentity_t object that is returned by “DmaGetUserIdentity()”. The user identity is usually of much more interest when applying site policies because it defines who is actually making the request as opposed to what process is negotiating the site policies. |
The prototype is as follows:
const DmaIdentity_t *
DmaGetProgramIdentity(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). |
The DmaGetUserIdentity() subroutine returns a pointer to the user DmaIdentity_t object in the dmacontext parameter.
The user DmaIdentity_t object contains as much information as could be reliably gathered regarding the identity of the originator of the request. For example, the user identity in the SitePutFile() policy subroutine would identify the process (such as dmput) that made the original DmuPutByPathSync() libdmfusr call.
If DmaGetUserIdentity() is called from within SiteKernRecall(), it will return the identity of dmfdaemon . The identity of the user who initiated the read request that caused SiteKernRecall() to be called is unknown to DMF.
Within SiteCreateContext(), the user details may be as yet unknown; therefore, DmaGetUserIdentity() may return different values than if it is called with the same context from another site-defined policy subroutine. In most cases, the user identity is determined after the call to SiteCreateContext() .
Under certain circumstances, some elements of the DmaIdentity_t structure may be unknown. For example, if a site-defined subroutine is called as a result of a command entered on a client machine running a release prior to DMF 3.1, some elements of the user identity may be unknown.
The prototype is as follows:
const DmaIdentity_t *
DmaGetUserIdentity(
const DmaContext_t dmacontext); |
The parameter is as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). |
The DmaOpenByHandle() subroutine opens a file by fhandle , in O_RDONLY mode, and returns the file descriptor.
If there is an error, -1 is returned. It is the caller's responsibility to close the file descriptor.
| Note: This subroutine is implemented on IRIX only. |
The prototype is as follows:
int
DmaOpenByHandle(
const DmaContext_t dmacontext,
const DmuFhandle_t *dmuhanp); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| dmuhanp | Specifies the DmuFhandle_t of the file to be opened. |
The DmaSendLogFmtMessage() subroutine formats and issues log messages, if log messages are possible. The messages will potentially appear in the calling program's log depending upon the DmaLogLevel_t of the message and the log level selected by the administrator in the DMF configuration file. If log messages are not possible, DmaSendLogFmtMessage() silently discards the message.
The prototype is as follows:
void
DmaSendLogFmtMessage(
const DmaContext_t dmacontext,
DmaLogLevel_t log_level,
const char *name,
const char *format,
...); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| log_level | Specifies the level of the message. | |
| name | Specifies a string that is included as part of the log message. | |
| format | Specifies the format for the message that will be printed in the log. It looks like a printf(3S) format. Do not include \n as part of the message. If you want to print more than one line to the log, make multiple calls to DmaSendLogFmtMessage(). |
For example, the following will issue an error message to the calling program's log:
DmaSendLogFmtMessage (dmacontext, DmaLogErr,
"SiteCreateContext", "sitelib.so problem errno %d",
errno); |
The DmaSendUserFmtMessage() subroutine formats and sends messages to the user, if user messages are possible. The messages will potentially appear as output from commands such as dmput and dmget, depending upon the severity of the message and the level of message verbosity selected by the user. If user messages are not possible, DmaSendUserFmtMessage() silently discards the message.
The prototype is as follows:
void
DmaSendUserFmtMessage(
const DmaContext_t dmacontext,
DmuSeverity_t severity,
const char *position,
int err_no,
const char *format,
...); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| severity | Specifies the severity of the message. | |
| position | Specifies a string that can be included in the message. This string may be set to NULL. | |
| err_no | Specifies that if err_no is non-zero, the results of strerror(err_no) will be included in the message. | |
| format | Specifies the format for the message that will be sent to the user. It looks like a printf(3S) format. It is not necessary to put a \n at the end of the message. |
The DmaSetCookie() subroutine stores a pointer to site-defined subroutine information in dmacontext. This pointer may be retrieved by a call to DmaGetCookie(). The site-defined subroutines are responsible for memory management of the space pointed to by the cookie parameter.
The prototype is as follows:
void
DmaSetCookie(
const DmaContext_t dmacontext,
void *cookie); |
The parameters are as follows:
| dmacontext | Specifies the DmaContext_t parameter that is passed as input to all site-defined policy subroutines, such as SitePutFile(). | |
| cookie | Specifies a pointer to information that sitelib.so subroutines want to retain while the dmacontext is valid. |