Commit Graph

880 Commits

Author SHA1 Message Date
Jaegeuk Kim
858c4039c8 mkfs, fsck: change the results for readability
This patch cleans up several printing formats.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-06 11:09:41 +09:00
Changman Lee
28d45d09cd 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>
2014-02-03 15:05:03 +09:00
Jaegeuk Kim
0255d52ebf 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>
2014-01-28 19:31:35 +09:00
Jaegeuk Kim
4f267323a2 f2fs-tools: resolve build warnings
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-01-20 17:42:21 +09:00
Changman Lee
b611e1155a 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>
2014-01-16 17:29:13 +09:00
Changman Lee
e296161af0 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>
2014-01-16 17:29:13 +09:00
Changman Lee
a0a5567e3e 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>
2014-01-14 17:48:35 +09:00
JP Abgrall
6da30100ee 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>
2014-01-13 10:21:56 +09:00
JP Abgrall
cb54e79739 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>
2014-01-13 10:21:19 +09:00
JP Abgrall
437dbf6773 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>
2014-01-13 10:21:08 +09:00
Jaegeuk Kim
1aae03594b fibmap: fix wrong block count
This is an obvious bug fix patch.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-12-27 12:57:51 +09:00
Huajun Li
061ee67915 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>
2013-12-16 12:42:43 +09:00
Jaegeuk Kim
11d187cdfa 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>
2013-12-16 12:33:41 +09:00
Jaegeuk Kim
ffbada4298 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>
2013-11-11 18:58:48 +09:00
Jaegeuk Kim
f1d452af4a 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>
2013-10-30 11:16:01 +09:00
Jaegeuk Kim
576cb469e7 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>
2013-10-25 16:10:18 +09:00
Jaegeuk Kim
2ad1fcd800 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>
2013-10-17 17:28:15 +09:00
Jaegeuk Kim
5b9f641c06 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>
2013-10-17 15:26:23 +09:00
Jaegeuk Kim
050e8712a6 README: add description how to cross-compile
This patch adds description for the cross-compilation.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-17 15:19:40 +09:00
Jaegeuk Kim
8e678b2edf fsck: fix checking orphan inodes
This patch fixes bugs in the orphan inode procedure.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-16 13:52:16 +09:00
Jaegeuk Kim
465e4e7f10 libf2fs: avoid warning of implicit declaration
This patch adds extern declaration.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-08 20:04:35 +09:00
Jaegeuk Kim
76a069430a 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>
2013-10-08 19:17:22 +09:00
Jaegeuk Kim
78b795e05d 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>
2013-10-08 18:17:33 +09:00
Changman Lee
b155ea8e18 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>
2013-09-03 09:45:44 +09:00
Jaegeuk Kim
cd1e4704d0 fsck, lib: support inline xattr
This patch adjusts the modification to handle inline xattrs.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-20 18:12:04 +09:00
Jaegeuk Kim
9455376cd0 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>
2013-08-09 06:41:02 +09:00
Changman Lee
e23d58533c 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>
2013-08-08 14:53:41 +09:00
Changman Lee
6e8f2d5d22 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>
2013-08-07 18:21:24 +09:00
Jaegeuk Kim
2c877a862d 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>
2013-08-02 17:06:26 +09:00
Changman Lee
57baa23a32 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>
2013-07-30 17:06:44 +09:00
Changman Lee
932f9845f6 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>
2013-07-30 17:06:44 +09:00
Changman Lee
223fdf3e00 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>
2013-07-30 17:06:44 +09:00
Changman Lee
c81ded6cf0 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>
2013-07-30 17:06:44 +09:00
Jaegeuk Kim
8e19033a63 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>
2013-07-30 16:30:53 +09:00
Changman Lee
dfe2a3384f 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>
2013-07-22 21:52:03 +09:00
Changman Lee
8843554c8c 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>
2013-07-18 15:45:30 +09:00
Jaegeuk Kim
0307b93ce2 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>
2013-07-18 09:19:54 +09:00
Jaegeuk Kim
679ca83b9e 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>
2013-07-16 14:20:41 +09:00
Changman Lee
7f35b548d4 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>
2013-07-04 23:15:25 +09:00
Wang Sheng-Hui
716ea385be 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>
2013-07-02 09:55:13 +09:00
Jaegeuk Kim
c5bf205a4d 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>
2013-07-02 09:54:38 +09:00
Jaegeuk Kim
cc9d9caeb6 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>
2013-07-02 09:54:34 +09:00
Oded Gabbay
b6ae58ed44 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>
2013-07-02 09:54:26 +09:00
Changman Lee
fef98ebdf3 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>
2013-04-04 09:20:04 +09:00
Mike Fleetwood
9799d6364d 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>
2013-04-04 09:19:52 +09:00
Mike Fleetwood
089d0e7202 mkfs: default to blank label
Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-04-04 09:19:47 +09:00
Namjae Jeon
8d3802b257 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>
2013-04-04 09:19:36 +09:00
Jaegeuk Kim
1dc688d2fd 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.
2013-04-04 09:19:30 +09:00
Jaegeuk Kim
f5f440f086 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>
2013-04-04 09:19:25 +09:00
Jaegeuk Kim
e1e843d29c build: compile static by default
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-04-04 09:19:19 +09:00