git: a04aa80e773a - main - lindebugfs: Add `debugfs_create_file_size()`

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Wed, 25 Jan 2023 22:27:35 UTC
The branch main has been updated by dumbbell (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=a04aa80e773a4bfdc4e72bab85d6e16f0083745e

commit a04aa80e773a4bfdc4e72bab85d6e16f0083745e
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2022-12-30 09:57:49 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2023-01-25 22:23:16 +0000

    lindebugfs: Add `debugfs_create_file_size()`
    
    This is the same as `debugfs_create_file()` but takes the initial size
    of the file. In FreeBSD, the given size is ignored and
    `debugfs_create_file()` is called.
    
    Reviewed by:    emaste, manu
    Approved by:    manu
    Differential Revision:  https://reviews.freebsd.org/D37914
---
 sys/compat/lindebugfs/lindebugfs.c                 | 11 +++++++++++
 sys/compat/linuxkpi/common/include/linux/debugfs.h |  8 +++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c
index 8e878b1cd446..168d591625f2 100644
--- a/sys/compat/lindebugfs/lindebugfs.c
+++ b/sys/compat/lindebugfs/lindebugfs.c
@@ -213,6 +213,16 @@ debugfs_create_file(const char *name, umode_t mode,
 	return (dnode);
 }
 
+struct dentry *
+debugfs_create_file_size(const char *name, umode_t mode,
+    struct dentry *parent, void *data,
+    const struct file_operations *fops,
+    loff_t file_size __unused)
+{
+
+	return debugfs_create_file(name, mode, parent, data, fops);
+}
+
 /*
  * NOTE: Files created with the _unsafe moniker will not be protected from
  * debugfs core file removals. It is the responsibility of @fops to protect
@@ -228,6 +238,7 @@ debugfs_create_file_unsafe(const char *name, umode_t mode,
     struct dentry *parent, void *data,
     const struct file_operations *fops)
 {
+
 	return (debugfs_create_file(name, mode, parent, data, fops));
 }
 
diff --git a/sys/compat/linuxkpi/common/include/linux/debugfs.h b/sys/compat/linuxkpi/common/include/linux/debugfs.h
index 074f709114eb..abda2d149582 100644
--- a/sys/compat/linuxkpi/common/include/linux/debugfs.h
+++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h
@@ -56,8 +56,14 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
     struct dentry *parent, void *data,
     const struct file_operations *fops);
 
-struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
+/* TODO: We currently ignore the `file_size` argument. */
+struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
     struct dentry *parent, void *data,
+    const struct file_operations *fops,
+    loff_t file_size);
+
+struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
+struct dentry *parent, void *data,
     const struct file_operations *fops);
 
 struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode,