Changeset 72bde81 in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c


Ignore:
Timestamp:
2008-01-27T14:59:32Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2db4ac8
Parents:
1fe186f
Message:

Support for mkdir().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r1fe186f r72bde81  
    212212    const char *component, int lflag)
    213213{
    214         return 0;
     214        assert(dentry->type == TMPFS_DIRECTORY);
     215        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
     216
     217        tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
     218        if (!node)
     219                return 0;
     220        size_t len = strlen(component);
     221        char *name = malloc(len + 1);
     222        if (!name) {
     223                free(node);
     224                return 0;
     225        }
     226        strcpy(name, component);
     227
     228        tmpfs_dentry_initialize(node);
     229        node->index = tmpfs_next_index++;
     230        node->name = name;
     231        node->parent = dentry;
     232        if (lflag & L_DIRECTORY)
     233                node->type = TMPFS_DIRECTORY;
     234        else
     235                node->type = TMPFS_FILE;
     236
     237        /* Insert the new node into the namespace. */
     238        if (dentry->child) {
     239                tmpfs_dentry_t *tmp = dentry->child;
     240                while (tmp->sibling)
     241                        tmp = tmp->sibling;
     242                tmp->sibling = node;
     243        } else {
     244                dentry->child = node;
     245        }
     246
     247        /* Insert the new node into the dentry hash table. */
     248        hash_table_insert(&dentries, &node->index, &node->dh_link);
     249        return node->index;
    215250}
    216251
     
    257292                        component[len++] = PLB_GET_CHAR(next);
    258293                        next++; /* process next character */
    259                         if (next <= last)
     294                        if (next <= last) 
    260295                                continue;
    261296                }
     
    280315                                unsigned long index = create_node(dcur,
    281316                                    component, lflag);
    282                                 if (index) {
     317                                if (index > 0) {
    283318                                        ipc_answer_4(rid, EOK,
    284319                                            tmpfs_reg.fs_handle, dev_handle,
Note: See TracChangeset for help on using the changeset viewer.