diff mbox

[v2,2/8] btrfs: rename btrfs_mask_flags to reflect which flags it touches

Message ID e25035869a53c49266de464621a92184546750d5.1525873677.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Sterba May 9, 2018, 1:54 p.m. UTC
The FS_*_FL flags cannot be easily identified by a variable name prefix
but we still need to recognize them so the 'fsflags' should be closer to
the naming scheme but again the 'fs' part sounds like it's a filesystem
flag. I don't have a better idea for now.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Nikolay Borisov May 10, 2018, 6:38 a.m. UTC | #1
On  9.05.2018 16:54, David Sterba wrote:
> The FS_*_FL flags cannot be easily identified by a variable name prefix
> but we still need to recognize them so the 'fsflags' should be closer to
> the naming scheme but again the 'fs' part sounds like it's a filesystem
> flag. I don't have a better idea for now.

Why not using iflags, my reasoning is that the official documentation of
those flags: http://man7.org/linux/man-pages/man2/ioctl_iflags.2.html
refers to them as "inode flags" hence iflags or the slightly longer
inode_flags?

> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/ioctl.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 11edbdf3df7d..e93dc3a6f554 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -93,11 +93,12 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
>  		       int no_time_update);
>  
>  /* Mask out flags that are inappropriate for the given type of inode. */
> -static unsigned int btrfs_mask_flags(umode_t mode, unsigned int flags)
> +static unsigned int btrfs_mask_fsflags_for_type(struct inode *inode,
> +		unsigned int flags)
>  {
> -	if (S_ISDIR(mode))
> +	if (S_ISDIR(inode->i_mode))
>  		return flags;
> -	else if (S_ISREG(mode))
> +	else if (S_ISREG(inode->i_mode))
>  		return flags & ~FS_DIRSYNC_FL;
>  	else
>  		return flags & (FS_NODUMP_FL | FS_NOATIME_FL);
> @@ -218,7 +219,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>  	i_oldflags = inode->i_flags;
>  	mode = inode->i_mode;
>  
> -	flags = btrfs_mask_flags(inode->i_mode, flags);
> +	flags = btrfs_mask_fsflags_for_type(inode, flags);
>  	oldflags = btrfs_flags_to_ioctl(ip->flags);
>  	if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
>  		if (!capable(CAP_LINUX_IMMUTABLE)) {
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba May 10, 2018, 2:11 p.m. UTC | #2
On Thu, May 10, 2018 at 09:38:12AM +0300, Nikolay Borisov wrote:
> On  9.05.2018 16:54, David Sterba wrote:
> > The FS_*_FL flags cannot be easily identified by a variable name prefix
> > but we still need to recognize them so the 'fsflags' should be closer to
> > the naming scheme but again the 'fs' part sounds like it's a filesystem
> > flag. I don't have a better idea for now.
> 
> Why not using iflags, my reasoning is that the official documentation of
> those flags: http://man7.org/linux/man-pages/man2/ioctl_iflags.2.html
> refers to them as "inode flags" hence iflags or the slightly longer
> inode_flags?

The first patch tries to capture the inode flags name for the btrfs
inode ... "The btrfs inode flag flavour is now simply called 'inode
flags'"

The manual page talks only about one ioctl and namespace, but in the
code we have to deal with several. I'm not happy about the naming, but
at least it's obvious which namespace is used.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 11edbdf3df7d..e93dc3a6f554 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -93,11 +93,12 @@  static int btrfs_clone(struct inode *src, struct inode *inode,
 		       int no_time_update);
 
 /* Mask out flags that are inappropriate for the given type of inode. */
-static unsigned int btrfs_mask_flags(umode_t mode, unsigned int flags)
+static unsigned int btrfs_mask_fsflags_for_type(struct inode *inode,
+		unsigned int flags)
 {
-	if (S_ISDIR(mode))
+	if (S_ISDIR(inode->i_mode))
 		return flags;
-	else if (S_ISREG(mode))
+	else if (S_ISREG(inode->i_mode))
 		return flags & ~FS_DIRSYNC_FL;
 	else
 		return flags & (FS_NODUMP_FL | FS_NOATIME_FL);
@@ -218,7 +219,7 @@  static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 	i_oldflags = inode->i_flags;
 	mode = inode->i_mode;
 
-	flags = btrfs_mask_flags(inode->i_mode, flags);
+	flags = btrfs_mask_fsflags_for_type(inode, flags);
 	oldflags = btrfs_flags_to_ioctl(ip->flags);
 	if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
 		if (!capable(CAP_LINUX_IMMUTABLE)) {