History log of /external/f2fs-tools/lib/libf2fs.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
29ab4d8788d204edb362f01879e1d3d4f516e967 05-Feb-2015 Chao Yu <chao2.yu@samsung.com> mkfs.f2fs: support large sector size

Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large
sector size", block device with sector size of 512/1024/2048/4096 bytes can be
supported.

But mkfs.f2fs still use default sector size: 512 bytes as sector size, let's fix
this issue in this patch.

v2:
o remove unneeded printed message when sector size is large than 512 bytes
suggested by Kinglong.
o show correct sector size in printed message.
o use config.sectors_per_blk instead of DEFAULT_SECTORS_PER_BLOCK suggested by
Kinglong.
v3:
o remove another unneeded printed message when sector size is large than 512
bytes suggested by Kinglong.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Reviewed-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
/external/f2fs-tools/lib/libf2fs.c
060292e67ad6c191be086c6dd520fd7365050ed6 17-Nov-2014 Changman Lee <cm224.lee@samsung.com> mkfs.f2fs: introduce some macros to simplify coding style

This patch tries to simplify coding style for readability.
Rename shortly
o rename super_block to sb

And, introduce some macros.
o set/get_cp
o set/get_sb
o next/prev_zone, last_zone and last_section
o ALIGN, SEG_ALIGN and ZONE_ALIGN

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
/external/f2fs-tools/lib/libf2fs.c
c07795e73cbc509286e35193759e80d65ee12a44 07-Nov-2014 Jaegeuk Kim <jaegeuk@kernel.org> fsck.f2fs: trigger fsck.f2fs when new change was made

This patch remains user specified triggering information in superblock.
Then, if the information was changed, fsck.f2fs is triggered.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
/external/f2fs-tools/lib/libf2fs.c
290d040e855230dbc21c35ccec7ee76fa6696567 26-Sep-2014 joerg jungermann <jj@borkum.net> 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>
/external/f2fs-tools/lib/libf2fs.c
347fe81d8e860d29a254ac066d87c5efe87d717b 27-Aug-2014 Jaegeuk Kim <jaegeuk@kernel.org> 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>
/external/f2fs-tools/lib/libf2fs.c
5005fb18214a234e944dcb74a10b8719f672add2 13-Jun-2014 JP Abgrall <jpa@google.com> 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

Change-Id: I65451596e6b9c654b1ff356de4812d113e80dda8
Signed-off-by: JP Abgrall <jpa@google.com>
/external/f2fs-tools/lib/libf2fs.c
c5786963aef93bb7747cb04454e1041738b3255f 13-Jun-2014 Jaegeuk Kim <jaegeuk@kernel.org> 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>
Change-Id: I145413c94339d8941e4d7da8545ca017e76c61f2
/external/f2fs-tools/lib/libf2fs.c
94f92855ceae3de54cbbfef146b14fdedac49654 12-Jun-2014 JP Abgrall <jpa@google.com> 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>
/external/f2fs-tools/lib/libf2fs.c
fd9816f31e5cd668962f00511d7a91d055d76048 12-May-2014 Changman Lee <cm224.lee@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
0fbdf6cbd4dfc633454eba2f841c123789e297ad 06-Apr-2014 Jaegeuk Kim <jaegeuk.kim@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
3c85e737308ef95629b232745d6a8d141d87cc9a 14-May-2014 JP Abgrall <jpa@google.com> 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>
/external/f2fs-tools/lib/libf2fs.c
15ea79b3ae7f0474ade43ba8b6eb328806e01e15 06-Feb-2014 JP Abgrall <jpa@google.com> 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>
/external/f2fs-tools/lib/libf2fs.c
b155ea8e18a2de5a5d09d3c969cc6fd79a04cb1d 31-Aug-2013 Changman Lee <cm224.lee@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
cd1e4704d0cbf1cbb49b3f33c576566b4b1e296e 20-Aug-2013 Jaegeuk Kim <jaegeuk.kim@samsung.com> fsck, lib: support inline xattr

This patch adjusts the modification to handle inline xattrs.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
/external/f2fs-tools/lib/libf2fs.c
2c877a862d6d22ff5324e90b726c7d6a26febfb7 02-Aug-2013 Jaegeuk Kim <jaegeuk.kim@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
57baa23a3279a4b9e9df0ab92ee20a2c79b839d8 30-Jul-2013 Changman Lee <cm224.lee@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
8e19033a635ca778ba089d5cf341e26728d77711 30-Jul-2013 Jaegeuk Kim <jaegeuk.kim@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
7f35b548d4b0e3c8577ad7a09433e589a0ab3f2a 04-Jul-2013 Changman Lee <cm224.lee@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
9799d6364dc93e1fd259d812d4a50ed984a6456b 03-Apr-2013 Mike Fleetwood <mike.fleetwood@googlemail.com> 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>
/external/f2fs-tools/lib/libf2fs.c
089d0e7202147a7e81796c38e2d704c144403fef 03-Apr-2013 Mike Fleetwood <mike.fleetwood@googlemail.com> mkfs: default to blank label

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
/external/f2fs-tools/lib/libf2fs.c
8d3802b257de83686a327c8e4fa84fba32b563ff 31-Mar-2013 Namjae Jeon <namjae.jeon@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c
5043dffbd1d2b89c71966dde31780b0ca313b5c9 12-Feb-2013 Jaegeuk Kim <jaegeuk.kim@samsung.com> build: clean up the base functions

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
/external/f2fs-tools/lib/libf2fs.c
e69e4378500b836863dfb7f6e88e39935f23ae80 25-Jan-2013 Jaegeuk Kim <jaegeuk.kim@samsung.com> 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>
/external/f2fs-tools/lib/libf2fs.c