hurd: Avoid PLTs for longjmp & siglongjmp
[glibc.git] / dirent / list.c
blob803b85abf1e78452772f78b9e6295fdc6f259ce4
1 /* Copyright (C) 1991-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <stddef.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <dirent.h>
25 static int
26 test (const char *name)
28 DIR *dirp;
29 struct dirent *entp;
30 int retval = 0;
32 puts (name);
34 dirp = opendir (name);
35 if (dirp == NULL)
37 perror ("opendir");
38 return 1;
41 errno = 0;
42 while ((entp = readdir (dirp)) != NULL)
43 printf ("%s\tfile number %lu\n",
44 entp->d_name, (unsigned long int) entp->d_fileno);
46 if (errno)
48 perror ("readdir");
49 retval = 1;
52 if (closedir (dirp) < 0)
54 perror ("closedir");
55 retval = 1;
58 return retval;
61 int
62 main (int argc, char **argv)
64 int retval = 0;
65 --argc;
66 ++argv;
68 if (argc == 0)
69 retval = test (".");
70 else
71 while (argc-- > 0)
72 retval |= test (*argv++);
74 return retval;