FAT | RFS | XFS | ZFS

vol_lock()

PROTOTYPE

#include <posix.h>

void *vol_lock(const char *path);

DESCRIPTION

vol_lock() is a non-standard routine that reserves a volume for exclusive use by the running task. If another task tries to access the volume while it is locked, it will block until the handle returned by vol_lock() is used to call vol_unlock().

path selects the volume to be locked. If it equals NULL, the volume holding the CWD is selected. Otherwise, it is the pathname to any file or directory on the selected volume.

vol_lock() and vol_unlock() support multitasking applications. If a task needs to update a file using multiple writes, these calls ensure those writes are not interleaved with writes by other tasks.

If successful, vol_lock() returns a handle for later use by vol_unlock(). Otherwise, it sets errno and returns NULL.

ERROR CODES

ENAMETOOLONG A name in path exceeds the effective maximum file name length.
ENOENT path is the empty string or includes a name that was not found.
ENOTDIR One of the non-leaf path components is not a directory.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Lock volume use to just the running task.                         */
  /*-------------------------------------------------------------------*/
  hndl = vol_lock(vol_name);