Back to index

glibc  2.9
Defines | Functions | Variables
opendir-tst1.c File Reference
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <test-skeleton.c>

Go to the source code of this file.

Defines

#define CLEANUP_HANDLER   do_cleanup ()

Functions

static int real_test (void)
static int do_test (int argc, char *argv[])
static void do_cleanup (void)

Variables

char tmpname [] = "fifoXXXXXX"

Define Documentation

#define CLEANUP_HANDLER   do_cleanup ()

Definition at line 93 of file opendir-tst1.c.


Function Documentation

static void do_cleanup ( void  ) [static]

Definition at line 89 of file opendir-tst1.c.

{
  remove (tmpname);
}
static int do_test ( int  argc,
char *  argv[] 
) [static]

Definition at line 62 of file opendir-tst1.c.

{
  int retval;

  if (mktemp (tmpname) == NULL)
    {
      perror ("mktemp");
      return 1;
    }

  /* Try to generate a FIFO.  */
  if (mknod (tmpname, 0600 | S_IFIFO, 0) < 0)
    {
      perror ("mknod");
      /* We cannot make this an error.  */
      return 0;
    }

  retval = real_test ();

  remove (tmpname);

  return retval;
}

Here is the call graph for this function:

static int real_test ( void  ) [static]

Definition at line 34 of file opendir-tst1.c.

{
  DIR *dirp;

  /* This should not block for an FIFO.  */
  dirp = opendir (tmpname);

  /* Successful.  */
  if (dirp != NULL)
    {
      /* Oh, oh, how can this work?  */
      fputs ("`opendir' succeeded on a FIFO???\n", stdout);
      closedir (dirp);
      return 1;
    }

  if (errno != ENOTDIR)
    {
      fprintf (stdout, "`opendir' return error `%s' instead of `%s'\n",
              strerror (errno), strerror (ENOTDIR));
      return 1;
    }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char tmpname[] = "fifoXXXXXX"

Definition at line 29 of file opendir-tst1.c.