Go to the source code of this file.
Functions | |
int | le_flock_Open (const char *pathNamePtr, le_flock_AccessMode_t accessMode) |
int | le_flock_Create (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions) |
int | le_flock_TryOpen (const char *pathNamePtr, le_flock_AccessMode_t accessMode) |
int | le_flock_TryCreate (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions) |
void | le_flock_Close (int fd) |
FILE * | le_flock_OpenStream (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_result_t *resultPtr) |
FILE * | le_flock_CreateStream (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions, le_result_t *resultPtr) |
FILE * | le_flock_TryOpenStream (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_result_t *resultPtr) |
FILE * | le_flock_TryCreateStream (const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions, le_result_t *resultPtr) |
void | le_flock_CloseStream (FILE *fileStreamPtr) |
Legato File Locking API include file.
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
File access modes.
void le_flock_Close | ( | int | fd | ) |
Closes the file and releases the lock.
[in] | fd | File descriptor of the file to close. |
void le_flock_CloseStream | ( | FILE * | fileStreamPtr | ) |
Closes the file stream and releases the lock.
int le_flock_Create | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_flock_CreateMode_t | createMode, | ||
mode_t | permissions | ||
) |
Creates, opens and locks file.
If the file does not exist, it will be created with the file permissions specified in the arugment permissions (modified by the process's umask). Refer to the POSIX function open(2) for details of mode_t:
http://man7.org/linux/man-pages/man2/open.2.html
If the file already exists, then this function will either replace the existing file, open the existing file or fail depending on the createMode argument. The permissions argument is ignored if the file already exists.
The file can be opened for reading, writing or both as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE, a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will block until the lock can be obtained. This function may block even if it creates the file because creating the file and locking it is not atomic.
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[in] | createMode | Action to take if the file already exists. |
[in] | permissions | File permissions used when creating the file. See the function header comments for more details. |
FILE* le_flock_CreateStream | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_flock_CreateMode_t | createMode, | ||
mode_t | permissions, | ||
le_result_t * | resultPtr | ||
) |
Creates a file, locks it and opens a C standard library buffered file stream to it.
If the file does not exist it will be created with the file permissions specified in the arugment permissions (modified by the process's umask). Refer to the POSIX function open(2) for details of mode_t:
http://man7.org/linux/man-pages/man2/open.2.html
If the file already exists then this function will either replace the existing file, open the existing file or fail depending on the createMode argument.
The file can be opened for reading, writing or both as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it this function will block until the lock can be obtained. This function may block even if it creates the file because creating the file and locking it is not atomic.
If there was an error NULL is returned and resultPtr is set to:
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[in] | createMode | Action to take if the file already exists. |
[in] | permissions | File permissions used when creating the file. See the function header comments for more details. |
[out] | resultPtr | Pointer to result code. This can be NULL if the result code is not wanted. |
int le_flock_Open | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode | ||
) |
Opens and locks an existing file.
The file can be open for reading, writing or both as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it this function will block until the lock can be obtained.
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
FILE* le_flock_OpenStream | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_result_t * | resultPtr | ||
) |
Locks an existing file and opens a C standard library buffered file stream to it.
The file can be open for reading, writing or both read and write as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will block until the lock can be obtained.
If there was an error NULL is returned and resultPtr is set to:
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[out] | resultPtr | Pointer to result code. This can be NULL if the result code is not wanted. |
int le_flock_TryCreate | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_flock_CreateMode_t | createMode, | ||
mode_t | permissions | ||
) |
Creates, opens and locks file.
If the file does not exist, it will be created with the file permissions specified in the argument permissions (modified by the process's umask). Refer to the POSIX function open(2) for details of mode_t:
http://man7.org/linux/man-pages/man2/open.2.html
If the file already exists, this function will either replace the existing file, open the existing file or fail depending on the createMode argument. The permissions argument is ignored if the file already exists.
The file can be opened for reading, writing or both as specified in the accessMode argument. f accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE, a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will fail and return LE_WOULD_BLOCK immediately. This function may fail with LE_WOULD_BLOCK even if it creates the file because creating the file and locking it is not atomic.
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[in] | createMode | Action to take if the file already exists. |
[in] | permissions | File permissions used when creating the file. See the function header comments for more details. |
FILE* le_flock_TryCreateStream | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_flock_CreateMode_t | createMode, | ||
mode_t | permissions, | ||
le_result_t * | resultPtr | ||
) |
Creates a file, locks it and opens a C standard library buffered file stream to it.
If the file does not exist, it will be created with the file permissions specified in the arugment permissions (modified by the process's umask). Refer to the POSIX function open(2) for details of mode_t:
http://man7.org/linux/man-pages/man2/open.2.html
If the file already exists, this function will either replace the existing file, open the existing file or fail depending on the createMode argument.
The file can be opened for reading, writing or both as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will return NULL immediately and set resultPtr to LE_WOULD_BLOCK. This function may fail with LE_WOULD_BLOCK even if it creates the file because creating the file and locking it is not atomic.
If there was an error NULL is returned and resultPtr is set to:
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[in] | createMode | Action to take if the file already exists. |
[in] | permissions | File permissions used when creating the file. See the function header comments for more details. |
[out] | resultPtr | Pointer to result code. |
int le_flock_TryOpen | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode | ||
) |
Opens and locks an existing file.
The file can be open for reading, writing or both as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE, a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will fail and return LE_WOULD_BLOCK immediately.
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
FILE* le_flock_TryOpenStream | ( | const char * | pathNamePtr, |
le_flock_AccessMode_t | accessMode, | ||
le_result_t * | resultPtr | ||
) |
Locks an existing file and opens a C standard library buffered file stream to it.
The file can be open for reading, writing or both read and write as specified in the accessMode argument. If accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed on the file, otherwise a read lock will be placed on the file.
If attempting to lock a file that already has an incompatible lock on it, this function will return NULL immediately and set resultPtr to LE_WOULD_BLOCK.
If there was an error NULL is returned and resultPtr is set to:
[in] | pathNamePtr | Pointer to the path name of the file to open. |
[in] | accessMode | Access mode to open the file. |
[out] | resultPtr | Pointer to result code. |