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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#ifndef _LINUX_DEVFS_FS_KERNEL_H
#define _LINUX_DEVFS_FS_KERNEL_H
#include <linux/fs.h>
#include <linux/config.h>
#include <linux/spinlock.h>
#include <linux/kdev_t.h>
#include <linux/types.h>
#include <asm/semaphore.h>
#define DEVFS_SUPER_MAGIC 0x1373
#define DEVFS_FL_NONE 0x000 /* This helps to make code more readable
*/
#define DEVFS_FL_WAIT 0x010 /* Wait for devfsd to finish */
#define DEVFS_FL_CURRENT_OWNER 0x020 /* Set initial ownership to current */
#define DEVFS_FL_DEFAULT DEVFS_FL_NONE
typedef struct devfs_entry * devfs_handle_t;
#ifdef CONFIG_DEVFS_FS
struct unique_numspace
{
spinlock_t init_lock;
unsigned char sem_initialised;
unsigned int num_free; /* Num free in bits */
unsigned int length; /* Array length in bytes */
unsigned long *bits;
struct semaphore semaphore;
};
#define UNIQUE_NUMBERSPACE_INITIALISER {SPIN_LOCK_UNLOCKED, 0, 0, 0, NULL}
extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
unsigned int flags,
unsigned int major, unsigned int minor,
umode_t mode, void *ops, void *info);
extern void devfs_unregister (devfs_handle_t de);
extern int devfs_mk_symlink (const char *name, const char *link);
extern devfs_handle_t devfs_mk_dir(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
extern void devfs_remove(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
extern int devfs_generate_path (devfs_handle_t de, char *path, int buflen);
extern int devfs_register_tape (devfs_handle_t de);
extern void devfs_unregister_tape(int num);
extern int devfs_alloc_unique_number (struct unique_numspace *space);
extern void devfs_dealloc_unique_number (struct unique_numspace *space,
int number);
extern void mount_devfs_fs (void);
#else /* CONFIG_DEVFS_FS */
struct unique_numspace
{
char dummy;
};
#define UNIQUE_NUMBERSPACE_INITIALISER {0}
static inline devfs_handle_t devfs_register (devfs_handle_t dir,
const char *name,
unsigned int flags,
unsigned int major,
unsigned int minor,
umode_t mode,
void *ops, void *info)
{
return NULL;
}
static inline void devfs_unregister (devfs_handle_t de)
{
return;
}
static inline int devfs_mk_symlink (const char *name, const char *link)
{
return 0;
}
static inline devfs_handle_t devfs_mk_dir(const char *fmt, ...)
{
return NULL;
}
static inline void devfs_remove(const char *fmt, ...)
{
}
static inline int devfs_generate_path (devfs_handle_t de, char *path,
int buflen)
{
return -ENOSYS;
}
static inline int devfs_register_tape (devfs_handle_t de)
{
return -1;
}
static inline void devfs_unregister_tape(int num)
{
}
static inline int devfs_alloc_unique_number (struct unique_numspace *space)
{
return -1;
}
static inline void devfs_dealloc_unique_number (struct unique_numspace *space,
int number)
{
return;
}
static inline void mount_devfs_fs (void)
{
return;
}
#endif /* CONFIG_DEVFS_FS */
#endif /* _LINUX_DEVFS_FS_KERNEL_H */
|