File system considerations for multithreaded programming

When you work with file systems in multithreaded programs, be aware of these considerations.

  • Threadsafe file systems

    The "root" (/), QOpenSys, User-Defined (UDFS), QNTC, QSYS.LIB, QOPT, NFS, and QFileSvr.400 file systems are threadsafe and do not have any restrictions. The QDLS file system is not threadsafe. If you try to use an integrated file system application programming interface (API) or command on a file or file descriptor that represents an object in a file system that is not threadsafe, it fails with ENOTSAFE. This failure occurs only when multiple threads are in a job.

    An attempt to spawn a program from a job that has multiple threads fails with ENOTSAFE if you inherit the current working directory or open file descriptors that represent files in a file system that is not threadsafe.

  • Integrated file system APIs

    All of the integrated file system APIs are threadsafe when directed to an object that resides in a threadsafe file system. If you do not know the file system where an object resides, you can query the path to see if the threadsafe integrated file system interfaces can safely access it. You can use the pathconf(), fpathconf(), statvfs(), and fstatvfs() APIs to determine whether a path or file descriptor refers to an object in one of the threadsafe file systems.