platform/upstream/f2fs-tools.git
9 years agomkfs.f2fs: avoid build warning
Jaegeuk Kim [Tue, 7 Oct 2014 22:34:28 +0000 (15:34 -0700)]
mkfs.f2fs: avoid build warning

Avoid build warning for printf.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: fix wrong block addres of nids
Jaegeuk Kim [Mon, 29 Sep 2014 18:29:13 +0000 (11:29 -0700)]
fsck.f2fs: fix wrong block addres of nids

This patch avoids assert when nid has wrong block address.
Let's fix this.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agomkfs.f2fs: possible endianes bug in mkfs.f2fs roll-forward speed
joerg jungermann [Fri, 26 Sep 2014 05:05:12 +0000 (22:05 -0700)]
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>
9 years agof2fs-tools: fix for build big-endian processors
Jaegeuk Kim [Tue, 23 Sep 2014 05:22:33 +0000 (22:22 -0700)]
f2fs-tools: fix for build big-endian processors

This patch fixes build failure on big-endian systems.

Reported-and-Tested-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agof2fs-tools: release 1.4.0 v1.4.0
Jaegeuk Kim [Thu, 18 Sep 2014 16:57:09 +0000 (09:57 -0700)]
f2fs-tools: release 1.4.0

This version includes:
 - fsck.f2fs fixing corrupted images/partitions
 - dump.f2fs retrieving speicific file
 - bug fixes on f2fsstat and fibmap.f2fs
 - refactor code blocks for android build

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agof2fstat: enhance readability of output
Jaegeuk Kim [Thu, 18 Sep 2014 18:35:53 +0000 (03:35 +0900)]
f2fstat: enhance readability of output

This patch enhances output readability of f2fstat.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agotracepoint.sh: update latest tracepoints
Jaegeuk Kim [Mon, 8 Sep 2014 18:13:00 +0000 (11:13 -0700)]
tracepoint.sh: update latest tracepoints

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agof2fs: rearrange options to remove redundant check
Jaegeuk Kim [Thu, 4 Sep 2014 02:41:44 +0000 (19:41 -0700)]
f2fs: rearrange options to remove redundant check

This patch summarizes the usage of options.

-a : auto_fix, fix corruption, only if f2fs reported some potential errors
-f : force,    fix corruption entire partition
None : prompt, if fsck.f2fs detets any corruption

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: add auto_fix feature
Jaegeuk Kim [Wed, 3 Sep 2014 01:07:35 +0000 (18:07 -0700)]
fsck.f2fs: add auto_fix feature

This patch adds an auto_fix feature which fixes inconsistency of f2fs images.

E.g.,

With this option, -a, fsck.f2fs tries to fix inconsistency only if its valid
checkpoint has CP_FSCK_FLAG, written by previous bug_on cases.

So, normally it does fix nothing, so that there is no performance regression.
But, if a sort of corruption was reported by the f2fs module, this tries to
fix potential corrupted partition.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: avoid build warnings
Jaegeuk Kim [Tue, 2 Sep 2014 17:52:56 +0000 (10:52 -0700)]
fsck.f2fs: avoid build warnings

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: remove list.h
Jaegeuk Kim [Sat, 30 Aug 2014 00:15:09 +0000 (17:15 -0700)]
fsck.f2fs: remove list.h

Just use list_head only.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: check next block is free or not
Jaegeuk Kim [Thu, 28 Aug 2014 23:55:45 +0000 (16:55 -0700)]
fsck.f2fs: check next block is free or not

If block allocation is made to the next block offset, we should drop that
block.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: fix checkpoint
Jaegeuk Kim [Thu, 28 Aug 2014 21:55:07 +0000 (14:55 -0700)]
fsck.f2fs: fix checkpoint

