diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
commit | 71cd8e3a743046573744123777061b64881bf372 (patch) | |
tree | 82522befe647f4fff186a5630cad0cad33f8ef53 /src/du.c | |
parent | c18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff) | |
download | coreutils-upstream.tar.gz |
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'src/du.c')
-rw-r--r-- | src/du.c | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -1,5 +1,5 @@ /* du -- summarize disk usage - Copyright (C) 1988-2014 Free Software Foundation, Inc. + Copyright (C) 1988-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -283,7 +283,7 @@ Usage: %s [OPTION]... [FILE]...\n\ or: %s [OPTION]... --files0-from=F\n\ "), program_name, program_name); fputs (_("\ -Summarize disk usage of each FILE, recursively for directories.\n\ +Summarize disk usage of the set of FILEs, recursively for directories.\n\ "), stdout); emit_mandatory_arg_note (); @@ -351,7 +351,7 @@ Summarize disk usage of each FILE, recursively for directories.\n\ fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_blocksize_note ("DU"); emit_size_note (); - emit_ancillary_info (); + emit_ancillary_info (PROGRAM_NAME); } exit (status); } @@ -419,6 +419,27 @@ print_size (const struct duinfo *pdui, const char *string) fflush (stdout); } +/* This function checks whether any of the directories in the cycle that + fts detected is a mount point. */ + +static bool +mount_point_in_fts_cycle (FTSENT const *ent) +{ + FTSENT const *cycle_ent = ent->fts_cycle; + + while (ent && ent != cycle_ent) + { + if (di_set_lookup (di_mnt, ent->fts_statp->st_dev, + ent->fts_statp->st_ino) > 0) + { + return true; + } + ent = ent->fts_parent; + } + + return false; +} + /* This function is called once for every file system object that fts encounters. fts does a depth-first traversal. This function knows that and accumulates per-directory totals based on changes in @@ -516,7 +537,7 @@ process_file (FTS *fts, FTSENT *ent) case FTS_DC: /* If not following symlinks and not a (bind) mount point. */ if (cycle_warning_required (fts, ent) - && ! di_set_lookup (di_mnt, sb->st_dev, sb->st_ino)) + && ! mount_point_in_fts_cycle (ent)) { emit_cycle_warning (file); return false; @@ -947,9 +968,9 @@ main (int argc, char **argv) { /* Ignore "posix-" prefix, for compatibility with ls. */ static char const posix_prefix[] = "posix-"; - while (strncmp (time_style, posix_prefix, sizeof posix_prefix - 1) - == 0) - time_style += sizeof posix_prefix - 1; + static const size_t prefix_len = sizeof posix_prefix - 1; + while (STREQ_LEN (time_style, posix_prefix, prefix_len)) + time_style += prefix_len; } } @@ -1108,5 +1129,5 @@ main (int argc, char **argv) if (print_grand_total) print_size (&tot_dui, _("total")); - exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); + return ok ? EXIT_SUCCESS : EXIT_FAILURE; } |