1331722Seadler/* 21590Srgrimes * Copyright (c) 1989, 1993, 1994 31590Srgrimes * The Regents of the University of California. All rights reserved. 41590Srgrimes * 51590Srgrimes * This code is derived from software contributed to Berkeley by 61590Srgrimes * Chris Newcomb. 71590Srgrimes * 81590Srgrimes * Redistribution and use in source and binary forms, with or without 91590Srgrimes * modification, are permitted provided that the following conditions 101590Srgrimes * are met: 111590Srgrimes * 1. Redistributions of source code must retain the above copyright 121590Srgrimes * notice, this list of conditions and the following disclaimer. 131590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141590Srgrimes * notice, this list of conditions and the following disclaimer in the 151590Srgrimes * documentation and/or other materials provided with the distribution. 161590Srgrimes * 4. Neither the name of the University nor the names of its contributors 171590Srgrimes * may be used to endorse or promote products derived from this software 181590Srgrimes * without specific prior written permission. 191590Srgrimes * 201590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301590Srgrimes * SUCH DAMAGE. 311590Srgrimes */ 321590Srgrimes 331590Srgrimes#ifndef lint 3441568Sarchiestatic const char copyright[] = 351590Srgrimes"@(#) Copyright (c) 1989, 1993, 1994\n\ 361590Srgrimes The Regents of the University of California. All rights reserved.\n"; 371590Srgrimes#endif /* not lint */ 381590Srgrimes 391590Srgrimes#ifndef lint 4056597Smharo#if 0 4141568Sarchiestatic const char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95"; 4256597Smharo#endif 431590Srgrimes#endif /* not lint */ 4499112Sobrien#include <sys/cdefs.h> 4599112Sobrien__FBSDID("$FreeBSD: stable/11/usr.bin/du/du.c 328139 2018-01-18 21:32:50Z kevans $"); 461590Srgrimes 471590Srgrimes#include <sys/param.h> 4878158Sroam#include <sys/queue.h> 491590Srgrimes#include <sys/stat.h> 501590Srgrimes#include <err.h> 511590Srgrimes#include <errno.h> 5278158Sroam#include <fnmatch.h> 531590Srgrimes#include <fts.h> 54328139Skevans#include <getopt.h> 55129678Spjd#include <libutil.h> 56132201Stjr#include <locale.h> 57139813Spjd#include <stdint.h> 581590Srgrimes#include <stdio.h> 591590Srgrimes#include <stdlib.h> 601590Srgrimes#include <string.h> 6156597Smharo#include <sysexits.h> 6223693Speter#include <unistd.h> 631590Srgrimes 64328139Skevans#define SI_OPT (CHAR_MAX + 1) 65328139Skevans 66328139Skevans#define UNITS_2 1 67328139Skevans#define UNITS_SI 2 68328139Skevans 69227164Sedstatic SLIST_HEAD(ignhead, ignentry) ignores; 7078158Sroamstruct ignentry { 7178158Sroam char *mask; 7278158Sroam SLIST_ENTRY(ignentry) next; 7378158Sroam}; 7478158Sroam 75128772Skientzlestatic int linkchk(FTSENT *); 7692920Simpstatic void usage(void); 77184656Smlaierstatic void prthumanval(int64_t); 78184656Smlaierstatic void ignoreadd(const char *); 79184656Smlaierstatic void ignoreclean(void); 80184656Smlaierstatic int ignorep(FTSENT *); 81191677Simpstatic void siginfo(int __unused); 821590Srgrimes 83184656Smlaierstatic int nodumpflag = 0; 84328139Skevansstatic int Aflag, hflag; 85184733Smlaierstatic long blocksize, cblocksize; 86191677Simpstatic volatile sig_atomic_t info; 87158339Smaxim 88328139Skevansstatic const struct option long_options[] = 89328139Skevans{ 90328139Skevans { "si", no_argument, NULL, SI_OPT }, 91328139Skevans { NULL, no_argument, NULL, 0 }, 92328139Skevans}; 93328139Skevans 941590Srgrimesint 95100822Sdwmalonemain(int argc, char *argv[]) 961590Srgrimes{ 9732097Sjkh FTS *fts; 9832097Sjkh FTSENT *p; 99184733Smlaier off_t savednumber, curblocks; 100209362Sbrian off_t threshold, threshold_sign; 10132097Sjkh int ftsoptions; 10232097Sjkh int depth; 103228669Sjilles int Hflag, Lflag, aflag, sflag, dflag, cflag; 104328139Skevans int lflag, ch, notused, rval; 10532097Sjkh char **save; 10687216Smarkm static char dot[] = "."; 1071590Srgrimes 108132201Stjr setlocale(LC_ALL, ""); 109132201Stjr 110328139Skevans Hflag = Lflag = aflag = sflag = dflag = cflag = lflag = Aflag = 0; 111128772Skientzle 1121590Srgrimes save = argv; 113228669Sjilles ftsoptions = FTS_PHYSICAL; 114184654Smlaier savednumber = 0; 115209362Sbrian threshold = 0; 116209362Sbrian threshold_sign = 1; 117184733Smlaier cblocksize = DEV_BSIZE; 118184733Smlaier blocksize = 0; 11919120Sscrappy depth = INT_MAX; 12078158Sroam SLIST_INIT(&ignores); 121128772Skientzle 122328139Skevans while ((ch = getopt_long(argc, argv, "+AB:HI:LPasd:cghklmnrt:x", 123328139Skevans long_options, NULL)) != -1) 1241590Srgrimes switch (ch) { 125184733Smlaier case 'A': 126184733Smlaier Aflag = 1; 127184733Smlaier break; 128184733Smlaier case 'B': 129184733Smlaier errno = 0; 130184733Smlaier cblocksize = atoi(optarg); 131184733Smlaier if (errno == ERANGE || cblocksize <= 0) { 132184733Smlaier warnx("invalid argument to option B: %s", 133184733Smlaier optarg); 134184733Smlaier usage(); 135184733Smlaier } 136184733Smlaier break; 137184654Smlaier case 'H': 138184654Smlaier Hflag = 1; 139228669Sjilles Lflag = 0; 140184654Smlaier break; 141184654Smlaier case 'I': 142184654Smlaier ignoreadd(optarg); 143184654Smlaier break; 144184654Smlaier case 'L': 145184654Smlaier Lflag = 1; 146228669Sjilles Hflag = 0; 147184654Smlaier break; 148184654Smlaier case 'P': 149228669Sjilles Hflag = Lflag = 0; 150184654Smlaier break; 151184654Smlaier case 'a': 152184654Smlaier aflag = 1; 153184654Smlaier break; 154184654Smlaier case 's': 155184654Smlaier sflag = 1; 156184654Smlaier break; 157184654Smlaier case 'd': 158184654Smlaier dflag = 1; 159184654Smlaier errno = 0; 160184654Smlaier depth = atoi(optarg); 161184654Smlaier if (errno == ERANGE || depth < 0) { 162184654Smlaier warnx("invalid argument to option d: %s", 163184654Smlaier optarg); 164184654Smlaier usage(); 165184654Smlaier } 166184654Smlaier break; 167184654Smlaier case 'c': 168184654Smlaier cflag = 1; 169184654Smlaier break; 170238602Sdes case 'g': 171238602Sdes hflag = 0; 172238602Sdes blocksize = 1073741824; 173238602Sdes break; 174184654Smlaier case 'h': 175328139Skevans hflag = UNITS_2; 176184654Smlaier break; 177184654Smlaier case 'k': 178184654Smlaier hflag = 0; 179184733Smlaier blocksize = 1024; 180184654Smlaier break; 181184654Smlaier case 'l': 182184654Smlaier lflag = 1; 183184654Smlaier break; 184184654Smlaier case 'm': 185184654Smlaier hflag = 0; 186184733Smlaier blocksize = 1048576; 187184654Smlaier break; 188184654Smlaier case 'n': 189184654Smlaier nodumpflag = 1; 190184654Smlaier break; 191184654Smlaier case 'r': /* Compatibility. */ 192184654Smlaier break; 193209362Sbrian case 't' : 194209362Sbrian if (expand_number(optarg, &threshold) != 0 || 195209362Sbrian threshold == 0) { 196209362Sbrian warnx("invalid threshold: %s", optarg); 197209362Sbrian usage(); 198209362Sbrian } else if (threshold < 0) 199209362Sbrian threshold_sign = -1; 200209362Sbrian break; 201184654Smlaier case 'x': 202184654Smlaier ftsoptions |= FTS_XDEV; 203184654Smlaier break; 204328139Skevans case SI_OPT: 205328139Skevans hflag = UNITS_SI; 206328139Skevans break; 207184654Smlaier case '?': 208184654Smlaier default: 209184654Smlaier usage(); 210184654Smlaier /* NOTREACHED */ 2111590Srgrimes } 21232097Sjkh 2131590Srgrimes argc -= optind; 2141590Srgrimes argv += optind; 2151590Srgrimes 2161590Srgrimes /* 2171590Srgrimes * XXX 2181590Srgrimes * Because of the way that fts(3) works, logical walks will not count 2191590Srgrimes * the blocks actually used by symbolic links. We rationalize this by 2201590Srgrimes * noting that users computing logical sizes are likely to do logical 2211590Srgrimes * copies, so not counting the links is correct. The real reason is 2221590Srgrimes * that we'd have to re-implement the kernel's symbolic link traversing 2231590Srgrimes * algorithm to get this right. If, for example, you have relative 2241590Srgrimes * symbolic links referencing other relative symbolic links, it gets 2251590Srgrimes * very nasty, very fast. The bottom line is that it's documented in 2261590Srgrimes * the man page, so it's a feature. 2271590Srgrimes */ 22832097Sjkh 2291590Srgrimes if (Hflag) 2301590Srgrimes ftsoptions |= FTS_COMFOLLOW; 231228669Sjilles if (Lflag) { 232228669Sjilles ftsoptions &= ~FTS_PHYSICAL; 2331590Srgrimes ftsoptions |= FTS_LOGICAL; 234228669Sjilles } 2351590Srgrimes 236184733Smlaier if (!Aflag && (cblocksize % DEV_BSIZE) != 0) 237184733Smlaier cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE; 238184733Smlaier 239227335Sed if (aflag + dflag + sflag > 1) 240227335Sed usage(); 241227335Sed if (sflag) 24232097Sjkh depth = 0; 2431590Srgrimes 2441590Srgrimes if (!*argv) { 2451590Srgrimes argv = save; 24687216Smarkm argv[0] = dot; 2471590Srgrimes argv[1] = NULL; 2481590Srgrimes } 2491590Srgrimes 250184733Smlaier if (blocksize == 0) 251184733Smlaier (void)getbsize(¬used, &blocksize); 2521590Srgrimes 253184733Smlaier if (!Aflag) { 254184733Smlaier cblocksize /= DEV_BSIZE; 255184733Smlaier blocksize /= DEV_BSIZE; 256184733Smlaier } 257184733Smlaier 258209362Sbrian if (threshold != 0) 259209362Sbrian threshold = howmany(threshold / DEV_BSIZE * cblocksize, 260209362Sbrian blocksize); 261209362Sbrian 26232097Sjkh rval = 0; 263128772Skientzle 264191677Simp (void)signal(SIGINFO, siginfo); 265191677Simp 2661590Srgrimes if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL) 26732097Sjkh err(1, "fts_open"); 2681590Srgrimes 26932097Sjkh while ((p = fts_read(fts)) != NULL) { 2701590Srgrimes switch (p->fts_info) { 271184654Smlaier case FTS_D: /* Ignore. */ 272184654Smlaier if (ignorep(p)) 273184654Smlaier fts_set(fts, p, FTS_SKIP); 274184654Smlaier break; 275184654Smlaier case FTS_DP: 276184654Smlaier if (ignorep(p)) 2771590Srgrimes break; 27878158Sroam 279184733Smlaier curblocks = Aflag ? 280184733Smlaier howmany(p->fts_statp->st_size, cblocksize) : 281184733Smlaier howmany(p->fts_statp->st_blocks, cblocksize); 282184654Smlaier p->fts_parent->fts_bignum += p->fts_bignum += 283184733Smlaier curblocks; 284128772Skientzle 285209362Sbrian if (p->fts_level <= depth && threshold <= 286209362Sbrian threshold_sign * howmany(p->fts_bignum * 287209362Sbrian cblocksize, blocksize)) { 288328139Skevans if (hflag > 0) { 289184733Smlaier prthumanval(p->fts_bignum); 290184654Smlaier (void)printf("\t%s\n", p->fts_path); 291184654Smlaier } else { 292184654Smlaier (void)printf("%jd\t%s\n", 293184742Smlaier (intmax_t)howmany(p->fts_bignum * 294184742Smlaier cblocksize, blocksize), 295184742Smlaier p->fts_path); 29658601Scharnier } 297184654Smlaier } 298191677Simp if (info) { 299191677Simp info = 0; 300191677Simp (void)printf("\t%s\n", p->fts_path); 301191677Simp } 302184654Smlaier break; 303184654Smlaier case FTS_DC: /* Ignore. */ 304184654Smlaier break; 305184654Smlaier case FTS_DNR: /* Warn, continue. */ 306184654Smlaier case FTS_ERR: 307184654Smlaier case FTS_NS: 308184654Smlaier warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); 309184654Smlaier rval = 1; 310184654Smlaier break; 311184654Smlaier default: 312184654Smlaier if (ignorep(p)) 31332097Sjkh break; 314184654Smlaier 315184654Smlaier if (lflag == 0 && p->fts_statp->st_nlink > 1 && 316184654Smlaier linkchk(p)) 31732097Sjkh break; 31878158Sroam 319184733Smlaier curblocks = Aflag ? 320184733Smlaier howmany(p->fts_statp->st_size, cblocksize) : 321184733Smlaier howmany(p->fts_statp->st_blocks, cblocksize); 322184733Smlaier 323227335Sed if (aflag || p->fts_level == 0) { 324328139Skevans if (hflag > 0) { 325184733Smlaier prthumanval(curblocks); 326184654Smlaier (void)printf("\t%s\n", p->fts_path); 327184654Smlaier } else { 328184654Smlaier (void)printf("%jd\t%s\n", 329184742Smlaier (intmax_t)howmany(curblocks * 330184742Smlaier cblocksize, blocksize), 331184742Smlaier p->fts_path); 33258601Scharnier } 333184654Smlaier } 33432097Sjkh 335184733Smlaier p->fts_parent->fts_bignum += curblocks; 3361590Srgrimes } 337139813Spjd savednumber = p->fts_parent->fts_bignum; 33832097Sjkh } 33932097Sjkh 3401590Srgrimes if (errno) 3411590Srgrimes err(1, "fts_read"); 34232097Sjkh 34358601Scharnier if (cflag) { 344328139Skevans if (hflag > 0) { 345184733Smlaier prthumanval(savednumber); 346184654Smlaier (void)printf("\ttotal\n"); 34756597Smharo } else { 348184654Smlaier (void)printf("%jd\ttotal\n", (intmax_t)howmany( 349184733Smlaier savednumber * cblocksize, blocksize)); 35056597Smharo } 35158601Scharnier } 35232097Sjkh 35378158Sroam ignoreclean(); 35428891Swosch exit(rval); 3551590Srgrimes} 3561590Srgrimes 357128772Skientzlestatic int 358128772Skientzlelinkchk(FTSENT *p) 359128772Skientzle{ 360128772Skientzle struct links_entry { 361128806Skientzle struct links_entry *next; 362128806Skientzle struct links_entry *previous; 363128806Skientzle int links; 364128806Skientzle dev_t dev; 365128806Skientzle ino_t ino; 366128772Skientzle }; 367128806Skientzle static const size_t links_hash_initial_size = 8192; 368128806Skientzle static struct links_entry **buckets; 369128806Skientzle static struct links_entry *free_list; 370128806Skientzle static size_t number_buckets; 371128806Skientzle static unsigned long number_entries; 372128806Skientzle static char stop_allocating; 373128806Skientzle struct links_entry *le, **new_buckets; 374128806Skientzle struct stat *st; 375128806Skientzle size_t i, new_size; 376144840Sstefanf int hash; 37732097Sjkh 378128772Skientzle st = p->fts_statp; 37932097Sjkh 380128772Skientzle /* If necessary, initialize the hash table. */ 381128772Skientzle if (buckets == NULL) { 382128772Skientzle number_buckets = links_hash_initial_size; 383128772Skientzle buckets = malloc(number_buckets * sizeof(buckets[0])); 384128772Skientzle if (buckets == NULL) 385128834Skientzle errx(1, "No memory for hardlink detection"); 386128772Skientzle for (i = 0; i < number_buckets; i++) 387128772Skientzle buckets[i] = NULL; 388128772Skientzle } 3891590Srgrimes 390128772Skientzle /* If the hash table is getting too full, enlarge it. */ 391128772Skientzle if (number_entries > number_buckets * 10 && !stop_allocating) { 392128772Skientzle new_size = number_buckets * 2; 393278921Spfg new_buckets = calloc(new_size, sizeof(struct links_entry *)); 394128772Skientzle 395128772Skientzle /* Try releasing the free list to see if that helps. */ 396128772Skientzle if (new_buckets == NULL && free_list != NULL) { 397128772Skientzle while (free_list != NULL) { 398128772Skientzle le = free_list; 399128772Skientzle free_list = le->next; 400128772Skientzle free(le); 401128772Skientzle } 402278921Spfg new_buckets = calloc(new_size, sizeof(new_buckets[0])); 403128772Skientzle } 404128772Skientzle 405128772Skientzle if (new_buckets == NULL) { 406128772Skientzle stop_allocating = 1; 407128834Skientzle warnx("No more memory for tracking hard links"); 408128772Skientzle } else { 409128772Skientzle for (i = 0; i < number_buckets; i++) { 410128772Skientzle while (buckets[i] != NULL) { 411128772Skientzle /* Remove entry from old bucket. */ 412128772Skientzle le = buckets[i]; 413128772Skientzle buckets[i] = le->next; 414128772Skientzle 415128772Skientzle /* Add entry to new bucket. */ 416128772Skientzle hash = (le->dev ^ le->ino) % new_size; 417128772Skientzle 418128772Skientzle if (new_buckets[hash] != NULL) 419128772Skientzle new_buckets[hash]->previous = 420128772Skientzle le; 421128772Skientzle le->next = new_buckets[hash]; 422128772Skientzle le->previous = NULL; 423128772Skientzle new_buckets[hash] = le; 424128772Skientzle } 425128772Skientzle } 426128772Skientzle free(buckets); 427128772Skientzle buckets = new_buckets; 428128772Skientzle number_buckets = new_size; 429128772Skientzle } 430128772Skientzle } 431128772Skientzle 432128772Skientzle /* Try to locate this entry in the hash table. */ 433128772Skientzle hash = ( st->st_dev ^ st->st_ino ) % number_buckets; 434128772Skientzle for (le = buckets[hash]; le != NULL; le = le->next) { 435128772Skientzle if (le->dev == st->st_dev && le->ino == st->st_ino) { 436128772Skientzle /* 437128772Skientzle * Save memory by releasing an entry when we've seen 438128772Skientzle * all of it's links. 439128772Skientzle */ 440128772Skientzle if (--le->links <= 0) { 441128772Skientzle if (le->previous != NULL) 442128772Skientzle le->previous->next = le->next; 443128772Skientzle if (le->next != NULL) 444128772Skientzle le->next->previous = le->previous; 445128772Skientzle if (buckets[hash] == le) 446128772Skientzle buckets[hash] = le->next; 447128772Skientzle number_entries--; 448128772Skientzle /* Recycle this node through the free list */ 449128772Skientzle if (stop_allocating) { 450128772Skientzle free(le); 451128772Skientzle } else { 452128772Skientzle le->next = free_list; 453128772Skientzle free_list = le; 454128772Skientzle } 455128772Skientzle } 456128772Skientzle return (1); 457128772Skientzle } 458128772Skientzle } 459128772Skientzle 460128772Skientzle if (stop_allocating) 461128772Skientzle return (0); 462128772Skientzle 463128772Skientzle /* Add this entry to the links cache. */ 464128772Skientzle if (free_list != NULL) { 465128772Skientzle /* Pull a node from the free list if we can. */ 466128772Skientzle le = free_list; 467128772Skientzle free_list = le->next; 468128772Skientzle } else 469128772Skientzle /* Malloc one if we have to. */ 470128772Skientzle le = malloc(sizeof(struct links_entry)); 471128772Skientzle if (le == NULL) { 472128772Skientzle stop_allocating = 1; 473128834Skientzle warnx("No more memory for tracking hard links"); 474128772Skientzle return (0); 475128772Skientzle } 476128772Skientzle le->dev = st->st_dev; 477128772Skientzle le->ino = st->st_ino; 478128772Skientzle le->links = st->st_nlink - 1; 479128772Skientzle number_entries++; 480128772Skientzle le->next = buckets[hash]; 481128772Skientzle le->previous = NULL; 482128772Skientzle if (buckets[hash] != NULL) 483128772Skientzle buckets[hash]->previous = le; 484128772Skientzle buckets[hash] = le; 4851590Srgrimes return (0); 4861590Srgrimes} 4871590Srgrimes 488184656Smlaierstatic void 489129678Spjdprthumanval(int64_t bytes) 49056597Smharo{ 491129678Spjd char buf[5]; 492328139Skevans int flags; 49356597Smharo 494184733Smlaier bytes *= cblocksize; 495328139Skevans flags = HN_B | HN_NOSPACE | HN_DECIMAL; 496184733Smlaier if (!Aflag) 497184733Smlaier bytes *= DEV_BSIZE; 498328139Skevans if (hflag == UNITS_SI) 499328139Skevans flags |= HN_DIVISOR_1000; 50056597Smharo 501328139Skevans humanize_number(buf, sizeof(buf), bytes, "", HN_AUTOSCALE, flags); 50256597Smharo 503129678Spjd (void)printf("%4s", buf); 50456597Smharo} 50556597Smharo 50627099Scharnierstatic void 507100822Sdwmaloneusage(void) 5081590Srgrimes{ 5091590Srgrimes (void)fprintf(stderr, 510238817Spluknet "usage: du [-Aclnx] [-H | -L | -P] [-g | -h | -k | -m] " 511228356Sgjb "[-a | -s | -d depth] [-B blocksize] [-I mask] " 512228356Sgjb "[-t threshold] [file ...]\n"); 51356597Smharo exit(EX_USAGE); 5141590Srgrimes} 51578158Sroam 516184656Smlaierstatic void 517100822Sdwmaloneignoreadd(const char *mask) 51878158Sroam{ 51978158Sroam struct ignentry *ign; 52078158Sroam 52178158Sroam ign = calloc(1, sizeof(*ign)); 52278158Sroam if (ign == NULL) 52378158Sroam errx(1, "cannot allocate memory"); 52478158Sroam ign->mask = strdup(mask); 52578158Sroam if (ign->mask == NULL) 52678158Sroam errx(1, "cannot allocate memory"); 52778158Sroam SLIST_INSERT_HEAD(&ignores, ign, next); 52878158Sroam} 52978158Sroam 530184656Smlaierstatic void 531100822Sdwmaloneignoreclean(void) 53278158Sroam{ 53378158Sroam struct ignentry *ign; 534321096Sngie 53578158Sroam while (!SLIST_EMPTY(&ignores)) { 53678158Sroam ign = SLIST_FIRST(&ignores); 53778158Sroam SLIST_REMOVE_HEAD(&ignores, next); 53878158Sroam free(ign->mask); 53978158Sroam free(ign); 54078158Sroam } 54178158Sroam} 54278158Sroam 543184656Smlaierstatic int 544100822Sdwmaloneignorep(FTSENT *ent) 54578158Sroam{ 54678158Sroam struct ignentry *ign; 54778158Sroam 548158339Smaxim if (nodumpflag && (ent->fts_statp->st_flags & UF_NODUMP)) 549158339Smaxim return 1; 55078158Sroam SLIST_FOREACH(ign, &ignores, next) 55178158Sroam if (fnmatch(ign->mask, ent->fts_name, 0) != FNM_NOMATCH) 55278158Sroam return 1; 55378158Sroam return 0; 55478158Sroam} 555191677Simp 556191677Simpstatic void 557191677Simpsiginfo(int sig __unused) 558191677Simp{ 559191677Simp 560191677Simp info = 1; 561191677Simp} 562