NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

Data Structures

struct  NvOsStatTypeRec
 

Macros

#define NVOS_OPEN_READ   (0x1U)
 
#define NVOS_OPEN_WRITE   (0x2U)
 
#define NVOS_OPEN_CREATE   (0x4U)
 
#define NVOS_OPEN_APPEND   (0x8U)
 

Typedefs

typedef void * NvOsDirHandle
 
typedef struct NvOsFileRec * NvOsFileHandle
 
typedef struct NvOsStatTypeRec NvOsStatType
 

Enumerations

enum  NvOsFileType {
  NvOsFileType_Unknown = 0,
  NvOsFileType_File = 1,
  NvOsFileType_Directory = 2,
  NvOsFileType_Fifo = 3,
  NvOsFileType_CharacterDevice = 4,
  NvOsFileType_BlockDevice = 5,
  NvOsFileType_Force32 = 0x7FFFFFFF
}
 
enum  NvOsSeekEnum {
  NvOsSeek_Set = 0,
  NvOsSeek_Cur = 1,
  NvOsSeek_End = 2,
  NvOsSeek_Force32 = 0x7FFFFFFF
}
 

Functions

NvError NvOsOpendir (const char *path, NvOsDirHandle *dir)
 This function opens a directory. More...
 
void NvOsClosedir (NvOsDirHandle dir)
 This function closes a directory. More...
 
NvError NvOsFgetc (NvOsFileHandle hFile, NvU8 *c)
 This function read a character from the current position of a file stream,and the read character is stored into c parameter. More...
 
NvError NvOsFopen (const char *path, NvU32 flags, NvOsFileHandle *file)
 This function opens a file stream from path parameter. More...
 
NvError NvOsFcloseEx (NvOsFileHandle hFile)
 This function closes a file stream. More...
 
NvError NvOsFread (NvOsFileHandle hFile, void *ptr, size_t size, size_t *bytes)
 This function read from a file stream and store to ptr parameter. More...
 
NvError NvOsFseek (NvOsFileHandle hFile, NvS64 offset, NvOsSeekEnum whence)
 This function changes the current position of file stream as it is specified by offset and whence parameter. More...
 
NvError NvOsFstat (NvOsFileHandle hFile, NvOsStatType *filestat)
 This function gets a type of file stream, as file, directory, fifo, character device and unknown. More...
 
NvError NvOsFtell (NvOsFileHandle hFile, NvU64 *position)
 This function gets the current position of file stream, and it is stored to position parameter as bytes. More...
 
NvError NvOsFwrite (NvOsFileHandle hFile, const void *ptr, size_t size)
 This function writes the buffer to a file stream, and the length or writing is up to size parameter. More...
 
NvError NvOsFflush (NvOsFileHandle hFile)
 This function flush a file stream, if there is any buffered/unwritten memory regarding the file stream. More...
 
NvError NvOsStat (const char *filename, NvOsStatType *filestat)
 This function gets a type of path. More...
 

Macro Definition Documentation

◆ NVOS_OPEN_APPEND

#define NVOS_OPEN_APPEND   (0x8U)

Open file in append mode. Implies WRITE.

Definition at line 70 of file nvos_common_tegra_safety.h.

◆ NVOS_OPEN_CREATE

#define NVOS_OPEN_CREATE   (0x4U)

Creates a file if is not present on the file system.

Definition at line 65 of file nvos_common_tegra_safety.h.

◆ NVOS_OPEN_READ

#define NVOS_OPEN_READ   (0x1U)

Opens a file with read permissions.

Definition at line 55 of file nvos_common_tegra_safety.h.

◆ NVOS_OPEN_WRITE

#define NVOS_OPEN_WRITE   (0x2U)

Opens a file with write persmissions.

Definition at line 60 of file nvos_common_tegra_safety.h.

Typedef Documentation

◆ NvOsDirHandle

typedef void* NvOsDirHandle

Directory Handle

Definition at line 75 of file nvos_common_tegra_safety.h.

◆ NvOsFileHandle

typedef struct NvOsFileRec* NvOsFileHandle

File Handle

Definition at line 114 of file nvos_common_tegra_safety.h.

◆ NvOsStatType

typedef struct NvOsStatTypeRec NvOsStatType

NvOsFileType is used as a parameter of NvOsStat() function to get the stat of given path

Enumeration Type Documentation

◆ NvOsFileType

NvOsFileType is used as a parameter of NvOsStat() function to get the type of given path

Enumerator
NvOsFileType_Unknown 
NvOsFileType_File 
NvOsFileType_Directory 
NvOsFileType_Fifo 
NvOsFileType_CharacterDevice 
NvOsFileType_BlockDevice 
NvOsFileType_Force32 

Definition at line 81 of file nvos_common_tegra_safety.h.

◆ NvOsSeekEnum

NvOsSeekEnum is used as a parameter of NvOsFseek() function to move the current position of file

Enumerator
NvOsSeek_Set 

NvOS equivalent of SEEK_SET.

NvOsSeek_Cur 

NvOS equivalent of SEEK_CUR.

NvOsSeek_End 

