From a04aa80e773a4bfdc4e72bab85d6e16f0083745e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Fri, 30 Dec 2022 10:57:49 +0100 Subject: [PATCH] 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,