Subversion Repositories HelenOS

Rev

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

Rev 4153 Rev 4327
1
/*
1
/*
2
 * Copyright (c) 2008 Jakub Jermar
2
 * Copyright (c) 2008 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
/**
33
/**
34
 * @file    tmpfs_ops.c
34
 * @file    tmpfs_ops.c
35
 * @brief   Implementation of VFS operations for the TMPFS file system
35
 * @brief   Implementation of VFS operations for the TMPFS file system
36
 *      server.
36
 *      server.
37
 */
37
 */
38
 
38
 
39
#include "tmpfs.h"
39
#include "tmpfs.h"
40
#include "../../vfs/vfs.h"
40
#include "../../vfs/vfs.h"
41
#include <ipc/ipc.h>
41
#include <ipc/ipc.h>
42
#include <async.h>
42
#include <async.h>
43
#include <errno.h>
43
#include <errno.h>
44
#include <atomic.h>
44
#include <atomic.h>
45
#include <stdlib.h>
45
#include <stdlib.h>
46
#include <string.h>
46
#include <string.h>
47
#include <stdio.h>
47
#include <stdio.h>
48
#include <assert.h>
48
#include <assert.h>
49
#include <sys/types.h>
49
#include <sys/types.h>
50
#include <libadt/hash_table.h>
50
#include <libadt/hash_table.h>
51
#include <as.h>
51
#include <as.h>
52
#include <libfs.h>
52
#include <libfs.h>
53
 
53
 
54
#define min(a, b)       ((a) < (b) ? (a) : (b))
54
#define min(a, b)       ((a) < (b) ? (a) : (b))
55
#define max(a, b)       ((a) > (b) ? (a) : (b))
55
#define max(a, b)       ((a) > (b) ? (a) : (b))
56
 
56
 
57
#define DENTRIES_BUCKETS    256
57
#define DENTRIES_BUCKETS    256
58
 
58
 
59
#define NAMES_BUCKETS       4
59
#define NAMES_BUCKETS       4
60
 
60
 
61
/*
-
 
62
 * For now, we don't distinguish between different dev_handles/instances. All
61
/** All root nodes have index 0. */
-
 
62
#define TMPFS_SOME_ROOT     0
63
 * requests resolve to the only instance, rooted in the following variable.
63
/** Global counter for assigning node indices. Shared by all instances. */
64
 */
-
 
65
static tmpfs_dentry_t *root;
64
fs_index_t tmpfs_next_index = 1;
66
 
-
 
67
#define TMPFS_DEV       0   /**< Dummy device handle for TMPFS */
-
 
68
 
65
 
69
/*
66
/*
70
 * Implementation of the libfs interface.
67
 * Implementation of the libfs interface.
71
 */
68
 */
72
 
69
 
73
/* Forward declarations of static functions. */
70
/* Forward declarations of static functions. */
74
static void *tmpfs_match(void *, const char *);
71
static void *tmpfs_match(void *, const char *);
75
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
72
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
76
static void tmpfs_node_put(void *);
73
static void tmpfs_node_put(void *);
77
static void *tmpfs_create_node(dev_handle_t, int);
74
static void *tmpfs_create_node(dev_handle_t, int);
78
static int tmpfs_link_node(void *, void *, const char *);
75
static int tmpfs_link_node(void *, void *, const char *);
79
static int tmpfs_unlink_node(void *, void *);
76
static int tmpfs_unlink_node(void *, void *);
80
static int tmpfs_destroy_node(void *);
77
static int tmpfs_destroy_node(void *);
81
 
78
 
82
/* Implementation of helper functions. */
79
/* Implementation of helper functions. */
83
static fs_index_t tmpfs_index_get(void *nodep)
80
static fs_index_t tmpfs_index_get(void *nodep)
84
{
81
{
85
    return ((tmpfs_dentry_t *) nodep)->index;
82
    return ((tmpfs_dentry_t *) nodep)->index;
86
}
83
}
87
 
84
 
88
static size_t tmpfs_size_get(void *nodep)
85
static size_t tmpfs_size_get(void *nodep)
89
{
86
{
90
    return ((tmpfs_dentry_t *) nodep)->size;
87
    return ((tmpfs_dentry_t *) nodep)->size;
91
}
88
}
92
 
89
 
93
static unsigned tmpfs_lnkcnt_get(void *nodep)
90
static unsigned tmpfs_lnkcnt_get(void *nodep)
94
{
91
{
95
    return ((tmpfs_dentry_t *) nodep)->lnkcnt;
92
    return ((tmpfs_dentry_t *) nodep)->lnkcnt;
96
}
93
}
97
 
94
 
98
static bool tmpfs_has_children(void *nodep)
95
static bool tmpfs_has_children(void *nodep)
99
{
96
{
100
    return ((tmpfs_dentry_t *) nodep)->child != NULL;
97
    return ((tmpfs_dentry_t *) nodep)->child != NULL;
101
}
98
}
102
 
99
 
103
static void *tmpfs_root_get(dev_handle_t dev_handle)
100
static void *tmpfs_root_get(dev_handle_t dev_handle)
104
{
101
{
105
    return root;
102
    return tmpfs_node_get(dev_handle, TMPFS_SOME_ROOT);
106
}
103
}
107
 
