]>
Commit | Line | Data |
---|---|---|
de149cdb | 1 | /* Copyright (C) 1991, 1993, 1997, 1998, 2000 Free Software Foundation, Inc. |
c84142e8 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
c84142e8 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 8 | |
c84142e8 UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 AJ |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, write to the Free | |
16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | 02111-1307 USA. */ | |
28f540f4 | 18 | |
28f540f4 RM |
19 | #include <errno.h> |
20 | #include <stddef.h> | |
21 | #include <stdio.h> | |
22 | #include <stdlib.h> | |
23 | #include <dirent.h> | |
24 | ||
25 | ||
de149cdb | 26 | static int |
c84142e8 | 27 | test (const char *name) |
28f540f4 RM |
28 | { |
29 | DIR *dirp; | |
30 | struct dirent *entp; | |
80a18298 | 31 | int retval = 0; |
28f540f4 | 32 | |
c84142e8 | 33 | puts (name); |
28f540f4 | 34 | |
c84142e8 | 35 | dirp = opendir (name); |
28f540f4 RM |
36 | if (dirp == NULL) |
37 | { | |
c84142e8 | 38 | perror ("opendir"); |
80a18298 | 39 | return 1; |
28f540f4 RM |
40 | } |
41 | ||
42 | errno = 0; | |
c84142e8 UD |
43 | while ((entp = readdir (dirp)) != NULL) |
44 | printf ("%s\tfile number %lu\n", | |
45 | entp->d_name, (unsigned long int) entp->d_fileno); | |
28f540f4 RM |
46 | |
47 | if (errno) | |
80a18298 UD |
48 | { |
49 | perror ("readdir"); | |
50 | retval = 1; | |
51 | } | |
28f540f4 | 52 | |
c84142e8 | 53 | if (closedir (dirp) < 0) |
80a18298 UD |
54 | { |
55 | perror ("closedir"); | |
56 | retval = 1; | |
57 | } | |
58 | ||
59 | return retval; | |
28f540f4 RM |
60 | } |
61 | ||
62 | int | |
c84142e8 | 63 | main (int argc, char **argv) |
28f540f4 | 64 | { |
80a18298 | 65 | int retval = 0; |
28f540f4 RM |
66 | --argc; |
67 | ++argv; | |
68 | ||
69 | if (argc == 0) | |
80a18298 | 70 | retval = test ("."); |
28f540f4 RM |
71 | else |
72 | while (argc-- > 0) | |
80a18298 | 73 | retval |= test (*argv++); |
28f540f4 | 74 | |
80a18298 | 75 | return retval; |
28f540f4 | 76 | } |