- fix nat entries
- fix sit entries
- fix checkpoint

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: handle correctly segment summary entries
Jaegeuk Kim [Thu, 28 Aug 2014 20:49:04 +0000 (13:49 -0700)]
fsck.f2fs: handle correctly segment summary entries

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: remove corrupted xattr block
Jaegeuk Kim [Thu, 28 Aug 2014 17:56:14 +0000 (10:56 -0700)]
fsck.f2fs: remove corrupted xattr block

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: corrupted orphan inode will be removed
Jaegeuk Kim [Thu, 28 Aug 2014 17:50:51 +0000 (10:50 -0700)]
fsck.f2fs: corrupted orphan inode will be removed

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: remove dentry if its inode block is corrupted
Jaegeuk Kim [Fri, 29 Aug 2014 18:26:57 +0000 (11:26 -0700)]
fsck.f2fs: remove dentry if its inode block is corrupted

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: add fixing messeages
Jaegeuk Kim [Thu, 28 Aug 2014 17:27:17 +0000 (10:27 -0700)]
fsck.f2fs: add fixing messeages

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: fix inode block inconsistency
Jaegeuk Kim [Fri, 29 Aug 2014 18:46:25 +0000 (11:46 -0700)]
fsck.f2fs: fix inode block inconsistency

This patch is to fix inode block inconsistency such as iblocks and ilinks.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: give a chance to recover sit entries
Jaegeuk Kim [Thu, 28 Aug 2014 00:15:55 +0000 (17:15 -0700)]
fsck.f2fs: give a chance to recover sit entries

This patch skips initial verfication on SIT entries, which checks the number of
valid blocks from its bitmap.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: cleanup mount.c
Jaegeuk Kim [Thu, 28 Aug 2014 00:13:23 +0000 (17:13 -0700)]
fsck.f2fs: cleanup mount.c

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: handle error cases
Jaegeuk Kim [Thu, 28 Aug 2014 00:06:17 +0000 (17:06 -0700)]
fsck.f2fs: handle error cases

Do sanity check first and then update metadata.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: remove return value of get_node_info
Jaegeuk Kim [Wed, 27 Aug 2014 23:39:23 +0000 (16:39 -0700)]
fsck.f2fs: remove return value of get_node_info

We don't need to get the return value.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: handle IS_VALID_BLK_ADDR
Jaegeuk Kim [Wed, 27 Aug 2014 23:32:06 +0000 (16:32 -0700)]
fsck.f2fs: handle IS_VALID_BLK_ADDR

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: clean up codes
Jaegeuk Kim [Wed, 27 Aug 2014 23:16:16 +0000 (16:16 -0700)]
fsck.f2fs: clean up codes

Fix wrong coding style.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: retry to fix corrupted image
Jaegeuk Kim [Wed, 27 Aug 2014 00:26:01 +0000 (17:26 -0700)]
fsck.f2fs: retry to fix corrupted image

This patch adds a facility to retry conducting fsck.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agof2fs_dentry_hash: avoid casting unsigned char to singed char
Jaegeuk Kim [Tue, 26 Aug 2014 23:28:12 +0000 (16:28 -0700)]
f2fs_dentry_hash: avoid casting unsigned char to singed char

This can hurt when calculating hash value, resulting in false alarm.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agofsck.f2fs: show inode numbers
Jaegeuk Kim [Tue, 19 Aug 2014 22:10:47 +0000 (15:10 -0700)]
fsck.f2fs: show inode numbers

fsck.f2fs -d 1 [dev]
 : shows inode informations
fsck.f2fs -d -1 [dev]
 : shows directory tree with inode number

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
9 years agodump.f2fs: support dump_file from image
Jaegeuk Kim [Tue, 19 Aug 2014 21:05:21 +0000 (14:05 -0700)]
dump.f2fs: support dump_file from image

This patch adds supporting dump_file, which can extract a file from image.

You can simply select [yes|no] when doing dump.f2fs -i [inode number] [img].

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agomkfs.f2fs: remove build warning
Jaegeuk Kim [Tue, 29 Jul 2014 23:24:52 +0000 (16:24 -0700)]
mkfs.f2fs: remove build warning

Should be unsigned int for le32_to_cpu.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agotracepoint.sh: add missing tracepoints
Jaegeuk Kim [Tue, 29 Jul 2014 23:24:11 +0000 (16:24 -0700)]
tracepoint.sh: add missing tracepoints

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agomkfs.f2fs: fix name conflict for BLKDISCARD
Sankalp Bose [Wed, 23 Jul 2014 00:28:14 +0000 (03:28 +0300)]
mkfs.f2fs: fix name conflict for BLKDISCARD