104
 
108
static char tmpfs_plb_get_char(unsigned pos)
105
static char tmpfs_plb_get_char(unsigned pos)
109
{
106
{
110
    return tmpfs_reg.plb_ro[pos % PLB_SIZE];
107
    return tmpfs_reg.plb_ro[pos % PLB_SIZE];
111
}
108
}
112
 
109
 
113
static bool tmpfs_is_directory(void *nodep)
110
static bool tmpfs_is_directory(void *nodep)
114
{
111
{
115
    return ((tmpfs_dentry_t *) nodep)->type == TMPFS_DIRECTORY;
112
    return ((tmpfs_dentry_t *) nodep)->type == TMPFS_DIRECTORY;
116
}
113
}
117
 
114
 
118
static bool tmpfs_is_file(void *nodep)
115
static bool tmpfs_is_file(void *nodep)
119
{
116
{
120
    return ((tmpfs_dentry_t *) nodep)->type == TMPFS_FILE;
117
    return ((tmpfs_dentry_t *) nodep)->type == TMPFS_FILE;
121
}
118
}
122
 
119
 
123
/** libfs operations */
120
/** libfs operations */
124
libfs_ops_t tmpfs_libfs_ops = {
121
libfs_ops_t tmpfs_libfs_ops = {
125
    .match = tmpfs_match,
122
    .match = tmpfs_match,
126
    .node_get = tmpfs_node_get,
123
    .node_get = tmpfs_node_get,
127
    .node_put = tmpfs_node_put,
124
    .node_put = tmpfs_node_put,
128
    .create = tmpfs_create_node,
125
    .create = tmpfs_create_node,
129
    .destroy = tmpfs_destroy_node,
126
    .destroy = tmpfs_destroy_node,
130
    .link = tmpfs_link_node,
127
    .link = tmpfs_link_node,
131
    .unlink = tmpfs_unlink_node,
128
    .unlink = tmpfs_unlink_node,
132
    .index_get = tmpfs_index_get,
129
    .index_get = tmpfs_index_get,
133
    .size_get = tmpfs_size_get,
130
    .size_get = tmpfs_size_get,
134
    .lnkcnt_get = tmpfs_lnkcnt_get,
131
    .lnkcnt_get = tmpfs_lnkcnt_get,
135
    .has_children = tmpfs_has_children,
132
    .has_children = tmpfs_has_children,
136
    .root_get = tmpfs_root_get,
133
    .root_get = tmpfs_root_get,
137
    .plb_get_char = tmpfs_plb_get_char,
134
    .plb_get_char = tmpfs_plb_get_char,
138
    .is_directory = tmpfs_is_directory,
135
    .is_directory = tmpfs_is_directory,
139
    .is_file = tmpfs_is_file
136
    .is_file = tmpfs_is_file
140
};
137
};
141
 
138
 
142
/** Hash table of all directory entries. */
139
/** Hash table of all directory entries. */
143
hash_table_t dentries;
140
hash_table_t dentries;
144
 
141
 
-
 
142
#define DENTRIES_KEY_INDEX  0
-
 
143
#define DENTRIES_KEY_DEV    1
-
 
144
 
145
/* Implementation of hash table interface for the dentries hash table. */
145
/* Implementation of hash table interface for the dentries hash table. */
146
static hash_index_t dentries_hash(unsigned long *key)
146
static hash_index_t dentries_hash(unsigned long key[])
147
{
147
{
148
    return *key % DENTRIES_BUCKETS;
148
    return key[DENTRIES_KEY_INDEX] % DENTRIES_BUCKETS;
149
}
149
}
150
 
150
 
151
static int dentries_compare(unsigned long *key, hash_count_t keys,
151
static int dentries_compare(unsigned long key[], hash_count_t keys,
152
    link_t *item)
152
    link_t *item)
153
{
153
{
154
    tmpfs_dentry_t *dentry = hash_table_get_instance(item, tmpfs_dentry_t,
154
    tmpfs_dentry_t *dentry = hash_table_get_instance(item, tmpfs_dentry_t,
155
        dh_link);
155
        dh_link);
156
    return dentry->index == *key;
156
    return (dentry->index == key[DENTRIES_KEY_INDEX] &&
-
 
157
        dentry->dev_handle == key[DENTRIES_KEY_DEV]);
157
}
158
}
158
 
159
 
159
static void dentries_remove_callback(link_t *item)
160
static void dentries_remove_callback(link_t *item)
160
{
161
{
161
}
162
}
162
 
163
 
163
/** TMPFS dentries hash table operations. */
164
/** TMPFS dentries hash table operations. */
164
hash_table_operations_t dentries_ops = {
165
hash_table_operations_t dentries_ops = {
165
    .hash = dentries_hash,
166
    .hash = dentries_hash,
166
    .compare = dentries_compare,
167
    .compare = dentries_compare,
167
    .remove_callback = dentries_remove_callback
168
    .remove_callback = dentries_remove_callback
168
};
169
};
169
 
170
 
170
fs_index_t tmpfs_next_index = 1;
-
 
