This patch adds xid support to du. diff -Naurp coreutils-5.2.1.orig/configure.ac coreutils-5.2.1/configure.ac --- coreutils-5.2.1.orig/configure.ac 2004-03-02 23:47:31.000000000 +0100 +++ coreutils-5.2.1/configure.ac 2005-02-20 02:00:51.000000000 +0100 @@ -235,6 +235,10 @@ jm_LIB_CHECK AM_GNU_GETTEXT([external], [need-ngettext]) AM_GNU_GETTEXT_VERSION(0.13.1) +dnl vserver check +AC_CHECK_LIB([vserver], [vc_get_iattr]) +AC_CHECK_TYPES([xid_t, nid_t]) + AC_CONFIG_FILES( Makefile doc/Makefile diff -Naurp coreutils-5.2.1.orig/src/du.c coreutils-5.2.1/src/du.c --- coreutils-5.2.1.orig/src/du.c 2004-02-22 22:21:35.000000000 +0100 +++ coreutils-5.2.1/src/du.c 2005-02-20 01:58:42.000000000 +0100 @@ -41,6 +41,15 @@ #include "same.h" #include "xfts.h" #include "xstrtol.h" +#ifdef HAVE_LIBVSERVER +#ifndef HAVE_XID_T +typedef unsigned int xid_t; +#endif +#ifndef HAVE_NID_T +typedef unsigned int nid_t; +#endif +#include +#endif extern int fts_debug; @@ -115,6 +124,11 @@ static uintmax_t tot_size = 0; /* Nonzero indicates that du should exit with EXIT_FAILURE upon completion. */ int G_fail; +#ifdef HAVE_LIBVSERVER +/* xid to sum files for */ +xid_t xid = VC_NOCTX; +#endif + #define IS_DIR_TYPE(Type) \ ((Type) == FTS_DP \ || (Type) == FTS_DNR) @@ -151,6 +165,9 @@ static struct option const long_options[ {"separate-dirs", no_argument, NULL, 'S'}, {"summarize", no_argument, NULL, 's'}, {"total", no_argument, NULL, 'c'}, +#ifdef HAVE_LIBVSERVER + {"xid", required_argument, NULL, 'C'}, +#endif {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -365,12 +382,19 @@ process_file (FTS *fts, FTSENT *ent) if (ent->fts_info == FTS_D || skip) return; - /* If the file is being excluded or if it has already been counted - via a hard link, then don't let it contribute to the sums. */ + /* If the file is being excluded, if it has already been counted + via a hard link, or if it's xid is wrong and it's not a + directory, then don't let it contribute to the sums. */ if (skip || (!opt_count_all && 1 < sb->st_nlink - && hash_ins (sb->st_ino, sb->st_dev))) + && hash_ins (sb->st_ino, sb->st_dev)) +#ifdef HAVE_LIBVSERVER + || (xid != VC_NOCTX + && !IS_DIR_TYPE(ent->fts_info) + && vc_getfilecontext(ent->fts_name) != xid) +#endif + ) { /* Note that we must not simply return here. We still have to update prev_level and maybe propagate @@ -681,6 +705,21 @@ main (int argc, char **argv) add_exclude (exclude, optarg, EXCLUDE_WILDCARDS); break; +#ifdef HAVE_LIBVSERVER + case 'C': + { + const char *errstr = NULL; + xid = vc_xidopt2xid(optarg, true, &errstr); + if (xid == VC_NOCTX) + { + error (0, 0, _("invalid xid %s: %s"), + quote (optarg), errstr); + fail = 1; + } + } + break; +#endif + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);