The compile time option BLKDISCARD conflicts with ioctl code
for discard. This causes discard to fail with "Info: This
device doesn't support TRIM". Rename compile time option
to WITH_BLKDISCARD.

Signed-off-by: Sankalp Bose <sankalp@tuxera.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agomkfs.f2fs: large volume support
Changman Lee [Thu, 10 Jul 2014 06:26:04 +0000 (15:26 +0900)]
mkfs.f2fs: large volume support

This patch supports large volume over about 3TB.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agof2fs-tools: 64-bit compile issue
Mark Salyzyn [Mon, 30 Jun 2014 20:57:17 +0000 (13:57 -0700)]
f2fs-tools: 64-bit compile issue

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Change-Id: I9398b877571d3dabbcb29c87a67d59672ea7fbaa
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agolibf2fs: move the finalize_device() into the io lib.
JP Abgrall [Fri, 13 Jun 2014 20:25:20 +0000 (13:25 -0700)]
libf2fs: move the finalize_device() into the io lib.

This is required so that libf2fs.c can be used against any kind
of device (E.g. an in-memory sparse file) just by linking against
something that provides the libf2fs_io.c functions.

libf2fs is currently libf2fs.c + libf2fs_io.c

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agomkfs: set BLKDISCARD by default
Jaegeuk Kim [Fri, 13 Jun 2014 08:41:58 +0000 (17:41 +0900)]
mkfs: set BLKDISCARD by default

And let's show some debug info as well.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agolibf2fs, fsck, mkfs: call f2fs_finalize_device before exit
Jaegeuk Kim [Fri, 13 Jun 2014 07:51:32 +0000 (16:51 +0900)]
libf2fs, fsck, mkfs: call f2fs_finalize_device before exit

The fsck tool should call f2fs_finalize_device before exit to close the device
file.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agomkfs: support passing in the number of sectors to use
JP Abgrall [Thu, 12 Jun 2014 04:55:38 +0000 (21:55 -0700)]
mkfs: support passing in the number of sectors to use

Adds the optional sectors count:
  mkfs.f2fs [options] device [sectors]

Change-Id: I3ac83121576574bda074140ffa60195a2bc9947b

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agoLicense tweak: LGPL v2.1 vs LGPL v2
JP Abgrall [Thu, 12 Jun 2014 04:56:56 +0000 (21:56 -0700)]
License tweak: LGPL v2.1 vs LGPL v2

The important part is

    b) Use a suitable shared library mechanism for linking with the
    Library.  A suitable mechanism is one that (1) uses at run time a
    copy of the library already present on the user's computer system,
    rather than copying library functions into the executable, and (2)
    will operate properly with a modified version of the library, if
    the user installs one, as long as the modified version is
    interface-compatible with the version that the work was made with.

Change-Id: Ic1a02ec5cfcb2bedda3d53f3061037e1e7437221
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agofsck.f2fs: large volume support
Changman Lee [Mon, 12 May 2014 13:03:46 +0000 (22:03 +0900)]
fsck.f2fs: large volume support

This patch support large volume over about 3TB.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
[Jaegeuk Kim: add missing cp_payload in f2fs_super_block]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agofibmap: need linux/fs.h for FIBMAP
Jaegeuk Kim [Wed, 21 May 2014 03:05:31 +0000 (12:05 +0900)]
fibmap: need linux/fs.h for FIBMAP

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10 years agoCleanup various build warnings (signed vs unsigned, unused vars,...)
JP Abgrall [Wed, 14 May 2014 00:02:55 +0000 (17:02 -0700)]
Cleanup various build warnings (signed vs unsigned, unused vars,...)

* removed unused includes.
* removed unused parameters.
* Fixed a bunch of warnings around:
    int i;
    if (i < some_uint) ...
  and
    u32 x;
    ...
    if (x < 0) return error;
* Protect BLKDISCARD usage if it is not available.

