summaryrefslogtreecommitdiffstats
path: root/misc-utils/whereis.c
diff options
context:
space:
mode:
authorSami Kerola2013-03-16 21:12:49 +0100
committerKarel Zak2013-03-19 16:02:32 +0100
commit3bfb96365dc7a7971f4cc941e95e1ce0d1f288c7 (patch)
tree0acbb331c080bc0a319b2b0b04f0886a9e4c7225 /misc-utils/whereis.c
parentwhereis: rewrite most of the command (diff)
downloadkernel-qcow2-util-linux-3bfb96365dc7a7971f4cc941e95e1ce0d1f288c7.tar.gz
kernel-qcow2-util-linux-3bfb96365dc7a7971f4cc941e95e1ce0d1f288c7.tar.xz
kernel-qcow2-util-linux-3bfb96365dc7a7971f4cc941e95e1ce0d1f288c7.zip
whereis: add search scope listing option
Mostly useful when debugging why the command does, or does not, work. Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/whereis.c')
-rw-r--r--misc-utils/whereis.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index 97ec45cb2..0f14267f3 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -176,6 +176,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
" -s search only for sources\n"
" -S <dirs> define sources lookup path\n"
" -u search for unusual entries\n"
+ " -l output effective lookup paths\n"
" -V output version information and exit\n"
" -h display this help and exit\n\n"), out);
@@ -436,6 +437,29 @@ static void lookup(const char *pattern, struct wh_dirlist *ls, int want)
return;
}
+static void list_dirlist(struct wh_dirlist *ls)
+{
+ while (ls) {
+ if (ls->path) {
+ switch (ls->type) {
+ case BIN_DIR:
+ printf("bin: ");
+ break;
+ case MAN_DIR:
+ printf("man: ");
+ break;
+ case SRC_DIR:
+ printf("src: ");
+ break;
+ default:
+ abort();
+ }
+ printf("%s\n", ls->path);
+ }
+ ls = ls->next;
+ }
+}
+
int main(int argc, char **argv)
{
struct wh_dirlist *ls = NULL;
@@ -515,6 +539,9 @@ int main(int argc, char **argv)
case 's':
want = want == ALL_DIRS ? SRC_DIR : want | SRC_DIR;
break;
+ case 'l':
+ list_dirlist(ls);
+ break;
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
@@ -526,6 +553,8 @@ int main(int argc, char **argv)
}
}
+
+ DBG(printf("DONE"));
free_dirlist(&ls, ALL_DIRS);
return EXIT_SUCCESS;
}