NvOS equivalent of SEEK_END.

NvOsSeek_Force32 

Max value of NvOsSeekEnum.

Definition at line 1847 of file nvos_common_tegra_safety.h.

Function Documentation

◆ NvOsClosedir()

void NvOsClosedir ( NvOsDirHandle  dir)

This function closes a directory.

Parameters
[in]dirDirectory handle to be closed
Returns
N/A
Precondition
NvOsOpendir() must be called to get the directory handle
Note
This function does not include a check for API mode as a simple wrapper of the underlying QNX_System libc_api. It is the responsibility of the caller to ensure that this API is invoked in the appropriate VM state, as described in the "API group" section below.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFcloseEx()

NvError NvOsFcloseEx ( NvOsFileHandle  hFile)

This function closes a file stream.

Parameters
[in]hFileFile stream to be closed
Returns
NvSuccess Success
NvError_BadParameter Error when stream is NULL.
NvError_Busy Error when stream is being used.
NvError_FileOperationFailed Error when the file descriptor in stream is not valid.
NvError_InvalidSize Error when an attempt was made to write a file that exceeds maximum file size or maximum offset.
NvError_InvalidState Error when an attempt was made to write a pipe.
Precondition
NvOsFopen() must be called to get the file handle before calling this function
Note
This function does not include a check for API mode as a simple wrapper of the underlying QNX_System libc_api. It is the responsibility of the caller to ensure that this API is invoked in the appropriate VM state, as described in the "API group" section below.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFflush()

NvError NvOsFflush ( NvOsFileHandle  hFile)

This function flush a file stream, if there is any buffered/unwritten memory regarding the file stream.

Parameters
[in]hFileFile stream to be flushed
Returns
NvSuccess Success
NvError_BadParameter Error if stream parameter is NULL
NvError_Busy Error Flushing to file stream is delayed due to another writing to file stream
NvError_FileOperationFailed Error File stream is not valid for flushing
NvError_InvalidSize file size is over the maximum file size
NvError_Timeout Error Flushing file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_InvalidSize No free space in which is containing the file stream
NvError_ModuleNotPresent Error Flushing to non-existed device
NvError_FileOperationFailed Error if fflush() in QNX libc, return error
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFgetc()

NvError NvOsFgetc ( NvOsFileHandle  hFile,
NvU8 *  c 
)

This function read a character from the current position of a file stream,and the read character is stored into c parameter.

Parameters
[in]hFileFile stream to read
[out]cTo store a read character
Returns
NvSuccess Success
NvError_BadParameter hFile or c parameter is NULL
NvError_EndOfFile Error Reading is reached to the end of file
NvError_Busy Error Reading from file stream is delayed due to writing to file stream
NvError_FileOperationFailed Error File stream is not valid for reading
NvError_Timeout Error Reading file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_ModuleNotPresent Error Reading from non-existed device
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFopen()

NvError NvOsFopen ( const char *  path,
NvU32  flags,
NvOsFileHandle *  file 
)

This function opens a file stream from path parameter.

Parameters
[in]pathFile path to open, passed to filename parameter of fopen() in QNX libc
[in]flagsTo describe an access mode, the combination of four flags can be used, please see note below for valid combinations.
[out]fileOpened file stream
Returns
NvSuccess Success
NvError_BadParameter path or file parameter is NULL.
NvError_BadParameter flags is not valid
NvError_InsufficientMemory Error Failed to allocate for creating file stream handle
NvError_Busy Error Opening file stream is delayed due to another writing to file
NvError_FileOperationFailed Error path parameter is not valid for opening file
NvError_Timeout Error Opening file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_ModuleNotPresent Error Opening to non-existed device
Note
  • Valid combinations of flags parameter
    • NVOS_OPEN_READ, open to read
    • NVOS_OPEN_WRITE, open to write
    • NVOS_OPEN_APPEND, internally converts to (NVOS_OPEN_WRITE | NVOS_OPEN_APPEND), open to write in append mode.
    • NVOS_OPEN_READ | NVOS_OPEN_WRITE, open to read/write
    • NVOS_OPEN_CREATE | NVOS_OPEN_WRITE, create and open to write, if existed, file length is truncated to 0
    • NVOS_OPEN_CREATE | NVOS_OPEN_READ | NVOS_OPEN_WRITE, create and open to read/write, if existed, file length is truncated to 0
Precondition
None
Note
This function does not include a check for API mode as a simple wrapper of the underlying QNX_System libc_api. It is the responsibility of the caller to ensure that this API is invoked in the appropriate VM state, as described in the "API group" section below.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Maturity: GA

◆ NvOsFread()

NvError NvOsFread ( NvOsFileHandle  hFile,
void *  ptr,
size_t  size,
size_t *  bytes 
)

This function read from a file stream and store to ptr parameter.

  • Maximum length of reading is up to size parameter.
  • Actual reading length may be less than size parameter as per length of file or current position of file stream