Change-Id: Iede035b1beb2df01c961589a69aff47a5258ecd2
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs: fix to remove the test code that should not be merged
Jaegeuk Kim [Fri, 9 May 2014 01:32:14 +0000 (10:32 +0900)]
f2fs: fix to remove the test code that should not be merged

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: announce dual licenses with GPL and LGPL v2
Jaegeuk Kim [Mon, 7 Apr 2014 03:10:59 +0000 (12:10 +0900)]
f2fs-tools: announce dual licenses with GPL and LGPL v2

This patch announces LGPL v2 for the following files.
- include/f2fs_fs.h
- lib/libf2fs.c
- lib/libf2fs_io.c
- mkfs/f2fs_format.c
- mkfs/f2fs_format_main.c
- mkfs/f2fs_format_utils.c
- mkfs/f2fs_format_utils.h

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agoformat: add support for dev_fill() and extra dev_*() debugging.
JP Abgrall [Mon, 31 Mar 2014 22:33:01 +0000 (15:33 -0700)]
format: add support for dev_fill() and extra dev_*() debugging.

Support an fs_io dev_fill().
This helps with devices that actually already return 0 on uninitialized
data. It also helps with in memory devices using sparse libs: don't
allocate a block of 0s.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofurther split up lib2fs so that it does not do any IO directly.
JP Abgrall [Thu, 6 Feb 2014 03:54:12 +0000 (19:54 -0800)]
further split up lib2fs so that it does not do any IO directly.

This will allow turning mkfs into a libarary more easily.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agosplit up mkfs format into main and just the format code.
JP Abgrall [Thu, 6 Feb 2014 03:53:19 +0000 (19:53 -0800)]
split up mkfs format into main and just the format code.

This will allow using the format code as a library.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: fix wrong extension count
Dongho Sim [Wed, 26 Mar 2014 08:25:14 +0000 (08:25 +0000)]
mkfs: fix wrong extension count

fix an bug related to extension list.
there was the potential bug in set_cold_files function, namei.c.

Signed-off-by: Dongho Sim <dh.sim@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofibmap.f2fs: compile fix for musl libc
Natanael Copa [Mon, 3 Mar 2014 09:20:58 +0000 (09:20 +0000)]
fibmap.f2fs: compile fix for musl libc

Include sys/types.h for major/minor macros.

This fixes the following compile error with musl libc:
fibmap.o: In function `print_stat':
/home/ncopa/src/f2fs-tools/tools/fibmap.c:34: undefined reference to `minor'
/home/ncopa/src/f2fs-tools/tools/fibmap.c:34: undefined reference to `major'
fibmap.o: In function `stat_bdev':
/home/ncopa/src/f2fs-tools/tools/fibmap.c:54: undefined reference to `minor'
/home/ncopa/src/f2fs-tools/tools/fibmap.c:54: undefined reference to `major'
collect2: error: ld returned 1 exit status

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: support large directory
Jaegeuk Kim [Thu, 27 Feb 2014 11:12:35 +0000 (20:12 +0900)]
mkfs: support large directory

This patch synchronizes mkfs with the latest f2fs configuration in which
supports large directory by assigning dir_level.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck: remove build warnings
Jaegeuk Kim [Mon, 24 Feb 2014 23:07:25 +0000 (08:07 +0900)]
fsck: remove build warnings

This patch casts some variable types to remove build warnings.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fstat: add nat caches and free nids
Changman Lee [Thu, 13 Feb 2014 06:13:23 +0000 (15:13 +0900)]
f2fstat: add nat caches and free nids

This patch shows nat caches and free nids using f2fs.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fstat: show cp count calling f2fs
Changman Lee [Thu, 13 Feb 2014 06:13:22 +0000 (15:13 +0900)]
f2fstat: show cp count calling f2fs

This patch is to inform how many checkpoint is called.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fstat: add memory information used by f2fs
Changman Lee [Thu, 6 Feb 2014 07:37:53 +0000 (16:37 +0900)]
f2fstat: add memory information used by f2fs

This patch adds memory information used by f2fs.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs, fsck: change the results for readability v1.3.0
Jaegeuk Kim [Wed, 5 Feb 2014 16:09:36 +0000 (01:09 +0900)]
mkfs, fsck: change the results for readability

This patch cleans up several printing formats.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fstat: add option to select partition to see status
Changman Lee [Wed, 29 Jan 2014 04:36:54 +0000 (13:36 +0900)]
f2fstat: add option to select partition to see status

