This patch builds bb_guess_fstype from busybox sources.
bb_guess_fstype is identical in function with guess_fstype and is indeed meant
as a replacement.

How to use:
 1. extract plain busybox 1.21 
 2. patch
 3. go to busybox/util-linux/volume-id
 4. edit Makefile, change the CC and CFLAGS as needed
 5. make

Tested with:
 - plain gcc in Fatdog64
 - Aboriginal x64 cross compiler
 - musl-gcc 64-bit compiler

Note: This patch includes f2fs patch by Sven-Göran Bergh (Jan 13).
Author: jamesbond 2013
License: same as busybox, GPL v2

diff -Nur busybox-1.21.0/util-linux/Config.src bb/util-linux/Config.src
--- busybox-1.21.0/util-linux/Config.src	2013-01-14 08:20:18.000000000 +0700
+++ bb/util-linux/Config.src	2013-05-16 00:50:35.653201593 +0700
@@ -771,6 +771,16 @@
 	help
 	  TODO
 
+config FEATURE_VOLUMEID_F2FS
+	bool "f2fs filesystem"
+	default y
+	depends on VOLUMEID
+	help
+	  F2FS (aka Flash-Friendly File System) is a log-structured file system,
+	  which is adapted to newer forms of storage. F2FS also remedies some
+	  known issues of the older log structured file systems, such as high
+	  cleaning overhead.
+
 config FEATURE_VOLUMEID_NILFS
 	bool "nilfs filesystem"
 	default y
