Back to index

glibc  2.9
Functions
sem_unlink.c File Reference
#include <errno.h>
#include <semaphore.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "semaphoreP.h"

Go to the source code of this file.

Functions

int sem_unlink (char *name) const

Function Documentation

int sem_unlink ( char *  name) const

Definition at line 29 of file sem_unlink.c.

{
  char *fname;
  size_t namelen;

  /* Determine where the shmfs is mounted.  */
  INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);

  /* If we don't know the mount points there is nothing we can do.  Ever.  */
  if (mountpoint.dir == NULL)
    {
      __set_errno (ENOSYS);
      return -1;
    }

  /* Construct the filename.  */
  while (name[0] == '/')
    ++name;

  if (name[0] == '\0')
    {
      /* The name "/" is not supported.  */
      __set_errno (ENOENT);
      return -1;
    }
  namelen = strlen (name);

  /* Create the name of the file.  */
  fname = (char *) alloca (mountpoint.dirlen + namelen + 1);
  __mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen),
            name, namelen + 1);

  /* Now try removing it.  */
  int ret = unlink (fname);
  if (ret < 0 && errno == EPERM)
    __set_errno (EACCES);
  return ret;
}

Here is the call graph for this function: