fscrypt: remove fscrypt_operations::max_namelen
authorEric Biggers <ebiggers@google.com>
Thu, 9 Sep 2021 18:45:13 +0000 (11:45 -0700)
committerEric Biggers <ebiggers@google.com>
Tue, 21 Sep 2021 02:32:33 +0000 (19:32 -0700)
The max_namelen field is unnecessary, as it is set to 255 (NAME_MAX) on
all filesystems that support fscrypt (or plan to support fscrypt).  For
simplicity, just use NAME_MAX directly instead.

Link: https://lore.kernel.org/r/20210909184513.139281-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/fname.c
fs/ext4/super.c
fs/f2fs/super.c
fs/ubifs/crypto.c
include/linux/fscrypt.h

index eb538c28df940d207c810e8aaf4479a17894f6e2..a9be4bc74a94a02342ce0e1309fb0567605379c1 100644 (file)
@@ -429,8 +429,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
 
        if (fscrypt_has_encryption_key(dir)) {
                if (!fscrypt_fname_encrypted_size(&dir->i_crypt_info->ci_policy,
-                                                 iname->len,
-                                                 dir->i_sb->s_cop->max_namelen,
+                                                 iname->len, NAME_MAX,
                                                  &fname->crypto_buf.len))
                        return -ENAMETOOLONG;
                fname->crypto_buf.name = kmalloc(fname->crypto_buf.len,
index 0775950ee84e311980d29fb8fca95385cb8e10ff..f37e64f72b5d89396e51f788b7532efb04627668 100644 (file)
@@ -1566,7 +1566,6 @@ static const struct fscrypt_operations ext4_cryptops = {
        .set_context            = ext4_set_context,
        .get_dummy_policy       = ext4_get_dummy_policy,
        .empty_dir              = ext4_empty_dir,
-       .max_namelen            = EXT4_NAME_LEN,
        .has_stable_inodes      = ext4_has_stable_inodes,
        .get_ino_and_lblk_bits  = ext4_get_ino_and_lblk_bits,
 };
index 78ebc306ee2b544f159c5d7e872388930c8f35f5..cf049a042482b90efc3f0f26d64ef455982f29fa 100644 (file)
@@ -2976,7 +2976,6 @@ static const struct fscrypt_operations f2fs_cryptops = {
        .set_context            = f2fs_set_context,
        .get_dummy_policy       = f2fs_get_dummy_policy,
        .empty_dir              = f2fs_empty_dir,
-       .max_namelen            = F2FS_NAME_LEN,
        .has_stable_inodes      = f2fs_has_stable_inodes,
        .get_ino_and_lblk_bits  = f2fs_get_ino_and_lblk_bits,
        .get_num_devices        = f2fs_get_num_devices,
index 22be7aeb96c4fe121b6963888de66408f972c86c..c57b46a352d8fd6637f2e51256e093f364161034 100644 (file)
@@ -82,5 +82,4 @@ const struct fscrypt_operations ubifs_crypt_operations = {
        .get_context            = ubifs_crypt_get_context,
        .set_context            = ubifs_crypt_set_context,
        .empty_dir              = ubifs_crypt_empty_dir,
-       .max_namelen            = UBIFS_MAX_NLEN,
 };
index e912ed9141d9dfbb4b091dd6d86e37e9f72df37a..91ea9477e9bd21c8b87fcc19f138caa42841f5a6 100644 (file)
@@ -118,9 +118,6 @@ struct fscrypt_operations {
         */
        bool (*empty_dir)(struct inode *inode);
 
-       /* The filesystem's maximum ciphertext filename length, in bytes */
-       unsigned int max_namelen;
-
        /*
         * Check whether the filesystem's inode numbers and UUID are stable,
         * meaning that they will never be changed even by offline operations