Go to file
joerg jungermann fe067853b0 mkfs.f2fs: possible endianes bug in mkfs.f2fs roll-forward speed
I might found a bug in mkfs.f2fs. while experimenting with f2fs on my big
endian MIPS32 device (platform lantiq, 14.07-rc3, uclibc).

I ran into an issue that mkfs.f2fs, was not able to format block devices if I
did not specify the sector count manually.

I hunted it down to lib/libf2fs.c.
After I found that the detected sector count equals to the wanted sector count
shifted left (32+9) times.

I found two issues:
Firstly it uses ioctl BLKGETSIZE, which writes to an uint32_t the size of the
device.
As c->total_sectors is of type uint64_t, the value is written in to the first
4 bytes.
That explained the left shift of 32 bits.

Secondly BLKGETSIZE determines the size of the device in bytes (AFAIK, learned
by observation).
In the first branch of the if-block patched below, the c->total_sectors is
calculated by
  c->total_sectors = stat_buf.st_size / c->sector_size;
The else branch omits the devision. sector_sice is mostly 512, that explained
the left shift by 9 bytes.

 * fixes sector count calculation
 * uses BLKGETSIZE64 if avail

Signed-off-by: joerg jungermann <jj@borkum.net>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-25 22:14:45 -07:00
fsck f2fs: rearrange options to remove redundant check 2014-09-03 19:45:42 -07:00
include f2fs-tools: fix for build big-endian processors 2014-09-23 10:21:56 -07:00
lib mkfs.f2fs: possible endianes bug in mkfs.f2fs roll-forward speed 2014-09-25 22:14:45 -07:00
m4 mkfs: Initial commit for patch v2 series 2012-11-26 19:45:59 +09:00
man build: make several base functions as a library 2013-04-04 09:19:07 +09:00
mkfs mkfs.f2fs: remove build warning 2014-07-29 16:24:52 -07:00
scripts tracepoint.sh: update latest tracepoints 2014-09-08 11:13:00 -07:00
tools f2fstat: enhance readability of output 2014-09-18 18:10:34 -07:00
.gitignore build: make several base functions as a library 2013-04-04 09:19:07 +09:00
AUTHORS mkfs: Initial commit for patch v2 series 2012-11-26 19:45:59 +09:00
ChangeLog f2fs-tools: add fsck.f2fs and dump.f2fs 2013-07-04 23:15:25 +09:00
configure.ac mkfs.f2fs: fix name conflict for BLKDISCARD 2014-07-25 08:11:16 -07:00
COPYING License tweak: LGPL v2.1 vs LGPL v2 2014-06-12 16:52:59 +09:00
Makefile.am f2fs-tools: add f2fstat to print f2fs's status in sec 2014-01-14 17:48:35 +09:00
README README: add libtool guide 2013-12-16 12:33:41 +09:00
VERSION f2fs-tools: release 1.4.0 2014-09-18 18:10:37 -07:00

F2FS format utilility
---------------------

To use f2fs filesystem, you should format the storage partition
with this utilility. Otherwise, you cannot mount f2fs.

Before compilation
------------------

Your should install the following packages.
 - libuuid-devel or uuid-dev
 - pkg-config
 - autoconf
 - libtool

Initial compilation
-------------------

Before compilation initially, autoconf/automake tools should be run.

 # autoreconf --install

How to compile
--------------

 # ./configure
 # make

How to cross-compile (e.g., for ARM)
------------------------------------

 1. Add the below line into mkfs/Makefile.am:
 mkfs_f2fs_LDFLAGS = -all-static

 2. Add the below line into fsck/Makefile.am:
 fsck_f2fs_LDFLAGS = -all-static

 3. then, do:
 # LDFLAGS=--static ./configure \
	--host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi
 # make

How to run by default
---------------------

 $ ./mkfs.f2fs -l [LABEL] $DEV

For more mkfs options, see man page.