Start of change

IFS_ACCESS scalar function

The IFS_ACCESS scalar function determines whether a file can be accessed in a particular manner.

This function uses the access()--Determine File Accessibility API. When checking whether a job has appropriate permissions, the API looks at the real user ID (UID) and group ID (GID), not the effective IDs. Adopted authority is not used.

The function requires that Option 13 (System Openness Includes) of the IBM i operating system is installed.

Authorization: See Note below.

Read syntax diagramSkip visual syntax diagram IFS_ACCESS ( PATH_NAME =>  path-name ,READ => read,WRITE => write,EXECUTE => execute )
The schema is SYSTOOLS.
path-name
A character string containing the path of the file to be checked.
read
Test whether the file can be accessed for reading.
NO
Do not check for read access. This is the default.
YES
Check for read access.
write
Test whether the file can be accessed for writing.
NO
Do not check for write access. This is the default.
YES
Check for write access.
execute
Test whether the file can be accessed for execution.
NO
Do not check for execute access. This is the default.
YES
Check for execute access.
The result of the function is an integer. If the access is allowed, the function returns a value of 0. If the access returns an error, the function returns the errno value from the API.

Note

This function is provided in the SYSTOOLS schema as an example of how to embed a C language interface in an SQL scalar function. Similar to other Db2® for i provided tools within SYSTOOLS, the SQL source can be extracted and used as a model for building similar helper functions, or to create a customized version within a user-specified schema.

Services provided in SYSTOOLS have authorization requirements that are determined by the interfaces used to implement the service. To understand the authority requirements, extract the SQL for the service and examine the implementation.

Example

Determine whether the invoker of the function has read access to /usr/reportdata.txt.

VALUES SYSTOOLS.IFS_ACCESS(PATH_NAME => '/usr/reportdata.txt', 
                           READ => 'YES');
End of change