aboutsummaryrefslogtreecommitdiffstats
path: root/plpnfsd/builtins.h
blob: 644f18b71c252957cad8a70df4b00cc6a187fef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * $Id$
 */

#ifndef _BUILTINS_H_
#define _BUILTINS_H_

struct builtin_node_t;

typedef struct builtin_child_t {
	struct builtin_child_t *next;
	struct builtin_node_t *node;
} builtin_child;

/**
 * Support for procfs-like builtin virtual files/directories
 */
typedef struct builtin_node_t {
	struct builtin_node_t *next;
	struct builtin_node_t *parent;
	builtin_child *childs;
	char *private_data;
	char *name;
	unsigned long flags;
	long attr;
	long size;
	long (*getsize)(struct builtin_node_t *node);
	long (*read)(struct builtin_node_t *node, char *buf, unsigned long offset, long len);
	long (*write)(struct builtin_node_t *node, char *buf, unsigned long offset, long len);
	long (*sattr)(struct builtin_node_t *node, unsigned long sa, unsigned long da);
	long (*getlinks)(struct builtin_node_t *node);
	long (*getdents)(struct builtin_node_t *node, dentry **entries);
} builtin_node;

#define BF_EXISTS_ALWAYS 1
#define BF_NOCACHE       2
#define BF_ISPROCESS     4

/**
 * Register a builtin handler for an entry in /proc
 */
builtin_node *register_builtin(char *parent, builtin_node *node);

/**
 * Deregister a previously registered handler.
 */
extern int unregister_builtin(builtin_node *);

extern char *builtin_path(builtin_node *node);
extern long generic_getlinks(builtin_node *node);
extern long generic_getdents(builtin_node *node, dentry **entries);

#endif /* _BUILTINS_H_ */