If there are some partitions, this may select a partition to see its
status. If no selection, you will see first section of status.

e.g.) f2fstat -p /dev/sda3

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: fix the wrong nat bitmap size
Jaegeuk Kim [Tue, 28 Jan 2014 10:23:57 +0000 (19:23 +0900)]
mkfs: fix the wrong nat bitmap size

We should consider checksum bytes in the checkpoint block.
Previously, this bug incured very critical panics for node entry handling.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: resolve build warnings
Jaegeuk Kim [Mon, 20 Jan 2014 08:42:21 +0000 (17:42 +0900)]
f2fs-tools: resolve build warnings

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofibmap.f2fs: add bdev information
Changman Lee [Thu, 16 Jan 2014 03:01:27 +0000 (12:01 +0900)]
fibmap.f2fs: add bdev information

This patch shows devname and start_lba based on zero sector.
fibmap reports related lba, sometimes we want to know absolute lba of
file to compare with blktrace.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: move fsck/fibmap.f2fs to tools/
Changman Lee [Thu, 16 Jan 2014 03:01:26 +0000 (12:01 +0900)]
f2fs-tools: move fsck/fibmap.f2fs to tools/

Let's move miscellaneous utilities into tools directory.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: add f2fstat to print f2fs's status in sec
Changman Lee [Fri, 10 Jan 2014 08:44:59 +0000 (17:44 +0900)]
f2fs-tools: add f2fstat to print f2fs's status in sec

This tool prints /sys/kernel/debug/f2fs/status in sec so that we
can monitor variation of f2fs status.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: write the cp page 2 of the checkpoint pack 2 during format
JP Abgrall [Fri, 10 Jan 2014 01:53:18 +0000 (17:53 -0800)]
mkfs: write the cp page 2 of the checkpoint pack 2 during format

Currently mkfs followed by fsck will fail with

  [f2fs_crc_valid: 351] CRC validation failed: cal_crc = 4076150800 blk_crc = 0 buff_size = 0x0

This is because the validatie_checkpoint() tries to read and checksum the
cp page 2, and it is invoked on both cp packs.
But format only writes the page 1 of the 2nd checkpoint pack.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofix typo around CONFIG_64BIT usage
JP Abgrall [Thu, 9 Jan 2014 21:56:07 +0000 (13:56 -0800)]
fix typo around CONFIG_64BIT usage

Would do 64 BITS_PER_LONG when CONFIG_64BIT was NOT defined,
causing BITS_PER_LONG to be wrong on 32bit systems.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: completely abstract the dev IO during format
JP Abgrall [Sat, 11 Jan 2014 05:16:10 +0000 (21:16 -0800)]
mkfs: completely abstract the dev IO during format

This change allows for f2fs_format to work on a non-standard device (e.g.
sparse-memory backed file).
Removes direct access to config.fd from within f2fs_format.c.

Now, f2fs_format_device() can be made to work against any device by
providing
 f2fs_finalize_device()
 f2fs_trim_device()
and the lib2fs.c functions
  ASCIIToUNICODE
  dev_write
  f2fs_cal_crc32
  f2fs_set_bit
  log_base_2

This will allow Android's fastboot to use f2fs against a libsparse.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofibmap: fix wrong block count
Jaegeuk Kim [Fri, 27 Dec 2013 03:57:51 +0000 (12:57 +0900)]
fibmap: fix wrong block count

This is an obvious bug fix patch.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: add inline data check
Huajun Li [Fri, 25 Oct 2013 16:12:40 +0000 (00:12 +0800)]
f2fs-tools: add inline data check

Add inline data check

Signed-off-by: Weihong Xu <weihong.xu@intel.com>
Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agoREADME: add libtool guide
Jaegeuk Kim [Mon, 16 Dec 2013 03:32:37 +0000 (12:32 +0900)]
README: add libtool guide

The f2fs-tools needs libtool package to compile sources.

Suggested-by: Sérgio Benjamim <sergio_br2@ig.com.br>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: remove stale node blocks
Jaegeuk Kim [Mon, 11 Nov 2013 04:29:11 +0000 (13:29 +0900)]
mkfs: remove stale node blocks

