le_fileLock.h
Go to the documentation of this file.
14 * This API only supports regular files. Attempts to use this API on sockets, devices, etc. results19 * Co-operative file locks (also known as advisory file locks) means that the processes and threads31 * Use @c le_flock_Open() to lock a file and open it for access. When attempting to lock a file that32 * already has an incompatible lock on it, @c le_flock_Open() will block until it can obtain the lock.36 * that all the calls to le_flock_Open() in the example occur in chronological order as they appear:49 * -------------------------------------------------------------------------------------------------61 * -------------------------------------------------------------------------------------------------80 * When multiple processes are blocked waiting to obtain a lock on the file, it's unspecified which83 * The le_flock_Create() function can be used to create, lock and open a file in one function call.87 * The functions @c le_flock_OpenStream() and @c le_flock_CreateStream() can be used to obtain a file88 * stream to a locked file. @c le_flock_CloseStream() is used to close the stream and remove the lock.89 * These functions are analogous to le_flock_Open(), le_flock_Create() and le_flock_Close() except111 * le_flock_Close() and le_flock_CloseStream() are provided as a convenience. When a process dies,155 //--------------------------------------------------------------------------------------------------167 //--------------------------------------------------------------------------------------------------171 * @note When writing to a file, the writes are always appended to the end of the file by default.174 //--------------------------------------------------------------------------------------------------188 //--------------------------------------------------------------------------------------------------192 //--------------------------------------------------------------------------------------------------202 //--------------------------------------------------------------------------------------------------207 * accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed210 * If attempting to lock a file that already has an incompatible lock on it this function will block218 //--------------------------------------------------------------------------------------------------226 //--------------------------------------------------------------------------------------------------230 * If the file does not exist, it will be created with the file permissions specified in the arugment231 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details236 * If the file already exists, then this function will either replace the existing file, open the237 * existing file or fail depending on the createMode argument. The permissions argument is ignored240 * The file can be opened for reading, writing or both as specified in the accessMode argument. If244 * If attempting to lock a file that already has an incompatible lock on it, this function will block253 //--------------------------------------------------------------------------------------------------264 //--------------------------------------------------------------------------------------------------272 * If attempting to lock a file that already has an incompatible lock on it, this function will fail281 //--------------------------------------------------------------------------------------------------289 //--------------------------------------------------------------------------------------------------293 * If the file does not exist, it will be created with the file permissions specified in the argument294 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details300 * existing file or fail depending on the createMode argument. The permissions argument is ignored303 * The file can be opened for reading, writing or both as specified in the accessMode argument. f307 * If attempting to lock a file that already has an incompatible lock on it, this function will fail317 //--------------------------------------------------------------------------------------------------328 //--------------------------------------------------------------------------------------------------332 //--------------------------------------------------------------------------------------------------339 //--------------------------------------------------------------------------------------------------343 * The file can be open for reading, writing or both read and write as specified in the accessMode347 * If attempting to lock a file that already has an incompatible lock on it, this function will block358 //--------------------------------------------------------------------------------------------------368 //--------------------------------------------------------------------------------------------------372 * If the file does not exist it will be created with the file permissions specified in the arugment373 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details381 * The file can be opened for reading, writing or both as specified in the accessMode argument. If382 * accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed385 * If attempting to lock a file that already has an incompatible lock on it this function will block390 * - LE_DUPLICATE if the file already exists and LE_FLOCK_FAIL_IF_EXIST is specified in createMode.397 //--------------------------------------------------------------------------------------------------410 //--------------------------------------------------------------------------------------------------414 * The file can be open for reading, writing or both read and write as specified in the accessMode430 //--------------------------------------------------------------------------------------------------439 //--------------------------------------------------------------------------------------------------443 * If the file does not exist, it will be created with the file permissions specified in the arugment444 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details452 * The file can be opened for reading, writing or both as specified in the accessMode argument. If453 * accessMode is either LE_FLOCK_WRITE or LE_FLOCK_READ_AND_WRITE then a write lock will be placed462 * - LE_DUPLICATE if the file already exists and LE_FLOCK_FAIL_IF_EXIST is specified in createMode.470 //--------------------------------------------------------------------------------------------------482 //--------------------------------------------------------------------------------------------------486 //--------------------------------------------------------------------------------------------------int le_flock_Open(const char *pathNamePtr, le_flock_AccessMode_t accessMode)Definition: le_fileLock.h:182Definition: le_fileLock.h:179void le_flock_CloseStream(FILE *fileStreamPtr)FILE * le_flock_TryCreateStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions, le_result_t *resultPtr)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)int le_flock_Create(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions)FILE * le_flock_TryOpenStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_result_t *resultPtr)int le_flock_TryOpen(const char *pathNamePtr, le_flock_AccessMode_t accessMode)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)