platform/upstream/f2fs-tools.git
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>
11 years agomkfs: fix to avoid format of device when already mounted
Namjae Jeon [Sun, 31 Mar 2013 02:51:29 +0000 (11:51 +0900)]
mkfs: fix to avoid format of device when already mounted

In case of embedded devices, where /etc/ is mounted as 'read-only'.
We donot have the /etc/mtab file. So, checking if the device is already
mounted from this file is not sufficient.
Try to read /proc/mounts in case of failure from /etc/mtab.

Issue logs:
/dev/sdb4 /mnt vfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,
iocharset=ascii,errors=remount-ro 0 0

Here device - sb4 is already mounted.
But, when trying to format using mkfs.f2fs

F2FS-tools: Ver: 1.1.0 (2013-01-14)
Info: sector size = 512
Info: total sectors = 13108784 (in 512bytes)
WARN: Align start sector number in a unit of pages
        i.e., start sector: 2542124, ofs:4 (sectors per page: 8)
Info: zone aligned segment0 blkaddr: 186
Info: This device doesn't support TRIM
Info: format successful

After Change:

F2FS-tools: Ver: 1.1.0 (2013-01-14)
Error: /dev/sdb4 is already mounted

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: revert "Compile static by default"
Jaegeuk Kim [Tue, 2 Apr 2013 07:23:53 +0000 (16:23 +0900)]
build: revert "Compile static by default"

By default, we should use dynamic linking.
If anyone need to build 100% statically, add -all-static.

This reverts commit 2eb19102d4c5bec57c04c944ee697584a493ef9c.

11 years agobuild: change f2fs_fs.h
Jaegeuk Kim [Sun, 3 Mar 2013 05:00:50 +0000 (14:00 +0900)]
build: change f2fs_fs.h

Let's sync f2fs_fs.h in the kernel source tree.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: compile static by default
Jaegeuk Kim [Tue, 12 Feb 2013 06:15:49 +0000 (15:15 +0900)]
build: compile static by default

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: clean up the base functions
Jaegeuk Kim [Tue, 12 Feb 2013 02:03:24 +0000 (11:03 +0900)]
build: clean up the base functions

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: make several base functions as a library
Jaegeuk Kim [Fri, 25 Jan 2013 08:20:16 +0000 (17:20 +0900)]
build: make several base functions as a library

Let's make a library and relocate functions for other tools like fsck.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: sync f2fs_fs.h with current f2fs sources
Jaegeuk Kim [Fri, 25 Jan 2013 04:39:34 +0000 (13:39 +0900)]
build: sync f2fs_fs.h with current f2fs sources

Rearrange positions of all the data structures for easy synchronization between
f2fs-tools and f2fs kernel sources.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: move f2fs_format.h to ../include/f2fs_fs.h
Jaegeuk Kim [Fri, 25 Jan 2013 04:23:23 +0000 (13:23 +0900)]
build: move f2fs_format.h to ../include/f2fs_fs.h

This is to use f2fs.h globally, which will be used by other tools such as
fsck.f2fs.

Siged-mff-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: add description of prerequisite to build
Jaegeuk Kim [Wed, 23 Jan 2013 17:22:13 +0000 (02:22 +0900)]
build: add description of prerequisite to build

Let's check two more packages before building f2fs-tools.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: reserve x2 sections
Jaegeuk Kim [Mon, 14 Jan 2013 00:26:51 +0000 (09:26 +0900)]
mkfs: reserve x2 sections

This is due to GC on data sections.
When a data section is cleaned, it produces maximum same number of dirty node
blocks additionally.
So, we should reserve x2 sections to flush dirty node blocks safely.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agobuild: place mkfs into sbindir
Jan Engelhardt [Wed, 12 Dec 2012 03:05:07 +0000 (04:05 +0100)]
build: place mkfs into sbindir

Filesystem creation utilities have always been in *sbin*.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agobuild: replace obsolete build macros
Jan Engelhardt [Wed, 12 Dec 2012 02:59:16 +0000 (03:59 +0100)]
build: replace obsolete build macros

AM_CONFIG_HEADER is obsolete. Since v1.6.1b(!) already.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agobuild: set some automake options
Jan Engelhardt [Wed, 12 Dec 2012 02:57:11 +0000 (03:57 +0100)]
build: set some automake options

