aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* f2fs-tools: hack headers to unbreak darwin buildstaging/cm-14.1-cafrebasecm-14.1_prerebasecm-14.1Alexander Martinz2016-11-251-0/+7
| | | | | | | * headers taken from FreeBSD Change-Id: I1f09a9def520e26ecd8e309b7dd85b72cf789725 Signed-off-by: Alexander Martinz <eviscerationls@gmail.com>
* mkfs.f2fs: ZBC device supportJaegeuk Kim2016-11-124-1/+1026
| | | | | | | | | | This patch adds "-m" option to configure ZBC device. This is to support host-managed SMR device and configure some major features and on-disk layout in f2fs. Change-Id: I383c04e6c3f4845e61910bea102f418a9b945dc0 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* libf2fs: limit the total size up to 16TJunling Zheng2016-08-241-0/+5
| | | | | | | | | F2FS can support 16T bytes at most. Limit the config.total_sectors so that most parameters calculated according to it in sb/cp can be limited correctly too. Signed-off-by: Junling Zheng <zhengjunling@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* fsck.f2fs: check /proc/mounts first to detect readonlyJaegeuk Kim2016-08-241-8/+8
| | | | | | | | Once f2fs_stop_checkpoint makes f2fs as readonly, only /proc/mounts shows RDONLY whereas /etc/mtab does not. Change-Id: I389cc1589147fcf4da8822de32cd3313d881e65f Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* Fix readonly for androidGreg Wallace2016-08-241-1/+22
| | | | | | | | | The hasmntopt() function doesn't exist in android, so it needs to be defined if we are building for android. Also, MNTOPT_RO isn't defined on android (and maybe others), so we need to manually specify if if it isn't already defined. Change-Id: I55330e37cebc087e138cdf6a0cbbe61df59f55fa
* f2fs-tools: avoid failure and warnings for android buildJaegeuk Kim2016-08-241-6/+7
| | | | | | | | This patch fixes to resolve build failure and warnings when compiling it under AOSP. Change-Id: I26f65615203183ad4d4c54c28fc152042707251b Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* lib: use u8/u32/u64 for bit operationsJaegeuk Kim2016-08-241-11/+8
| | | | | | | This cleans up the bit operations. Change-Id: Ie2b303cc6eddc4ef5315f8f55616dbe182664ddc Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* lib: fix test_bit_le functionsJaegeuk Kim2016-08-241-16/+10
| | | | | | | This patch fixes test_bit_le functions for dentry bit operations. Change-Id: I3f8c03e54e3f6b068ccaa9d498d984340065f90d Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: fix storing volume label correctly in utf16Jaegeuk Kim2016-08-241-9/+168
| | | | | | | | | This patch fixes to store volume label as utf16 correctly. Many conversion codes are copied from exfat-tools. Change-Id: Iee96b27a5bfc4938f285b4de49d32e01a181d17f Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* libf2fs: enhance the bit operationsJaegeuk Kim2016-08-241-58/+46
| | | | | | | This patch modifies the existing bit operations. Change-Id: Ib6c9ba77d5426b31ee31e0d811d45a85ac89cc57 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs-tools: add library version infoJaegeuk Kim2016-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch gives the version info for two libraries. mkfs/libf2fs_format.la lib/libf2fs.la The versioning rule should be: 1. Start with version information of '0:0:0' for each libtool library. 2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster. 2. If the library source code has changed at all since the last update, then increment revision (c:r:a) becomes (c:r+1:a). 3. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. 4. If any interfaces have been added since the last public release, then increment age. 5. If any interfaces have been removed or changed since the last public release, then set age to 0. quoted from: http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info Change-Id: I2226ec841157adeb65bceda06eb2e4bcafce66a4 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: show correct partition sizeJaegeuk Kim2016-08-241-1/+2
| | | | | | | | It needs to consider different sector size when showing the total size. Change-Id: I1eaea7df37dd1d6a26e8cda9033f816a040db789 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* fsck.f2fs: support a readonly filesystemJaegeuk Kim2016-08-241-6/+11
| | | | | | | If f2fs is mounted as ro, we can do fsck.f2fs. Change-Id: If20a055242824fd94110bcde12988ddc019a4011 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: don't need to limit MIN_VOLUME SIZEJaegeuk Kim2016-08-241-7/+0
| | | | | | | The minimum volume size is determined while preparing superblock. Change-Id: I4d55d97a7016c86adf7736e17185fb5d2ca3307f Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: set overprovision size more preciselyJaegeuk Kim2016-08-241-2/+2
| | | | | | | | This patch introduces to set the default overprovision space according to the partition size in order to provide more space. Change-Id: I18462accda6b2ac19666b37d7062b147a5be5dc9 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: show bytes for total_sectorsJaegeuk Kim2016-08-241-2/+2
| | | | | | | This patch shows correct information about total_sectors. Change-Id: Ic3c258fa806a66a0b19aefad4a1963be0cae7f77 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* Add darwin support for building the host toolsKeith Mok2016-08-242-3/+14
| | | | Change-Id: Ibe5976c3db03020fcdad41ead53cb141a9b35d80
* Modifications to reserve space for encrypted filesystem supportqemx132016-08-241-1/+37
| | | | | | Original patch by Motorola modified for lollipop Change-Id: Ie77467a11c6b50d51c67d63644677caec7959031
* mkfs.f2fs: support large sector sizeChao Yu2015-03-231-9/+5
| | | | | | | | | | | | | | | | | | | | | | | 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>
* fsck.f2fs: readahead node blocks to speed upJaegeuk Kim2015-03-231-0/+14
| | | | | | This patch adds readahead system call to speed up node block reads. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* mkfs.f2fs: introduce some macros to simplify coding styleChangman Lee2015-03-231-0/+1
| | | | | | | | | | | | | | | 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>
* fsck.f2fs: trigger fsck.f2fs when new change was madeJaegeuk Kim2015-03-232-0/+25
| | | | | | | 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>
* mkfs.f2fs: possible endianes bug in mkfs.f2fs roll-forward speedjoerg jungermann2014-11-071-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* fsck.f2fs: fix inode block inconsistencyJaegeuk Kim2014-09-081-0/+5
| | | | | | This patch is to fix inode block inconsistency such as iblocks and ilinks. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* f2fs_dentry_hash: avoid casting unsigned char to singed charJaegeuk Kim2014-09-081-19/+12
| | | | | | This can hurt when calculating hash value, resulting in false alarm. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
* dump.f2fs: support dump_file from imageJaegeuk Kim2014-09-081-0/+9
| | | | | | | | 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>
* libf2fs: move the finalize_device() into the io lib.JP Abgrall2014-06-132-12/+13
| | | | | | | | | | | 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>
* libf2fs, fsck, mkfs: call f2fs_finalize_device before exitJaegeuk Kim2014-06-131-0/+12
| | | | | | | | 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
* mkfs: support passing in the number of sectors to useJP Abgrall2014-06-121-0/+7
| | | | | | | | | | 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>
* fsck.f2fs: large volume supportChangman Lee2014-06-121-2/+2
| | | | | | | | 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>
* f2fs-tools: announce dual licenses with GPL and LGPL v2Jaegeuk Kim2014-06-052-6/+2
| | | | | | | | | | | | | 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>
* Cleanup various build warnings (signed vs unsigned, unused vars,...)JP Abgrall2014-05-142-3/+1
| | | | | | | | | | | | | | | | | * 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>
* format: add support for dev_fill() and extra dev_*() debugging.JP Abgrall2014-04-071-0/+12
| | | | | | | | | | 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>
* further split up lib2fs so that it does not do any IO directly.JP Abgrall2014-04-073-33/+61
| | | | | | | 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>
* f2fs-tools: discard is default but not set in configChangman Lee2013-09-031-0/+1
| | | | | | | | 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>
* fsck, lib: support inline xattrJaegeuk Kim2013-08-201-0/+7
| | | | | | This patch adjusts the modification to handle inline xattrs. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
* libf2fs: check more conditions on mounted filesystemJaegeuk Kim2013-08-021-16/+44
| | | | | | | | | 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>
* f2fs-tools: add option to display directory treeChangman Lee2013-07-301-0/+70
| | | | | | | | | | | | | | | | | | 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>
* libf2fs: add an error message for a mounted deviceJaegeuk Kim2013-07-301-0/+1
| | | | | | We need to notify the mounted device. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
* f2fs-tools: add fsck.f2fs and dump.f2fsChangman Lee2013-07-041-2/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* mkfs: handle labels longer than 16 charactersMike Fleetwood2013-04-041-2/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* mkfs: default to blank labelMike Fleetwood2013-04-041-6/+1
| | | | | Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
* mkfs: fix to avoid format of device when already mountedNamjae Jeon2013-04-041-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* build: clean up the base functionsJaegeuk Kim2013-04-041-10/+25
| | | | Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
* build: make several base functions as a libraryJaegeuk Kim2013-04-042-0/+254
Let's make a library and relocate functions for other tools like fsck.f2fs. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>