Back to index

glibc  2.9
Functions | Variables
bug-ftw3.c File Reference
#include <errno.h>
#include <ftw.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static int cb (const char *fname, const struct stat *st, int flag)
int main (void)

Variables

static int cb_called

Function Documentation

static int cb ( const char *  fname,
const struct stat st,
int  flag 
) [static]

Definition at line 11 of file bug-ftw3.c.

{
  printf ("%s %d\n", fname, flag);
  cb_called = 1;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

Definition at line 19 of file bug-ftw3.c.

{
  char tmp[] = "/tmp/ftwXXXXXX";
  char tmp2[] = "/tmp/ftwXXXXXX/ftwXXXXXX";
  char *dname;
  char *dname2;
  int r;
  int e;

  if (getuid () == 0)
    {
      puts ("this test needs to be run by ordinary user");
      exit (0);
    }

  dname = mkdtemp (tmp);
  if (dname == NULL)
    {
      printf ("mkdtemp: %m\n");
      exit (1);
    }

  memcpy (tmp2, tmp, strlen (tmp));
  dname2 = mkdtemp (tmp2);
  if (dname2 == NULL)
    {
      printf ("mkdtemp: %m\n");
      rmdir (dname);
      exit (1);
    }

  if (chmod (dname, S_IWUSR|S_IWGRP|S_IWOTH) != 0)
    {
      printf ("chmod: %m\n");
      rmdir (dname);
      exit (1);
    }

  r = ftw (dname2, cb, 10);
  e = errno;
  printf ("r = %d", r);
  if (r != 0)
    printf (", errno = %d", errno);
  puts ("");

  chmod (dname, S_IRWXU|S_IRWXG|S_IRWXO);
  rmdir (dname2);
  rmdir (dname);

  return (r != -1 && e == EACCES) || cb_called;
}

Here is the call graph for this function:


Variable Documentation

int cb_called [static]

Definition at line 8 of file bug-ftw3.c.