171
 
-
 
172
typedef struct {
171
typedef struct {
173
    char *name;
172
    char *name;
174
    tmpfs_dentry_t *parent;
173
    tmpfs_dentry_t *parent;
175
    link_t link;
174
    link_t link;
176
} tmpfs_name_t;
175
} tmpfs_name_t;
177
 
176
 
178
/* Implementation of hash table interface for the names hash table. */
177
/* Implementation of hash table interface for the names hash table. */
179
static hash_index_t names_hash(unsigned long *key)
178
static hash_index_t names_hash(unsigned long *key)
180
{
179
{
181
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key;
180
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key;
182
    return dentry->index % NAMES_BUCKETS;
181
    return dentry->index % NAMES_BUCKETS;
183
}
182
}
184
 
183
 
185
static int names_compare(unsigned long *key, hash_count_t keys, link_t *item)
184
static int names_compare(unsigned long *key, hash_count_t keys, link_t *item)
186
{
185
{
187
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key;
186
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key;
188
    tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t,
187
    tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t,
189
        link);
188
        link);
190
    return dentry == namep->parent;
189
    return dentry == namep->parent;
191
}
190
}
192
 
191
 
193
static void names_remove_callback(link_t *item)
192
static void names_remove_callback(link_t *item)
194
{
193
{
195
    tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t,
194
    tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t,
196
        link);
195
        link);
197
    free(namep->name);
196
    free(namep->name);
198
    free(namep);
197
    free(namep);
199
}
198
}
200
 
199
 
201
/** TMPFS node names hash table operations. */
200
/** TMPFS node names hash table operations. */
202
static hash_table_operations_t names_ops = {
201
static hash_table_operations_t names_ops = {
203
    .hash = names_hash,
202
    .hash = names_hash,
204
    .compare = names_compare,
203
    .compare = names_compare,
205
    .remove_callback = names_remove_callback
204
    .remove_callback = names_remove_callback
206
};
205
};
207
 
206
 
208
static void tmpfs_name_initialize(tmpfs_name_t *namep)
207
static void tmpfs_name_initialize(tmpfs_name_t *namep)
209
{
208
{
210
    namep->name = NULL;
209
    namep->name = NULL;
211
    namep->parent = NULL;
210
    namep->parent = NULL;
212
    link_initialize(&namep->link);
211
    link_initialize(&namep->link);
213
}
212
}
214
 
213
 
215
static bool tmpfs_dentry_initialize(tmpfs_dentry_t *dentry)
214
static bool tmpfs_dentry_initialize(tmpfs_dentry_t *dentry)
216
{
215
{
217
    dentry->index = 0;
216
    dentry->index = 0;
-
 
217
    dentry->dev_handle = 0;
218
    dentry->sibling = NULL;
218
    dentry->sibling = NULL;
219
    dentry->child = NULL;
219
    dentry->child = NULL;
220
    dentry->type = TMPFS_NONE;
220
    dentry->type = TMPFS_NONE;
221
    dentry->lnkcnt = 0;
221
    dentry->lnkcnt = 0;
222
    dentry->size = 0;
222
    dentry->size = 0;
223
    dentry->data = NULL;
223
    dentry->data = NULL;
224
    link_initialize(&dentry->dh_link);
224
    link_initialize(&dentry->dh_link);
225
    return (bool)hash_table_create(&dentry->names, NAMES_BUCKETS, 1,
225
    return (bool)hash_table_create(&dentry->names, NAMES_BUCKETS, 1,
226
        &names_ops);
226
        &names_ops);
227
}
227
}
228
 
228
 
229
static bool tmpfs_init(void)
229
bool tmpfs_init(void)
230
{
230
{
231
    if (!hash_table_create(&dentries, DENTRIES_BUCKETS, 1, &dentries_ops))
231
    if (!hash_table_create(&dentries, DENTRIES_BUCKETS, 2, &dentries_ops))
232
        return false;
232
        return false;
-
 
233
   
-
 
234
    return true;
-
 
235
}
-
 
236
 
-
 
237
static bool tmpfs_instance_init(dev_handle_t dev_handle)
-
 
238
{
-
 
239
    tmpfs_dentry_t *root;
-
 
240
   
233
    root = (tmpfs_dentry_t *) tmpfs_create_node(TMPFS_DEV, L_DIRECTORY);
241
    root = (tmpfs_dentry_t *) tmpfs_create_node(dev_handle, L_DIRECTORY);
234
    if (!root) {
242
    if (!root)
235
        hash_table_destroy(&dentries);
-
 
236
        return false;
243
        return false;
237
    }
-
 
238
    root->lnkcnt = 0;   /* FS root is not linked */
244
    root->lnkcnt = 0;   /* FS root is not linked */
239
    return true;
245
    return true;
240
}
246
}
241
 
247
 
242
/** Compare one component of path to a directory entry.
248
/** Compare one component of path to a directory entry.
243
 *
249
 *
244
 * @param parentp   Pointer to node from which we descended.
250
 * @param parentp   Pointer to node from which we descended.
245
 * @param childp    Pointer to node to compare the path component with.
251
 * @param childp    Pointer to node to compare the path component with.
246
 * @param component Array of characters holding component name.
252
 * @param component Array of characters holding component name.
247
 *
253
 *
248
 * @return      True on match, false otherwise.
254
 * @return      True on match, false otherwise.
249
 */
