aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-10-22 18:07:37 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-11-28 16:30:16 +0000
commitefeb199fc6de3072e21144fd151591507e3eaac2 (patch)
tree3702a0da4dbc4cd6c460fc3f71df0890794e7e6c /sys/compat
parent390fb97e18a65f26f29477557dee53a5d128d459 (diff)
downloadsrc-efeb199fc6de3072e21144fd151591507e3eaac2.tar.gz
src-efeb199fc6de3072e21144fd151591507e3eaac2.zip
LinuxKPI: seq_file add "private" versions.
Add __seq_open_private() and seq_release_private() needed by iwlwifi debugfs support. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37089 (cherry picked from commit b5a81075903b3d97265151960b731210c0e80244)
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/seq_file.h3
-rw-r--r--sys/compat/linuxkpi/common/src/linux_seq_file.c33
2 files changed, 36 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/seq_file.h b/sys/compat/linuxkpi/common/include/linux/seq_file.h
index 9ab5ecce7768..4e7582b7acc2 100644
--- a/sys/compat/linuxkpi/common/include/linux/seq_file.h
+++ b/sys/compat/linuxkpi/common/include/linux/seq_file.h
@@ -71,6 +71,9 @@ struct seq_operations {
ssize_t seq_read(struct linux_file *, char *, size_t, off_t *);
int seq_write(struct seq_file *seq, const void *data, size_t len);
+void *__seq_open_private(struct linux_file *, const struct seq_operations *, int);
+int seq_release_private(struct inode *, struct linux_file *);
+
int seq_open(struct linux_file *f, const struct seq_operations *op);
int seq_release(struct inode *inode, struct linux_file *file);
diff --git a/sys/compat/linuxkpi/common/src/linux_seq_file.c b/sys/compat/linuxkpi/common/src/linux_seq_file.c
index ed23bf8d010f..3ac8315a425f 100644
--- a/sys/compat/linuxkpi/common/src/linux_seq_file.c
+++ b/sys/compat/linuxkpi/common/src/linux_seq_file.c
@@ -113,6 +113,29 @@ seq_open(struct linux_file *f, const struct seq_operations *op)
return (0);
}
+void *
+__seq_open_private(struct linux_file *f, const struct seq_operations *op, int size)
+{
+ struct seq_file *seq_file;
+ void *private;
+ int error;
+
+ private = malloc(size, M_LSEQ, M_NOWAIT|M_ZERO);
+ if (private == NULL)
+ return (NULL);
+
+ error = seq_open(f, op);
+ if (error < 0) {
+ free(private, M_LSEQ);
+ return (NULL);
+ }
+
+ seq_file = (struct seq_file *)f->private_data;
+ seq_file->private = private;
+
+ return (private);
+}
+
int
single_open(struct linux_file *f, int (*show)(struct seq_file *, void *), void *d)
{
@@ -145,6 +168,16 @@ seq_release(struct inode *inode __unused, struct linux_file *file)
}
int
+seq_release_private(struct inode *inode __unused, struct linux_file *f)
+{
+ struct seq_file *seq;
+
+ seq = (struct seq_file *)f->private_data;
+ free(seq->private, M_LSEQ);
+ return (seq_release(inode, f));
+}
+
+int
single_release(struct vnode *v, struct linux_file *f)
{
const struct seq_operations *op;