24 #ifndef _XENO_NUCLEUS_VFILE_H
25 #define _XENO_NUCLEUS_VFILE_H
27 #if defined(CONFIG_XENO_OPT_VFILE) || defined(DOXYGEN_CPP)
32 #include <linux/proc_fs.h>
33 #include <linux/seq_file.h>
34 #include <nucleus/types.h>
36 struct xnvfile_directory;
42 struct proc_dir_entry *pde;
70 int (*
get)(
struct xnvfile *vfile);
78 void (*
put)(
struct xnvfile *vfile);
86 struct xnvfile_hostlock_class {
91 struct xnvfile_nklock_class {
96 struct xnvfile_input {
97 const char __user *u_buf;
99 struct xnvfile *vfile;
256 ssize_t (*
store)(
struct xnvfile_input *input);
259 struct xnvfile_regular {
260 struct xnvfile entry;
265 struct xnvfile_regular_template {
480 ssize_t (*
store)(
struct xnvfile_input *input);
495 struct xnvfile_snapshot_template {
515 struct xnvfile entry;
546 struct xnvfile_directory {
547 struct xnvfile entry;
550 struct xnvfile_link {
551 struct xnvfile entry;
555 #define VFILE_SEQ_EMPTY ((void *)-1)
557 #define VFILE_SEQ_START SEQ_START_TOKEN
559 #define VFILE_SEQ_SKIP 2
561 #define xnvfile_printf(it, args...) seq_printf((it)->seq, ##args)
562 #define xnvfile_write(it, data, len) seq_write((it)->seq, (data),(len))
563 #define xnvfile_puts(it, s) seq_puts((it)->seq, (s))
564 #define xnvfile_putc(it, c) seq_putc((it)->seq, (c))
573 xnvfile_touch_tag(vfile->tag);
576 #define xnvfile_noentry \
584 #define xnvfile_nodir { .entry = xnvfile_noentry }
585 #define xnvfile_nolink { .entry = xnvfile_noentry }
586 #define xnvfile_nofile { .entry = xnvfile_noentry }
588 #define xnvfile_priv(e) ((e)->entry.private)
589 #define xnvfile_nref(e) ((e)->entry.refcnt)
590 #define xnvfile_file(e) ((e)->entry.file)
591 #define xnvfile_iterator_priv(it) ((void *)(&(it)->private))
593 extern struct xnvfile_nklock_class xnvfile_nucleus_lock;
595 extern struct xnvfile_directory
nkvfroot;
597 int xnvfile_init_root(
void);
599 void xnvfile_destroy_root(
void);
607 struct xnvfile_directory *parent);
610 struct xnvfile_regular *vfile,
611 struct xnvfile_directory *parent);
614 struct xnvfile_directory *vdir,
615 struct xnvfile_directory *parent);
619 struct xnvfile_link *vlink,
620 struct xnvfile_directory *parent);
625 void *data,
size_t size);
628 char *s,
size_t maxlen);
632 int __vfile_hostlock_get(
struct xnvfile *vfile);
634 void __vfile_hostlock_put(
struct xnvfile *vfile);
647 void xnvfile_destroy_regular(
struct xnvfile_regular *vfile)
653 void xnvfile_destroy_dir(
struct xnvfile_directory *vdir)
659 void xnvfile_destroy_link(
struct xnvfile_link *vlink)
664 #define DEFINE_VFILE_HOSTLOCK(name) \
665 struct xnvfile_hostlock_class name = { \
667 .get = __vfile_hostlock_get, \
668 .put = __vfile_hostlock_put, \
670 .sem = __SEMAPHORE_INITIALIZER(name.sem, 1), \
675 #define xnvfile_touch_tag(tag) do { } while (0)
677 #define xnvfile_touch(vfile) do { } while (0)
struct xnvfile_snapshot * vfile
Backlink to the vfile being read.
Definition: vfile.h:536
Snapshot-driven vfile iterator.
Definition: vfile.h:528
struct xnvfile_directory nkvfroot
Xenomai vfile root directory.
Definition: vfile.c:88
void(* endfn)(struct xnvfile_snapshot_iterator *it, void *buf)
Buffer release handler.
Definition: vfile.h:538
int(* show)(struct xnvfile_regular_iterator *it, void *data)
Definition: vfile.h:227
loff_t pos
Current record position while iterating.
Definition: vfile.h:279
Vfile locking operations.
Definition: vfile.h:57
ssize_t(* store)(struct xnvfile_input *input)
Definition: vfile.h:256
ssize_t(* store)(struct xnvfile_input *input)
Definition: vfile.h:480
struct seq_file * seq
Backlink to the host sequential file supporting the vfile.
Definition: vfile.h:534
Snapshot revision tag.
Definition: vfile.h:490
int xnvfile_init_dir(const char *name, struct xnvfile_directory *vdir, struct xnvfile_directory *parent)
Initialize a virtual directory entry.
Definition: vfile.c:695
Snapshot vfile operation descriptor.
Definition: vfile.h:301
int(* next)(struct xnvfile_snapshot_iterator *it, void *data)
Definition: vfile.h:421
int xnvfile_init_link(const char *from, const char *to, struct xnvfile_link *vlink, struct xnvfile_directory *parent)
Initialize a virtual link entry.
Definition: vfile.c:741
int(* rewind)(struct xnvfile_regular_iterator *it)
Definition: vfile.h:129
void(* put)(struct xnvfile *vfile)
Definition: vfile.h:78
ssize_t xnvfile_get_string(struct xnvfile_input *input, char *s, size_t maxlen)
Read in a C-string written to the vfile.
Definition: vfile.c:845
int xnvfile_init_regular(const char *name, struct xnvfile_regular *vfile, struct xnvfile_directory *parent)
Initialize a regular vfile.
Definition: vfile.c:651
struct xnvfile_regular * vfile
Backlink to the vfile being read.
Definition: vfile.h:283
Regular vfile iterator.
Definition: vfile.h:277
void(* end)(struct xnvfile_regular_iterator *it)
Definition: vfile.h:198
int(* show)(struct xnvfile_snapshot_iterator *it, void *data)
Definition: vfile.h:450
int rev
Current revision number.
Definition: vfile.h:492
caddr_t databuf
Address of record buffer.
Definition: vfile.h:532
int xnvfile_init_snapshot(const char *name, struct xnvfile_snapshot *vfile, struct xnvfile_directory *parent)
Initialize a snapshot-driven vfile.
Definition: vfile.c:412
Regular vfile operation descriptor.
Definition: vfile.h:111
struct seq_file * seq
Backlink to the host sequential file supporting the vfile.
Definition: vfile.h:281
ssize_t xnvfile_get_blob(struct xnvfile_input *input, void *data, size_t size)
Read in a data bulk written to the vfile.
Definition: vfile.c:803
int(* rewind)(struct xnvfile_snapshot_iterator *it)
Definition: vfile.h:342
ssize_t xnvfile_get_integer(struct xnvfile_input *input, long *valp)
Evaluate the string written to the vfile as a long integer.
Definition: vfile.c:895
void xnvfile_destroy(struct xnvfile *vfile)
Removes a virtual file entry.
Definition: vfile.c:772
void(* end)(struct xnvfile_snapshot_iterator *it, void *buf)
Definition: vfile.h:388
Snapshot vfile descriptor.
Definition: vfile.h:514
int nrdata
Number of collected records.
Definition: vfile.h:530