255
 */
250
static bool
256
static bool
251
tmpfs_match_one(tmpfs_dentry_t *parentp, tmpfs_dentry_t *childp,
257
tmpfs_match_one(tmpfs_dentry_t *parentp, tmpfs_dentry_t *childp,
252
    const char *component)
258
    const char *component)
253
{
259
{
254
    unsigned long key = (unsigned long) parentp;
260
    unsigned long key = (unsigned long) parentp;
255
    link_t *hlp = hash_table_find(&childp->names, &key);
261
    link_t *hlp = hash_table_find(&childp->names, &key);
256
    assert(hlp);
262
    assert(hlp);
257
    tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, link);
263
    tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, link);
258
    return !strcmp(namep->name, component);
264
    return !str_cmp(namep->name, component);
259
}
265
}
260
 
266
 
261
void *tmpfs_match(void *prnt, const char *component)
267
void *tmpfs_match(void *prnt, const char *component)
262
{
268
{
263
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
269
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
264
    tmpfs_dentry_t *childp = parentp->child;
270
    tmpfs_dentry_t *childp = parentp->child;
265
 
271
 
266
    while (childp && !tmpfs_match_one(parentp, childp, component))
272
    while (childp && !tmpfs_match_one(parentp, childp, component))
267
        childp = childp->sibling;
273
        childp = childp->sibling;
268
 
274
 
269
    return (void *) childp;
275
    return (void *) childp;
270
}
276
}
271
 
277
 
272
void *
278
void *
273
tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index)
279
tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index)
274
{
280
{
275
    unsigned long key = index;
281
    unsigned long key[] = {
-
 
282
        [DENTRIES_KEY_INDEX] = index,
-
 
283
        [DENTRIES_KEY_DEV] = dev_handle
-
 
284
    };
276
    link_t *lnk = hash_table_find(&dentries, &key);
285
    link_t *lnk = hash_table_find(&dentries, key);
277
    if (!lnk)
286
    if (!lnk)
278
        return NULL;
287
        return NULL;
279
    return hash_table_get_instance(lnk, tmpfs_dentry_t, dh_link);
288
    return hash_table_get_instance(lnk, tmpfs_dentry_t, dh_link);
280
}
289
}
281
 
290
 
282
void tmpfs_node_put(void *node)
291
void tmpfs_node_put(void *node)
283
{
292
{
284
    /* nothing to do */
293
    /* nothing to do */
285
}
294
}
286
 
295
 
287
void *tmpfs_create_node(dev_handle_t dev_handle, int lflag)
296
void *tmpfs_create_node(dev_handle_t dev_handle, int lflag)
288
{
297
{
289
    assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
298
    assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
290
 
299
 
291
    tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
300
    tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
292
    if (!node)
301
    if (!node)
293
        return NULL;
302
        return NULL;
294
 
303
 
295
    if (!tmpfs_dentry_initialize(node)) {
304
    if (!tmpfs_dentry_initialize(node)) {
296
        free(node);
305
        free(node);
297
        return NULL;
306
        return NULL;
298
    }
307
    }
-
 
308
    if (!tmpfs_root_get(dev_handle))
-
 
309
        node->index = TMPFS_SOME_ROOT;
-
 
310
    else
299
    node->index = tmpfs_next_index++;
311
        node->index = tmpfs_next_index++;
-
 
312
    node->dev_handle = dev_handle;
300
    if (lflag & L_DIRECTORY)
313
    if (lflag & L_DIRECTORY)
301
        node->type = TMPFS_DIRECTORY;
314
        node->type = TMPFS_DIRECTORY;
302
    else
315
    else
303
        node->type = TMPFS_FILE;
316
        node->type = TMPFS_FILE;
304
 
317
 
305
    /* Insert the new node into the dentry hash table. */
318
    /* Insert the new node into the dentry hash table. */
306
    unsigned long key = node->index;
319
    unsigned long key[] = {
-
 
320
        [DENTRIES_KEY_INDEX] = node->index,
-
 
321
        [DENTRIES_KEY_DEV] = node->dev_handle
-
 
322
    };
307
    hash_table_insert(&dentries, &key, &node->dh_link);
323
    hash_table_insert(&dentries, key, &node->dh_link);
308
    return (void *) node;
324
    return (void *) node;
309
}
325
}
310
 
326
 
