summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-12-21 12:05:42 +0000
committerJim Meyering <jim@meyering.net>1997-12-21 12:05:42 +0000
commitbdcaa361bc85be251ee4329d44042ce24379b7c8 (patch)
treea3d4ef2c6013b8ade718924212269cac63335329 /src/du.c
parenta1003f154f40607674f8a0fd1d7b2de3c889bca4 (diff)
downloadcoreutils-bdcaa361bc85be251ee4329d44042ce24379b7c8.tar.xz
Include exclude.h.
(exclude): New static var. (long_options, usage, main): Add --exclude and --exclude-from or -X. (count_entry): Skip excluded entries.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/du.c b/src/du.c
index ab27050b6..7deac25d5 100644
--- a/src/du.c
+++ b/src/du.c
@@ -106,10 +106,10 @@ int lstat ();
static int hash_insert PARAMS ((ino_t ino, dev_t dev));
static int hash_insert2 PARAMS ((struct htab *_htab, ino_t ino, dev_t dev));
static uintmax_t count_entry PARAMS ((const char *ent, int top, dev_t last_dev,
- int depth));
+ int depth));
static void du_files PARAMS ((char **files));
static void hash_init PARAMS ((unsigned int modulus,
- unsigned int entry_tab_size));
+ unsigned int entry_tab_size));
static void hash_reset PARAMS ((void));
static void str_concatc PARAMS ((String *s1, char *cstr));
static void str_copyc PARAMS ((String *s1, char *cstr));
@@ -539,9 +539,8 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
through_symlink = (xstat == stat
&& lstat (ent, &e_buf) == 0
&& S_ISLNK (e_buf.st_mode));
- if (through_symlink)
- if (save_cwd (&cwd))
- exit (1);
+ if (through_symlink && save_cwd (&cwd))
+ exit (1);
if (chdir (ent) < 0)
{
@@ -579,12 +578,15 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
pathlen = path->length;
for (namep = name_space; *namep; namep += strlen (namep) + 1)
- if (!excluded_filename (exclude, namep))
- {
- str_concatc (path, namep);
- size += count_entry (namep, 0, dir_dev, depth + 1);
- str_trunc (path, pathlen);
- }
+ {
+ if (!excluded_filename (exclude, namep))
+ {
+ str_concatc (path, namep);
+ size += count_entry (namep, 0, dir_dev, depth + 1);
+ str_trunc (path, pathlen);
+ }
+ }
+
free (name_space);
if (through_symlink)
{
@@ -592,8 +594,10 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
free_cwd (&cwd);
}
else if (chdir ("..") < 0)
- error (1, errno,
- _("cannot change to `..' from directory %s"), path->text);
+ {
+ error (1, errno,
+ _("cannot change to `..' from directory %s"), path->text);
+ }
str_trunc (path, pathlen - 1); /* Remove the "/" we added. */
if (depth <= max_depth || top)
@@ -686,7 +690,7 @@ hash_insert (ino_t ino, dev_t dev)
htab_r->entry_tab = (struct entry *)
xrealloc ((char *) htab_r->entry_tab,
- sizeof (struct entry) * entry_tab_size);
+ sizeof (struct entry) * entry_tab_size);
/* Increase the size of htab again. */
@@ -774,7 +778,7 @@ str_init (String **s1, unsigned int size)
}
static void
-ensure_space (String * s, unsigned int size)
+ensure_space (String *s, unsigned int size)
{
if (s->alloc < size)
{