Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_seq_file.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
MALLOC_DEFINE(M_LSEQ, "seq_file", "seq_file"); | MALLOC_DEFINE(M_LSEQ, "seq_file", "seq_file"); | ||||
ssize_t | ssize_t | ||||
seq_read(struct linux_file *f, char *ubuf, size_t size, off_t *ppos) | seq_read(struct linux_file *f, char *ubuf, size_t size, off_t *ppos) | ||||
{ | { | ||||
struct seq_file *m = f->private_data; | struct seq_file *m = f->private_data; | ||||
void *p; | void *p; | ||||
int rc; | int rc; | ||||
off_t pos = 0; | |||||
p = m->op->start(m, &pos); | p = m->op->start(m, ppos); | ||||
markj: Is this a bug fix? | |||||
jfreeAuthorUnsubmitted Done Inline ActionsYes. jfree: Yes. | |||||
rc = m->op->show(m, p); | rc = m->op->show(m, p); | ||||
if (rc) | if (rc) | ||||
return (rc); | return (rc); | ||||
return (size); | return (size); | ||||
} | } | ||||
int | int | ||||
seq_write(struct seq_file *seq, const void *data, size_t len) | seq_write(struct seq_file *seq, const void *data, size_t len) | ||||
Show All 34 Lines | |||||
{ | { | ||||
} | } | ||||
int | int | ||||
seq_open(struct linux_file *f, const struct seq_operations *op) | seq_open(struct linux_file *f, const struct seq_operations *op) | ||||
{ | { | ||||
struct seq_file *p; | struct seq_file *p; | ||||
if (f->private_data != NULL) | |||||
log(LOG_WARNING, "%s private_data not NULL", __func__); | |||||
if ((p = malloc(sizeof(*p), M_LSEQ, M_NOWAIT|M_ZERO)) == NULL) | if ((p = malloc(sizeof(*p), M_LSEQ, M_NOWAIT|M_ZERO)) == NULL) | ||||
return (-ENOMEM); | return (-ENOMEM); | ||||
f->private_data = p; | /* | ||||
* This seq_file's ->buf is passed in through f->private_data. | |||||
* A clean seq_file implementation is needed to remove the | |||||
* FreeBSD sbuf dependency. | |||||
*/ | |||||
if (f->private_data != NULL) | |||||
p->buf = (struct sbuf *) f->private_data; | |||||
p->op = op; | p->op = op; | ||||
p->file = f; | p->file = f; | ||||
f->private_data = (void *) p; | |||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
single_open(struct linux_file *f, int (*show)(struct seq_file *, void *), void *d) | single_open(struct linux_file *f, int (*show)(struct seq_file *, void *), void *d) | ||||
{ | { | ||||
struct seq_operations *op; | struct seq_operations *op; | ||||
int rc = -ENOMEM; | int rc = -ENOMEM; | ||||
Show All 33 Lines | single_release(struct vnode *v, struct linux_file *f) | ||||
/* be NULL safe */ | /* be NULL safe */ | ||||
if ((m = f->private_data) == NULL) | if ((m = f->private_data) == NULL) | ||||
return (0); | return (0); | ||||
op = m->op; | op = m->op; | ||||
rc = seq_release(v, f); | rc = seq_release(v, f); | ||||
free(__DECONST(void *, op), M_LSEQ); | free(__DECONST(void *, op), M_LSEQ); | ||||
return (rc); | return (rc); | ||||
} | |||||
void | |||||
seq_vprintf(struct seq_file *m, const char *fmt, va_list args) | |||||
{ | |||||
sbuf_vprintf(m->buf, fmt, args); | |||||
return; | |||||
} | |||||
void | |||||
seq_printf(struct seq_file *m, const char *fmt, ...) | |||||
{ | |||||
va_list args; | |||||
va_start(args, fmt); | |||||
seq_vprintf(m, fmt, args); | |||||
va_end(args); | |||||
return; | |||||
} | } |
Is this a bug fix?