diff -Nur busybox-1.21.0/util-linux/volume_id/f2fs.c bb/util-linux/volume_id/f2fs.c
--- busybox-1.21.0/util-linux/volume_id/f2fs.c	1970-01-01 07:00:00.000000000 +0700
+++ bb/util-linux/volume_id/f2fs.c	2013-05-16 00:50:35.653201593 +0700
@@ -0,0 +1,81 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+#include "volume_id_internal.h"
+
+#define	F2FS_MAGIC		0xF2F52010	// F2FS Magic Number
+#define F2FS_UUID_SIZE		16
+#define F2FS_LABEL_SIZE		512
+#define F2FS_LABEL_BYTES	1024
+#define	F2FS_SB1_OFFSET		0x400		// offset for 1:st super block
+/*
+#define F2FS_SB2_OFFSET		0x1400		// offset for 2:nd super block
+*/
+
+struct f2fs_super_block {	// According to version 1.1
+/* 0x00 */	uint32_t	magic;			// Magic Number
+/* 0x04 */	uint16_t	major_ver;		// Major Version
+/* 0x06 */	uint16_t	minor_ver;		// Minor Version
+/* 0x08 */	uint32_t	log_sectorsize;		// log2 sector size in bytes
+/* 0x0C */	uint32_t	log_sectors_per_block;	// log2 # of sectors per block
+/* 0x10 */	uint32_t	log_blocksize;		// log2 block size in bytes
+/* 0x14 */	uint32_t	log_blocks_per_seg;	// log2 # of blocks per segment
+/* 0x18 */	uint32_t	segs_per_sec;		// # of segments per section
+/* 0x1C */	uint32_t	secs_per_zone;		// # of sections per zone
+/* 0x20 */	uint32_t	checksum_offset;	// checksum offset inside super block
+/* 0x24 */	uint64_t	block_count;		// total # of user blocks
+/* 0x2C */	uint32_t	section_count;		// total # of sections
+/* 0x30 */	uint32_t	segment_count;		// total # of segments
+/* 0x34 */	uint32_t	segment_count_ckpt;	// # of segments for checkpoint
+/* 0x38 */	uint32_t	segment_count_sit;	// # of segments for SIT
+/* 0x3C */	uint32_t	segment_count_nat;	// # of segments for NAT
+/* 0x40 */	uint32_t	segment_count_ssa;	// # of segments for SSA
+/* 0x44 */	uint32_t	segment_count_main;	// # of segments for main area
+/* 0x48 */	uint32_t	segment0_blkaddr;	// start block address of segment 0
+/* 0x4C */	uint32_t	cp_blkaddr;		// start block address of checkpoint
+/* 0x50 */	uint32_t	sit_blkaddr;		// start block address of SIT
+/* 0x54 */	uint32_t	nat_blkaddr;		// start block address of NAT
+/* 0x58 */	uint32_t	ssa_blkaddr;		// start block address of SSA
+/* 0x5C */	uint32_t	main_blkaddr;		// start block address of main area
+/* 0x60 */	uint32_t	root_ino;		// root inode number
+/* 0x64 */	uint32_t	node_ino;		// node inode number
+/* 0x68 */	uint32_t	meta_ino;		// meta inode number
+/* 0x6C */	uint8_t		uuid[F2FS_UUID_SIZE];	// 128-bit uuid for volume
+/* 0x7C */	uint16_t	volume_name[F2FS_LABEL_SIZE];	// volume name
+//* 0x47C */	uint32_t	extension_count;	// # of extensions below
+//* 0x480 */	uint8_t		extension_list[64][8];	// extension array
+} PACKED;
+
+
+int FAST_FUNC volume_id_probe_f2fs(struct volume_id *id /*,uint64_t off*/)
+{
+	struct f2fs_super_block *sb;
+
+	// Go for primary super block (ignore second sb)
+	dbg("f2fs: probing at offset 0x%x", F2FS_SB1_OFFSET);
+	sb = volume_id_get_buffer(id, F2FS_SB1_OFFSET, sizeof(*sb));
+
+	if (!sb)
+		return -1;
+
+	if (sb->magic != cpu_to_le32(F2FS_MAGIC))
+		return -1;
+
+	IF_FEATURE_BLKID_TYPE(id->type = "f2fs");
+
+	// For version 1.0 we cannot know the correct sb structure...
+	if (le16_to_cpu(sb->major_ver) == 1 && le16_to_cpu(sb->minor_ver) == 0)
+		return 0;
+
+	volume_id_set_label_unicode16(id, (uint8_t *)sb->volume_name,
+				      LE, MIN(F2FS_LABEL_BYTES, VOLUME_ID_LABEL_SIZE));
+
+	volume_id_set_uuid(id, sb->uuid, UUID_DCE);
+
+	return 0;
+}
diff -Nur busybox-1.21.0/util-linux/volume_id/fake_libbb.c bb/util-linux/volume_id/fake_libbb.c
--- busybox-1.21.0/util-linux/volume_id/fake_libbb.c	1970-01-01 07:00:00.000000000 +0700
+++ bb/util-linux/volume_id/fake_libbb.c	2013-05-16 01:01:05.409822820 +0700
@@ -0,0 +1,53 @@
+#include "fake_libbb.h" 
+
+void *xzalloc(size_t size) {
+	void *p = malloc (size);
+	if (p) memset (p, 0, size);
+	return p;
+}
+
+/* from read.c */
+ssize_t FAST_FUNC safe_read(int fd, void *buf, size_t count)
+{
+	ssize_t n;
+
+	do {
+		n = read(fd, buf, count);
+	} while (n < 0 && errno == EINTR);
+
+	return n;
+}
+
+/*
+ * Read all of the supplied buffer from a file.
+ * This does multiple reads as necessary.
+ * Returns the amount read, or -1 on an error.
+ * A short read is returned on an end of file.
+ */
+ssize_t FAST_FUNC full_read(int fd, void *buf, size_t len)
+{
+	ssize_t cc;
+	ssize_t total;
+
+	total = 0;
+
+	while (len) {
+		cc = safe_read(fd, buf, len);
+
+		if (cc < 0) {
+			if (total) {
+				/* we already have some! */
+				/* user can do another read to know the error code */
+				return total;
+			}
+			return cc; /* read() returns -1 on failure. */
+		}
+		if (cc == 0)
+			break;
+		buf = ((char *)buf) + cc;
+		total += cc;
+		len -= cc;
+	}
+
+	return total;
+}
diff -Nur busybox-1.21.0/util-linux/volume_id/fake_libbb.h bb/util-linux/volume_id/fake_libbb.h
--- busybox-1.21.0/util-linux/volume_id/fake_libbb.h	1970-01-01 07:00:00.000000000 +0700
+++ bb/util-linux/volume_id/fake_libbb.h	2013-05-16 00:57:53.056503400 +0700
@@ -0,0 +1,74 @@
+/* prevent the real libbb from being invoked */
+#ifndef LIBBB_H
+#define LIBBB_H 1
+
+/* little endian systems, change to zero for big endian systems */
+#define BB_LITTLE_ENDIAN 1
+#ifdef __GNUC__
+#define PACKED __attribute__ ((__packed__))
+#endif
+
+/* define all that we need from libbb without actually invoking libbb.h */
+#define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+#define POP_SAVED_FUNCTION_VISIBILITY
+#define FAST_FUNC
+#define FIX_ALIASING
+
+#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
+#define xmalloc malloc
+#define xrealloc realloc
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+
+/* std includes */
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+void *xzalloc(size_t size);
+ssize_t FAST_FUNC full_read(int fd, void *buf, size_t len);
+
+/* stuff we want from volume_id */
+#define ENABLE_FEATURE_BLKID_TYPE 1
+#define IF_FEATURE_BLKID_TYPE(x) x
+
+//#define ENABLE_FEATURE_VOLUMEID_LVM 0 //marked as unused
+//#define ENABLE_FEATURE_VOLUMEID_MAC 0 //marked as unused
+//#define ENABLE_FEATURE_VOLUMEID_HFS 1 //not linking - requires md5 lib
+//#define ENABLE_FEATURE_VOLUMEID_UFS 1 // marked as unused
+//#define ENABLE_FEATURE_VOLUMEID_MINIX 1 // marked as unused
+//#define ENABLE_FEATURE_VOLUMEID_HPFS 1 //marked as unused
+#define ENABLE_FEATURE_VOLUMEID_LINUXRAID 1
+#define ENABLE_FEATURE_VOLUMEID_LUKS 1
+
+#define ENABLE_FEATURE_VOLUMEID_FAT 1
+#define ENABLE_FEATURE_VOLUMEID_EXFAT 1
+#define ENABLE_FEATURE_VOLUMEID_SQUASHFS 1
+#define ENABLE_FEATURE_VOLUMEID_XFS 1
+#define ENABLE_FEATURE_VOLUMEID_LINUXSWAP 1
+#define ENABLE_FEATURE_VOLUMEID_EXT 1
+#define ENABLE_FEATURE_VOLUMEID_BTRFS 1
+#define ENABLE_FEATURE_VOLUMEID_REISERFS 1
+#define ENABLE_FEATURE_VOLUMEID_JFS 1
+#define ENABLE_FEATURE_VOLUMEID_UDF 1
+#define ENABLE_FEATURE_VOLUMEID_ISO9660 1
+#define ENABLE_FEATURE_VOLUMEID_NILFS 1
+#define ENABLE_FEATURE_VOLUMEID_NTFS 1
+#define ENABLE_FEATURE_VOLUMEID_CRAMFS 1
+#define ENABLE_FEATURE_VOLUMEID_ROMFS 1
+
+#define ENABLE_FEATURE_VOLUMEID_SYSV 1
+#define ENABLE_FEATURE_VOLUMEID_OCFS2 1
+#define ENABLE_FEATURE_VOLUMEID_F2FS 1
+
+#endif
diff -Nur busybox-1.21.0/util-linux/volume_id/Kbuild.src bb/util-linux/volume_id/Kbuild.src
--- busybox-1.21.0/util-linux/volume_id/Kbuild.src	2012-12-23 05:39:04.000000000 +0700
+++ bb/util-linux/volume_id/Kbuild.src	2013-05-16 00:50:35.653201593 +0700
@@ -31,6 +31,7 @@
 ### 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_F2FS)             += f2fs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_NILFS)            += nilfs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_NTFS)             += ntfs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT)            += exfat.o
diff -Nur busybox-1.21.0/util-linux/volume_id/main.c bb/util-linux/volume_id/main.c
--- busybox-1.21.0/util-linux/volume_id/main.c	1970-01-01 07:00:00.000000000 +0700
+++ bb/util-linux/volume_id/main.c	2013-05-16 00:50:35.653201593 +0700
@@ -0,0 +1,37 @@
+#include "fake_libbb.h" 
+#include "volume_id_internal.h"
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#define PSTR(x) (x), strlen(x)
+
+int main (int argc, char *argv[]) {	
+	struct volume_id *id=0;
+	int retcode=1; //assume failure
+	int fd;
+	
+	// check args
+	if (argc < 2) {
+		write (1, PSTR("Usage: guess_fstype device\n"));
+		return 2;
+	}
+	
+	// identify
+	fd = open (argv[1], O_RDONLY);
+	if (fd >= 0) {
+		id = volume_id_open_node (fd);
+		if (id) {
+			retcode = volume_id_probe_all (id, 0);
+			if (!retcode && id->type) {
+				write (1, PSTR(id->type));
+				write (1, PSTR("\n"));
+			} else retcode=1;
+			free_volume_id (id);
+		}
+	}
+	
+	//failure result code
+	if (retcode) write (1, PSTR("unknown\n"));
+
+	return retcode;
+}
\ No newline at end of file
diff -Nur busybox-1.21.0/util-linux/volume_id/Makefile bb/util-linux/volume_id/Makefile
--- busybox-1.21.0/util-linux/volume_id/Makefile	1970-01-01 07:00:00.000000000 +0700
+++ bb/util-linux/volume_id/Makefile	2013-05-16 01:02:40.679815928 +0700
@@ -0,0 +1,46 @@
+#CC=/mnt/sda5/play/abo64/bin/x86_64-gcc -static
+#CC=/mnt/sda5/play/abo386/bin/i686-gcc -static
+CC=musl-gcc
+CFLAGS=-I../../include/ -g -Wall -Os -fno-strict-aliasing
+
+FS_OBJS=ext.o squashfs.o udf.o iso9660.o ntfs.o luks.o fat.o exfat.o linux_raid.o \
+        ocfs2.o jfs.o reiserfs.o btrfs.o xfs.o f2fs.o sysv.o cramfs.o romfs.o nilfs.o \
+        linux_swap.o
+
+.PHONY: all clean
+
+all: bb_guess_fstype
+
+main.o: main.c fake_libbb.h
+volume_id.o: volume_id.c fake_libbb.h
+util.o: util.c fake_libbb.h
+fake_libbb.o: fake_libbb.c
+
+btrfs.o: btrfs.c fake_libbb.h
+cramfs.o: cramfs.c fake_libbb.h
+exfat.o: exfat.c fake_libbb.h
+ext.o: ext.c fake_libbb.h
+fat.o: fat.c fake_libbb.h
+hfs.o: hfs.c fake_libbb.h
+iso9660.o: iso9660.c fake_libbb.h
+jfs.o: jfs.c fake_libbb.h
+linux_raid.o: linux_raid.c fake_libbb.h
+linux_swap.o: linux_swap.c fake_libbb.h
+luks.o: luks.c fake_libbb.h
+nilfs.o: nilfs.c fake_libbb.h
+ntfs.o: ntfs.c fake_libbb.h
+ocfs2.o: ocfs2.c fake_libbb.h
+reiserfs.o: reiserfs.c fake_libbb.h
+romfs.o: romfs.c fake_libbb.h
+squashfs.o: squashfs.c fake_libbb.h
+sysv.o: sysv.c fake_libbb.h
+udf.o: udf.c fake_libbb.h
+xfs.o: xfs.c fake_libbb.h
+f2fs.o: f2fs.c fake_libbb.h 
+
+bb_guess_fstype: main.o volume_id.o util.o fake_libbb.o $(FS_OBJS)
+	$(CC) $(CFLAGS) -o bb_guess_fstype main.o volume_id.o util.o fake_libbb.o $(FS_OBJS)
+
+clean:
+	-rm *.o
+	-rm bb_guess_fstype
diff -Nur busybox-1.21.0/util-linux/volume_id/util.c bb/util-linux/volume_id/util.c
--- busybox-1.21.0/util-linux/volume_id/util.c	2013-01-14 07:04:35.000000000 +0700
+++ bb/util-linux/volume_id/util.c	2013-05-16 00:50:35.653201593 +0700
@@ -19,6 +19,7 @@
  */
 
 #include "volume_id_internal.h"