If the device does not support discard, we should write zero blocks
to avoid roll-forward recovery.

Reported-and-tested-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck: fix orphan node blocks
Jaegeuk Kim [Wed, 30 Oct 2013 02:16:01 +0000 (11:16 +0900)]
fsck: fix orphan node blocks

Previously, fsck handles only the orphan inode block excpet its indirect node
blocks.
This causes false-alarm, unreachable nat entries [xxx].
This patch fixes to cover indirect node blocks in an orphan inode.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: release 1.2.0 v1.2.0
Jaegeuk Kim [Fri, 25 Oct 2013 07:10:18 +0000 (16:10 +0900)]
f2fs-tools: release 1.2.0

This version includes:
- initial fsck and dump tools
- libraries for f2fs
- bug fixes
- etc

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agomkfs: add two file extensions for android
Jaegeuk Kim [Thu, 17 Oct 2013 08:28:15 +0000 (17:28 +0900)]
mkfs: add two file extensions for android

This patch adds two file extensions, jpeg and video, to identify cold files
in android systems.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agoscripts: add some scripts
Jaegeuk Kim [Thu, 17 Oct 2013 06:26:23 +0000 (15:26 +0900)]
scripts: add some scripts

1. dumpf2fs.sh
 : to see internal device with hexdump
2. spo_test.sh
 : to run SPOR
3. tracepoint.sh
 : to turn on tracepoints

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agoREADME: add description how to cross-compile
Jaegeuk Kim [Thu, 17 Oct 2013 06:15:54 +0000 (15:15 +0900)]
README: add description how to cross-compile

This patch adds description for the cross-compilation.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck: fix checking orphan inodes
Jaegeuk Kim [Wed, 16 Oct 2013 04:48:45 +0000 (13:48 +0900)]
fsck: fix checking orphan inodes

This patch fixes bugs in the orphan inode procedure.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agolibf2fs: avoid warning of implicit declaration
Jaegeuk Kim [Tue, 8 Oct 2013 11:04:35 +0000 (20:04 +0900)]
libf2fs: avoid warning of implicit declaration

This patch adds extern declaration.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck: fix to handle file types correctly
Jaegeuk Kim [Tue, 8 Oct 2013 09:46:55 +0000 (18:46 +0900)]
fsck: fix to handle file types correctly

The file type is based on the number, not bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck: skip to check block addresses in device files
Jaegeuk Kim [Tue, 8 Oct 2013 09:17:33 +0000 (18:17 +0900)]
fsck: skip to check block addresses in device files

The device files use i_addr or i_nid fields for their rdev numbers.
So, fsck should skip to check block addresses inside of them.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: discard is default but not set in config
Changman Lee [Fri, 30 Aug 2013 23:41:31 +0000 (08:41 +0900)]
f2fs-tools: discard is default but not set in config

flash devices support discard therefore discard is default but not set
in config

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofsck, lib: support inline xattr
Jaegeuk Kim [Tue, 20 Aug 2013 09:05:56 +0000 (18:05 +0900)]
fsck, lib: support inline xattr

This patch adjusts the modification to handle inline xattrs.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agofibmap.f2fs: change fibmap to fibmap.f2fs
Jaegeuk Kim [Thu, 8 Aug 2013 21:39:40 +0000 (06:39 +0900)]
fibmap.f2fs: change fibmap to fibmap.f2fs

The fibmap tool is for debugging f2fs especially.

CC: Changman Lee <cm224.lee@samsung.com>
CC: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: add stat information into fibmap
Changman Lee [Thu, 8 Aug 2013 02:12:21 +0000 (11:12 +0900)]
f2fs-tools: add stat information into fibmap

This patch shows stat information about a file with fragmented state.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
10 years agof2fs-tools: add debug message for checking xattr
Changman Lee [Wed, 7 Aug 2013 08:18:50 +0000 (17:18 +0900)]
f2fs-tools: add debug message for checking xattr

This patch adds debug message to confirm xattr block is checked.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agolibf2fs: check more conditions on mounted filesystem
Jaegeuk Kim [Fri, 2 Aug 2013 08:03:10 +0000 (17:03 +0900)]
libf2fs: check more conditions on mounted filesystem

