Qp0lGetPathFromFileID()--Get Path Name of Object from Its File ID


  Syntax
 #include <Qp0lstdi.h>

 char *Qp0lGetPathFromFileID(char *buf, size_t size,
                             Qp0lFID_t fileid);  
  Service Program Name: QP0LLIB2

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0lGetPathFromFileID() function determines an absolute path name of the file identified by fileid and stores it in buf. The components of the returned path name are not symbolic links. If the file has more than one path name, only one is returned.

The access time of each directory in the absolute path name of the file (excluding the file itself) is updated.

If buf is a NULL pointer, Qp0lGetPathFromFileID() returns a NULL pointer and the EINVAL error.

The contents of buf after an error are not defined.

Qp0lGetPathFromFileID() is supported in the "root" (/), QOpenSys, QDLS, QSYS.LIB, Independent ASP QSYS.LIB, and user-defined file systems.


Parameters

buf
(Output) A pointer to a buffer that will be used to hold an absolute path name of the file identified by fileid. The buffer must be large enough to contain the full path name including the terminating NULL character.

The path name is returned in the CCSID (coded character set identifier) currently in effect for the job. If the CCSID of the job is 65535, this parameter is assumed to be represented in the default CCSID of the job.

See QlgGetPathFromFileID()--Get Path Name of Object from Its File ID (using NLS-enabled path name) for a description and an example of supplying the buf in any CCSID.


size
(Input) The number of bytes in the buffer buf.

fileid
(Input) The identifier of the file whose path name is to be returned. This identifier is logged in audit journal entries to identify the file being audited. See the Parent File ID and Object File ID fields of the audit journal entries described in Security reference. The file identifier is also described and returned by the Qp0lGetAttr() API.

Authorities

Note: Adopted authority is not used.

Authorization required for Qp0lGetPathFromFileID()
Object Referred to Authority Required errno
Each directory in the path name preceding the file *RX EACCES
The file itself *R EACCES

Return Value

value
Qp0lGetPathFromFileID() was successful. The value returned is a pointer to buf.
NULL
Qp0lGetPathFromFileID() was not successful. The errno global variable is set to indicate the error. After an error, the contents of buf are not defined.

Error Conditions

If Qp0lGetPathFromFileID() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

Error condition Additional information
[EACCES]

If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems.

[EAGAIN]  
[EBADFID]  
[EBUSY]  
[EDAMAGE]  
[EFAULT]  
[EFILECVT]  
[EINVAL]  
[EIO]  
[ENOENT]

No path names were found for this fileid or the user is not authorized to any of the paths.

[ENOMEM]  
[ENOTAVAIL]  
[ERANGE]

For example, the size argument is too small. It is greater than zero but smaller than the length of the path name plus a NULL character.

[ESTALE]

If you are accessing a remote file through the Network File System, the file may have been deleted at the server.

[EUNKNOWN]  


Error Messages

The following messages may be sent from this function:

Message ID Error Message Text
CPE3418 E Possible APAR condition or hardware failure.
CPFA0D4 E File system error occurred. Error number &1.
CPF3CF2 E Error(s) occurred during running of &1 API.
CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.


Usage Notes

  1. The following file systems do not support Qp0lGetPathFromFileID():


Related Information


Example

The following example determines the path name of a file, given its file ID. In this example, the fileid is hardcoded. More realistically, the fileid is obtained from the audit journal entry and passed to Qp0lGetPathFromFileID().

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <Qp0lstdi.h>
#include <stdio.h>

main()
{
  char       path[1024];
  Qp0lFID_t  fileid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xCF, 0x00};

  if (Qp0lGetPathFromFileID(path, sizeof(path), fileid) == NULL)
    perror("Qp0lGetPathFromFileID() error");
  else
    printf("The file's path is: %s\n", path);
}

Output:

The file's path is: /myfile


API introduced: V3R1

[ Back to top | UNIX-Type APIs | APIs by category ]