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()

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 Messages

The following messages may be sent from this function:



Usage Notes

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

    • Network File System
    • QOPT
    • QFileSvr.400
    • QNTC

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 ]