BTRFS: Added function to convert standard filetypes to btrfs filetypes.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
hyche 2017-08-27 05:18:04 +07:00 committed by Augustin Cavalier
parent 2b6c2ec390
commit 02bce792d8
2 changed files with 37 additions and 0 deletions

View File

@ -22,6 +22,32 @@ enum inode_type {
};
inline uint8
get_filetype(int32 mode)
{
mode &= S_IFMT;
switch (mode)
{
case S_IFSOCK:
return BTRFS_FILETYPE_SOCKET;
case S_IFLNK:
return BTRFS_FILETYPE_SYMLINK;
case S_IFREG:
return BTRFS_FILETYPE_REGULAR;
case S_IFBLK:
return BTRFS_FILETYPE_BLKDEV;
case S_IFDIR:
return BTRFS_FILETYPE_DIRECTORY;
case S_IFCHR:
return BTRFS_FILETYPE_CHRDEV;
case S_IFIFO:
return BTRFS_FILETYPE_FIFO;
default:
return BTRFS_FILETYPE_UNKNOWN;
}
}
/*! Converts the open mode, the open flags given to bfs_open(), into
access modes, e.g. since O_RDONLY requires read access to the
file, it will be converted to R_OK.

View File

@ -475,6 +475,17 @@ struct btrfs_extent_data_ref {
#define BTRFS_BLOCKGROUP_FLAG_RAID6 256
#define BTRFS_BLOCKGROUP_FLAG_MASK 511
// d_type in struct dirent
#define BTRFS_FILETYPE_UNKNOWN 0
#define BTRFS_FILETYPE_REGULAR 1
#define BTRFS_FILETYPE_DIRECTORY 2
#define BTRFS_FILETYPE_CHRDEV 3 // character device
#define BTRFS_FILETYPE_BLKDEV 4 // block device
#define BTRFS_FILETYPE_FIFO 5 // fifo device
#define BTRFS_FILETYPE_SOCKET 6
#define BTRFS_FILETYPE_SYMLINK 7
#define BTRFS_FILETYPE_XATTR 8 // ondisk but not user-visible
struct file_cookie {
bigtime_t last_notification;