Skip to contentSkip to conversation

debufgs: debugfs_create_blob can set the file size

PATCH In review Timur Tabi 2 participants 2 messages Feb 7, 2024 – Mar 7, 2024

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v2 1/1 debufgs: debugfs_create_blob can set the file size

debugfs_create_blob() is given the size of the blob, so use it to also set the size of the dentry. For example, efi=debug previously showed

-r-------- 1 root root 0 Feb  7 13:30 boot_services_code0
-r-------- 1 root root 0 Feb  7 13:30 boot_services_code1
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data0
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data1
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data2
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data3
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data4

but with this patch it shows

-r-------- 1 root root  12783616 Feb  7 13:26 boot_services_code0
-r-------- 1 root root    262144 Feb  7 13:26 boot_services_code1
-r-------- 1 root root  41705472 Feb  7 13:26 boot_services_data0
-r-------- 1 root root  23187456 Feb  7 13:26 boot_services_data1
-r-------- 1 root root 110645248 Feb  7 13:26 boot_services_data2
-r-------- 1 root root   1048576 Feb  7 13:26 boot_services_data3
-r-------- 1 root root      4096 Feb  7 13:26 boot_services_data4
---
 fs/debugfs/file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/debugfs/file.c +8 -1
index c6f4a9a98b85..848deff11b7e 100644
@@ -1152,7 +1152,14 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
 				   struct dentry *parent,
 				   struct debugfs_blob_wrapper *blob)
 {
-	return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob);
+	struct dentry *dentry;
+
+	dentry = debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob);
+	if (!IS_ERR(dentry))
+		i_size_write(d_inode(dentry), blob->size);
+
+	return dentry;
+
 }
 EXPORT_SYMBOL_GPL(debugfs_create_blob);
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 50 lines · Timur Tabi

debugfs_create_blob() is given the size of the blob, so use it to also set the size of the dentry. For example, efi=debug previously showed

(quoted diff) +0 -7
-r-------- 1 root root 0 Feb  7 13:30 boot_services_code0
-r-------- 1 root root 0 Feb  7 13:30 boot_services_code1
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data0
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data1
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data2
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data3
-r-------- 1 root root 0 Feb  7 13:30 boot_services_data4

but with this patch it shows

(quoted diff) +0 -7
-r-------- 1 root root  12783616 Feb  7 13:26 boot_services_code0
-r-------- 1 root root    262144 Feb  7 13:26 boot_services_code1
-r-------- 1 root root  41705472 Feb  7 13:26 boot_services_data0
-r-------- 1 root root  23187456 Feb  7 13:26 boot_services_data1
-r-------- 1 root root 110645248 Feb  7 13:26 boot_services_data2
-r-------- 1 root root   1048576 Feb  7 13:26 boot_services_data3
-r-------- 1 root root      4096 Feb  7 13:26 boot_services_data4
---
 fs/debugfs/file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/debugfs/file.c +8 -1
index c6f4a9a98b85..848deff11b7e 100644
@@ -1152,7 +1152,14 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
 				   struct dentry *parent,
 				   struct debugfs_blob_wrapper *blob)
 {
-	return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob);
+	struct dentry *dentry;
+
+	dentry = debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob);
+	if (!IS_ERR(dentry))
+		i_size_write(d_inode(dentry), blob->size);
+
+	return dentry;
+
 }
 EXPORT_SYMBOL_GPL(debugfs_create_blob);
 
Signature · 1 line
2.34.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot