Skip to contentSkip to conversation

fscrypt: constify struct fscrypt_operations

PATCH Superseded Eric Biggers 3 participants 6 messages Jan 5, 2017 – Feb 8, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fscrypt: constify struct fscrypt_operations

From: Eric Biggers <[email protected]>

---
 fs/ext4/super.c   | 4 ++--
 fs/f2fs/super.c   | 4 ++--
 fs/ubifs/crypto.c | 2 +-
 fs/ubifs/super.c  | 2 +-
 fs/ubifs/ubifs.h  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/super.c +2 -2
index 66845a08a87a..2358714bbc33 100644
@@ -1179,7 +1179,7 @@ static unsigned ext4_max_namelen(struct inode *inode)
 		EXT4_NAME_LEN;
 }
 
-static struct fscrypt_operations ext4_cryptops = {
+static const struct fscrypt_operations ext4_cryptops = {
 	.get_context		= ext4_get_context,
 	.key_prefix		= ext4_key_prefix,
 	.prepare_context	= ext4_prepare_context,
@@ -1190,7 +1190,7 @@ static struct fscrypt_operations ext4_cryptops = {
 	.max_namelen		= ext4_max_namelen,
 };
 #else
-static struct fscrypt_operations ext4_cryptops = {
+static const struct fscrypt_operations ext4_cryptops = {
 	.is_encrypted		= ext4_encrypted_inode,
 };
 #endif
fs/f2fs/super.c +2 -2
index 702638e21c76..30198e5bdf26 100644
@@ -1176,7 +1176,7 @@ static unsigned f2fs_max_namelen(struct inode *inode)
 			inode->i_sb->s_blocksize : F2FS_NAME_LEN;
 }
 
-static struct fscrypt_operations f2fs_cryptops = {
+static const struct fscrypt_operations f2fs_cryptops = {
 	.get_context	= f2fs_get_context,
 	.key_prefix	= f2fs_key_prefix,
 	.set_context	= f2fs_set_context,
@@ -1185,7 +1185,7 @@ static struct fscrypt_operations f2fs_cryptops = {
 	.max_namelen	= f2fs_max_namelen,
 };
 #else
-static struct fscrypt_operations f2fs_cryptops = {
+static const struct fscrypt_operations f2fs_cryptops = {
 	.is_encrypted	= f2fs_encrypted_inode,
 };
 #endif
fs/ubifs/crypto.c +1 -1
index 3402720f2b28..182419b245e7 100644
@@ -86,7 +86,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 	return 0;
 }
 
-struct fscrypt_operations ubifs_crypt_operations = {
+const struct fscrypt_operations ubifs_crypt_operations = {
 	.flags			= FS_CFLG_OWN_PAGES,
 	.get_context		= ubifs_crypt_get_context,
 	.set_context		= ubifs_crypt_set_context,
fs/ubifs/super.c +1 -1
index e08aa04fc835..b73811bd7676 100644
@@ -2000,7 +2000,7 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
 }
 
 #ifndef CONFIG_UBIFS_FS_ENCRYPTION
-struct fscrypt_operations ubifs_crypt_operations = {
+const struct fscrypt_operations ubifs_crypt_operations = {
 	.is_encrypted		= __ubifs_crypt_is_encrypted,
 };
 #endif
fs/ubifs/ubifs.h +1 -1
index ca72382ce6cc..15f1d1f129b6 100644
@@ -1842,7 +1842,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 		  unsigned int *out_len, int block);
 #endif
 
-extern struct fscrypt_operations ubifs_crypt_operations;
+extern const struct fscrypt_operations ubifs_crypt_operations;
 
 static inline bool __ubifs_crypt_is_encrypted(struct inode *inode)
 {
Signature · 1 line
2.11.0.390.gc69c2f50cf-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 05.01.2017 um 21:42 schrieb Eric Biggers:

Quoted 10 lines

From: Eric Biggers <[email protected]>

---
 fs/ext4/super.c   | 4 ++--
 fs/f2fs/super.c   | 4 ++--
 fs/ubifs/crypto.c | 2 +-
 fs/ubifs/super.c  | 2 +-
 fs/ubifs/ubifs.h  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

Eric, I assume you did also a build test with UBIFS enabled, right? Constifying stuff often looks easy but can uncover horrors. ;D

Thanks,
//richard

#2 lore raw
Quoted 12 lines · Richard Weinberger

Am 05.01.2017 um 21:42 schrieb Eric Biggers:

Quoted 10 lines

From: Eric Biggers <[email protected]>

---
 fs/ext4/super.c   | 4 ++--
 fs/f2fs/super.c   | 4 ++--
 fs/ubifs/crypto.c | 2 +-
 fs/ubifs/super.c  | 2 +-
 fs/ubifs/ubifs.h  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)
Quoted 5 lines

Eric, I assume you did also a build test with UBIFS enabled, right? Constifying stuff often looks easy but can uncover horrors. ;D

Yes, I compiled with ext4, f2fs, and ubifs enabled, both with and without encryption enabled for each filesystem.

Eric

#3 lore raw
In reply to Eric Biggers
Quoted 11 lines · Eric Biggers

From: Eric Biggers <[email protected]>

---
 fs/ext4/super.c   | 4 ++--
 fs/f2fs/super.c   | 4 ++--
 fs/ubifs/crypto.c | 2 +-
 fs/ubifs/super.c  | 2 +-
 fs/ubifs/ubifs.h  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

Ted, are you interested in taking this patch? If you'd like I can resend to fix the conflict with the ->key_prefix change.

Eric

#4 lore raw

PATCH v2 1/1 fscrypt: constify struct fscrypt_operations

From: Eric Biggers <[email protected]>

[v2: fix conflict with .key_prefix change]

---
 fs/ext4/super.c   | 4 ++--
 fs/f2fs/super.c   | 4 ++--
 fs/ubifs/crypto.c | 2 +-
 fs/ubifs/super.c  | 2 +-
 fs/ubifs/ubifs.h  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/super.c +2 -2
index 9d15a6293124..20539c2cd6d8 100644
@@ -1173,7 +1173,7 @@ static unsigned ext4_max_namelen(struct inode *inode)
 		EXT4_NAME_LEN;
 }
 
-static struct fscrypt_operations ext4_cryptops = {
+static const struct fscrypt_operations ext4_cryptops = {
 	.key_prefix		= "ext4:",
 	.get_context		= ext4_get_context,
 	.prepare_context	= ext4_prepare_context,
@@ -1184,7 +1184,7 @@ static struct fscrypt_operations ext4_cryptops = {
 	.max_namelen		= ext4_max_namelen,
 };
 #else
-static struct fscrypt_operations ext4_cryptops = {
+static const struct fscrypt_operations ext4_cryptops = {
 	.is_encrypted		= ext4_encrypted_inode,
 };
 #endif
fs/f2fs/super.c +2 -2
index 739192d95e71..24f40197eb00 100644
@@ -1170,7 +1170,7 @@ static unsigned f2fs_max_namelen(struct inode *inode)
 			inode->i_sb->s_blocksize : F2FS_NAME_LEN;
 }
 
-static struct fscrypt_operations f2fs_cryptops = {
+static const struct fscrypt_operations f2fs_cryptops = {
 	.key_prefix	= "f2fs:",
 	.get_context	= f2fs_get_context,
 	.set_context	= f2fs_set_context,
@@ -1179,7 +1179,7 @@ static struct fscrypt_operations f2fs_cryptops = {
 	.max_namelen	= f2fs_max_namelen,
 };
 #else
-static struct fscrypt_operations f2fs_cryptops = {
+static const struct fscrypt_operations f2fs_cryptops = {
 	.is_encrypted	= f2fs_encrypted_inode,
 };
 #endif
fs/ubifs/crypto.c +1 -1
index 6335abcf98df..382ed428cfd2 100644
@@ -77,7 +77,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 	return 0;
 }
 
-struct fscrypt_operations ubifs_crypt_operations = {
+const struct fscrypt_operations ubifs_crypt_operations = {
 	.flags			= FS_CFLG_OWN_PAGES,
 	.key_prefix		= "ubifs:",
 	.get_context		= ubifs_crypt_get_context,
fs/ubifs/super.c +1 -1
index e08aa04fc835..b73811bd7676 100644
@@ -2000,7 +2000,7 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
 }
 
 #ifndef CONFIG_UBIFS_FS_ENCRYPTION
-struct fscrypt_operations ubifs_crypt_operations = {
+const struct fscrypt_operations ubifs_crypt_operations = {
 	.is_encrypted		= __ubifs_crypt_is_encrypted,
 };
 #endif
fs/ubifs/ubifs.h +1 -1
index d9df379bacc6..f0c86f076535 100644
@@ -1824,7 +1824,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 		  unsigned int *out_len, int block);
 #endif
 
-extern struct fscrypt_operations ubifs_crypt_operations;
+extern const struct fscrypt_operations ubifs_crypt_operations;
 
 static inline bool __ubifs_crypt_is_encrypted(struct inode *inode)
 {
Signature · 1 line
2.11.0.483.g087da7b7c-goog