ext4: cleanup function defs from ext4.h into crypto.c
Some of these functions when CONFIG_FS_ENCRYPTION is enabled are not really inline (let compiler be the best judge of it). Remove inline and move them into crypto.c where they should be present. Reviewed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Ritesh Harjani <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/b7b9de2c7226298663fb5a0c28909135e2ab220f.1652595565.git.ritesh.list@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
b1241c8eb9
commit
3030b59c85
@ -6,6 +6,71 @@
|
||||
#include "xattr.h"
|
||||
#include "ext4_jbd2.h"
|
||||
|
||||
static void ext4_fname_from_fscrypt_name(struct ext4_filename *dst,
|
||||
const struct fscrypt_name *src)
|
||||
{
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
|
||||
dst->usr_fname = src->usr_fname;
|
||||
dst->disk_name = src->disk_name;
|
||||
dst->hinfo.hash = src->hash;
|
||||
dst->hinfo.minor_hash = src->minor_hash;
|
||||
dst->crypto_buf = src->crypto_buf;
|
||||
}
|
||||
|
||||
int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,
|
||||
int lookup, struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
int err;
|
||||
|
||||
err = fscrypt_setup_filename(dir, iname, lookup, &name);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ext4_fname_from_fscrypt_name(fname, &name);
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
err = ext4_fname_setup_ci_filename(dir, iname, fname);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,
|
||||
struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
int err;
|
||||
|
||||
err = fscrypt_prepare_lookup(dir, dentry, &name);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ext4_fname_from_fscrypt_name(fname, &name);
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
void ext4_fname_free_filename(struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
|
||||
name.crypto_buf = fname->crypto_buf;
|
||||
fscrypt_free_filename(&name);
|
||||
|
||||
fname->crypto_buf.name = NULL;
|
||||
fname->usr_fname = NULL;
|
||||
fname->disk_name.name = NULL;
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
kfree(fname->cf_name.name);
|
||||
fname->cf_name.name = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ext4_get_context(struct inode *inode, void *ctx, size_t len)
|
||||
{
|
||||
return ext4_xattr_get(inode, EXT4_XATTR_INDEX_ENCRYPTION,
|
||||
|
@ -2737,73 +2737,14 @@ extern int ext4_fname_setup_ci_filename(struct inode *dir,
|
||||
#ifdef CONFIG_FS_ENCRYPTION
|
||||
extern const struct fscrypt_operations ext4_cryptops;
|
||||
|
||||
static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst,
|
||||
const struct fscrypt_name *src)
|
||||
{
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,
|
||||
int lookup, struct ext4_filename *fname);
|
||||
|
||||
dst->usr_fname = src->usr_fname;
|
||||
dst->disk_name = src->disk_name;
|
||||
dst->hinfo.hash = src->hash;
|
||||
dst->hinfo.minor_hash = src->minor_hash;
|
||||
dst->crypto_buf = src->crypto_buf;
|
||||
}
|
||||
int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,
|
||||
struct ext4_filename *fname);
|
||||
|
||||
static inline int ext4_fname_setup_filename(struct inode *dir,
|
||||
const struct qstr *iname,
|
||||
int lookup,
|
||||
struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
int err;
|
||||
void ext4_fname_free_filename(struct ext4_filename *fname);
|
||||
|
||||
err = fscrypt_setup_filename(dir, iname, lookup, &name);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ext4_fname_from_fscrypt_name(fname, &name);
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
err = ext4_fname_setup_ci_filename(dir, iname, fname);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int ext4_fname_prepare_lookup(struct inode *dir,
|
||||
struct dentry *dentry,
|
||||
struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
int err;
|
||||
|
||||
err = fscrypt_prepare_lookup(dir, dentry, &name);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ext4_fname_from_fscrypt_name(fname, &name);
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline void ext4_fname_free_filename(struct ext4_filename *fname)
|
||||
{
|
||||
struct fscrypt_name name;
|
||||
|
||||
name.crypto_buf = fname->crypto_buf;
|
||||
fscrypt_free_filename(&name);
|
||||
|
||||
fname->crypto_buf.name = NULL;
|
||||
fname->usr_fname = NULL;
|
||||
fname->disk_name.name = NULL;
|
||||
|
||||
#if IS_ENABLED(CONFIG_UNICODE)
|
||||
kfree(fname->cf_name.name);
|
||||
fname->cf_name.name = NULL;
|
||||
#endif
|
||||
}
|
||||
#else /* !CONFIG_FS_ENCRYPTION */
|
||||
static inline int ext4_fname_setup_filename(struct inode *dir,
|
||||
const struct qstr *iname,
|
||||
|
Loading…
x
Reference in New Issue
Block a user