source: mainline/uspace/srv/fs/ext2/ext2_ops.c@ a49c4002

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a49c4002 was 3bd76491, checked in by Martin Sucha <sucha14@…>, 15 years ago

Basic skeleton for libext2 and ext2 server

  • Property mode set to 100644
File size: 7.6 KB
Line 
1/*
2 * Copyright (c) 2008 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
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
15 * derived from this software without specific prior written permission.
16 *
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
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup fs
30 * @{
31 */
32
33/**
34 * @file ext2_ops.c
35 * @brief Implementation of VFS operations for the EXT2 file system server.
36 */
37
38#include "ext2.h"
39#include "../../vfs/vfs.h"
40#include <libfs.h>
41#include <libblock.h>
42#include <libext2.h>
43#include <ipc/ipc.h>
44#include <ipc/services.h>
45#include <ipc/devmap.h>
46#include <macros.h>
47#include <async.h>
48#include <errno.h>
49#include <str.h>
50#include <byteorder.h>
51#include <adt/hash_table.h>
52#include <adt/list.h>
53#include <assert.h>
54#include <fibril_synch.h>
55#include <sys/mman.h>
56#include <align.h>
57
58#define EXT2_NODE(node) ((node) ? (ext2_node_t *) (node)->data : NULL)
59#define FS_NODE(node) ((node) ? (node)->bp : NULL)
60
61/*
62 * Forward declarations of EXT2 libfs operations.
63 */
64static int ext2_root_get(fs_node_t **, devmap_handle_t);
65static int ext2_match(fs_node_t **, fs_node_t *, const char *);
66static int ext2_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
67static int ext2_node_open(fs_node_t *);
68static int ext2_node_put(fs_node_t *);
69static int ext2_create_node(fs_node_t **, devmap_handle_t, int);
70static int ext2_destroy_node(fs_node_t *);
71static int ext2_link(fs_node_t *, fs_node_t *, const char *);
72static int ext2_unlink(fs_node_t *, fs_node_t *, const char *);
73static int ext2_has_children(bool *, fs_node_t *);
74static fs_index_t ext2_index_get(fs_node_t *);
75static aoff64_t ext2_size_get(fs_node_t *);
76static unsigned ext2_lnkcnt_get(fs_node_t *);
77static char ext2_plb_get_char(unsigned);
78static bool ext2_is_directory(fs_node_t *);
79static bool ext2_is_file(fs_node_t *node);
80static devmap_handle_t ext2_device_get(fs_node_t *node);
81
82/*
83 * EXT2 libfs operations.
84 */
85
86int ext2_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
87{
88 // TODO
89 return 0;
90 //return ext2_node_get(rfn, devmap_handle, 0);
91}
92
93int ext2_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
94{
95 // TODO
96 return ENOTSUP;
97}
98
99/** Instantiate a EXT2 in-core node. */
100int ext2_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
101{
102 // TODO
103 return ENOTSUP;
104}
105
106int ext2_node_open(fs_node_t *fn)
107{
108 /*
109 * Opening a file is stateless, nothing
110 * to be done here.
111 */
112 return EOK;
113}
114
115int ext2_node_put(fs_node_t *fn)
116{
117 // TODO
118 return ENOTSUP;
119}
120
121int ext2_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
122{
123 // TODO
124 return ENOTSUP;
125}
126
127int ext2_destroy_node(fs_node_t *fn)
128{
129 // TODO
130 return ENOTSUP;
131}
132
133int ext2_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
134{
135 // TODO
136 return ENOTSUP;
137}
138
139int ext2_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
140{
141 // TODO
142 return ENOTSUP;
143}
144
145int ext2_has_children(bool *has_children, fs_node_t *fn)
146{
147 // TODO
148 return ENOTSUP;
149}
150
151
152fs_index_t ext2_index_get(fs_node_t *fn)
153{
154 // TODO
155 return 0;
156}
157
158aoff64_t ext2_size_get(fs_node_t *fn)
159{
160 // TODO
161 return 0;
162}
163
164unsigned ext2_lnkcnt_get(fs_node_t *fn)
165{
166 // TODO
167 return 0;
168}
169
170char ext2_plb_get_char(unsigned pos)
171{
172 return ext2_reg.plb_ro[pos % PLB_SIZE];
173}
174
175bool ext2_is_directory(fs_node_t *fn)
176{
177 // TODO
178 return false;
179}
180
181bool ext2_is_file(fs_node_t *fn)
182{
183 // TODO
184 return false;
185}
186
187devmap_handle_t ext2_device_get(fs_node_t *node)
188{
189 return 0;
190}
191
192/** libfs operations */
193libfs_ops_t ext2_libfs_ops = {
194 .root_get = ext2_root_get,
195 .match = ext2_match,
196 .node_get = ext2_node_get,
197 .node_open = ext2_node_open,
198 .node_put = ext2_node_put,
199 .create = ext2_create_node,
200 .destroy = ext2_destroy_node,
201 .link = ext2_link,
202 .unlink = ext2_unlink,
203 .has_children = ext2_has_children,
204 .index_get = ext2_index_get,
205 .size_get = ext2_size_get,
206 .lnkcnt_get = ext2_lnkcnt_get,
207 .plb_get_char = ext2_plb_get_char,
208 .is_directory = ext2_is_directory,
209 .is_file = ext2_is_file,
210 .device_get = ext2_device_get
211};
212
213/*
214 * VFS operations.
215 */
216
217void ext2_mounted(ipc_callid_t rid, ipc_call_t *request)
218{
219// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
220 // TODO
221 ipc_answer_0(rid, ENOTSUP);
222}
223
224void ext2_mount(ipc_callid_t rid, ipc_call_t *request)
225{
226 libfs_mount(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
227}
228
229void ext2_unmounted(ipc_callid_t rid, ipc_call_t *request)
230{
231// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
232 // TODO
233 ipc_answer_0(rid, ENOTSUP);
234}
235
236void ext2_unmount(ipc_callid_t rid, ipc_call_t *request)
237{
238 libfs_unmount(&ext2_libfs_ops, rid, request);
239}
240
241void ext2_lookup(ipc_callid_t rid, ipc_call_t *request)
242{
243 libfs_lookup(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
244}
245
246void ext2_read(ipc_callid_t rid, ipc_call_t *request)
247{
248// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
249// fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
250// aoff64_t pos =
251// (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
252
253 // TODO
254 ipc_answer_0(rid, ENOTSUP);
255}
256
257void ext2_write(ipc_callid_t rid, ipc_call_t *request)
258{
259// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
260// fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
261// aoff64_t pos =
262// (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
263
264 // TODO
265 ipc_answer_0(rid, ENOTSUP);
266}
267
268void ext2_truncate(ipc_callid_t rid, ipc_call_t *request)
269{
270// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
271// fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
272// aoff64_t size =
273// (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
274
275 // TODO
276 ipc_answer_0(rid, ENOTSUP);
277}
278
279void ext2_close(ipc_callid_t rid, ipc_call_t *request)
280{
281 ipc_answer_0(rid, EOK);
282}
283
284void ext2_destroy(ipc_callid_t rid, ipc_call_t *request)
285{
286// devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
287// fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
288
289 // TODO
290 ipc_answer_0(rid, ENOTSUP);
291}
292
293void ext2_open_node(ipc_callid_t rid, ipc_call_t *request)
294{
295 libfs_open_node(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
296}
297
298void ext2_stat(ipc_callid_t rid, ipc_call_t *request)
299{
300 libfs_stat(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
301}
302
303void ext2_sync(ipc_callid_t rid, ipc_call_t *request)
304{
305// devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
306// fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
307
308 // TODO
309 ipc_answer_0(rid, ENOTSUP);
310}
311
312/**
313 * @}
314 */
Note: See TracBrowser for help on using the repository browser.