311
int tmpfs_link_node(void *prnt, void *chld, const char *nm)
327
int tmpfs_link_node(void *prnt, void *chld, const char *nm)
312
{
328
{
313
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
329
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
314
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld;
330
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld;
315
 
331
 
316
    assert(parentp->type == TMPFS_DIRECTORY);
332
    assert(parentp->type == TMPFS_DIRECTORY);
317
 
333
 
318
    tmpfs_name_t *namep = malloc(sizeof(tmpfs_name_t));
334
    tmpfs_name_t *namep = malloc(sizeof(tmpfs_name_t));
319
    if (!namep)
335
    if (!namep)
320
        return ENOMEM;
336
        return ENOMEM;
321
    tmpfs_name_initialize(namep);
337
    tmpfs_name_initialize(namep);
322
    size_t len = strlen(nm);
338
    size_t size = str_size(nm);
323
    namep->name = malloc(len + 1);
339
    namep->name = malloc(size + 1);
324
    if (!namep->name) {
340
    if (!namep->name) {
325
        free(namep);
341
        free(namep);
326
        return ENOMEM;
342
        return ENOMEM;
327
    }
343
    }
328
    strcpy(namep->name, nm);
344
    str_cpy(namep->name, size + 1, nm);
329
    namep->parent = parentp;
345
    namep->parent = parentp;
330
   
346
   
331
    childp->lnkcnt++;
347
    childp->lnkcnt++;
332
 
348
 
333
    unsigned long key = (unsigned long) parentp;
349
    unsigned long key = (unsigned long) parentp;
334
    hash_table_insert(&childp->names, &key, &namep->link);
350
    hash_table_insert(&childp->names, &key, &namep->link);
335
 
351
 
336
    /* Insert the new node into the namespace. */
352
    /* Insert the new node into the namespace. */
337
    if (parentp->child) {
353
    if (parentp->child) {
338
        tmpfs_dentry_t *tmp = parentp->child;
354
        tmpfs_dentry_t *tmp = parentp->child;
339
        while (tmp->sibling)
355
        while (tmp->sibling)
340
            tmp = tmp->sibling;
356
            tmp = tmp->sibling;
341
        tmp->sibling = childp;
357
        tmp->sibling = childp;
342
    } else {
358
    } else {
343
        parentp->child = childp;
359
        parentp->child = childp;
344
    }
360
    }
345
 
361
 
346
    return EOK;
362
    return EOK;
347
}
363
}
348
 
364
 
349
int tmpfs_unlink_node(void *prnt, void *chld)
365
int tmpfs_unlink_node(void *prnt, void *chld)
350
{
366
{
351
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;
367
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;
352
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld;
368
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld;
353
 
369
 
354
    if (!parentp)
370
    if (!parentp)
355
        return EBUSY;
371
        return EBUSY;
356
 
372
 
357
    if (childp->child)
373
    if (childp->child)
358
        return ENOTEMPTY;
374
        return ENOTEMPTY;
359
 
375
 
360
    if (parentp->child == childp) {
376
    if (parentp->child == childp) {
361
        parentp->child = childp->sibling;
377
        parentp->child = childp->sibling;
362
    } else {
378
    } else {
363
        /* TODO: consider doubly linked list for organizing siblings. */
379
        /* TODO: consider doubly linked list for organizing siblings. */
364
        tmpfs_dentry_t *tmp = parentp->child;
380
        tmpfs_dentry_t *tmp = parentp->child;
365
        while (tmp->sibling != childp)
381
        while (tmp->sibling != childp)
366
            tmp = tmp->sibling;
382
            tmp = tmp->sibling;
367
        tmp->sibling = childp->sibling;
383
        tmp->sibling = childp->sibling;
368
    }
384
    }
369
    childp->sibling = NULL;
385
    childp->sibling = NULL;
370
 
386
 
371
    unsigned long key = (unsigned long) parentp;
387
    unsigned long key = (unsigned long) parentp;
372
    hash_table_remove(&childp->names, &key, 1);
388
    hash_table_remove(&childp->names, &key, 1);
373
 
389
 
374
    childp->lnkcnt--;
390
    childp->lnkcnt--;
375
 
391
 
376
    return EOK;
392
    return EOK;
377
}
393
}
378
 
394
 
379
int tmpfs_destroy_node(void *nodep)
395
int tmpfs_destroy_node(void *nodep)
380
{
396
{
381
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep;
397
    tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep;
382
   
398
   
383
    assert(!dentry->lnkcnt);
399
    assert(!dentry->lnkcnt);
384
    assert(!dentry->child);
400
    assert(!dentry->child);
385
    assert(!dentry->sibling);
401
    assert(!dentry->sibling);
386
 
402
 
387
    unsigned long key = dentry->index;
403
    unsigned long key[] = {
-
 
404
        [DENTRIES_KEY_INDEX] = dentry->index,
-
 
405
        [DENTRIES_KEY_DEV] = dentry->dev_handle
-
 
406
    };
388
    hash_table_remove(&dentries, &key, 1);
407
    hash_table_remove(&dentries, key, 2);
389
 
408
 
390
    hash_table_destroy(&dentry->names);
409
    hash_table_destroy(&dentry->names);
391
 
410
 
392
    if (dentry->type == TMPFS_FILE)
411
    if (dentry->type == TMPFS_FILE)
393
        free(dentry->data);
412
        free(dentry->data);
394
    free(dentry);
413
    free(dentry);
395
    return EOK;
414
    return EOK;
396
}
415
}
397
 
416
 
