Subversion Repositories HelenOS

Rev

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

Rev 3597 Rev 3675
Line 73... Line 73...
73
/* Forward declarations of static functions. */
73
/* Forward declarations of static functions. */
74
static void *tmpfs_match(void *, const char *);
74
static void *tmpfs_match(void *, const char *);
75
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
75
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
76
static void tmpfs_node_put(void *);
76
static void tmpfs_node_put(void *);
77
static void *tmpfs_create_node(dev_handle_t, int);
77
static void *tmpfs_create_node(dev_handle_t, int);
78
static bool tmpfs_link_node(void *, void *, const char *);
78
static int tmpfs_link_node(void *, void *, const char *);
79
static int tmpfs_unlink_node(void *, void *);
79
static int tmpfs_unlink_node(void *, void *);
80
static int tmpfs_destroy_node(void *);
80
static int tmpfs_destroy_node(void *);
81
 
81
 
82
/* Implementation of helper functions. */
82
/* Implementation of helper functions. */
83
static fs_index_t tmpfs_index_get(void *nodep)
83
static fs_index_t tmpfs_index_get(void *nodep)
Line 306... Line 306...
306
    unsigned long key = node->index;
306
    unsigned long key = node->index;
307
    hash_table_insert(&dentries, &key, &node->dh_link);
307
    hash_table_insert(&dentries, &key, &node->dh_link);
308
    return (void *) node;
308
    return (void *) node;
309
}
309
}
310
 
310
 
311
bool tmpfs_link_node(void *prnt, void *chld, const char *nm)
311
int tmpfs_link_node(void *prnt, void *chld, const char *nm)
312
{
312
{
313
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
313
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
314
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld;
314
    tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld;
315
 
315
 
316
    assert(parentp->type == TMPFS_DIRECTORY);
316
    assert(parentp->type == TMPFS_DIRECTORY);
317
 
317
 
318
    tmpfs_name_t *namep = malloc(sizeof(tmpfs_name_t));
318
    tmpfs_name_t *namep = malloc(sizeof(tmpfs_name_t));
319
    if (!namep)
319
    if (!namep)
320
        return false;
320
        return ENOMEM;
321
    tmpfs_name_initialize(namep);
321
    tmpfs_name_initialize(namep);
322
    size_t len = strlen(nm);
322
    size_t len = strlen(nm);
323
    namep->name = malloc(len + 1);
323
    namep->name = malloc(len + 1);
324
    if (!namep->name) {
324
    if (!namep->name) {
325
        free(namep);
325
        free(namep);
326
        return false;
326
        return ENOMEM;
327
    }
327
    }
328
    strcpy(namep->name, nm);
328
    strcpy(namep->name, nm);
329
    namep->parent = parentp;
329
    namep->parent = parentp;
330
   
330
   
331
    childp->lnkcnt++;
331
    childp->lnkcnt++;
Line 341... Line 341...
341
        tmp->sibling = childp;
341
        tmp->sibling = childp;
342
    } else {
342
    } else {
343
        parentp->child = childp;
343
        parentp->child = childp;
344
    }
344
    }
345
 
345
 
346
    return true;
346
    return EOK;
347
}
347
}
348
 
348
 
349
int tmpfs_unlink_node(void *prnt, void *chld)
349
int tmpfs_unlink_node(void *prnt, void *chld)
350
{
350
{
351
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;
351
    tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;