1 /* -*- c-file-style: "linux" -*-
3 * Copyright (C) 2001 by Martin Pool
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version
7 * 2 as published by the Free Software Foundation.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * tls -- Trivial recursive ls, for comparing two directories after
25 * The problem with using the system's own ls is that some features
26 * have little quirks that make directories look different when for
27 * our purposes they're the same -- for example, the BSD braindamage
28 * about setting the mode on symlinks based on your current umask.
30 * There are some restrictions compared to regular ls: all the names
31 * on the command line must be directories rather than files; you
32 * can't give wildcards either.
34 * At the moment we don't sort the output, but all the files have full
35 * names, so you can run it through sort(1).
37 * We need to recurse downwards and show all the interesting
38 * information and no more.
40 * \todo Use readdir64 if available?
49 /* These are to make syscall.o shut up. */
55 static void failed (char const *what
,
58 fprintf (stderr
, PROGRAM
": %s %s: %s\n",
59 what
, where
, strerror (errno
));
65 static void list_dir (char const *dn
)
70 if (!(d
= opendir (dn
)))
71 failed ("opendir", dn
);
73 while ((de
= readdir (d
))) {
74 char *dname
= d_name (de
);
75 if (!strcmp (dname
, ".") || !strcmp (dname
, ".."))
77 printf ("%s\n", dname
);
80 if (closedir (d
) == -1)
81 failed ("closedir", dn
);
85 int main (int argc
, char *argv
[])
88 fprintf (stderr
, "usage: " PROGRAM
" DIR ...\n"
89 "Trivial file listing program for portably checking rsync\n");
93 for (argv
++; *argv
; argv
++) {