Subversion Repositories HelenOS

Rev

Rev 3425 | Rev 3675 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3425 Rev 3597
Line 62... Line 62...
62
 * For now, we don't distinguish between different dev_handles/instances. All
62
 * For now, we don't distinguish between different dev_handles/instances. All
63
 * requests resolve to the only instance, rooted in the following variable.
63
 * requests resolve to the only instance, rooted in the following variable.
64
 */
64
 */
65
static tmpfs_dentry_t *root;
65
static tmpfs_dentry_t *root;
66
 
66
 
-
 
67
#define TMPFS_DEV       0   /**< Dummy device handle for TMPFS */
-
 
68
 
67
/*
69
/*
68
 * Implementation of the libfs interface.
70
 * Implementation of the libfs interface.
69
 */
71
 */
70
 
72
 
71
/* Forward declarations of static functions. */
73
/* Forward declarations of static functions. */
72
static void *tmpfs_match(void *, const char *);
74
static void *tmpfs_match(void *, const char *);
73
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
75
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
74
static void tmpfs_node_put(void *);
76
static void tmpfs_node_put(void *);
75
static void *tmpfs_create_node(int);
77
static void *tmpfs_create_node(dev_handle_t, int);
76
static bool tmpfs_link_node(void *, void *, const char *);
78
static bool tmpfs_link_node(void *, void *, const char *);
77
static int tmpfs_unlink_node(void *, void *);
79
static int tmpfs_unlink_node(void *, void *);
78
static int tmpfs_destroy_node(void *);
80
static int tmpfs_destroy_node(void *);
79
 
81
 
80
/* Implementation of helper functions. */
82
/* Implementation of helper functions. */
Line 226... Line 228...
226
 
228
 
227
static bool tmpfs_init(void)
229
static bool tmpfs_init(void)
228
{
230
{
229
    if (!hash_table_create(&dentries, DENTRIES_BUCKETS, 1, &dentries_ops))
231
    if (!hash_table_create(&dentries, DENTRIES_BUCKETS, 1, &dentries_ops))
230
        return false;
232
        return false;
231
    root = (tmpfs_dentry_t *) tmpfs_create_node(L_DIRECTORY);
233
    root = (tmpfs_dentry_t *) tmpfs_create_node(TMPFS_DEV, L_DIRECTORY);
232
    if (!root) {
234
    if (!root) {
233
        hash_table_destroy(&dentries);
235
        hash_table_destroy(&dentries);
234
        return false;
236
        return false;
235
    }
237
    }
236
    root->lnkcnt = 0;   /* FS root is not linked */
238
    root->lnkcnt = 0;   /* FS root is not linked */
Line 280... Line 282...
280
void tmpfs_node_put(void *node)
282
void tmpfs_node_put(void *node)
281
{
283
{
282
    /* nothing to do */
284
    /* nothing to do */
283
}
285
}
284
 
286
 
285
void *tmpfs_create_node(int lflag)
287
void *tmpfs_create_node(dev_handle_t dev_handle, int lflag)
286
{
288
{
287
    assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
289
    assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
288
 
290
 
289
    tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
291
    tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
290
    if (!node)
292
    if (!node)