Changeset 16dc887 in mainline for uspace/srv/fs/tmpfs


Ignore:
Timestamp:
2011-08-16T14:00:32Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
278ac72, b112055
Parents:
3751a08 (diff), cc574511 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Location service.

Location:
uspace/srv/fs/tmpfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs.h

    r3751a08 r16dc887  
    6161        fs_node_t *bp;          /**< Back pointer to the FS node. */
    6262        fs_index_t index;       /**< TMPFS node index. */
    63         devmap_handle_t devmap_handle;/**< Device handle. */
     63        service_id_t service_id;/**< Service ID of block device. */
    6464        link_t nh_link;         /**< Nodes hash table link. */
    6565        tmpfs_dentry_type_t type;
     
    7474
    7575extern bool tmpfs_init(void);
    76 extern bool tmpfs_restore(devmap_handle_t);
     76extern bool tmpfs_restore(service_id_t);
    7777
    7878#endif
  • uspace/srv/fs/tmpfs/tmpfs_dump.c

    r3751a08 r16dc887  
    5555
    5656static bool
    57 tmpfs_restore_recursion(devmap_handle_t dev, size_t *bufpos, size_t *buflen,
     57tmpfs_restore_recursion(service_id_t dsid, size_t *bufpos, size_t *buflen,
    5858    aoff64_t *pos, fs_node_t *pfn)
    5959{
     
    6868                uint32_t size;
    6969               
    70                 if (block_seqread(dev, bufpos, buflen, pos, &entry,
     70                if (block_seqread(dsid, bufpos, buflen, pos, &entry,
    7171                    sizeof(entry)) != EOK)
    7272                        return false;
     
    8282                                return false;
    8383                       
    84                         rc = ops->create(&fn, dev, L_FILE);
     84                        rc = ops->create(&fn, dsid, L_FILE);
    8585                        if (rc != EOK || fn == NULL) {
    8686                                free(fname);
     
    8888                        }
    8989                       
    90                         if (block_seqread(dev, bufpos, buflen, pos, fname,
     90                        if (block_seqread(dsid, bufpos, buflen, pos, fname,
    9191                            entry.len) != EOK) {
    9292                                (void) ops->destroy(fn);
     
    104104                        free(fname);
    105105                       
    106                         if (block_seqread(dev, bufpos, buflen, pos, &size,
     106                        if (block_seqread(dsid, bufpos, buflen, pos, &size,
    107107                            sizeof(size)) != EOK)
    108108                                return false;
     
    116116                       
    117117                        nodep->size = size;
    118                         if (block_seqread(dev, bufpos, buflen, pos, nodep->data,
     118                        if (block_seqread(dsid, bufpos, buflen, pos, nodep->data,
    119119                            size) != EOK)
    120120                                return false;
     
    126126                                return false;
    127127                       
    128                         rc = ops->create(&fn, dev, L_DIRECTORY);
     128                        rc = ops->create(&fn, dsid, L_DIRECTORY);
    129129                        if (rc != EOK || fn == NULL) {
    130130                                free(fname);
     
    132132                        }
    133133                       
    134                         if (block_seqread(dev, bufpos, buflen, pos, fname,
     134                        if (block_seqread(dsid, bufpos, buflen, pos, fname,
    135135                            entry.len) != EOK) {
    136136                                (void) ops->destroy(fn);
     
    148148                        free(fname);
    149149                       
    150                         if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos,
     150                        if (!tmpfs_restore_recursion(dsid, bufpos, buflen, pos,
    151151                            fn))
    152152                                return false;
     
    161161}
    162162
    163 bool tmpfs_restore(devmap_handle_t dev)
     163bool tmpfs_restore(service_id_t dsid)
    164164{
    165165        libfs_ops_t *ops = &tmpfs_libfs_ops;
     
    167167        int rc;
    168168
    169         rc = block_init(EXCHANGE_SERIALIZE, dev, TMPFS_COMM_SIZE);
     169        rc = block_init(EXCHANGE_SERIALIZE, dsid, TMPFS_COMM_SIZE);
    170170        if (rc != EOK)
    171171                return false;
     
    176176       
    177177        char tag[6];
    178         if (block_seqread(dev, &bufpos, &buflen, &pos, tag, 5) != EOK)
     178        if (block_seqread(dsid, &bufpos, &buflen, &pos, tag, 5) != EOK)
    179179                goto error;
    180180       
     
    183183                goto error;
    184184       
    185         rc = ops->root_get(&fn, dev);
     185        rc = ops->root_get(&fn, dsid);
    186186        if (rc != EOK)
    187187                goto error;
    188188
    189         if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos, fn))
    190                 goto error;
    191                
    192         block_fini(dev);
     189        if (!tmpfs_restore_recursion(dsid, &bufpos, &buflen, &pos, fn))
     190                goto error;
     191               
     192        block_fini(dsid);
    193193        return true;
    194194       
    195195error:
    196         block_fini(dev);
     196        block_fini(dsid);
    197197        return false;
    198198}
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r3751a08 r16dc887  
    6969/* Forward declarations of static functions. */
    7070static int tmpfs_match(fs_node_t **, fs_node_t *, const char *);
    71 static int tmpfs_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
     71static int tmpfs_node_get(fs_node_t **, service_id_t, fs_index_t);
    7272static int tmpfs_node_open(fs_node_t *);
    7373static int tmpfs_node_put(fs_node_t *);
    74 static int tmpfs_create_node(fs_node_t **, devmap_handle_t, int);
     74static int tmpfs_create_node(fs_node_t **, service_id_t, int);
    7575static int tmpfs_destroy_node(fs_node_t *);
    7676static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *);
     
    7878
    7979/* Implementation of helper functions. */
    80 static int tmpfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    81 {
    82         return tmpfs_node_get(rfn, devmap_handle, TMPFS_SOME_ROOT);
     80static int tmpfs_root_get(fs_node_t **rfn, service_id_t service_id)
     81{
     82        return tmpfs_node_get(rfn, service_id, TMPFS_SOME_ROOT);
    8383}
    8484
     
    114114}
    115115
    116 static devmap_handle_t tmpfs_device_get(fs_node_t *fn)
     116static service_id_t tmpfs_device_get(fs_node_t *fn)
    117117{
    118118        return 0;
     
    158158        switch (keys) {
    159159        case 1:
    160                 return (nodep->devmap_handle == key[NODES_KEY_DEV]);
     160                return (nodep->service_id == key[NODES_KEY_DEV]);
    161161        case 2:
    162                 return ((nodep->devmap_handle == key[NODES_KEY_DEV]) &&
     162                return ((nodep->service_id == key[NODES_KEY_DEV]) &&
    163163                    (nodep->index == key[NODES_KEY_INDEX]));
    164164        default:
     
    202202        nodep->bp = NULL;
    203203        nodep->index = 0;
    204         nodep->devmap_handle = 0;
     204        nodep->service_id = 0;
    205205        nodep->type = TMPFS_NONE;
    206206        nodep->lnkcnt = 0;
     
    226226}
    227227
    228 static bool tmpfs_instance_init(devmap_handle_t devmap_handle)
     228static bool tmpfs_instance_init(service_id_t service_id)
    229229{
    230230        fs_node_t *rfn;
    231231        int rc;
    232232       
    233         rc = tmpfs_create_node(&rfn, devmap_handle, L_DIRECTORY);
     233        rc = tmpfs_create_node(&rfn, service_id, L_DIRECTORY);
    234234        if (rc != EOK || !rfn)
    235235                return false;
     
    238238}
    239239
    240 static void tmpfs_instance_done(devmap_handle_t devmap_handle)
    241 {
    242         unsigned long key[] = {
    243                 [NODES_KEY_DEV] = devmap_handle
     240static void tmpfs_instance_done(service_id_t service_id)
     241{
     242        unsigned long key[] = {
     243                [NODES_KEY_DEV] = service_id
    244244        };
    245245        /*
     
    270270}
    271271
    272 int tmpfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
    273 {
    274         unsigned long key[] = {
    275                 [NODES_KEY_DEV] = devmap_handle,
     272int tmpfs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
     273{
     274        unsigned long key[] = {
     275                [NODES_KEY_DEV] = service_id,
    276276                [NODES_KEY_INDEX] = index
    277277        };
     
    299299}
    300300
    301 int tmpfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
     301int tmpfs_create_node(fs_node_t **rfn, service_id_t service_id, int lflag)
    302302{
    303303        fs_node_t *rootfn;
     
    318318        nodep->bp->data = nodep;        /* link the FS and TMPFS nodes */
    319319
    320         rc = tmpfs_root_get(&rootfn, devmap_handle);
     320        rc = tmpfs_root_get(&rootfn, service_id);
    321321        assert(rc == EOK);
    322322        if (!rootfn)
     
    324324        else
    325325                nodep->index = tmpfs_next_index++;
    326         nodep->devmap_handle = devmap_handle;
     326        nodep->service_id = service_id;
    327327        if (lflag & L_DIRECTORY)
    328328                nodep->type = TMPFS_DIRECTORY;
     
    332332        /* Insert the new node into the nodes hash table. */
    333333        unsigned long key[] = {
    334                 [NODES_KEY_DEV] = nodep->devmap_handle,
     334                [NODES_KEY_DEV] = nodep->service_id,
    335335                [NODES_KEY_INDEX] = nodep->index
    336336        };
     
    348348
    349349        unsigned long key[] = {
    350                 [NODES_KEY_DEV] = nodep->devmap_handle,
     350                [NODES_KEY_DEV] = nodep->service_id,
    351351                [NODES_KEY_INDEX] = nodep->index
    352352        };
     
    432432
    433433static int
    434 tmpfs_mounted(devmap_handle_t devmap_handle, const char *opts,
     434tmpfs_mounted(service_id_t service_id, const char *opts,
    435435    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    436436{
     
    439439       
    440440        /* Check if this device is not already mounted. */
    441         rc = tmpfs_root_get(&rootfn, devmap_handle);
     441        rc = tmpfs_root_get(&rootfn, service_id);
    442442        if ((rc == EOK) && (rootfn)) {
    443443                (void) tmpfs_node_put(rootfn);
     
    446446
    447447        /* Initialize TMPFS instance. */
    448         if (!tmpfs_instance_init(devmap_handle))
     448        if (!tmpfs_instance_init(service_id))
    449449                return ENOMEM;
    450450
    451         rc = tmpfs_root_get(&rootfn, devmap_handle);
     451        rc = tmpfs_root_get(&rootfn, service_id);
    452452        assert(rc == EOK);
    453453        tmpfs_node_t *rootp = TMPFS_NODE(rootfn);
    454454        if (str_cmp(opts, "restore") == 0) {
    455                 if (!tmpfs_restore(devmap_handle))
     455                if (!tmpfs_restore(service_id))
    456456                        return ELIMIT;
    457457        }
     
    464464}
    465465
    466 static int tmpfs_unmounted(devmap_handle_t devmap_handle)
    467 {
    468         tmpfs_instance_done(devmap_handle);
    469         return EOK;
    470 }
    471 
    472 static int tmpfs_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     466static int tmpfs_unmounted(service_id_t service_id)
     467{
     468        tmpfs_instance_done(service_id);
     469        return EOK;
     470}
     471
     472static int tmpfs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    473473    size_t *rbytes)
    474474{
     
    478478        link_t *hlp;
    479479        unsigned long key[] = {
    480                 [NODES_KEY_DEV] = devmap_handle,
     480                [NODES_KEY_DEV] = service_id,
    481481                [NODES_KEY_INDEX] = index
    482482        };
     
    532532
    533533static int
    534 tmpfs_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     534tmpfs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    535535    size_t *wbytes, aoff64_t *nsize)
    536536{
     
    540540        link_t *hlp;
    541541        unsigned long key[] = {
    542                 [NODES_KEY_DEV] = devmap_handle,
     542                [NODES_KEY_DEV] = service_id,
    543543                [NODES_KEY_INDEX] = index
    544544        };
     
    594594}
    595595
    596 static int tmpfs_truncate(devmap_handle_t devmap_handle, fs_index_t index,
     596static int tmpfs_truncate(service_id_t service_id, fs_index_t index,
    597597    aoff64_t size)
    598598{
     
    601601         */
    602602        unsigned long key[] = {
    603                 [NODES_KEY_DEV] = devmap_handle,
     603                [NODES_KEY_DEV] = service_id,
    604604                [NODES_KEY_INDEX] = index
    605605        };
     
    629629}
    630630
    631 static int tmpfs_close(devmap_handle_t devmap_handle, fs_index_t index)
    632 {
    633         return EOK;
    634 }
    635 
    636 static int tmpfs_destroy(devmap_handle_t devmap_handle, fs_index_t index)
     631static int tmpfs_close(service_id_t service_id, fs_index_t index)
     632{
     633        return EOK;
     634}
     635
     636static int tmpfs_destroy(service_id_t service_id, fs_index_t index)
    637637{
    638638        link_t *hlp;
    639639        unsigned long key[] = {
    640                 [NODES_KEY_DEV] = devmap_handle,
     640                [NODES_KEY_DEV] = service_id,
    641641                [NODES_KEY_INDEX] = index
    642642        };
     
    649649}
    650650
    651 static int tmpfs_sync(devmap_handle_t devmap_handle, fs_index_t index)
     651static int tmpfs_sync(service_id_t service_id, fs_index_t index)
    652652{
    653653        /*
Note: See TracChangeset for help on using the changeset viewer.