The immutable bit disallows selinux permission which gives no way to clear it.
Fixes: 8cc4e257ec ("mkfs.f2fs: add device aliasing feature")
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
F2FS_BLKSIZE and 4096 are both used in f2fs_io for
IO/buffer size, but F2FS_BLKSIZE may confuse user becasue
it may be 4KB, 16KB, so use macro F2FS_DEFAULT_BLKSIZE
to unify F2FS_BLKSIZE and 4096 in f2fs_io, also adjust
"-c" parameters in mkfs man, to be consistent with commit
c35fa8cd75 ("mkfs.f2fs: change -c option description").
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When formatting conventional partition with zoned one, we are already
aligning the starting block address of the next device to the zone size.
Therefore, we do not align the segment0 address to the zone alignment.
This reduces the wasted zone_align_start_offset.
Test result
segment0 blkaddr 389583 -> 119251
Add one additional section to main
Signed-off-by: Yohan Joung <yohan.joung@sk.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If dot or dotdot is lost, fsck tries to add a new dentry by
f2fs_add_link(). The blkaddr of the directory inode should be
passed to it in order to update the dirty inode at the right
place. This patch fixes the uninitialized `blkaddr' to avoid
corrupting f2fs image.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The existing bool definition is broken for c23, where bool is now a keyword.
Signed-off-by: Elliott Hughes <enh@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Hand over immutable flag clearing functionality from setflags to
clearflags, since the flag name is immutable rather than noimmutable.
And support setting functionality in subcommand setflags.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We can add a device aliasing file which can map the whole device with an
extent, not using node blocks. This mapped area should be pinned and
normally used for read-only usages. After finished using it, we can
deallocate the whole area and return it back to use it for other files.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Current description confuses users like they can add addtional devices
with one -c option using commas(,) at the same time.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables support for write hints by segment type.
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Removed a redundant code to set i_ext.len to zero.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Previously, once fsck.f2fs detects that directory missed '.' or
'..' dirent, it tags inode w/ F2FS_INLINE_DOTS flag, and expects
f2fs kernel module can repaire it online during it runs to lookup()
on target directory.
This patch abandons previous implementation, and do repaires directly.
Reviewed-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If there are double '.' or '..' dirents in directory, fsck.f2fs won't
detect and repaire the issue correctly, fix it.
Reviewed-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The conversion between cpu and little endian is incorrect.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting dentry block or dir entry.
print_raw_dentry_info() is added to show values of node footer.
The meanings of options are:
* dent: means dentry is injected.
The members could be injected in cp contains:
* d_bitmap: dentry block d_bitmap of nid
* d_hash: dentry hash
* d_ino: dentry ino
* d_ftype: dentry ftype
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If overprov_segment_count < rsvd_segment_count will
set_cp(overprov_segment_count) twice, reduce it.
Signed-off-by: zhangxirui <xirui.zhang@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Should finish zones if they are open.
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The cp_ver of node footer is useful when analyzing data corruption
issues.
Signed-off-by: Wu Bo <bo.wu@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The path field in c.devices[i] is a pointer and is normally filled
in using strdup. This makes it invalid to copy MAX_PATH_LEN bytes
from it because the string may be shorter than that. Therefore,
fix the code to use strncpy to copy the string instead.
Signed-off-by: Peter Collingbourne <pcc@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting summary block or summary entry.
print_raw_sum_entry_info() and print_sum_footer_info() are added to show
values of the ssa entry and summary footer.
The meanings of options are:
* ssa: means ssa entry is injected.
The members could be injected in cp contains:
* entry_type: summary block footer entry_type
* check_sum: summary block footer check_sum
* nid: summary entry nid
* version: summary entry version
* ofs_in_node: summary entry ofs_in_node
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting sit entry. print_raw_sit_entry_info() is
added to show values of the sit entry.
The meanings of options are:
* sit: means sit entry is injected, its argument chooses which sit pack
to be injected, where 0 means the current valid sit is choosen
automatically.
* blk: is the block address of the sit entry.
The members could be injected in cp contains:
* vblocks: sit entry vblocks
* valid_map: sit entry valid_map
* mtime: sit entry mtime
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting nat entry. print_raw_nat_entry_info() is
added to show values of the nat entry.
The meanings of options are:
* nat: means nat entry is injected, its argument chooses which nat pack
to be injected, where 0 means the current valid nat is choosen
automatically.
* nid: is the nid of the nat entry
The members could be injected in cp contains:
* version: nat entry version
* ino: nat entry ino
* block_addr: nat entry block_addr
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting checkpoint. To archive this, a helper
write_raw_cp_blocks() is added to write the first and last blocks
of a specific cp. And print_ckpt_info() is exported to show new
checkpoint info.
The meanings of options are:
* cp: means cp is injected, its argument chooses which cp pack to be
injected, where 0 means the current valid cp is choosen
automatically.
The members could be injected in cp contains:
* checkpoint_ver: checkpoint version
* ckpt_flags: checkpoint flags
* cur_node_segno: cur_node_segno array
* cur_node_blkoff: cur_node_blkoff array
* cur_data_segno: cur_data_segno array
* cur_data_blkoff: cur_data_blkoff array
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch enables injecting super block.
The meanings of options are:
* sb: means sb is injected, its argument chooses which sb pack to be
injected, where 0 means the current valid sb is choosen
automatically.
* mb: indicates which member in sb is injected, its argument is the
member name.
* idx: is used when the mb is an array, its argument is the index of
the array.
* val: is the new value to be set when the type of mb is a number.
* str: is the new value to be set when the type of mb is a string.
The members could be injected in sb contains:
* magic: magic number
* s_stop_reason: s_stop_reason array
* s_errors: s_errors array
* devs.path: path in devs array
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch introduces a new tool inject.f2fs to modify metadata or data
(directory entry) of f2fs image offline flexibly.
With inject.f2fs, it is easier to generate a corrupted f2fs image, which
can help verify fsck or reproduce userspace behaviors of some a fault.
If option `--dry-run' is used, nothing really gets changed, and that
could be used to get the value of a specified field.
The following patches enable injecting each part of f2fs.
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Remove redundant function definition of is_sit_bitmap_set() and
export it.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
For zoned model, the first device (devices[0]) is not zoned device,
whose zoned_model is not F2FS_ZONED_HM. Let's skip it and check write
pointer of left devices continuously.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If a superblock failed in sanity check, it should be fixed. This patch
add a new state `sb_invalid' to tell fsck needs to update superblock
at the end of all checkings.
This patch also cleans up force_stop, abnormal_stop, fs_errors and
sb_invalid by merging them into an `invalid_sb' flags, and each of
them is indicated using one bit.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Introduce a new help addrs_per_page() to wrap common code
from addrs_per_inode() and addrs_per_block() for cleanup.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch fixes some cases in where we missed to consider
endianness when we access/update inode.i_flags.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Quoted from manual of chattr:
"
CHATTR(1)
...
ATTRIBUTES
A file with the 'd' attribute set is not a candidate for backup when
the dump(8) program is run.
"
Once we set F2FS_NODUMP_FL flag to inode, do not allow dumping info
from it.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
BLKFINISHZONE may not defined in old blkzoned.h, and cause build error.
Signed-off-by: Wu Bo <bo.wu@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Previously, dumped symlinks would always create regular files instead.
This allows symlinks to be dumped as symlinks with the -L option.
The i_name field's name may not be the same as the actual name from the
dirent, so we use the dirent name when available.
Currently hardlinks aren't detected, so print a warning if we notice a
nondirectory with a link count over 1.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When using the f2fs_io tool to set_verity, it will fail as follows:
unisc:/data # ./f2fs_io set_verity file
FS_IOC_ENABLE_VERITY: Inappropriate ioctl for device
this is because commit: 95ae251fe828 ("f2fs: add fs-verity support"),
the passed parameters do not match the latest kernel version.
After patch:
unisoc:/data # ./f2fs_io set_verity file
Set fsverity bit to file
unisoc:/data # ./f2fs_io getflags file
get a flag on file ret=0, flags=verity
Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If input exceeds int range, data will be truncated, such as lseek:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=2147483647
The offset is truncated.
After patch:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=3221225000
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The code for dumping files was ignoring i_extra_isize, leading to
invalid data for some inlined files after dumping. This swaps inode
dumping to use the common inline_data_addr function.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>