Use "foreign", so that we are not forced to have all files GNU
requires. It also gets us rid of the INSTALL boilerplate.

Use tar-pax dist-xz to select a modern compression scheme.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agobuild: make use of AC_CONFIG_AUX_DIR
Jan Engelhardt [Wed, 12 Dec 2012 02:55:42 +0000 (03:55 +0100)]
build: make use of AC_CONFIG_AUX_DIR

Place most of the autogenerated files in a separate directory that can
be ignored wholesale, thereby reducing files in the top-level
directory.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agoUpdate .gitignore
Jan Engelhardt [Wed, 12 Dec 2012 02:54:28 +0000 (03:54 +0100)]
Update .gitignore

Mark directories to be ignored as such.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agobuild: use pkgconfig to determine libuuid's parameters
Jan Engelhardt [Wed, 12 Dec 2012 02:53:28 +0000 (03:53 +0100)]
build: use pkgconfig to determine libuuid's parameters

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agobuild: remove unnecessary m4_flatten
Jan Engelhardt [Wed, 12 Dec 2012 02:52:24 +0000 (03:52 +0100)]
build: remove unnecessary m4_flatten

automake can cope with it as-is.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
11 years agomkfs: Make HDIO_GETGEO ioctl optional
Ezequiel Garcia [Wed, 12 Dec 2012 02:08:35 +0000 (23:08 -0300)]
mkfs: Make HDIO_GETGEO ioctl optional

Some block devices don't implement HDIO_GETGEP ioctl;
loop device being a notable example.
Without this patch, it's not possible to make a f2fs
on a file mounted over a loop device.

Signed-off-by: Ezequiel Garcia <ezequiel@free-electrons.com>
11 years agoMore files git should ignore
Sven-Göran Bergh [Fri, 7 Dec 2012 11:38:00 +0000 (12:38 +0100)]
More files git should ignore

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
11 years agoUnify version and date management
Sven-Göran Bergh [Fri, 7 Dec 2012 01:20:27 +0000 (10:20 +0900)]
Unify version and date management

Patch 1:
 Now we have two different versions that produce different superblocks/
 filesystems with the same version info. Major/minor version in the sb
 should reflect the version of the tool creating the filesystem. This
 patch will ensure that the version entered in the file VERSION will
 be used consistently throughout the code.

Patch 2:
 In order to simplify the maintenance with a new release the date
 in F2FS_TOOLS_DATE is now take from the last commit in git. Thus,
 git is needed to run autoconf. However, git is not needed for the
 simple build procedure, ./configure && make, that should be the
 only things needed to build the tool from a tar.gz package.

 Pros & Cons:
  [+] Automated
  [+] True
  [-] Git needed to run autoreconf

Change log by Jaegeuk from the initial patch-set:

- Merge two patches into one
 : Eliminate the intermediate state having version.h and VERSION.

- Remove the Git dependency which is one of Cons
 : If there is no git tree, just use DATE described in VERSION.

- Minor coding style

 Pros & Cons:
  [+] Automated
  [+] True
  [+] No Git dependency

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoIgnore configure.lineno
Sven-Göran Bergh [Wed, 5 Dec 2012 12:17:39 +0000 (13:17 +0100)]
Ignore configure.lineno

Autotools may spit out the file configure.lineno, which git
should ignore as well.

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
11 years agoSync the version management v1.1.0
Jaegeuk Kim [Thu, 29 Nov 2012 03:44:04 +0000 (12:44 +0900)]
Sync the version management

For debian packaing, I should have matched the previous verions, v1.1.0.
So, this is the start of f2fs-tools version.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoAdd version information v1.0.0
Jaegeuk Kim [Mon, 26 Nov 2012 11:04:39 +0000 (20:04 +0900)]
Add version information

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoBug fix: Fix overflow when calculating block address
Jaegeuk Kim [Tue, 13 Nov 2012 07:32:44 +0000 (16:32 +0900)]
Bug fix: Fix overflow when calculating block address

