diff --git a/sys/compat/linuxkpi/common/include/linux/seq_file.h b/sys/compat/linuxkpi/common/include/linux/seq_file.h --- a/sys/compat/linuxkpi/common/include/linux/seq_file.h +++ b/sys/compat/linuxkpi/common/include/linux/seq_file.h @@ -69,6 +69,9 @@ 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 --- a/sys/compat/linuxkpi/common/src/linux_seq_file.c +++ b/sys/compat/linuxkpi/common/src/linux_seq_file.c @@ -130,6 +130,29 @@ 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) { @@ -166,6 +189,16 @@ return (0); } +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) {