From: Eric Biggers <hidden> Date: 2017-09-20 22:46:49
From: Eric Biggers <redacted>
This series reduces code duplication among ext4, f2fs, and ubifs by
introducing a S_ENCRYPTED inode flag (so we don't have to call back into
the filesystem to test the filesystem-specific inode flag), then
introducing new helper functions that are called at the beginning of the
open, link, rename, lookup, and setattr operations.
In the future we maybe should even call these new helpers from the VFS
so that each individual filesystem doesn't have to do it. But that's
not possible currently because fs/crypto/ can be built as a module.
Making changes like this is a bit challenging due to interdependencies
between fscrypt and the individual filesystems, all of which have
different maintainers. For now my intent is that patches 1-10 be taken
through the fscrypt tree --- though it's not perfect since patches 1-4
do make some changes to each filesystem, as everyone must set
S_ENCRYPTED before we can use it everywhere in the shared code. But
afterwards, patches 11-25 can be picked up by the individual filesystems
to switch to the new helpers.
Eric Biggers (25):
fs, fscrypt: add an S_ENCRYPTED inode flag
fscrypt: switch from ->is_encrypted() to IS_ENCRYPTED()
fscrypt: remove ->is_encrypted()
fscrypt: remove unneeded empty fscrypt_operations structs
fscrypt: new helper function - fscrypt_require_key()
fscrypt: new helper function - fscrypt_file_open()
fscrypt: new helper function - fscrypt_prepare_link()
fscrypt: new helper function - fscrypt_prepare_rename()
fscrypt: new helper function - fscrypt_prepare_lookup()
fscrypt: new helper function - fscrypt_prepare_setattr()
ext4: switch to fscrypt_file_open()
ext4: switch to fscrypt_prepare_link()
ext4: switch to fscrypt_prepare_rename()
ext4: switch to fscrypt_prepare_lookup()
ext4: switch to fscrypt_prepare_setattr()
f2fs: switch to fscrypt_file_open()
f2fs: switch to fscrypt_prepare_link()
f2fs: switch to fscrypt_prepare_rename()
f2fs: switch to fscrypt_prepare_lookup()
f2fs: switch to fscrypt_prepare_setattr()
ubifs: switch to fscrypt_file_open()
ubifs: switch to fscrypt_prepare_link()
ubifs: switch to fscrypt_prepare_rename()
ubifs: switch to fscrypt_prepare_lookup()
ubifs: switch to fscrypt_prepare_setattr()
fs/crypto/Makefile | 2 +-
fs/crypto/crypto.c | 2 +-
fs/crypto/fname.c | 3 +-
fs/crypto/hooks.c | 112 +++++++++++++++++++++++++++++
fs/crypto/keyinfo.c | 2 +-
fs/crypto/policy.c | 6 +-
fs/ext4/file.c | 23 ++----
fs/ext4/inode.c | 19 +++--
fs/ext4/namei.c | 62 +++++-----------
fs/ext4/super.c | 15 ++--
fs/f2fs/f2fs.h | 1 +
fs/f2fs/file.c | 30 ++------
fs/f2fs/inode.c | 5 +-
fs/f2fs/namei.c | 54 ++++----------
fs/f2fs/super.c | 7 +-
fs/ubifs/crypto.c | 1 -
fs/ubifs/dir.c | 43 ++++-------
fs/ubifs/file.c | 41 ++---------
fs/ubifs/ioctl.c | 5 +-
fs/ubifs/super.c | 8 +--
fs/ubifs/ubifs.h | 9 +--
fs/ubifs/xattr.c | 1 +
include/linux/fs.h | 2 +
include/linux/fscrypt_common.h | 1 -
include/linux/fscrypt_notsupp.h | 54 +++++++++++++-
include/linux/fscrypt_supp.h | 153 ++++++++++++++++++++++++++++++++++++++++
26 files changed, 418 insertions(+), 243 deletions(-)
create mode 100644 fs/crypto/hooks.c
--
2.14.1.821.g8fa685d3b7-goog
From: Eric Biggers <hidden> Date: 2017-09-20 22:46:52
From: Eric Biggers <redacted>
Introduce a flag S_ENCRYPTED which can be set in ->i_flags to indicate
that the inode is encrypted using the fscrypt (fs/crypto/) mechanism.
Checking this flag will give the same information that
inode->i_sb->s_cop->is_encrypted(inode) currently does, but will be more
efficient. This will be useful for adding higher-level helper functions
for filesystems to use. For example we'll be able to replace this:
if (ext4_encrypted_inode(inode)) {
ret = fscrypt_get_encryption_info(inode);
if (ret)
return ret;
if (!fscrypt_has_encryption_key(inode))
return -ENOKEY;
}
with this:
ret = fscrypt_require_key(inode);
if (ret)
return ret;
... since we'll be able to retain the fast path for unencrypted files as
a single flag check, using an inline function. This wasn't possible
before because we'd have had to frequently call through the
->i_sb->s_cop->is_encrypted function pointer, even when the encryption
support was disabled or not being used.
Note: we don't define S_ENCRYPTED to 0 if CONFIG_FS_ENCRYPTION is
disabled because we want to continue to return an error if an encrypted
file is accessed without encryption support, rather than pretending that
it is unencrypted.
Signed-off-by: Eric Biggers <redacted>
---
fs/ext4/inode.c | 7 +++++--
fs/ext4/super.c | 8 ++++++--
fs/f2fs/f2fs.h | 1 +
fs/f2fs/inode.c | 5 ++++-
fs/ubifs/ioctl.c | 5 ++++-
fs/ubifs/xattr.c | 1 +
include/linux/fs.h | 2 ++
7 files changed, 23 insertions(+), 6 deletions(-)
From: Eric Biggers <hidden> Date: 2017-09-20 22:46:54
From: Eric Biggers <redacted>
IS_ENCRYPTED() now gives the same information as
i_sb->s_cop->is_encrypted() but is more efficient, since IS_ENCRYPTED()
is just a simple flag check. Prepare to remove ->is_encrypted() by
switching all callers to IS_ENCRYPTED().
Signed-off-by: Eric Biggers <redacted>
---
fs/crypto/crypto.c | 2 +-
fs/crypto/fname.c | 3 +--
fs/crypto/keyinfo.c | 2 +-
fs/crypto/policy.c | 6 +++---
include/linux/fscrypt_notsupp.h | 2 +-
5 files changed, 7 insertions(+), 8 deletions(-)
@@ -268,7 +268,7 @@ int fscrypt_get_encryption_info(struct inode *inode)res=inode->i_sb->s_cop->get_context(inode,&ctx,sizeof(ctx));if(res<0){if(!fscrypt_dummy_context_enabled(inode)||-inode->i_sb->s_cop->is_encrypted(inode))+IS_ENCRYPTED(inode))returnres;/* Fake up a context for an unencrypted directory */memset(&ctx,0,sizeof(ctx));
@@ -166,11 +166,11 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)return1;/* No restrictions if the parent directory is unencrypted */-if(!cops->is_encrypted(parent))+if(!IS_ENCRYPTED(parent))return1;/* Encrypted directories must not contain unencrypted files */-if(!cops->is_encrypted(child))+if(!IS_ENCRYPTED(child))return0;/*
@@ -97,7 +97,7 @@ static inline int fscrypt_setup_filename(struct inode *dir,conststructqstr*iname,intlookup,structfscrypt_name*fname){-if(dir->i_sb->s_cop->is_encrypted(dir))+if(IS_ENCRYPTED(dir))return-EOPNOTSUPP;memset(fname,0,sizeof(structfscrypt_name));
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Eric Biggers <hidden> Date: 2017-09-20 22:46:56
From: Eric Biggers <redacted>
In the case where a filesystem has been configured without encryption
support, there is no longer any need to initialize ->s_cop at all, since
none of the methods are ever called.
Signed-off-by: Eric Biggers <redacted>
---
fs/ext4/super.c | 5 ++---
fs/f2fs/super.c | 5 ++---
fs/ubifs/super.c | 7 ++-----
3 files changed, 6 insertions(+), 11 deletions(-)
@@ -2054,7 +2049,9 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)sb->s_maxbytes=c->max_inode_sz=MAX_LFS_FILESIZE;sb->s_op=&ubifs_super_operations;sb->s_xattr=ubifs_xattr_handlers;+#ifdef CONFIG_UBIFS_FS_ENCRYPTIONsb->s_cop=&ubifs_crypt_operations;+#endifmutex_lock(&c->umount_mutex);err=mount_ubifs(c);
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Eric Biggers <hidden> Date: 2017-09-20 22:46:57
From: Eric Biggers <redacted>
Add a helper function which checks if an inode is encrypted, and if so,
tries to set up its encryption key. This is a pattern which is
duplicated in multiple places in each of ext4, f2fs, and ubifs --- for
example, when a regular file is asked to be opened or truncated.
Signed-off-by: Eric Biggers <redacted>
---
include/linux/fscrypt_notsupp.h | 8 ++++++++
include/linux/fscrypt_supp.h | 28 ++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Eric Biggers <hidden> Date: 2017-09-20 22:46:58
From: Eric Biggers <redacted>
Add a helper function which prepares to open a regular file which may be
encrypted. It handles setting up the file's encryption key, then
checking that the file's encryption policy matches that of its parent
directory (if the parent directory is encrypted). It may be set as the
->open() method or it can be called from another ->open() method.
Signed-off-by: Eric Biggers <redacted>
---
fs/crypto/Makefile | 2 +-
fs/crypto/hooks.c | 49 +++++++++++++++++++++++++++++++++++++++++
include/linux/fscrypt_notsupp.h | 7 ++++++
include/linux/fscrypt_supp.h | 2 ++
4 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 fs/crypto/hooks.c
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Eric Biggers <hidden> Date: 2017-09-20 22:47:00
From: Eric Biggers <redacted>
Introduce a helper function which prepares to link an inode into a
possibly-encrypted directory. It handles setting up the target
directory's encryption key, then verifying that the link won't violate
the constraint that all files in an encrypted directory tree use the
same encryption policy.
Signed-off-by: Eric Biggers <redacted>
---
fs/crypto/hooks.c | 15 +++++++++++++++
include/linux/fscrypt_notsupp.h | 9 +++++++++
include/linux/fscrypt_supp.h | 29 +++++++++++++++++++++++++++++
3 files changed, 53 insertions(+)
From: Eric Biggers <hidden> Date: 2017-09-20 22:47:01
From: Eric Biggers <redacted>
Introduce a helper function which prepares to rename a file into a
possibly encrypted directory. It handles loading the encryption keys
for the source and target directories if needed, and it handles
enforcing that if the target directory (and the source directory for a
cross-rename) is encrypted, then the file being moved into the directory
has the same encryption policy as its containing directory.
Signed-off-by: Eric Biggers <redacted>
---
fs/crypto/hooks.c | 30 ++++++++++++++++++++++++++++++
include/linux/fscrypt_notsupp.h | 11 +++++++++++
include/linux/fscrypt_supp.h | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+)
From: Eric Biggers <hidden> Date: 2017-09-20 22:47:02
From: Eric Biggers <redacted>
Introduce a helper function which prepares to look up the given dentry
in the given directory. If the directory is encrypted, it handles
loading the directory's encryption key, setting the dentry's ->d_op to
fscrypt_d_ops, and setting DCACHE_ENCRYPTED_WITH_KEY if the directory's
encryption key is available.
Note: once all filesystems switch over to this, we'll be able to move
fscrypt_d_ops and fscrypt_set_encrypted_dentry() to fscrypt_private.h.
Signed-off-by: Eric Biggers <redacted>
---
fs/crypto/hooks.c | 18 ++++++++++++++++++
include/linux/fscrypt_notsupp.h | 9 +++++++++
include/linux/fscrypt_supp.h | 30 ++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Eric Biggers <hidden> Date: 2017-09-20 22:47:03
From: Eric Biggers <redacted>
Introduce a helper function for filesystems to call when processing
->setattr() on a possibly-encrypted inode. It handles enforcing that an
encrypted file can only be truncated if its encryption key is available.
Signed-off-by: Eric Biggers <redacted>
---
include/linux/fscrypt_notsupp.h | 8 ++++++++
include/linux/fscrypt_supp.h | 25 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
@@ -3221,9 +3221,10 @@ static int ext4_link(struct dentry *old_dentry,if(inode->i_nlink>=EXT4_LINK_MAX)return-EMLINK;-if(ext4_encrypted_inode(dir)&&-!fscrypt_has_permitted_context(dir,inode))-return-EPERM;++err=fscrypt_prepare_link(old_dentry,dir,dentry);+if(err)+returnerr;if((ext4_test_inode_flag(dir,EXT4_INODE_PROJINHERIT))&&(!projid_eq(EXT4_I(dir)->i_projid,
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
2.14.1.821.g8fa685d3b7-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: Dave Chinner <david@fromorbit.com> Date: 2017-09-21 06:45:07
On Wed, Sep 20, 2017 at 03:45:40PM -0700, Eric Biggers wrote:
From: Eric Biggers <redacted>
This series reduces code duplication among ext4, f2fs, and ubifs by
introducing a S_ENCRYPTED inode flag (so we don't have to call back into
the filesystem to test the filesystem-specific inode flag), then
introducing new helper functions that are called at the beginning of the
open, link, rename, lookup, and setattr operations.
In the future we maybe should even call these new helpers from the VFS
so that each individual filesystem doesn't have to do it. But that's
not possible currently because fs/crypto/ can be built as a module.
Making changes like this is a bit challenging due to interdependencies
between fscrypt and the individual filesystems, all of which have
different maintainers. For now my intent is that patches 1-10 be taken
through the fscrypt tree --- though it's not perfect since patches 1-4
do make some changes to each filesystem, as everyone must set
S_ENCRYPTED before we can use it everywhere in the shared code. But
afterwards, patches 11-25 can be picked up by the individual filesystems
to switch to the new helpers.
This all looks much nicer. Having just been looking at this stuff,
it makes the code much simpler to understand. So:
Acked-by: Dave Chinner <redacted>
While I'm here, the fscrypt header file includes are clunky and
nasty. I worte a quick patch a couple of days ago to clean it up.
See below....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
fscrypto: clean up include file mess
From: Dave Chinner <redacted>
Filesystems have to include different header files based on whether
they are compiled with encryption support or not. That's nasty and
messy.
Instead, rationalise the headers so we have a single include
fscrypt.h and let it decide what internal implementation to include
based on the __FS_HAS_ENCRYPTION define. Filesystems set
__FS_HAS_ENCRYPTION before including linux/fscrypt.h if they are
built with encryption support.
Add guards to prevent fscrypt_supp.h and fscrypt_notsupp.h from
being directly included by filesystems.
Signed-Off-By: Dave Chinner <redacted>
---
fs/crypto/fscrypt_private.h | 3 +-
fs/ext4/ext4.h | 11 +++----
fs/f2fs/f2fs.h | 8 +++---
fs/ubifs/ubifs.h | 9 +++---
include/linux/{fscrypt_common.h => fscrypt.h} | 41 ++++++++++++++++++---------
include/linux/fscrypt_notsupp.h | 7 +++--
include/linux/fscrypt_supp.h | 7 +++--
7 files changed, 54 insertions(+), 32 deletions(-)
@@ -38,12 +38,13 @@#include<linux/backing-dev.h>#include<linux/security.h>#include<linux/xattr.h>+#include<linux/random.h>+#ifdef CONFIG_UBIFS_FS_ENCRYPTION-#include<linux/fscrypt_supp.h>-#else-#include<linux/fscrypt_notsupp.h>+#define __FS_HAS_ENCRYPTION 1#endif-#include<linux/random.h>+#include<linux/fscrypt.h>+#include"ubifs-media.h"/* Version of this UBIFS implementation */
diff --git a/include/linux/fscrypt_common.h b/include/linux/fscrypt.hsimilarity index 79%rename from include/linux/fscrypt_common.hrename to include/linux/fscrypt.hindex 97f738628b36..4db0a7ec26d9 100644--- a/include/linux/fscrypt_common.h+++ b/include/linux/fscrypt.h
From: Eric Biggers <redacted>
This series reduces code duplication among ext4, f2fs, and ubifs by
introducing a S_ENCRYPTED inode flag (so we don't have to call back into
the filesystem to test the filesystem-specific inode flag), then
introducing new helper functions that are called at the beginning of the
open, link, rename, lookup, and setattr operations.
In the future we maybe should even call these new helpers from the VFS
so that each individual filesystem doesn't have to do it. But that's
not possible currently because fs/crypto/ can be built as a module.
Making changes like this is a bit challenging due to interdependencies
between fscrypt and the individual filesystems, all of which have
different maintainers. For now my intent is that patches 1-10 be taken
through the fscrypt tree --- though it's not perfect since patches 1-4
do make some changes to each filesystem, as everyone must set
S_ENCRYPTED before we can use it everywhere in the shared code. But
afterwards, patches 11-25 can be picked up by the individual filesystems
to switch to the new helpers.
For all patches touching f2fs, looks good to me, feel free to add:
Reviewed-by: Chao Yu <redacted>
Eric Biggers (25):
fs, fscrypt: add an S_ENCRYPTED inode flag
fscrypt: switch from ->is_encrypted() to IS_ENCRYPTED()
fscrypt: remove ->is_encrypted()
fscrypt: remove unneeded empty fscrypt_operations structs
fscrypt: new helper function - fscrypt_require_key()
fscrypt: new helper function - fscrypt_file_open()
fscrypt: new helper function - fscrypt_prepare_link()
fscrypt: new helper function - fscrypt_prepare_rename()
fscrypt: new helper function - fscrypt_prepare_lookup()
fscrypt: new helper function - fscrypt_prepare_setattr()
ext4: switch to fscrypt_file_open()
ext4: switch to fscrypt_prepare_link()
ext4: switch to fscrypt_prepare_rename()
ext4: switch to fscrypt_prepare_lookup()
ext4: switch to fscrypt_prepare_setattr()
f2fs: switch to fscrypt_file_open()
f2fs: switch to fscrypt_prepare_link()
f2fs: switch to fscrypt_prepare_rename()
f2fs: switch to fscrypt_prepare_lookup()
f2fs: switch to fscrypt_prepare_setattr()
ubifs: switch to fscrypt_file_open()
ubifs: switch to fscrypt_prepare_link()
ubifs: switch to fscrypt_prepare_rename()
ubifs: switch to fscrypt_prepare_lookup()
ubifs: switch to fscrypt_prepare_setattr()
fs/crypto/Makefile | 2 +-
fs/crypto/crypto.c | 2 +-
fs/crypto/fname.c | 3 +-
fs/crypto/hooks.c | 112 +++++++++++++++++++++++++++++
fs/crypto/keyinfo.c | 2 +-
fs/crypto/policy.c | 6 +-
fs/ext4/file.c | 23 ++----
fs/ext4/inode.c | 19 +++--
fs/ext4/namei.c | 62 +++++-----------
fs/ext4/super.c | 15 ++--
fs/f2fs/f2fs.h | 1 +
fs/f2fs/file.c | 30 ++------
fs/f2fs/inode.c | 5 +-
fs/f2fs/namei.c | 54 ++++----------
fs/f2fs/super.c | 7 +-
fs/ubifs/crypto.c | 1 -
fs/ubifs/dir.c | 43 ++++-------
fs/ubifs/file.c | 41 ++---------
fs/ubifs/ioctl.c | 5 +-
fs/ubifs/super.c | 8 +--
fs/ubifs/ubifs.h | 9 +--
fs/ubifs/xattr.c | 1 +
include/linux/fs.h | 2 +
include/linux/fscrypt_common.h | 1 -
include/linux/fscrypt_notsupp.h | 54 +++++++++++++-
include/linux/fscrypt_supp.h | 153 ++++++++++++++++++++++++++++++++++++++++
26 files changed, 418 insertions(+), 243 deletions(-)
create mode 100644 fs/crypto/hooks.c
From: Eric Biggers <hidden> Date: 2017-09-21 17:47:08
Hi Dave,
On Thu, Sep 21, 2017 at 04:45:02PM +1000, Dave Chinner wrote:
fscrypto: clean up include file mess
From: Dave Chinner <redacted>
Filesystems have to include different header files based on whether
they are compiled with encryption support or not. That's nasty and
messy.
Instead, rationalise the headers so we have a single include
fscrypt.h and let it decide what internal implementation to include
based on the __FS_HAS_ENCRYPTION define. Filesystems set
__FS_HAS_ENCRYPTION before including linux/fscrypt.h if they are
built with encryption support.
Add guards to prevent fscrypt_supp.h and fscrypt_notsupp.h from
being directly included by filesystems.
This looks good; we probably should have done it that way originally. This will
allow us to have the inline functions like fscrypt_prepare_rename() defined in
fscrypt.h, and then have supp/notsupp versions of __fscrypt_prepare_rename()
instead --- so common checks like for IS_ENCRYPTED() will be in one place only.
One nit:
How about doing
#define __FS_HAS_ENCRYPTION IS_ENABLED(CONFIG_EXT4_FS_ENCRYPTION)
(and likewise for f2fs and ubifs), then checking '#if __FS_HAS_ENCRYPTION'
rather than '#ifdef __FS_HAS_ENCRYPTION'?
Eric
From: Dave Chinner <david@fromorbit.com> Date: 2017-09-21 20:48:19
On Thu, Sep 21, 2017 at 10:47:05AM -0700, Eric Biggers wrote:
Hi Dave,
On Thu, Sep 21, 2017 at 04:45:02PM +1000, Dave Chinner wrote:
quoted
fscrypto: clean up include file mess
From: Dave Chinner <redacted>
Filesystems have to include different header files based on whether
they are compiled with encryption support or not. That's nasty and
messy.
Instead, rationalise the headers so we have a single include
fscrypt.h and let it decide what internal implementation to include
based on the __FS_HAS_ENCRYPTION define. Filesystems set
__FS_HAS_ENCRYPTION before including linux/fscrypt.h if they are
built with encryption support.
Add guards to prevent fscrypt_supp.h and fscrypt_notsupp.h from
being directly included by filesystems.
This looks good; we probably should have done it that way originally. This will
allow us to have the inline functions like fscrypt_prepare_rename() defined in
fscrypt.h, and then have supp/notsupp versions of __fscrypt_prepare_rename()
instead --- so common checks like for IS_ENCRYPTED() will be in one place only.
How about doing
#define __FS_HAS_ENCRYPTION IS_ENABLED(CONFIG_EXT4_FS_ENCRYPTION)
(and likewise for f2fs and ubifs), then checking '#if __FS_HAS_ENCRYPTION'
rather than '#ifdef __FS_HAS_ENCRYPTION'?
Yeah, that's cleaner. I'll modify it and resend as a standalone
patch.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com