dmi_file_lock

Synopsis

#include <opendmi/utils/file.h>

bool dmi_file_lock(int fd, off_t size);

Description

The dmi_file_lock function locks size bytes of the file starting at the current offset using lockf(F_LOCK). The call blocks until the lock is acquired. It retries automatically if interrupted by a signal (EINTR).

Passing size of 0 locks from the current offset to the end of the file.

Parameters

fd

Open file descriptor.

size

Number of bytes to lock, or 0 to lock to end of file.

Return value

Returns true if the lock was acquired, false on error.

Errors

None.

See also

dmi_file_unlock, lockf(3)