398
void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request)
417
void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request)
399
{
418
{
400
    dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
419
    dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
401
 
420
 
-
 
421
    /* accept the mount options */
-
 
422
    ipc_callid_t callid;
-
 
423
    size_t size;
-
 
424
    if (!ipc_data_write_receive(&callid, &size)) {
-
 
425
        ipc_answer_0(callid, EINVAL);
-
 
426
        ipc_answer_0(rid, EINVAL);
-
 
427
        return;
-
 
428
    }
-
 
429
    char *opts = malloc(size + 1);
-
 
430
    if (!opts) {
-
 
431
        ipc_answer_0(callid, ENOMEM);
-
 
432
        ipc_answer_0(rid, ENOMEM);
-
 
433
        return;
-
 
434
    }
-
 
435
    ipcarg_t retval = ipc_data_write_finalize(callid, opts, size);
-
 
436
    if (retval != EOK) {
-
 
437
        ipc_answer_0(rid, retval);
-
 
438
        free(opts);
-
 
439
        return;
-
 
440
    }
-
 
441
    opts[size] = '\0';
-
 
442
 
402
    /* Initialize TMPFS. */
443
    /* Initialize TMPFS instance. */
403
    if (!root && !tmpfs_init()) {
444
    if (!tmpfs_instance_init(dev_handle)) {
404
        ipc_answer_0(rid, ENOMEM);
445
        ipc_answer_0(rid, ENOMEM);
405
        return;
446
        return;
406
    }
447
    }
407
 
448
 
-
 
449
    tmpfs_dentry_t *root = tmpfs_root_get(dev_handle);
408
    if (dev_handle >= 0) {
450
    if (str_cmp(opts, "restore") == 0) {
409
        if (tmpfs_restore(dev_handle))
451
        if (tmpfs_restore(dev_handle))
410
            ipc_answer_3(rid, EOK, root->index, root->size,
452
            ipc_answer_3(rid, EOK, root->index, root->size,
411
                root->lnkcnt);
453
                root->lnkcnt);
412
        else
454
        else
413
            ipc_answer_0(rid, ELIMIT);
455
            ipc_answer_0(rid, ELIMIT);
414
    } else {
456
    } else {
415
        ipc_answer_3(rid, EOK, root->index, root->size, root->lnkcnt);
457
        ipc_answer_3(rid, EOK, root->index, root->size, root->lnkcnt);
416
    }
458
    }
417
}
459
}
418
 
460
 
419
void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request)
461
void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request)
420
{
462
{
421
    dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
463
    dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
422
    fs_index_t mp_index = (fs_index_t) IPC_GET_ARG2(*request);
464
    fs_index_t mp_index = (fs_index_t) IPC_GET_ARG2(*request);
423
    fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
465
    fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
424
    dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);
466
    dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);
425
   
467
   
426
    ipc_answer_0(rid, ENOTSUP);
468
    ipc_answer_0(rid, ENOTSUP);
427
}
469
}
428
 
470
 
429
void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
471
void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
430
{
472
{
431
    libfs_lookup(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request);
473
    libfs_lookup(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request);
432
}
474
}
433
 
475
 
434
void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
476
void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
435
{
477
{
436
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
478
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
437
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
479
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
438
    off_t pos = (off_t)IPC_GET_ARG3(*request);
480
    off_t pos = (off_t)IPC_GET_ARG3(*request);
439
 
481
 
440
    /*
482
    /*
441
     * Lookup the respective dentry.
483
     * Lookup the respective dentry.
442
     */
484
     */
443
    link_t *hlp;
485
    link_t *hlp;
444
    unsigned long key = index;
486
    unsigned long key[] = {
-
 
487
        [DENTRIES_KEY_INDEX] = index,
-
 
488
        [DENTRIES_KEY_DEV] = dev_handle,
-
 
489
    };
445
    hlp = hash_table_find(&dentries, &key);
490
    hlp = hash_table_find(&dentries, key);
446
    if (!hlp) {
491
    if (!hlp) {
447
        ipc_answer_0(rid, ENOENT);
492
        ipc_answer_0(rid, ENOENT);
448
        return;
493
        return;
449
    }
494
    }
450
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
495
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
451
        dh_link);
496
        dh_link);
452
 
497
 
453
    /*
498
    /*
454
     * Receive the read request.
499
     * Receive the read request.
455
     */
500
     */
456
    ipc_callid_t callid;
501
    ipc_callid_t callid;
457
    size_t len;
502
    size_t size;
458
    if (!ipc_data_read_receive(&callid, &len)) {
503
    if (!ipc_data_read_receive(&callid, &size)) {
459
        ipc_answer_0(callid, EINVAL);  
504
        ipc_answer_0(callid, EINVAL);  
460
        ipc_answer_0(rid, EINVAL);
505
        ipc_answer_0(rid, EINVAL);
461
        return;
506
        return;
462
    }
507
    }
463
 
508
 
464
    size_t bytes;
509
    size_t bytes;