+#define sprintf
 
 void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
 {
diff -Nur busybox-1.21.0/util-linux/volume_id/volume_id.c bb/util-linux/volume_id/volume_id.c
--- busybox-1.21.0/util-linux/volume_id/volume_id.c	2013-01-14 08:20:18.000000000 +0700
+++ bb/util-linux/volume_id/volume_id.c	2013-05-16 00:50:35.656534928 +0700
@@ -17,7 +17,6 @@
  *	License along with this library; if not, write to the Free Software
  *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
-
 #include "volume_id_internal.h"
 
 
@@ -136,6 +135,9 @@
 #if ENABLE_FEATURE_VOLUMEID_UFS
 	volume_id_probe_ufs,
 #endif
+#if ENABLE_FEATURE_VOLUMEID_F2FS
+	volume_id_probe_f2fs,
+#endif
 #if ENABLE_FEATURE_VOLUMEID_NILFS
 	volume_id_probe_nilfs,
 #endif
diff -Nur busybox-1.21.0/util-linux/volume_id/volume_id_internal.h bb/util-linux/volume_id/volume_id_internal.h
--- busybox-1.21.0/util-linux/volume_id/volume_id_internal.h	2013-01-14 08:20:18.000000000 +0700
+++ bb/util-linux/volume_id/volume_id_internal.h	2013-05-16 00:50:35.656534928 +0700
@@ -18,6 +18,7 @@
  *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include "fake_libbb.h"
 #include "libbb.h"
 #include "volume_id.h"
 
@@ -215,6 +216,8 @@
 
 //int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/);
 
+int FAST_FUNC volume_id_probe_f2fs(struct volume_id *id /*,uint64_t off*/);
+
 int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/);
 
 int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/);
