diff -Nur bb-orig/util-linux/guess_fstype.c busybox-git/util-linux/guess_fstype.c --- bb-orig/util-linux/guess_fstype.c 1970-01-01 07:00:00.000000000 +0700 +++ busybox-git/util-linux/guess_fstype.c 2013-08-21 23:15:45.577377154 +0700 @@ -0,0 +1,62 @@ +/* vi: set sw=4 ts=4: */ +/* + * guess_fs based on a version by "jamesbond" + * + * Copyright 2013, ???? + * + * Licensed under GPLv2, see file LICENSE in this source tree + */ + +//applet:IF_GUESS_FSTYPE(APPLET(guess_fstype, BB_DIR_BIN, BB_SUID_MAYBE)) + +//kbuild:lib-$(CONFIG_GUESS_FSTYPE) += guess_fstype.o + +//config:config GUESS_FSTYPE +//config: bool "guess_fstype" +//config: default n +//config: help +//config: Guess filesystem type of device. +//config: (As in Puppy guess_fstype) + +//usage:#define guess_fstype_trivial_usage +//usage: "[BLOCKDEV]..." +//usage:#define guess_fstype_full_usage "\n\n" +//usage: "[BLOCKDEV]..." + +#include "libbb.h" +#include "volume_id/volume_id_internal.h" +#include +#include + +int guess_fstype_main (int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int guess_fstype_main (int argc, char **argv) +{ + struct volume_id *id=0; + int retcode=0; //assume success + int fd; + + while (*++argv) { + // identify + fd = open (argv[0], O_RDONLY); + if (fd >= 0) { + id = volume_id_open_node (fd); + if (id) { + char const *type; + if ((!volume_id_probe_all (id, 0)) && id->type) + type = id->type; + else { + type = "unknown"; + retcode = 1; + } + + if (argc > 2) // if more than one, show original device + printf ("%s: ", argv[0]); + printf ("%s\n", type); + + free_volume_id (id); + } + } + } + + return retcode; +}