Commit Graph

241 Commits

Author SHA1 Message Date
Jaegeuk Kim
e35b8afb34 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>
2014-04-25 14:07:17 +09:00
JP Abgrall
a35529fce0 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>
2014-04-07 12:14:32 +09:00
JP Abgrall
af3c6803bd 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>
2014-04-07 12:13:51 +09:00
Dongho Sim
2f229b89a7 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>
2014-04-01 18:56:13 +09:00
Jaegeuk Kim
99250ec1aa 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>
2014-02-27 20:32:09 +09:00
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
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
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
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
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
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
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
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
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
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
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
e1e843d29c build: compile static by default
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-04-04 09:19:19 +09:00
Jaegeuk Kim
5043dffbd1 build: clean up the base functions
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-04-04 09:19:15 +09:00
Jaegeuk Kim
e69e437850 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>
2013-04-04 09:19:07 +09:00
Jaegeuk Kim
40b9f96587 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>
2013-04-04 09:18:55 +09:00
Jaegeuk Kim
d2387723a8 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>
2013-04-04 09:18:34 +09:00
Jan Engelhardt
c7e0a01375 build: place mkfs into sbindir
Filesystem creation utilities have always been in *sbin*.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2012-12-12 04:05:07 +01:00
Jan Engelhardt
fe2928a793 build: use pkgconfig to determine libuuid's parameters
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2012-12-12 03:53:28 +01:00
Ezequiel Garcia
07b815d395 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>
2012-12-12 11:17:34 +09:00
Sven-Göran Bergh
dd1ba078fa 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>
2012-12-07 14:56:27 +09:00
Jaegeuk Kim
8bdf26205d Add version information
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-26 20:04:39 +09:00
Jaegeuk Kim
c6ff6d09de 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>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
bbf6e62360 Cleanup: sync comments to kernel source
Remove unnecessary data fields too.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
4ed75df379 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>
2012-11-26 19:45:59 +09:00
Mike Frysinger
3dd5f8b400 use proper priu64 type to be portable
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
9db27ee071 Cleanup: add comments
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
22a75edd47 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>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
99b7439340 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>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
b5af7953f8 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>
2012-11-26 19:45:59 +09:00
Jaegeuk Kim
036d45e551 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>
2012-11-26 19:45:59 +09:00