Parameters
[in]hFileFile stream to read
[out]ptrTo store what read from file stream
[in]sizeMaximum length of reading
[out]bytesActual reading length is stored as byte
Returns
NvSuccess Success
NvError_BadParameter hFile or ptr parameter is NULL.
NvError_EndOfFile Error Reading is reached to the end of file
NvError_Busy Error Reading from file stream is delayed due to writing to file stream
NvError_FileOperationFailed Error File stream is not valid for reading
NvError_Timeout Error Reading file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_ModuleNotPresent Error Reading from non-existed device
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFseek()

NvError NvOsFseek ( NvOsFileHandle  hFile,
NvS64  offset,
NvOsSeekEnum  whence 
)

This function changes the current position of file stream as it is specified by offset and whence parameter.

Parameters
[in]hFileFile stream to change the current position
[in]offsetOffset from whence parameter
[in]whenceNvOsSeek_Set from start of file, NvOsSeek_Cur from current position, NvOsSeek_End from the end of file
Returns
NvSuccess Success
NvError_BadParameter hFile is NULL or whence is not valid.
NvError_Busy Error Seeking file stream is delayed due to writing to file stream
NvError_FileOperationFailed Error File stream is not valid for seeking
NvError_InvalidSize Error The length of file steam is bigger than maximum file size
NvError_Timeout Error Seeking file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_ModuleNotPresent Error Seeking from non-existed device
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFstat()

NvError NvOsFstat ( NvOsFileHandle  hFile,
NvOsStatType *  filestat 
)

This function gets a type of file stream, as file, directory, fifo, character device and unknown.

Parameters
[in]hFileFile stream to get file type
[out]filestattype of file stream, please see note for more detail.
Returns
NvSuccess Success
NvError_BadParameter hFile or filestat parameter is NULL
NvError_FileOperationFailed Error if error is returned from fstat() in QNX libc
Precondition
NvOsFopen() must be called to get the file handle before calling this function
Note
  • List of type for file stream
    • NvOsFileType_File File
    • NvOsFileType_Directory Directory
    • NvOsFileType_Fifo FIFO
    • NvOsFileType_CharacterDevice Character device
    • NvOsFileType_BlockDevice Block device
    • NvOsFileType_Unknown Unknown type


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFtell()

NvError NvOsFtell ( NvOsFileHandle  hFile,
NvU64 *  position 
)

This function gets the current position of file stream, and it is stored to position parameter as bytes.

Parameters
[in]hFileFile stream to get the current position
[out]positionCurrent position of file stream as bytes
Returns
NvSuccess Success
NvError_BadParameter hFile or position parameter is NULL
NvError_FileOperationFailed Error if error is returned from ftello() in QNX libc
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsFwrite()

NvError NvOsFwrite ( NvOsFileHandle  hFile,
const void *  ptr,
size_t  size 
)

This function writes the buffer to a file stream, and the length or writing is up to size parameter.

Parameters
[in]hFileFile stream to write
[in]ptrPointing buffer to write
[in]sizeMaximum length of writing
Returns
NvSuccess Success
NvError_BadParameter hFile or ptr parameter is NULL
NvError_EndOfFile Error Writing is reached to the end of file
NvError_Busy Error Writing from file stream is delayed due to another writing to file stream
NvError_FileOperationFailed Error File stream is not valid for writing
NvError_Timeout Error Writing file stream is terminated by signal
NvError_ResourceError Error Physical I/O is failed
NvError_ModuleNotPresent Error Writing to non-existed device
Precondition
NvOsFopen() must be called to get the file handle before calling this function


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsOpendir()

NvError NvOsOpendir ( const char *  path,
NvOsDirHandle *  dir 
)

This function opens a directory.

Parameters
[in]pathDirectory path to open
[out]dirDirectory handle
Returns
NvSuccess Success
NvError_BadParameter Error if either path or dir is NULL
NvError_FileOperationFailed Error if opendir() in QNX libc, return error
Precondition
None
Note
This function does not include a check for API mode as a simple wrapper of the underlying QNX_System libc_api. It is the responsibility of the caller to ensure that this API is invoked in the appropriate VM state, as described in the "API group" section below.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA

◆ NvOsStat()

NvError NvOsStat ( const char *  filename,
NvOsStatType *  filestat 
)

This function gets a type of path.

Parameters
[in]filenamepath to know the stats
[out]filestattype of filename parameter, please see note for more detail.
Returns
NvSuccess Success
NvError_AccessDenied: Permission is denied for a component of filename.
NvError_BadParameter: Either of filename or filestat is NULL.
NvError_DirOperationFailed: A component of filename is not a direcotory.
NvError_FileNotFound: File, filename, does not exist
NvError_InterruptedBySignal: The function is interrupted by a signal
NvError_InvalidState: The file serial number can't be represented correctly.
NvError_NotSupported: stat() is not implemented for the filesystem
NvError_ResourceError: Physical error on the block device
Precondition
None
Note
  • List of type for file stream
    • NvOsFileType_File File
    • NvOsFileType_Directory Directory
    • NvOsFileType_Fifo FIFO
    • NvOsFileType_CharacterDevice Character device
    • NvOsFileType_BlockDevice Block device
    • NvOsFileType_Unknown Unknown type


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes
  • Maturity: GA