465
    if (dentry->type == TMPFS_FILE) {
510
    if (dentry->type == TMPFS_FILE) {
466
        bytes = max(0, min(dentry->size - pos, len));
511
        bytes = max(0, min(dentry->size - pos, size));
467
        (void) ipc_data_read_finalize(callid, dentry->data + pos,
512
        (void) ipc_data_read_finalize(callid, dentry->data + pos,
468
            bytes);
513
            bytes);
469
    } else {
514
    } else {
470
        int i;
515
        int i;
471
        tmpfs_dentry_t *cur;
516
        tmpfs_dentry_t *cur;
472
       
517
       
473
        assert(dentry->type == TMPFS_DIRECTORY);
518
        assert(dentry->type == TMPFS_DIRECTORY);
474
       
519
       
475
        /*
520
        /*
476
         * Yes, we really use O(n) algorithm here.
521
         * Yes, we really use O(n) algorithm here.
477
         * If it bothers someone, it could be fixed by introducing a
522
         * If it bothers someone, it could be fixed by introducing a
478
         * hash table.
523
         * hash table.
479
         */
524
         */
480
        for (i = 0, cur = dentry->child; i < pos && cur; i++,
525
        for (i = 0, cur = dentry->child; i < pos && cur; i++,
481
            cur = cur->sibling)
526
            cur = cur->sibling)
482
            ;
527
            ;
483
 
528
 
484
        if (!cur) {
529
        if (!cur) {
485
            ipc_answer_0(callid, ENOENT);
530
            ipc_answer_0(callid, ENOENT);
486
            ipc_answer_1(rid, ENOENT, 0);
531
            ipc_answer_1(rid, ENOENT, 0);
487
            return;
532
            return;
488
        }
533
        }
489
 
534
 
490
        unsigned long key = (unsigned long) dentry;
535
        unsigned long key = (unsigned long) dentry;
491
        link_t *hlp = hash_table_find(&cur->names, &key);
536
        link_t *hlp = hash_table_find(&cur->names, &key);
492
        assert(hlp);
537
        assert(hlp);
493
        tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t,
538
        tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t,
494
            link);
539
            link);
495
 
540
 
496
        (void) ipc_data_read_finalize(callid, namep->name,
541
        (void) ipc_data_read_finalize(callid, namep->name,
497
            strlen(namep->name) + 1);
542
            str_size(namep->name) + 1);
498
        bytes = 1;
543
        bytes = 1;
499
    }
544
    }
500
 
545
 
501
    /*
546
    /*
502
     * Answer the VFS_READ call.
547
     * Answer the VFS_READ call.
503
     */
548
     */
504
    ipc_answer_1(rid, EOK, bytes);
549
    ipc_answer_1(rid, EOK, bytes);
505
}
550
}
506
 
551
 
507
void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
552
void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
508
{
553
{
509
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
554
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
510
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
555
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
511
    off_t pos = (off_t)IPC_GET_ARG3(*request);
556
    off_t pos = (off_t)IPC_GET_ARG3(*request);
512
 
557
 
513
    /*
558
    /*
514
     * Lookup the respective dentry.
559
     * Lookup the respective dentry.
515
     */
560
     */
516
    link_t *hlp;
561
    link_t *hlp;
517
    unsigned long key = index;
562
    unsigned long key[] = {
-
 
563
        [DENTRIES_KEY_INDEX] = index,
-
 
564
        [DENTRIES_KEY_DEV] = dev_handle
-
 
565
    };
518
    hlp = hash_table_find(&dentries, &key);
566
    hlp = hash_table_find(&dentries, key);
519
    if (!hlp) {
567
    if (!hlp) {
520
        ipc_answer_0(rid, ENOENT);
568
        ipc_answer_0(rid, ENOENT);
521
        return;
569
        return;
522
    }
570
    }
523
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
571
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
524
        dh_link);
572
        dh_link);
525
 
573
 
526
    /*
574
    /*
527
     * Receive the write request.
575
     * Receive the write request.
528
     */
576
     */
529
    ipc_callid_t callid;
577
    ipc_callid_t callid;
530
    size_t len;
578
    size_t size;
531
    if (!ipc_data_write_receive(&callid, &len)) {
579
    if (!ipc_data_write_receive(&callid, &size)) {
532
        ipc_answer_0(callid, EINVAL);  
580
        ipc_answer_0(callid, EINVAL);  
533
        ipc_answer_0(rid, EINVAL);
581
        ipc_answer_0(rid, EINVAL);
534
        return;
582
        return;
535
    }
583
    }
536
 
584
 
537
    /*
585
    /*
538
     * Check whether the file needs to grow.
586
     * Check whether the file needs to grow.
539
     */
587
     */
540
    if (pos + len <= dentry->size) {
588
    if (pos + size <= dentry->size) {
541
        /* The file size is not changing. */
589
        /* The file size is not changing. */
542
        (void) ipc_data_write_finalize(callid, dentry->data + pos, len);
590
        (void) ipc_data_write_finalize(callid, dentry->data + pos, size);
543
        ipc_answer_2(rid, EOK, len, dentry->size);
591
        ipc_answer_2(rid, EOK, size, dentry->size);
544
        return;
592
        return;
545
    }
593
    }
546
    size_t delta = (pos + len) - dentry->size;
594
    size_t delta = (pos + size) - dentry->size;
