Back to index

glibc  2.9
Functions
flock.c File Reference
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>

Go to the source code of this file.

Functions

int __flock (int fd, int operation)

Function Documentation

int __flock ( int  fd,
int  operation 
)

Definition at line 31 of file flock.c.

{
  struct flock lbuf;

  switch (operation & ~LOCK_NB)
    {
    case LOCK_SH:
      lbuf.l_type = F_RDLCK;
      break;
    case LOCK_EX:
      lbuf.l_type = F_WRLCK;
      break;
    case LOCK_UN:
      lbuf.l_type = F_UNLCK;
      break;
    default:
      __set_errno (EINVAL);
      return -1;
    }

  lbuf.l_whence = SEEK_SET;
  lbuf.l_start = lbuf.l_len = 0L; /* Lock the whole file.  */

  return __fcntl (fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function: