Subversion Repositories HelenOS

Rev

Rev 2529 | Rev 2540 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2529 Rev 2535
1
/*
1
/*
2
 * Copyright (c) 2007 Jakub Jermar
2
 * Copyright (c) 2007 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup fs
29
/** @addtogroup fs
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
#ifndef VFS_VFS_H_
33
#ifndef VFS_VFS_H_
34
#define VFS_VFS_H_
34
#define VFS_VFS_H_
35
 
35
 
36
#include <ipc/ipc.h>
36
#include <ipc/ipc.h>
37
#include <libadt/list.h>
37
#include <libadt/list.h>
38
 
38
 
-
 
39
#define dprintf(...)    printf(__VA_ARGS__)
-
 
40
 
39
#define VFS_FIRST   FIRST_USER_METHOD
41
#define VFS_FIRST   FIRST_USER_METHOD
40
 
42
 
41
#define IPC_METHOD_TO_VFS_OP(m) ((m) - VFS_FIRST)   
43
#define IPC_METHOD_TO_VFS_OP(m) ((m) - VFS_FIRST)   
42
 
44
 
43
typedef enum {
45
typedef enum {
44
    VFS_REGISTER = VFS_FIRST,
46
    VFS_REGISTER = VFS_FIRST,
45
    VFS_MOUNT,
47
    VFS_MOUNT,
46
    VFS_UNMOUNT,
48
    VFS_UNMOUNT,
47
    VFS_LOOKUP,
49
    VFS_LOOKUP,
48
    VFS_OPEN,
50
    VFS_OPEN,
49
    VFS_CREATE,
51
    VFS_CREATE,
50
    VFS_CLOSE,
52
    VFS_CLOSE,
51
    VFS_READ,
53
    VFS_READ,
52
    VFS_WRITE,
54
    VFS_WRITE,
53
    VFS_SEEK,
55
    VFS_SEEK,
54
    VFS_LAST,       /* keep this the last member of the enum */
56
    VFS_LAST,       /* keep this the last member of the enum */
55
} vfs_request_t;
57
} vfs_request_t;
56
 
58
 
57
 
59
 
58
/**
60
/**
59
 * An instance of this structure is associated with a particular FS operation.
61
 * An instance of this structure is associated with a particular FS operation.
60
 * It tells VFS if the FS supports the operation or maybe if a default one
62
 * It tells VFS if the FS supports the operation or maybe if a default one
61
 * should be used.
63
 * should be used.
62
 */
64
 */
63
typedef enum {
65
typedef enum {
64
    VFS_OP_NULL = 0,
66
    VFS_OP_NULL = 0,
65
    VFS_OP_DEFAULT,
67
    VFS_OP_DEFAULT,
66
    VFS_OP_DEFINED
68
    VFS_OP_DEFINED
67
} vfs_op_t;
69
} vfs_op_t;
68
 
70
 
69
#define FS_NAME_MAXLEN  20
71
#define FS_NAME_MAXLEN  20
70
 
72
 
71
/**
73
/**
72
 * A structure like this is passed to VFS by each individual FS upon its
74
 * A structure like this is passed to VFS by each individual FS upon its
73
 * registration. It assosiates a human-readable identifier with each
75
 * registration. It assosiates a human-readable identifier with each
74
 * registered FS. More importantly, through this structure, the FS announces
76
 * registered FS. More importantly, through this structure, the FS announces
75
 * what operations it supports.
77
 * what operations it supports.
76
 */
78
 */
77
typedef struct {
79
typedef struct {
78
    /** Unique identifier of the fs. */
80
    /** Unique identifier of the fs. */
79
    char name[FS_NAME_MAXLEN];
81
    char name[FS_NAME_MAXLEN];
80
   
82
   
81
    /** Operations. */
83
    /** Operations. */
82
    vfs_op_t ops[VFS_LAST - VFS_FIRST];
84
    vfs_op_t ops[VFS_LAST - VFS_FIRST];
83
} vfs_info_t;
85
} vfs_info_t;
84
 
86
 
85
typedef struct {
87
typedef struct {
86
    link_t fs_link;
88
    link_t fs_link;
87
    vfs_info_t vfs_info;
89
    vfs_info_t vfs_info;
88
    ipcarg_t phone;
90
    ipcarg_t phone;
89
} fs_info_t;
91
} fs_info_t;
90
 
92
 
-
 
93
extern link_t fs_head;
-
 
94
 
-
 
95
extern void vfs_register(ipc_callid_t rid, ipc_call_t *request);
-
 
96
 
91
#endif
97
#endif
92
 
98
 
93
/**
99
/**
94
 * @}
100
 * @}
95
 */
101
 */
96
 
102