547
    /*
595
    /*
548
     * At this point, we are deliberately extremely straightforward and
596
     * At this point, we are deliberately extremely straightforward and
549
     * simply realloc the contents of the file on every write that grows the
597
     * simply realloc the contents of the file on every write that grows the
550
     * file. In the end, the situation might not be as bad as it may look:
598
     * file. In the end, the situation might not be as bad as it may look:
551
     * our heap allocator can save us and just grow the block whenever
599
     * our heap allocator can save us and just grow the block whenever
552
     * possible.
600
     * possible.
553
     */
601
     */
554
    void *newdata = realloc(dentry->data, dentry->size + delta);
602
    void *newdata = realloc(dentry->data, dentry->size + delta);
555
    if (!newdata) {
603
    if (!newdata) {
556
        ipc_answer_0(callid, ENOMEM);
604
        ipc_answer_0(callid, ENOMEM);
557
        ipc_answer_2(rid, EOK, 0, dentry->size);
605
        ipc_answer_2(rid, EOK, 0, dentry->size);
558
        return;
606
        return;
559
    }
607
    }
560
    /* Clear any newly allocated memory in order to emulate gaps. */
608
    /* Clear any newly allocated memory in order to emulate gaps. */
561
    memset(newdata + dentry->size, 0, delta);
609
    memset(newdata + dentry->size, 0, delta);
562
    dentry->size += delta;
610
    dentry->size += delta;
563
    dentry->data = newdata;
611
    dentry->data = newdata;
564
    (void) ipc_data_write_finalize(callid, dentry->data + pos, len);
612
    (void) ipc_data_write_finalize(callid, dentry->data + pos, size);
565
    ipc_answer_2(rid, EOK, len, dentry->size);
613
    ipc_answer_2(rid, EOK, size, dentry->size);
566
}
614
}
567
 
615
 
568
void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
616
void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
569
{
617
{
570
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
618
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
571
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
619
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
572
    size_t size = (off_t)IPC_GET_ARG3(*request);
620
    size_t size = (off_t)IPC_GET_ARG3(*request);
573
 
621
 
574
    /*
622
    /*
575
     * Lookup the respective dentry.
623
     * Lookup the respective dentry.
576
     */
624
     */
577
    link_t *hlp;
625
    link_t *hlp;
578
    unsigned long key = index;
626
    unsigned long key[] = {
-
 
627
        [DENTRIES_KEY_INDEX] = index,
-
 
628
        [DENTRIES_KEY_DEV] = dev_handle
-
 
629
    };
579
    hlp = hash_table_find(&dentries, &key);
630
    hlp = hash_table_find(&dentries, key);
580
    if (!hlp) {
631
    if (!hlp) {
581
        ipc_answer_0(rid, ENOENT);
632
        ipc_answer_0(rid, ENOENT);
582
        return;
633
        return;
583
    }
634
    }
584
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
635
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
585
        dh_link);
636
        dh_link);
586
 
637
 
587
    if (size == dentry->size) {
638
    if (size == dentry->size) {
588
        ipc_answer_0(rid, EOK);
639
        ipc_answer_0(rid, EOK);
589
        return;
640
        return;
590
    }
641
    }
591
 
642
 
592
    void *newdata = realloc(dentry->data, size);
643
    void *newdata = realloc(dentry->data, size);
593
    if (!newdata) {
644
    if (!newdata) {
594
        ipc_answer_0(rid, ENOMEM);
645
        ipc_answer_0(rid, ENOMEM);
595
        return;
646
        return;
596
    }
647
    }
597
    if (size > dentry->size) {
648
    if (size > dentry->size) {
598
        size_t delta = size - dentry->size;
649
        size_t delta = size - dentry->size;
599
        memset(newdata + dentry->size, 0, delta);
650
        memset(newdata + dentry->size, 0, delta);
600
    }
651
    }
601
    dentry->size = size;
652
    dentry->size = size;
602
    dentry->data = newdata;
653
    dentry->data = newdata;
603
    ipc_answer_0(rid, EOK);
654
    ipc_answer_0(rid, EOK);
604
}
655
}
605
 
656
 
606
void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
657
void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
607
{
658
{
608
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
659
    dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
609
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
660
    fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
610
    int rc;
661
    int rc;
611
 
662
 
612
    link_t *hlp;
663
    link_t *hlp;
613
    unsigned long key = index;
664
    unsigned long key[] = {
-
 
665
        [DENTRIES_KEY_INDEX] = index,
-
 
666
        [DENTRIES_KEY_DEV] = dev_handle
-
 
667
    };
614
    hlp = hash_table_find(&dentries, &key);
668
    hlp = hash_table_find(&dentries, key);
615
    if (!hlp) {
669
    if (!hlp) {
616
        ipc_answer_0(rid, ENOENT);
670
        ipc_answer_0(rid, ENOENT);
617
        return;
671
        return;
618
    }
672
    }
619
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
673
    tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
620
        dh_link);
674
        dh_link);
621
    rc = tmpfs_destroy_node(dentry);
675
    rc = tmpfs_destroy_node(dentry);
622
    ipc_answer_0(rid, rc);
676
    ipc_answer_0(rid, rc);
623
}
677
}
624
 
678
 
625
/**
679
/**
626
 * @}
680
 * @}
627
 */
681
 */
628
 
682