This patch fixes the bug as follows.
"I'm trying to roll out f2fs on top of SDHC card and faced with following
issue - after mounting card I cannot read device root entry. It returns
-1 EINVAL (entry too big).
getdents(3, /* 1 entries */, 32768)     = 24
getdents(3, 0x1082c88, 32768)           = -1 EINVAL (Invalid argument)"
reported by Ruslan N. Marchenko [me@ruff.mobi].

This bug is easily reproducible and I couldn't have checked the mount
entry cautiously.
Due to the bug, f2fs couldn't get default dentries, . and .., in the root
directory. In the case of other newly created directories, that's fine.

The problem was the overflow during casting variables while calculating the
block address of the root dentry block.
In order to avoid that, I simply split the equation under consideration of
the casting issue.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoCleanup: sync comments to kernel source
Jaegeuk Kim [Wed, 31 Oct 2012 09:29:45 +0000 (18:29 +0900)]
Cleanup: sync comments to kernel source

Remove unnecessary data fields too.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoBug fix: store superblocks with correct offset
Jaegeuk Kim [Mon, 29 Oct 2012 23:43:28 +0000 (08:43 +0900)]
Bug fix: store superblocks with correct offset

There are two superblock writes in mkfs.f2fs.

offset: 0     1024                 4095      5119                 8191
        |------> 1'st superblock ----|--------> 2'nd superblock ----|

Therefore, each superblocks has 1024 byte-size offset.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agotouch up autotools
Mike Frysinger [Mon, 29 Oct 2012 22:38:59 +0000 (07:38 +0900)]
touch up autotools

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoignore generated files
Mike Frysinger [Mon, 29 Oct 2012 22:36:26 +0000 (07:36 +0900)]
ignore generated files

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agouse proper priu64 type to be portable
Mike Frysinger [Mon, 29 Oct 2012 22:38:30 +0000 (07:38 +0900)]
use proper priu64 type to be portable

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoCleanup: add comments
Jaegeuk Kim [Mon, 29 Oct 2012 22:35:49 +0000 (07:35 +0900)]
Cleanup: add comments

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoEnhancement: shorten umount time
Jaegeuk Kim [Mon, 29 Oct 2012 22:35:21 +0000 (07:35 +0900)]
Enhancement: shorten umount time

When f2fs is unmounted cleanly, it stores active summmary blocks of nodes in the
checkpoint pack in order to avoid reconstruct all of them at the later mount
time. Previously, mkfs didn't prepare that, which is why the initial mount time
is so huge.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoEnhancement: add uuid
Jaegeuk Kim [Mon, 29 Oct 2012 22:35:00 +0000 (07:35 +0900)]
Enhancement: add uuid

"Usually, it is used 128-bits UUID for serial number. Why do you use
__le32 as volume_serial_number?"
>From Vyacheslav Dubeyko.

I added an uuid facility for the serial number.
And sync with kernel/include/linux/f2fs_fs.h.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agoEnhancement: add i_atime and i_generation
Jaegeuk Kim [Mon, 29 Oct 2012 22:34:35 +0000 (07:34 +0900)]
Enhancement: add i_atime and i_generation

"You appear to have dropped i_btime - no big deal, you weren't using it anyway.
However if you ever want to support NFS export you will need some value which
is assigned when the inode is allocated and never changed until it is
de-allocated.  This is used to detect when an NFS file-handle refers to a
previous incarnation of an inode and so should be rejected as STALE.
i_btime could have possibly provided this, but not any more.  You might want
to add something back.
ext3 uses "i_generation" and has an 's_next_generation' in the superblock to
ensure that each new inode gets a new generation number.

You've also dropped i_atime.  I can certainly understand the desire to do
that, but I wonder if it is entirely wise.  There are some use-cases where
i_mtime is a poor substitute.

Also 'current_depth' looks a little odd without a 'i_' prefix.  It wouldn't
hurt to have a comment noting that it is for directories."

>From Neil Brown.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
11 years agomkfs: Initial commit for patch v2 series
Jaegeuk Kim [Fri, 26 Oct 2012 12:56:34 +0000 (21:56 +0900)]
mkfs: Initial commit for patch v2 series

This is same as f2fs-tools-1.1.0.tar.gz, and for patch v2 in kernel.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@gmail.com>