busybox: squashed commit of merging cm-12.1
With fixes to LOCAL_C_INCLUDES for libsepol in M and fixed
some missing includes to enable building for 64 bit devices
Conflicts:
Android.mk
android/libc/arch-x86/syscalls/swapoff.S
android/libc/arch-x86/syscalls/swapon.S
android/libc/arch-x86/syscalls/sysinfo.S
android/librpc/pmap_rmt.c
android/reboot.c
include-full/copy-current.sh
include-minimal/copy-current.sh
include/platform.h
networking/interface.c
networking/nslookup.c
Change-Id: If6092fa87f3d21190db1af4f70daa150eb462660
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 93b84ad..9af923e 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -81,6 +81,14 @@
<6>BIOS-provided physical RAM map:
<6> BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
+config FEATURE_DMESG_COLOR
+ bool "Colored dmesg output"
+ default y
+ depends on DMESG
+ help
+ Allow to show errors and warnings in different colors
+ dmesg -C
+
config FBSET
bool "fbset"
default y
@@ -699,250 +707,6 @@
About the only reason to use this is if you've removed /proc from
your kernel.
-config VOLUMEID
- bool #No description makes it a hidden option
- default n
-
-menu "Filesystem/Volume identification"
- depends on VOLUMEID
-
-config FEATURE_VOLUMEID_EXT
- bool "Ext filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_BTRFS
- bool "btrfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_REISERFS
- bool "Reiser filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_FAT
- bool "fat filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_EXFAT
- bool "exFAT filesystem"
- default y
- depends on VOLUMEID
- help
- exFAT (extended FAT) is a proprietary file system designed especially
- for flash drives. It has many features from NTFS, but with less
- overhead. exFAT is used on most SDXC cards for consumer electronics.
-
-config FEATURE_VOLUMEID_HFS
- bool "hfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_JFS
- bool "jfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-### config FEATURE_VOLUMEID_UFS
-### bool "ufs filesystem"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-config FEATURE_VOLUMEID_XFS
- bool "xfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_NILFS
- bool "nilfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_NTFS
- bool "ntfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_ISO9660
- bool "iso9660 filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_UDF
- bool "udf filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_LUKS
- bool "luks filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_LINUXSWAP
- bool "linux swap filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-### config FEATURE_VOLUMEID_LVM
-### bool "lvm"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-config FEATURE_VOLUMEID_CRAMFS
- bool "cramfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-### config FEATURE_VOLUMEID_HPFS
-### bool "hpfs filesystem"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-config FEATURE_VOLUMEID_ROMFS
- bool "romfs filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-config FEATURE_VOLUMEID_SQUASHFS
- bool "SquashFS filesystem"
- default y
- depends on VOLUMEID && FEATURE_BLKID_TYPE
- help
- Squashfs is a compressed read-only filesystem for Linux. Squashfs is
- intended for general read-only filesystem use and in constrained block
- device/memory systems (e.g. embedded systems) where low overhead is
- needed.
-
-config FEATURE_VOLUMEID_SYSV
- bool "sysv filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-### config FEATURE_VOLUMEID_MINIX
-### bool "minix filesystem"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### These only detect partition tables - not used (yet?)
-### config FEATURE_VOLUMEID_MAC
-### bool "mac filesystem"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-###
-### config FEATURE_VOLUMEID_MSDOS
-### bool "msdos filesystem"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-config FEATURE_VOLUMEID_OCFS2
- bool "ocfs2 filesystem"
- default y
- depends on VOLUMEID
- help
- TODO
-
-### config FEATURE_VOLUMEID_HIGHPOINTRAID
-### bool "highpoint raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_ISWRAID
-### bool "intel raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_LSIRAID
-### bool "lsi raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_VIARAID
-### bool "via raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_SILICONRAID
-### bool "silicon raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_NVIDIARAID
-### bool "nvidia raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-### config FEATURE_VOLUMEID_PROMISERAID
-### bool "promise raid"
-### default y
-### depends on VOLUMEID
-### help
-### TODO
-
-config FEATURE_VOLUMEID_LINUXRAID
- bool "linuxraid"
- default y
- depends on VOLUMEID
- help
- TODO
-
-endmenu
+source util-linux/volume_id/Config.in
endmenu
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 84173ce..ba52036 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -10,23 +10,37 @@
*/
//usage:#define dmesg_trivial_usage
-//usage: "[-c] [-n LEVEL] [-r] [-s SIZE] [-C]"
+//usage: "[-c] [-n LEVEL] [-s SIZE]"
+//usage: IF_FEATURE_DMESG_PRETTY(" [-r]")
+//usage: IF_FEATURE_DMESG_COLOR(" [-C]")
//usage:#define dmesg_full_usage "\n\n"
//usage: "Print or control the kernel ring buffer\n"
//usage: "\n -c Clear ring buffer after printing"
//usage: "\n -n LEVEL Set console logging level"
-//usage: "\n -r Show level prefix"
//usage: "\n -s SIZE Buffer size"
-//usage: "\n -C Colored output"
+//usage: IF_FEATURE_DMESG_PRETTY(
+//usage: "\n -r Show level prefix")
+//usage: IF_FEATURE_DMESG_COLOR(
+//usage: "\n -C Colored output")
#include <sys/klog.h>
#include "libbb.h"
+#if ENABLE_FEATURE_DMESG_COLOR
#define COLOR_DEFAULT 0
-#define COLOR_WHITE 231
-#define COLOR_YELLOW 226
-#define COLOR_ORANGE 166
-#define COLOR_RED 196
+#define COLOR_WHITE 97
+#define COLOR_YELLOW 93
+#define COLOR_ORANGE 33
+#define COLOR_RED 91
+
+static void set_color(int color)
+{
+ printf("%c[%dm", 0x1B, color);
+}
+
+#else
+#define set_color(c) {}
+#endif
int dmesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dmesg_main(int argc UNUSED_PARAM, char **argv)
@@ -34,12 +48,14 @@
int len, level;
char *buf;
unsigned opts;
+ int color = 0;
enum {
OPT_c = 1 << 0,
OPT_s = 1 << 1,
OPT_n = 1 << 2,
OPT_r = 1 << 3,
- OPT_C = 1 << 4
+ OPT_C = 1 << 4,
+ OPT_end
};
opt_complementary = "s+:n+"; /* numeric */
@@ -67,14 +83,15 @@
if ((ENABLE_FEATURE_DMESG_PRETTY || (opts & OPT_C)) && !(opts & OPT_r)) {
int last = '\n';
- int in = 0, l, color;
- char pfx[16], *lvl;
+ int in = 0;
/* Skip <[0-9]+> at the start of lines */
while (1) {
if (last == '\n' && buf[in] == '<') {
+
+#if ENABLE_FEATURE_DMESG_COLOR
if (opts & OPT_C) {
- lvl = buf + in + 1;
+ char *lvl = buf + in + 1;
sscanf(lvl, "%d", &level);
switch (level) {
@@ -84,18 +101,14 @@
case 4: color = COLOR_ORANGE; break;
case 5: color = COLOR_YELLOW; break;
case 7: color = COLOR_WHITE; break;
- case 6: // common dmesg info
- default: color = COLOR_DEFAULT;
+ case 6: /* common dmesg info */
+ default:
+ color = COLOR_DEFAULT;
}
- if (color != COLOR_DEFAULT)
- l = sprintf(pfx, "%c[%d;%d;%dm",
- 0x1B, 38, 5, color);
- else
- l = sprintf(pfx, "%c[%dm", 0x1B, 0);
-
- full_write(STDOUT_FILENO, pfx, l);
+ set_color(color);
}
+#endif
while (buf[in++] != '>' && in < len)
;
} else {
@@ -105,17 +118,9 @@
if (in >= len)
break;
}
-
- if (opts & OPT_C) {
- /* Reset default terminal color */
- l = sprintf(pfx, "%c[%dm", 0x1B, 0);
- full_write(STDOUT_FILENO, pfx, l);
- }
-
/* Make sure we end with a newline */
if (last != '\n')
bb_putchar('\n');
-
} else {
full_write(STDOUT_FILENO, buf, len);
if (buf[len-1] != '\n')
@@ -124,5 +129,9 @@
if (ENABLE_FEATURE_CLEAN_UP) free(buf);
+ /* Reset default terminal color */
+ if (color)
+ set_color(0);
+
return EXIT_SUCCESS;
}
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c
index b3e918f..6f49cec 100644
--- a/util-linux/fdformat.c
+++ b/util-linux/fdformat.c
@@ -72,7 +72,7 @@
/* original message was: "Could not determine current format type" */
xioctl(fd, FDGETPRM, ¶m);
- printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB\n",
+ printf("%s-sided, %u tracks, %u sec/track. Total capacity %d kB\n",
(param.head == 2) ? "Double" : "Single",
param.track, param.sect, param.size >> 1);
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index c1cca10..ce4c24f 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -2611,7 +2611,8 @@
static void
print_buffer(char *pbuffer)
{
- int i,l;
+ unsigned i;
+ int l;
for (i = 0, l = 0; i < sector_size; i++, l++) {
if (l == 0)
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c
index d43d9c7..4ec3ee4 100644
--- a/util-linux/fdisk_gpt.c
+++ b/util-linux/fdisk_gpt.c
@@ -47,7 +47,7 @@
static unsigned int part_entry_len;
static inline gpt_partition *
-gpt_part(int i)
+gpt_part(unsigned i)
{
if (i >= n_parts) {
return NULL;
@@ -90,12 +90,10 @@
static void
gpt_list_table(int xtra UNUSED_PARAM)
{
- int i;
+ unsigned i;
char numstr6[6];
- numstr6[5] = '\0';
-
- smart_ulltoa5(total_number_of_sectors, numstr6, " KMGTPEZY");
+ smart_ulltoa5(total_number_of_sectors * sector_size, numstr6, " KMGTPEZY")[0] = '\0';
printf("Disk %s: %llu sectors, %s\n", disk_device,
(unsigned long long)total_number_of_sectors,
numstr6);
@@ -112,8 +110,8 @@
for (i = 0; i < n_parts; i++) {
gpt_partition *p = gpt_part(i);
if (p->lba_start) {
- smart_ulltoa5(1 + SWAP_LE64(p->lba_end) - SWAP_LE64(p->lba_start),
- numstr6, " KMGTPEZY");
+ smart_ulltoa5((1 + SWAP_LE64(p->lba_end) - SWAP_LE64(p->lba_start)) * sector_size,
+ numstr6, " KMGTPEZY")[0] = '\0';
printf("%4u %15llu %15llu %11s %04x ",
i + 1,
(unsigned long long)SWAP_LE64(p->lba_start),
@@ -177,7 +175,7 @@
part_array_len = n_parts * part_entry_len;
part_array = xmalloc(part_array_len);
seek_sector(SWAP_LE64(gpt_hdr->first_part_lba));
- if (full_read(dev_fd, part_array, part_array_len) != part_array_len) {
+ if (full_read(dev_fd, part_array, part_array_len) != (ssize_t) part_array_len) {
fdisk_fatal(unable_to_read);
}
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index e7fcc06..e32740d 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -348,6 +348,7 @@
set_all_unchanged();
set_changed(0);
+ check_sun_label();
get_boot(CREATE_EMPTY_SUN);
}
@@ -497,11 +498,14 @@
else
first = read_int(scround(start), scround(stop)+1,
scround(stop), 0, mesg);
- if (display_in_cyl_units)
+ if (display_in_cyl_units) {
first *= units_per_sector;
- else
+ } else {
/* Starting sector has to be properly aligned */
- first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors);
+ first = (first + g_heads * g_sectors - 1) /
+ (g_heads * g_sectors);
+ first *= g_heads * g_sectors;
+ }
if (n == 2 && first != 0)
printf("\
It is highly recommended that the third partition covers the whole disk\n\
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index c1d1b2c..33767a1 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -686,7 +686,7 @@
total++;
if (!inode_count[nr]) {
if (!inode_in_use(nr)) {
- printf("Inode %d is marked as 'unused', but it is used "
+ printf("Inode %u is marked as 'unused', but it is used "
"for file '%s'\n", nr, current_name);
if (OPT_repair) {
if (ask("Mark as 'in use'", 1))
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 1ae0c59..58df1c8 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -35,27 +35,32 @@
//usage: "[OPTIONS] [--] OPTSTRING PARAMS"
//usage:#define getopt_full_usage "\n\n"
//usage: IF_LONG_OPTS(
-//usage: " -a,--alternative Allow long options starting with single -"
-//usage: "\n -l,--longoptions=LOPT[,...] Long options to be recognized"
-//usage: "\n -n,--name=PROGNAME The name under which errors are reported"
-//usage: "\n -o,--options=OPTSTRING Short options to be recognized"
-//usage: "\n -q,--quiet Disable error reporting by getopt(3)"
+//usage: IF_FEATURE_GETOPT_LONG(
+//usage: " -a,--alternative Allow long options starting with single -\n"
+//usage: " -l,--longoptions=LOPT[,...] Long options to recognize\n"
+//usage: )
+//usage: " -n,--name=PROGNAME The name under which errors are reported"
+//usage: "\n -o,--options=OPTSTRING Short options to recognize"
+//usage: "\n -q,--quiet No error messages on unrecognized options"
//usage: "\n -Q,--quiet-output No normal output"
//usage: "\n -s,--shell=SHELL Set shell quoting conventions"
-//usage: "\n -T,--test Test for getopt(1) version"
-//usage: "\n -u,--unquoted Don't quote the output"
+//usage: "\n -T,--test Version test (exits with 4)"
+//usage: "\n -u,--unquoted Don't quote output"
//usage: )
//usage: IF_NOT_LONG_OPTS(
-//usage: " -a Allow long options starting with single -"
-//usage: "\n -l LOPT[,...] Long options to be recognized"
-//usage: "\n -n PROGNAME The name under which errors are reported"
-//usage: "\n -o OPTSTRING Short options to be recognized"
-//usage: "\n -q Disable error reporting by getopt(3)"
+//usage: IF_FEATURE_GETOPT_LONG(
+//usage: " -a Allow long options starting with single -\n"
+//usage: " -l LOPT[,...] Long options to recognize\n"
+//usage: )
+//usage: " -n PROGNAME The name under which errors are reported"
+//usage: "\n -o OPTSTRING Short options to recognize"
+//usage: "\n -q No error messages on unrecognized options"
//usage: "\n -Q No normal output"
//usage: "\n -s SHELL Set shell quoting conventions"
-//usage: "\n -T Test for getopt(1) version"
-//usage: "\n -u Don't quote the output"
+//usage: "\n -T Version test (exits with 4)"
+//usage: "\n -u Don't quote output"
//usage: )
+//usage: IF_FEATURE_GETOPT_LONG( /* example uses -l, needs FEATURE_GETOPT_LONG */
//usage: "\n"
//usage: "\nExample:"
//usage: "\n"
@@ -73,6 +78,7 @@
//usage: "\n *) echo Error; exit 1;;"
//usage: "\n esac"
//usage: "\ndone"
+//usage: )
//usage:
//usage:#define getopt_example_usage
//usage: "$ cat getopt.test\n"
@@ -214,11 +220,6 @@
static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts)
{
int exit_code = 0; /* We assume everything will be OK */
- int opt;
-#if ENABLE_FEATURE_GETOPT_LONG
- int longindex;
-#endif
- const char *charptr;
if (quiet_errors) /* No error reporting from getopt(3) */
opterr = 0;
@@ -233,13 +234,14 @@
#endif
while (1) {
- opt =
#if ENABLE_FEATURE_GETOPT_LONG
- alternative ?
- getopt_long_only(argc, argv, optstr, longopts, &longindex) :
- getopt_long(argc, argv, optstr, longopts, &longindex);
+ int longindex;
+ int opt = alternative
+ ? getopt_long_only(argc, argv, optstr, longopts, &longindex)
+ : getopt_long(argc, argv, optstr, longopts, &longindex)
+ ;
#else
- getopt(argc, argv, optstr);
+ int opt = getopt(argc, argv, optstr);
#endif
if (opt == -1)
break;
@@ -257,9 +259,10 @@
if (opt == NON_OPT)
printf(" %s", normalize(optarg));
else {
+ const char *charptr;
printf(" -%c", opt);
charptr = strchr(optstr, opt);
- if (charptr != NULL && *++charptr == ':')
+ if (charptr && *++charptr == ':')
printf(" %s",
normalize(optarg ? optarg : ""));
}
@@ -267,9 +270,11 @@
}
if (!quiet_output) {
+ unsigned idx;
printf(" --");
- while (optind < argc)
- printf(" %s", normalize(argv[optind++]));
+ idx = optind;
+ while (argv[idx])
+ printf(" %s", normalize(argv[idx++]));
bb_putchar('\n');
}
return exit_code;
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c
index 9a312f9..ac7e24f 100644
--- a/util-linux/hexdump.c
+++ b/util-linux/hexdump.c
@@ -66,13 +66,6 @@
static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v" IF_FEATURE_HEXDUMP_REVERSE("R");
-static const struct suffix_mult suffixes[] = {
- { "b", 512 },
- { "k", 1024 },
- { "m", 1024*1024 },
- { "", 0 }
-};
-
int hexdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int hexdump_main(int argc, char **argv)
{
@@ -116,7 +109,12 @@
dumper->dump_length = xatoi_positive(optarg);
} /* else */
if (ch == 's') { /* compat: -s accepts hex numbers too */
- dumper->dump_skip = xstrtoul_range_sfx(optarg, /*base:*/ 0, /*lo:*/ 0, /*hi:*/ LONG_MAX, suffixes);
+ dumper->dump_skip = xstrtoull_range_sfx(
+ optarg,
+ /*base:*/ 0,
+ /*lo:*/ 0, /*hi:*/ OFF_T_MAX,
+ bkm_suffixes
+ );
} /* else */
if (ch == 'v') {
dumper->dump_vflag = ALL;
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index 2668caf..67a25a8 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -166,10 +166,10 @@
case STATUS:
printf("------ Shared Memory %s --------\n", "Status");
printf("segments allocated %d\n"
- "pages allocated %ld\n"
- "pages resident %ld\n"
- "pages swapped %ld\n"
- "Swap performance: %ld attempts\t%ld successes\n",
+ "pages allocated %lu\n"
+ "pages resident %lu\n"
+ "pages swapped %lu\n"
+ "Swap performance: %lu attempts\t%lu successes\n",
shm_info.used_ids,
shm_info.shm_tot,
shm_info.shm_rss,
@@ -569,7 +569,7 @@
if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
bb_perror_msg_and_die("semctl");
}
- printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
+ printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
}
bb_putchar('\n');
}
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 21108d0..d450b5a 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -8,16 +8,16 @@
*/
//usage:#define losetup_trivial_usage
-//usage: "[-r] [-o OFS] LOOPDEV FILE - associate loop devices\n"
+//usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE - associate loop devices\n"
//usage: " losetup -d LOOPDEV - disassociate\n"
-//usage: " losetup [-f] - show"
+//usage: " losetup -a - show status\n"
+//usage: " losetup -f - show next free loop device"
//usage:#define losetup_full_usage "\n\n"
//usage: " -o OFS Start OFS bytes into FILE"
//usage: "\n -r Read-only"
-//usage: "\n -f Show first free loop device"
+//usage: "\n -f Show/use next free loop device"
//usage:
//usage:#define losetup_notes_usage
-//usage: "No arguments will display all current associations.\n"
//usage: "One argument (losetup /dev/loop1) will display the current association\n"
//usage: "(if any), or disassociate it (with -d). The display shows the offset\n"
//usage: "and filename of the file the loop device is currently bound to.\n\n"
@@ -27,50 +27,32 @@
#include "libbb.h"
+/* 1048575 is a max possible minor number in Linux circa 2010 */
+/* for now use something less extreme */
+#define MAX_LOOP_NUM 1023
+
int losetup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int losetup_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opt;
- int n;
char *opt_o;
- unsigned long long offset = 0;
+ char dev[LOOP_NAMESIZE];
enum {
OPT_d = (1 << 0),
OPT_o = (1 << 1),
OPT_f = (1 << 2),
- OPT_r = (1 << 3), /* must be last */
+ OPT_a = (1 << 3),
+ OPT_r = (1 << 4), /* must be last */
};
- /* max 2 args, -d,-o,-f opts are mutually exclusive */
- opt_complementary = "?2:d--of:o--df:f--do";
- opt = getopt32(argv, "do:fr", &opt_o);
+ opt_complementary = "?2:d--ofar:a--ofr";
+ opt = getopt32(argv, "do:far", &opt_o);
argv += optind;
- if (opt == OPT_o)
- offset = xatoull(opt_o);
-
- if (opt == OPT_d) {
- /* -d BLOCKDEV */
- if (!argv[0] || argv[1])
- bb_show_usage();
- if (del_loop(argv[0]))
- bb_simple_perror_msg_and_die(argv[0]);
- return EXIT_SUCCESS;
- }
-
- if (argv[0]) {
+ /* LOOPDEV */
+ if (!opt && argv[0] && !argv[1]) {
char *s;
- if (opt == OPT_f) /* -f should not have arguments */
- bb_show_usage();
-
- if (argv[1]) {
- /* [-r] [-o OFS] BLOCKDEV FILE */
- if (set_loop(&argv[0], argv[1], offset, (opt / OPT_r)) < 0)
- bb_simple_perror_msg_and_die(argv[0]);
- return EXIT_SUCCESS;
- }
- /* [-r] [-o OFS] BLOCKDEV */
s = query_loop(argv[0]);
if (!s)
bb_simple_perror_msg_and_die(argv[0]);
@@ -80,28 +62,65 @@
return EXIT_SUCCESS;
}
- /* [-r] [-o OFS|-f] with no params */
- n = 0;
- while (1) {
- char *s;
- char dev[LOOP_NAMESIZE];
+ /* -d LOOPDEV */
+ if (opt == OPT_d && argv[0]) {
+ if (del_loop(argv[0]))
+ bb_simple_perror_msg_and_die(argv[0]);
+ return EXIT_SUCCESS;
+ }
- sprintf(dev, LOOP_FORMAT, n);
- s = query_loop(dev);
- n++;
- if (!s) {
- if (n > 9 && errno && errno != ENXIO)
- return EXIT_SUCCESS;
- if (opt == OPT_f) {
- puts(dev);
- return EXIT_SUCCESS;
- }
- } else {
- if (opt != OPT_f)
+ /* -a */
+ if (opt == OPT_a) {
+ int n;
+ for (n = 0; n < MAX_LOOP_NUM; n++) {
+ char *s;
+
+ sprintf(dev, LOOP_FORMAT, n);
+ s = query_loop(dev);
+ if (s) {
printf("%s: %s\n", dev, s);
- if (ENABLE_FEATURE_CLEAN_UP)
free(s);
+ }
+ }
+ return EXIT_SUCCESS;
+ }
+
+ /* contains -f */
+ if (opt & OPT_f) {
+ char *s;
+ int n = 0;
+
+ do {
+ if (n > MAX_LOOP_NUM)
+ bb_error_msg_and_die("no free loop devices");
+ sprintf(dev, LOOP_FORMAT, n++);
+ s = query_loop(dev);
+ free(s);
+ } while (s);
+ /* now: dev is next free "/dev/loopN" */
+ if ((opt == OPT_f) && !argv[0]) {
+ puts(dev);
+ return EXIT_SUCCESS;
}
}
- return EXIT_SUCCESS;
+
+ /* [-r] [-o OFS] {-f|LOOPDEV} FILE */
+ if (argv[0] && ((opt & OPT_f) || argv[1])) {
+ unsigned long long offset = 0;
+ char *d = dev;
+
+ if (opt & OPT_o)
+ offset = xatoull(opt_o);
+ if (!(opt & OPT_f))
+ d = *argv++;
+
+ if (argv[0]) {
+ if (set_loop(&d, argv[0], offset, (opt & OPT_r)) < 0)
+ bb_simple_perror_msg_and_die(argv[0]);
+ return EXIT_SUCCESS;
+ }
+ }
+
+ bb_show_usage(); /* does not return */
+ /*return EXIT_FAILURE;*/
}
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 3d4e135..e80b58f 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -325,23 +325,6 @@
make_default_cur_rule();
}
-/* In later versions, endofname is in libbb */
-#define endofname mdev_endofname
-static
-const char* FAST_FUNC
-endofname(const char *name)
-{
-#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
-#define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
- if (!is_name(*name))
- return name;
- while (*++name) {
- if (!is_in_name(*name))
- break;
- }
- return name;
-}
-
static char *parse_envmatch_pfx(char *val)
{
struct envmatch **nextp = &G.cur_rule.envmatch;
@@ -1100,15 +1083,15 @@
* ACTION can be "add", "remove", "change"
* DEVPATH is like "/block/sda" or "/class/input/mice"
*/
- action = getenv("ACTION");
- op = index_in_strings(keywords, action);
env_devname = getenv("DEVNAME"); /* can be NULL */
- env_devpath = getenv("DEVPATH");
G.subsystem = getenv("SUBSYSTEM");
+ action = getenv("ACTION");
+ env_devpath = getenv("DEVPATH");
if (!action || !env_devpath /*|| !G.subsystem*/)
bb_show_usage();
fw = getenv("FIRMWARE");
seq = getenv("SEQNUM");
+ op = index_in_strings(keywords, action);
my_pid = getpid();
open_mdev_log(seq, my_pid);
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index 900bfef..c437307 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -58,7 +58,7 @@
#define EXT2_FLAGS_UNSIGNED_HASH 0x0002
// storage helpers
-char BUG_wrong_field_size(void);
+unsigned char BUG_wrong_field_size(void);
#define STORE_LE(field, value) \
do { \
if (sizeof(field) == 4) \
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 59d7d23..d65a516 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -196,54 +196,6 @@
# define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
-
-static long valid_offset(int fd, int offset)
-{
- char ch;
-
- if (lseek(fd, offset, SEEK_SET) < 0)
- return 0;
- if (read(fd, &ch, 1) < 1)
- return 0;
- return 1;
-}
-
-static int count_blocks(int fd)
-{
- int high, low;
-
- low = 0;
- for (high = 1; valid_offset(fd, high); high *= 2)
- low = high;
-
- while (low < high - 1) {
- const int mid = (low + high) / 2;
-
- if (valid_offset(fd, mid))
- low = mid;
- else
- high = mid;
- }
- valid_offset(fd, 0);
- return (low + 1);
-}
-
-static int get_size(const char *file)
-{
- int fd;
- long size;
-
- fd = xopen(file, O_RDWR);
- if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
- close(fd);
- return (size * 512);
- }
-
- size = count_blocks(fd);
- close(fd);
- return size;
-}
-
static void write_tables(void)
{
/* Mark the superblock valid. */
@@ -553,7 +505,7 @@
listfile = xfopen_for_read(filename);
while (!feof(listfile)) {
- fscanf(listfile, "%ld\n", &blockno);
+ fscanf(listfile, "%lu\n", &blockno);
mark_zone(blockno);
G.badblocks++;
}
@@ -636,7 +588,6 @@
{
unsigned opt;
char *tmp;
- struct stat statbuf;
char *str_i;
char *listfile = NULL;
@@ -673,13 +624,17 @@
#endif
}
- G.device_name = *argv++;
+ G.device_name = argv[0];
if (!G.device_name)
bb_show_usage();
- if (*argv)
- G.total_blocks = xatou32(*argv);
- else
- G.total_blocks = get_size(G.device_name) / 1024;
+
+ /* Check if it is mounted */
+ if (find_mount_point(G.device_name, 0))
+ bb_error_msg_and_die("can't format mounted filesystem");
+
+ xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
+
+ G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, /*extend:*/ 1) / 1024;
if (G.total_blocks < 10)
bb_error_msg_and_die("must have at least 10 blocks");
@@ -690,25 +645,21 @@
G.magic = MINIX2_SUPER_MAGIC;
} else if (G.total_blocks > 65535)
G.total_blocks = 65535;
-
- /* Check if it is mounted */
- if (find_mount_point(G.device_name, 0))
- bb_error_msg_and_die("can't format mounted filesystem");
-
- xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
+#if 0
+ struct stat statbuf;
xfstat(dev_fd, &statbuf, G.device_name);
+/* why? */
if (!S_ISBLK(statbuf.st_mode))
opt &= ~1; // clear -c (check)
-
+#if 0
/* I don't know why someone has special code to prevent mkfs.minix
* on IDE devices. Why IDE but not SCSI, etc?... */
-#if 0
else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
/* what is this? */
bb_error_msg_and_die("will not try "
"to make filesystem on '%s'", G.device_name);
#endif
-
+#endif
tmp = G.root_block;
*(short *) tmp = 1;
strcpy(tmp + 2, ".");
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 7e547fe..6f1ce67 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -341,6 +341,7 @@
unsigned verbose;
#endif
llist_t *fslist;
+ int user_fstype;
char getmntent_buf[1];
} FIX_ALIASING;
enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) };
@@ -352,6 +353,7 @@
#define verbose 0
#endif
#define fslist (G.fslist )
+#define user_fstype (G.user_fstype )
#define getmntent_buf (G.getmntent_buf )
#define INIT_G() do { } while (0)
@@ -1776,6 +1778,7 @@
int rc = -1;
unsigned long vfsflags;
char *loopFile = NULL, *filteropts = NULL;
+ char *detected_fstype = NULL;
llist_t *fl = NULL;
struct stat st;
@@ -1783,9 +1786,19 @@
vfsflags = parse_mount_options(mp->mnt_opts, &filteropts);
- // Treat fstype "auto" as unspecified
- if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0)
- mp->mnt_type = NULL;
+ if (user_fstype) {
+ // Treat fstype "auto" as unspecified
+ if (mp->mnt_type && !strcmp(mp->mnt_type, "auto"))
+ mp->mnt_type = NULL;
+ } else if (mp->mnt_type) {
+ // If user didn't specify an fstype and blkid disagrees or the
+ // fstype is "auto", trust blkid's determination of the fstype.
+ detected_fstype = get_fstype_from_devname(mp->mnt_fsname);
+
+ if (!strcmp(mp->mnt_type, "auto") ||
+ (detected_fstype && strcmp(detected_fstype, mp->mnt_type)))
+ mp->mnt_type = detected_fstype;
+ }
// Might this be a virtual filesystem?
if (ENABLE_FEATURE_MOUNT_HELPERS && strchr(mp->mnt_fsname, '#')) {
@@ -1856,8 +1869,8 @@
len, share,
share + len + 1 /* "dir1/dir2" */
);
- parse_mount_options(unc, &filteropts);
- if (ENABLE_FEATURE_CLEAN_UP) free(unc);
+ parse_mount_options(unc, &filteropts);
+ if (ENABLE_FEATURE_CLEAN_UP) free(unc);
}
lsa = host2sockaddr(hostname, 0);
@@ -2062,6 +2075,8 @@
opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv");
opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch
IF_FEATURE_MOUNT_VERBOSE(, &verbose));
+
+ if (opt & OPT_t) user_fstype = 1;
while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o
if (opt & OPT_r) append_mount_options(&cmdopts, "ro"); // -r
if (opt & OPT_w) append_mount_options(&cmdopts, "rw"); // -w
@@ -2275,6 +2290,8 @@
mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);
append_mount_options(&(mtcur->mnt_opts), cmdopts);
resolve_mount_spec(&mtpair->mnt_fsname);
+ if (user_fstype)
+ mtcur->mnt_type = fstype;
rc = singlemount(mtcur, /*ignore_busy:*/ 0);
if (ENABLE_FEATURE_CLEAN_UP)
free(mtcur->mnt_opts);
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index 974fe89..a645404 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -152,7 +152,7 @@
step = buf[0];
if (optInfo) {
- printf("Sampling_step: %i\n", step);
+ printf("Sampling_step: %u\n", step);
return EXIT_SUCCESS;
}
@@ -219,10 +219,10 @@
&& (fn_len = next_add-fn_add) != 0
) {
if (optVerbose)
- printf("%016llx %-40s %6i %8.4f\n", fn_add,
+ printf("%016llx %-40s %6u %8.4f\n", fn_add,
fn_name, this, this/(double)fn_len);
else
- printf("%6i %-40s %8.4f\n",
+ printf("%6u %-40s %8.4f\n",
this, fn_name, this/(double)fn_len);
if (optSub) {
unsigned long long scan;
@@ -246,14 +246,14 @@
}
/* clock ticks, out of kernel text - probably modules */
- printf("%6i %s\n", buf[len/sizeof(*buf)-1], "*unknown*");
+ printf("%6u %s\n", buf[len/sizeof(*buf)-1], "*unknown*");
/* trailer */
if (optVerbose)
- printf("%016x %-40s %6i %8.4f\n",
+ printf("%016x %-40s %6u %8.4f\n",
0, "total", total, total/(double)(fn_add-add0));
else
- printf("%6i %-40s %8.4f\n",
+ printf("%6u %-40s %8.4f\n",
total, "total", total/(double)(fn_add-add0));
fclose(map);
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index 54867ec..963139a 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -60,7 +60,7 @@
#if ENABLE_DESKTOP
/* test for holes */
if (S_ISREG(st.st_mode))
- if (st.st_blocks * (off_t)512 < st.st_size)
+ if (st.st_blocks * (off_t)512 < (uint64_t) st.st_size)
bb_error_msg("warning: swap file has holes");
#endif
@@ -95,6 +95,20 @@
if (applet_name[5] != 'n'
|| hasmntopt(m, MNTOPT_NOAUTO) == NULL
) {
+#if ENABLE_FEATURE_SWAPON_PRI
+ const char *p;
+ g_flags = 0; /* each swap space might have different flags */
+ p = hasmntopt(m, "pri");
+ if (p) {
+ /* Max allowed 32767 (==SWAP_FLAG_PRIO_MASK) */
+ unsigned int swap_prio = MIN(bb_strtou(p + 4 , NULL, 10), SWAP_FLAG_PRIO_MASK);
+ /* We want to allow "NNNN,foo", thus errno == EINVAL is allowed too */
+ if (errno != ERANGE) {
+ g_flags = SWAP_FLAG_PREFER |
+ (swap_prio << SWAP_FLAG_PRIO_SHIFT);
+ }
+ }
+#endif
err += swap_enable_disable(m->mnt_fsname);
}
}
diff --git a/util-linux/volume_id/Config.src b/util-linux/volume_id/Config.src
new file mode 100644
index 0000000..ac208c9
--- /dev/null
+++ b/util-linux/volume_id/Config.src
@@ -0,0 +1,15 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+config VOLUMEID
+ bool #No description makes it a hidden option
+ default n
+
+menu "Filesystem/Volume identification"
+ depends on VOLUMEID
+
+INSERT
+
+endmenu
diff --git a/util-linux/volume_id/Kbuild.src b/util-linux/volume_id/Kbuild.src
index 759fdaa..6b4fb74 100644
--- a/util-linux/volume_id/Kbuild.src
+++ b/util-linux/volume_id/Kbuild.src
@@ -7,41 +7,3 @@
lib-y:=
INSERT
-
-lib-$(CONFIG_BLKID) += get_devname.o
-lib-$(CONFIG_FINDFS) += get_devname.o
-lib-$(CONFIG_FEATURE_MOUNT_LABEL) += get_devname.o
-
-lib-$(CONFIG_VOLUMEID) += volume_id.o util.o
-lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o
-lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o
-lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o
-lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
-lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
-lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
-lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
-lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o
-lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o
-### lib-$(CONFIG_FEATURE_VOLUMEID_MINIX) += minix.o
-lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o
-lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o
diff --git a/util-linux/volume_id/btrfs.c b/util-linux/volume_id/btrfs.c
index ee71d2e..e4dddf2 100644
--- a/util-linux/volume_id/btrfs.c
+++ b/util-linux/volume_id/btrfs.c
@@ -19,6 +19,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_BTRFS
+//config: bool "btrfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
#define BTRFS_UUID_SIZE 16
diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c
index 28e9970..aeb7f20 100644
--- a/util-linux/volume_id/cramfs.c
+++ b/util-linux/volume_id/cramfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_CRAMFS
+//config: bool "cramfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct cramfs_super {
diff --git a/util-linux/volume_id/exfat.c b/util-linux/volume_id/exfat.c
index a38a891..c3aa368 100644
--- a/util-linux/volume_id/exfat.c
+++ b/util-linux/volume_id/exfat.c
@@ -18,6 +18,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
+
+//config:
+//config:config FEATURE_VOLUMEID_EXFAT
+//config: bool "exFAT filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: exFAT (extended FAT) is a proprietary file system designed especially
+//config: for flash drives. It has many features from NTFS, but with less
+//config: overhead. exFAT is used on most SDXC cards for consumer electronics.
+//config:
+
#include "volume_id_internal.h"
#define EXFAT_SB_OFFSET 0
diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c
index 9745106..df39d93 100644
--- a/util-linux/volume_id/ext.c
+++ b/util-linux/volume_id/ext.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o
+
+//config:
+//config:config FEATURE_VOLUMEID_EXT
+//config: bool "Ext filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
#include "bb_e2fs_defs.h"
diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
index 904fbb2..476d500 100644
--- a/util-linux/volume_id/fat.c
+++ b/util-linux/volume_id/fat.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o
+
+//config:
+//config:config FEATURE_VOLUMEID_FAT
+//config: bool "fat filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
/* linux/msdos_fs.h says: */
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c
index 665cb9b..85b0fad 100644
--- a/util-linux/volume_id/get_devname.c
+++ b/util-linux/volume_id/get_devname.c
@@ -7,6 +7,11 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
+
+//kbuild:lib-$(CONFIG_BLKID) += get_devname.o
+//kbuild:lib-$(CONFIG_FINDFS) += get_devname.o
+//kbuild:lib-$(CONFIG_FEATURE_MOUNT_LABEL) += get_devname.o
+
#include <sys/mount.h> /* BLKGETSIZE64 */
#if !defined(BLKGETSIZE64)
# define BLKGETSIZE64 _IOR(0x12,114,size_t)
@@ -241,10 +246,10 @@
int add_to_uuid_cache(const char *device)
{
- char *uuid = uuid; /* for compiler */
- char *label = label;
+ static char *uuid; /* for compiler */
+ static char *label;
#if ENABLE_FEATURE_BLKID_TYPE
- const char *type = type;
+ static const char *type;
#endif
int fd;
@@ -261,6 +266,26 @@
return 0;
}
+char *get_fstype_from_devname(const char *device)
+{
+#if ENABLE_FEATURE_BLKID_TYPE
+ struct uuidCache_s *uc;
+ struct stat statbuf;
+
+ if (stat(device, &statbuf) < 0)
+ return NULL;
+
+ if (!S_ISBLK(statbuf.st_mode) && !S_ISREG(statbuf.st_mode))
+ return NULL;
+
+ add_to_uuid_cache(device);
+ uc = uuidcache_init(0);
+
+ return (uc != NULL ? (char*)uc->type : NULL);
+#else
+ return NULL;
+#endif
+}
/* Used by mount and findfs */
diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
index 3d9704d..8d34aaf 100644
--- a/util-linux/volume_id/hfs.c
+++ b/util-linux/volume_id/hfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_HFS
+//config: bool "hfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct hfs_finder_info{
diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c
index 1d7693a..3848de4 100644
--- a/util-linux/volume_id/iso9660.c
+++ b/util-linux/volume_id/iso9660.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
+
+//config:
+//config:config FEATURE_VOLUMEID_ISO9660
+//config: bool "iso9660 filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
#define ISO_SUPERBLOCK_OFFSET 0x8000
diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c
index 5333af2..a6eaff4 100644
--- a/util-linux/volume_id/jfs.c
+++ b/util-linux/volume_id/jfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_JFS
+//config: bool "jfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct jfs_super_block {
diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c
index 209eaab..f20823a 100644
--- a/util-linux/volume_id/linux_raid.c
+++ b/util-linux/volume_id/linux_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
+
+//config:
+//config:config FEATURE_VOLUMEID_LINUXRAID
+//config: bool "linuxraid"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct mdp_super_block {
diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c
index 1ee534a..39470d4 100644
--- a/util-linux/volume_id/linux_swap.c
+++ b/util-linux/volume_id/linux_swap.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
+
+//config:
+//config:config FEATURE_VOLUMEID_LINUXSWAP
+//config: bool "linux swap filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct swap_header_v1_2 {
diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c
index f9b3766..42bf876 100644
--- a/util-linux/volume_id/luks.c
+++ b/util-linux/volume_id/luks.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o
+
+//config:
+//config:config FEATURE_VOLUMEID_LUKS
+//config: bool "luks filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
#define LUKS_MAGIC_L 6
diff --git a/util-linux/volume_id/nilfs.c b/util-linux/volume_id/nilfs.c
index b88a9e4..f3a9ef5 100644
--- a/util-linux/volume_id/nilfs.c
+++ b/util-linux/volume_id/nilfs.c
@@ -19,6 +19,26 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_NILFS
+//config: bool "nilfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: NILFS is a New Implementation of a Log-Structured File System (LFS)
+//config: that supports continuous snapshots. This provides features like
+//config: versioning of the entire filesystem, restoration of files that
+//config: were deleted a few minutes ago. NILFS keeps consistency like
+//config: conventional LFS, so it provides quick recovery after system crashes.
+//config:
+//config: The possible use of NILFS includes versioning, tamper detection,
+//config: SOX compliance logging, and so forth. It can serve as an alternative
+//config: filesystem for Linux desktop environment, or as a basis of advanced
+//config: storage appliances.
+//config:
+
#include "volume_id_internal.h"
#define NILFS_UUID_SIZE 16
diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c
index 0444e54..46f687a 100644
--- a/util-linux/volume_id/ntfs.c
+++ b/util-linux/volume_id/ntfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_NTFS
+//config: bool "ntfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct ntfs_super_block {
diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c
index fcdb151..415e0bf 100644
--- a/util-linux/volume_id/ocfs2.c
+++ b/util-linux/volume_id/ocfs2.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o
+
+//config:
+//config:config FEATURE_VOLUMEID_OCFS2
+//config: bool "ocfs2 filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
/* All these values are taken from ocfs2-tools's ocfs2_fs.h */
diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c
index 67b4a18..24979fb 100644
--- a/util-linux/volume_id/reiserfs.c
+++ b/util-linux/volume_id/reiserfs.c
@@ -19,6 +19,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_REISERFS
+//config: bool "Reiser filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct reiserfs_super_block {
diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c
index 15653be..4754fdb 100644
--- a/util-linux/volume_id/romfs.c
+++ b/util-linux/volume_id/romfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_ROMFS
+//config: bool "romfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct romfs_super {
diff --git a/util-linux/volume_id/squashfs.c b/util-linux/volume_id/squashfs.c
index c5b4f9c..079b6cc 100644
--- a/util-linux/volume_id/squashfs.c
+++ b/util-linux/volume_id/squashfs.c
@@ -8,6 +8,18 @@
//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o
+//config:
+//config:config FEATURE_VOLUMEID_SQUASHFS
+//config: bool "SquashFS filesystem"
+//config: default y
+//config: depends on VOLUMEID && FEATURE_BLKID_TYPE
+//config: help
+//config: Squashfs is a compressed read-only filesystem for Linux. Squashfs is
+//config: intended for general read-only filesystem use and in constrained block
+//config: device/memory systems (e.g. embedded systems) where low overhead is
+//config: needed.
+//config:
+
#include "volume_id_internal.h"
struct squashfs_superblock {
diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c
index 6eb9646..7b4b536 100644
--- a/util-linux/volume_id/sysv.c
+++ b/util-linux/volume_id/sysv.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o
+
+//config:
+//config:config FEATURE_VOLUMEID_SYSV
+//config: bool "sysv filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
#define SYSV_NICINOD 100
diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c
index d3747fb..9214545 100644
--- a/util-linux/volume_id/udf.c
+++ b/util-linux/volume_id/udf.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
+
+//config:
+//config:config FEATURE_VOLUMEID_UDF
+//config: bool "udf filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct volume_descriptor {
diff --git a/util-linux/volume_id/unused_highpoint.c b/util-linux/volume_id/unused_highpoint.c
index 17b7b32..7231a1d 100644
--- a/util-linux/volume_id/unused_highpoint.c
+++ b/util-linux/volume_id/unused_highpoint.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_HIGHPOINTRAID
+//config:### bool "highpoint raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct hpt37x_meta {
diff --git a/util-linux/volume_id/unused_hpfs.c b/util-linux/volume_id/unused_hpfs.c
index 4429524..a87c89f 100644
--- a/util-linux/volume_id/unused_hpfs.c
+++ b/util-linux/volume_id/unused_hpfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_HPFS
+//config:### bool "hpfs filesystem"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct hpfs_super {
diff --git a/util-linux/volume_id/unused_isw_raid.c b/util-linux/volume_id/unused_isw_raid.c
index 7ab47b3..851bd2f 100644
--- a/util-linux/volume_id/unused_isw_raid.c
+++ b/util-linux/volume_id/unused_isw_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_ISWRAID
+//config:### bool "intel raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct isw_meta {
diff --git a/util-linux/volume_id/unused_lsi_raid.c b/util-linux/volume_id/unused_lsi_raid.c
index e6cc8ed..52d68de 100644
--- a/util-linux/volume_id/unused_lsi_raid.c
+++ b/util-linux/volume_id/unused_lsi_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_LSIRAID
+//config:### bool "lsi raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct lsi_meta {
diff --git a/util-linux/volume_id/unused_lvm.c b/util-linux/volume_id/unused_lvm.c
index 2206498..08fa052 100644
--- a/util-linux/volume_id/unused_lvm.c
+++ b/util-linux/volume_id/unused_lvm.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_LVM
+//config:### bool "lvm"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct lvm1_super_block {
diff --git a/util-linux/volume_id/unused_mac.c b/util-linux/volume_id/unused_mac.c
index e8deb97..a1a53d1 100644
--- a/util-linux/volume_id/unused_mac.c
+++ b/util-linux/volume_id/unused_mac.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_MAC
+//config:### bool "mac filesystem"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct mac_driver_desc {
diff --git a/util-linux/volume_id/unused_minix.c b/util-linux/volume_id/unused_minix.c
index a3e1077..50afd5c 100644
--- a/util-linux/volume_id/unused_minix.c
+++ b/util-linux/volume_id/unused_minix.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MINIX) += minix.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_MINIX
+//config:### bool "minix filesystem"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct minix_super_block {
diff --git a/util-linux/volume_id/unused_msdos.c b/util-linux/volume_id/unused_msdos.c
index 2e8cb19..5ebaa3e 100644
--- a/util-linux/volume_id/unused_msdos.c
+++ b/util-linux/volume_id/unused_msdos.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_MSDOS
+//config:### bool "msdos filesystem"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct msdos_partition_entry {
@@ -165,7 +176,7 @@
if (id->partition_count < 4)
id->partition_count = 4;
- p = &id->partitions[id->partition_count];
+// p = &id->partitions[id->partition_count];
// if (is_raid(part[i].sys_ind))
// volume_id_set_usage_part(p, VOLUME_ID_RAID);
diff --git a/util-linux/volume_id/unused_nvidia_raid.c b/util-linux/volume_id/unused_nvidia_raid.c
index 9e84729..d99a108 100644
--- a/util-linux/volume_id/unused_nvidia_raid.c
+++ b/util-linux/volume_id/unused_nvidia_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_NVIDIARAID
+//config:### bool "nvidia raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct nvidia_meta {
diff --git a/util-linux/volume_id/unused_promise_raid.c b/util-linux/volume_id/unused_promise_raid.c
index 0b0d006..cebebe3 100644
--- a/util-linux/volume_id/unused_promise_raid.c
+++ b/util-linux/volume_id/unused_promise_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_PROMISERAID
+//config:### bool "promise raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct promise_meta {
diff --git a/util-linux/volume_id/unused_silicon_raid.c b/util-linux/volume_id/unused_silicon_raid.c
index 878b881..40c8faa 100644
--- a/util-linux/volume_id/unused_silicon_raid.c
+++ b/util-linux/volume_id/unused_silicon_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_SILICONRAID
+//config:### bool "silicon raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct silicon_meta {
diff --git a/util-linux/volume_id/unused_ufs.c b/util-linux/volume_id/unused_ufs.c
index 9f925d9..d33c10f 100644
--- a/util-linux/volume_id/unused_ufs.c
+++ b/util-linux/volume_id/unused_ufs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_UFS
+//config:### bool "ufs filesystem"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct ufs_super_block {
diff --git a/util-linux/volume_id/unused_via_raid.c b/util-linux/volume_id/unused_via_raid.c
index a11eec1..258f93a 100644
--- a/util-linux/volume_id/unused_via_raid.c
+++ b/util-linux/volume_id/unused_via_raid.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o
+
+//config:
+//config:### config FEATURE_VOLUMEID_VIARAID
+//config:### bool "via raid"
+//config:### default y
+//config:### depends on VOLUMEID
+//config:### help
+//config:### TODO
+//config:
+
#include "volume_id_internal.h"
struct via_meta {
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c
index 73fc689..66690c2 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_VOLUMEID) += volume_id.o util.o
+
#include "volume_id_internal.h"
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
index 159e086..6e2dbd7 100644
--- a/util-linux/volume_id/volume_id_internal.h
+++ b/util-linux/volume_id/volume_id_internal.h
@@ -96,44 +96,24 @@
/* size of seek buffer, FAT cluster is 32k max */
#define SEEK_BUFFER_SIZE 0x10000
-#define bswap16(x) (uint16_t) ( \
- (((uint16_t)(x) & 0x00ffu) << 8) | \
- (((uint16_t)(x) & 0xff00u) >> 8))
-
-#define bswap32(x) (uint32_t) ( \
- (((uint32_t)(x) & 0xff000000u) >> 24) | \
- (((uint32_t)(x) & 0x00ff0000u) >> 8) | \
- (((uint32_t)(x) & 0x0000ff00u) << 8) | \
- (((uint32_t)(x) & 0x000000ffu) << 24))
-
-#define bswap64(x) (uint64_t) ( \
- (((uint64_t)(x) & 0xff00000000000000ull) >> 56) | \
- (((uint64_t)(x) & 0x00ff000000000000ull) >> 40) | \
- (((uint64_t)(x) & 0x0000ff0000000000ull) >> 24) | \
- (((uint64_t)(x) & 0x000000ff00000000ull) >> 8) | \
- (((uint64_t)(x) & 0x00000000ff000000ull) << 8) | \
- (((uint64_t)(x) & 0x0000000000ff0000ull) << 24) | \
- (((uint64_t)(x) & 0x000000000000ff00ull) << 40) | \
- (((uint64_t)(x) & 0x00000000000000ffull) << 56))
-
#if BB_LITTLE_ENDIAN
-#define le16_to_cpu(x) (x)
-#define le32_to_cpu(x) (x)
-#define le64_to_cpu(x) (x)
-#define be16_to_cpu(x) bswap16(x)
-#define be32_to_cpu(x) bswap32(x)
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#define cpu_to_be32(x) bswap32(x)
+# define le16_to_cpu(x) (uint16_t)(x)
+# define le32_to_cpu(x) (uint32_t)(x)
+# define le64_to_cpu(x) (uint64_t)(x)
+# define be16_to_cpu(x) (uint16_t)(bswap_16(x))
+# define be32_to_cpu(x) (uint32_t)(bswap_32(x))
+# define cpu_to_le16(x) (uint16_t)(x)
+# define cpu_to_le32(x) (uint32_t)(x)
+# define cpu_to_be32(x) (uint32_t)(bswap_32(x))
#else
-#define le16_to_cpu(x) bswap16(x)
-#define le32_to_cpu(x) bswap32(x)
-#define le64_to_cpu(x) bswap64(x)
-#define be16_to_cpu(x) (x)
-#define be32_to_cpu(x) (x)
-#define cpu_to_le16(x) bswap16(x)
-#define cpu_to_le32(x) bswap32(x)
-#define cpu_to_be32(x) (x)
+# define le16_to_cpu(x) (uint16_t)(bswap_16(x))
+# define le32_to_cpu(x) (uint32_t)(bswap_32(x))
+# define le64_to_cpu(x) (uint64_t)(bb_bswap_64(x))
+# define be16_to_cpu(x) (uint16_t)(x)
+# define be32_to_cpu(x) (uint32_t)(x)
+# define cpu_to_le16(x) (uint16_t)(bswap_16(x))
+# define cpu_to_le32(x) (uint32_t)(bswap_32(x))
+# define cpu_to_be32(x) (uint32_t)(x)
#endif
/* volume_id_set_uuid(id,buf,fmt) assumes size of uuid buf
diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c
index 8474602..5eefc20 100644
--- a/util-linux/volume_id/xfs.c
+++ b/util-linux/volume_id/xfs.c
@@ -18,6 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o
+
+//config:
+//config:config FEATURE_VOLUMEID_XFS
+//config: bool "xfs filesystem"
+//config: default y
+//config: depends on VOLUMEID
+//config: help
+//config: TODO
+//config:
+
#include "volume_id_internal.h"
struct xfs_super_block {