diff options
author | Qu Wenruo <quwenruo.btrfs@gmx.com> | 2017-09-04 12:43:19 +0900 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-09-08 16:15:05 +0200 |
commit | 081e4e9bb83283a7fa38c13da589e103f01e5f7d (patch) | |
tree | 0ccb66418ccbed9ca283d14489bd4725536ab905 /mkfs/main.c | |
parent | 944e14da14af9e292c7fbd7a006bb4b556ac6766 (diff) |
btrfs-progs: mkfs: Fix wrong file type for dir items and indexes when specifying root directory
[Bug]
If using mkfs.btrfs with "-r" parameter and specified directory has
fifo/socket/char/block special file, then created filesystem can't pass
fsck:
------
checking fs roots
unresolved ref dir 241158 index 3 namelen 9 name S.dirmngr filetype 0 errors 80, filetype mismatch
ERROR: errors found in fs roots
------
[Reason]
Btrfs dir items/indexes records inode type, while "-r" only handles
directories, regular files and symlink, it makes such special files type
to be regular file and caused the problem.
[Fix]
Add missing types for add_directory_items(), so that result of
"mkfs.btrfs -r" can pass mkfs.
Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs/main.c')
-rw-r--r-- | mkfs/main.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mkfs/main.c b/mkfs/main.c index f4952581..7592c1fb 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -436,6 +436,14 @@ static int add_directory_items(struct btrfs_trans_handle *trans, filetype = BTRFS_FT_REG_FILE; if (S_ISLNK(st->st_mode)) filetype = BTRFS_FT_SYMLINK; + if (S_ISSOCK(st->st_mode)) + filetype = BTRFS_FT_SOCK; + if (S_ISCHR(st->st_mode)) + filetype = BTRFS_FT_CHRDEV; + if (S_ISBLK(st->st_mode)) + filetype = BTRFS_FT_BLKDEV; + if (S_ISFIFO(st->st_mode)) + filetype = BTRFS_FT_FIFO; ret = btrfs_insert_dir_item(trans, root, name, name_len, parent_inum, &location, |