In the case of lazy umount, "umount -l", some processes are able to use the
file system even if its mountpoint was disconnected.
At this moment, we should not allow mkfs.f2fs.
This patch adds this condition check.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: add option to display directory tree
Changman Lee [Tue, 30 Jul 2013 07:39:06 +0000 (16:39 +0900)]
f2fs-tools: add option to display directory tree

This option shows directory tree of f2fs.

Usage: fsck.f2fs -t /dev/sdx

`-- p0
   |-- f4
   `-- d6
        |-- f5e
        |-- cb6
        |-- fdb
        |-- fe8
        `-- l9a

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: use either hex or decimal options
Changman Lee [Tue, 30 Jul 2013 07:39:05 +0000 (16:39 +0900)]
f2fs-tools: use either hex or decimal options

This patch supports both hex and decimal when using nid as option.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: cleanup debug statement
Changman Lee [Tue, 30 Jul 2013 07:39:04 +0000 (16:39 +0900)]
f2fs-tools: cleanup debug statement

The debug message is too verbose therefore decrease message.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: fix missing function declaration
Changman Lee [Tue, 30 Jul 2013 07:39:03 +0000 (16:39 +0900)]
f2fs-tools: fix missing function declaration

Explicitly declare function name.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agolibf2fs: add an error message for a mounted device
Jaegeuk Kim [Tue, 30 Jul 2013 07:30:53 +0000 (16:30 +0900)]
libf2fs: add an error message for a mounted device

We need to notify the mounted device.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: add fibmap
Changman Lee [Thu, 18 Jul 2013 09:08:01 +0000 (18:08 +0900)]
f2fs-tools: add fibmap

This is to get physical location of file data.
We can check the percentage of fragmentation on a file.

Note that it uses fsync to get exact blkaddr.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agodump: dump inode information from blkaddr
Changman Lee [Thu, 18 Jul 2013 02:20:05 +0000 (11:20 +0900)]
dump: dump inode information from blkaddr

This patch is to dump inode which blkaddr belongs in.
Usage:
  dump.f2fs /dev/sdx -b blk_addr (in 4KB)

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agofsck: fix name search
Jaegeuk Kim [Mon, 15 Jul 2013 11:48:52 +0000 (20:48 +0900)]
fsck: fix name search

The next name slots should be calculated by F2FS_SLOT_LEN not F2FS_NAME_LEN.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: add apk extension to indicate cold files
Jaegeuk Kim [Tue, 16 Jul 2013 05:20:41 +0000 (14:20 +0900)]
mkfs: add apk extension to indicate cold files

Android systems uses apks for their application packages.
These files are normally used as read-only.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agof2fs-tools: add fsck.f2fs and dump.f2fs
Changman Lee [Thu, 4 Jul 2013 08:11:32 +0000 (17:11 +0900)]
f2fs-tools: add fsck.f2fs and dump.f2fs

fsck.f2fs checks file system consistency, but does not repair a broken
file system yet.
dump.f2fs shows the information of a specific inode and makes dump file
of SSA and SIT.
f2fs checks file system consistency as follows:
 o When data about used area and its metadata are identical,
   f2fs is considered consistent. To verify such consistency, we use
   three bitmaps: nat_area_bitmap, sit_area_bitmap, and main_area_bitmap.
   First, each bit in nat_area_bitmap corresponds to a nid in NAT.
   Second, each bit in sit_area_bitmap corresponds to a valid block in a
   segment. This bitmap is same to the total valid_map of f2fs_sit_entries
   in SIT.
   Last, each bit in main_area_bitmap corresponds to a block in main area
   except meta area.
   After a consistency check of each block, we set or clear the
   corresponding bit of each bitmap.
   From the root node, we start consistency check. The verified
   information varies according to block type.
   1. NODE
     - Read information of node block from NAT
     - Check if block address is allocated using node info.
     - Check if the type of f2fs_summary related to nid in SSA is NODE.
     - Update the corresponding bit in nat_area_bitmap.
     - Update the corresponding bit in sit_area_bitmap.
     - Set the corresponding bit in main_area_bitmap to 1.
     - Then, read node block. According to its attribute, explore
       inode/direct node/indirect node/double indirect node
       recursively.
     - If it is an inode block, we also check its xattr and hard link.
   2. DATA
     - Check if the type of f2fs_summary related to nid in SSA is DATA.
     - Set the corresponding bits of sit_area_bitmap and
       main_area_bitmap to visited
     - If it is a dentry block, traverse each dentries that may be
       regular
       file or directory. At this time, it will check inode block again.
   Finally, we verify whether
     - every nat_area_bitmap is visited
     - any unreachable hard link exists
     - values of sit_area_bitmap and main_area_bitmap are identical
     - total_valid_block_count/node_count/inode_count are correct

Usage:
 o fsck.f2fs
   # fsck.f2fs /dev/sdx
   options:
     -d debug level [default:0]
 o dump.f2fs
   # dump.f2fs -i [ino] /dev/sdx
   # dump.f2fs -s 0~-1 /dev/sdx (SIT dump)
   # dump.f2fs -a 0~-1 /dev/sdx (SSA dump)
   options:
     -d debug level [default:0]
     -i inode no (hex)
     -s [SIT dump segno from #1~#2 (decimal), for all 0~-1]
     -a [SSA dump segno from #1~#2 (decimal), for all 0~-1]

Note: To use dump.f2fs, please run make install or ln -s fsck.f2fs
dump.f2fs

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Byoung Geun Kim <bgbg.kim@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: fix the total_zones calculation in f2fs_prepare_super_block
Wang Sheng-Hui [Fri, 28 Jun 2013 05:21:07 +0000 (13:21 +0800)]
mkfs: fix the total_zones calculation in f2fs_prepare_super_block

We can count the main area as the data zones. Remove the '-1' miscalcuation.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: fix to store __le32 for checkpoint flags
Jaegeuk Kim [Wed, 19 Jun 2013 12:36:39 +0000 (21:36 +0900)]
mkfs: fix to store __le32 for checkpoint flags

The checkpoint flags also should be stored as little endian style.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agolib, mkfs: fix endian conversion for crc calculation
Jaegeuk Kim [Wed, 19 Jun 2013 11:49:47 +0000 (20:49 +0900)]
lib, mkfs: fix endian conversion for crc calculation

Let's store the crc value for the checkpoint blocks with __le32.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: fix bug in endianness at f2fs_update_nat_root
Oded Gabbay [Thu, 13 Jun 2013 10:57:32 +0000 (13:57 +0300)]
mkfs: fix bug in endianness at f2fs_update_nat_root

This patch fixes a bug in the function "f2fs_update_nat_root", where the
access to the array "nat_blk->entries" was done using an index without
encapsulation of the "le32_to_cpu" macro.
The bug happens when trying to format an SD card in a powerpc architecture,
which natively runs at big-endian mode

Signed-off-by: Oded Gabbay <ogabbay@advaoptical.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: add option to disable trim at format
Changman Lee [Wed, 3 Apr 2013 06:26:48 +0000 (15:26 +0900)]
mkfs: add option to disable trim at format

This patch adds an option to disable trim command at format.
Default operation sends trim command to device.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: handle labels longer than 16 characters
Mike Fleetwood [Tue, 2 Apr 2013 22:15:20 +0000 (23:15 +0100)]
mkfs: handle labels longer than 16 characters

Mkfs copies labels up to 512 characters into a the 16 character buffer
config.vol_label corrupting memory afterwards and causing a core dump.

    # mkfs.f2fs -l aaaaaaaaaabbbbbbbbbbcccccccccc /dev/sda12

            F2FS-tools: mkfs.f2fs Ver: 1.1.0 (2013-03-08)

    Info: Label = aaaaaaaaaabbbbbbbbbbcccccccccc
    Info: sector size = 512
    Info: total sectors = 2097152 (in 512bytes)
    Info: zone aligned segment0 blkaddr: 256
    Segmentation fault (core dumped)

Make config.vol_label a pointer to the label in argv, rather than
copying it into a too small buffer.

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: default to blank label
Mike Fleetwood [Tue, 2 Apr 2013 22:12:13 +0000 (23:12 +0100)]
mkfs: default to blank label

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>