blob: 97d71830bc7f8171a9b0877205c6114e0efb4302 (
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
55
56
57
|
/**
* @file
*
* Simple mount point manager
* ==========================
*
* Add up to MAX_MOUNTS (as defined in kernel.h) mountpoints and use the
* provided functions to transparently dispatch them to the undelying
* infrastructure provided via the mount_struct structures
*
* unt_file_open() and mount_read_dir()
*
* The mount directories itself should exist inside the
* root direcotry '/'.
*/
#ifndef MOUNT_H
#define MOUNT_H
#include <stdint.h>
#include <sys/dirent.h> // provides fs_dirent structure for read_dir()
#include "fd.h" // file descriptor returned by open
/** the possible values for mount_struct.type */
enum MOUNT_TYPE{
MOUNT_TYPE_EXT2 = 1,
MOUNT_TYPE_SYS = 3
};
/** struct providing all the required info, about a single mountpoint */
typedef struct mount_struct
{
uint32_t type; // MOUNT_TYPE
char path[256]; // where are we mounted (provide leading and trailing slash!)
fd (*mount_file_open)(struct mount_struct*, char *path);
int (*mount_read_dir) (struct mount_struct*, char *path, struct dirent *dirs, uint32_t *pos);
void *data; // pointer to some opaque private data
}mount;
/** adds a new mountpoints */
void mount_add(mount mnt);
/** dispatchers to according mount points */
fd mount_file_open(char *path);
/** TODO: should use fd number instead of PATH on each call*/
int mount_read_dir (char *path, struct dirent *dirs, uint32_t *pos);
/** sysfs interface / exposing status via /sysfs/ file */
void mount_sysfs(ringbuffer *r, void (*f)(ringbuffer *r,char *fmt, ...));
#endif
|