Changeset 7858bc5f in mainline for uspace/srv/fs/tmpfs/tmpfs_dump.c


Ignore:
Timestamp:
2008-10-28T15:40:19Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
916bf1a
Parents:
5cf723b
Message:

Setup communication parameters with the block device in block_init(). The file
system now doesn't know anything about the communication with the block device.
Rename blockread() to block_read(). The boot block is now read only once. The file
system can get access it using the block_bb_get() function.

File:
1 edited

Legend:

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

    r5cf723b r7858bc5f  
    3939#include "tmpfs.h"
    4040#include "../../vfs/vfs.h"
    41 #include <ipc/ipc.h>
    42 #include <async.h>
    4341#include <errno.h>
    4442#include <stdlib.h>
     
    4745#include <as.h>
    4846#include <libblock.h>
    49 #include <ipc/services.h>
    50 #include <ipc/devmap.h>
    51 #include <sys/mman.h>
    5247#include <byteorder.h>
    5348
     
    6055
    6156static bool
    62 tmpfs_restore_recursion(int phone, void *block, off_t *bufpos, size_t *buflen,
    63     off_t *pos, tmpfs_dentry_t *parent)
     57tmpfs_restore_recursion(int dev, off_t *bufpos, size_t *buflen, off_t *pos,
     58    tmpfs_dentry_t *parent)
    6459{
    6560        struct rdentry entry;
     
    7166                uint32_t size;
    7267               
    73                 if (!blockread(phone, block, bufpos, buflen, pos, &entry,
    74                     sizeof(entry), TMPFS_BLOCK_SIZE))
     68                if (!block_read(dev, bufpos, buflen, pos, &entry, sizeof(entry),
     69                    TMPFS_BLOCK_SIZE))
    7570                        return false;
    7671               
     
    9186                        }
    9287                       
    93                         if (!blockread(phone, block, bufpos, buflen, pos, fname,
     88                        if (!block_read(dev, bufpos, buflen, pos, fname,
    9489                            entry.len, TMPFS_BLOCK_SIZE)) {
    9590                                ops->destroy((void *) node);
     
    106101                        free(fname);
    107102                       
    108                         if (!blockread(phone, block, bufpos, buflen, pos, &size,
     103                        if (!block_read(dev, bufpos, buflen, pos, &size,
    109104                            sizeof(size), TMPFS_BLOCK_SIZE))
    110105                                return false;
     
    117112                       
    118113                        node->size = size;
    119                         if (!blockread(phone, block, bufpos, buflen, pos,
    120                             node->data, size, TMPFS_BLOCK_SIZE))
     114                        if (!block_read(dev, bufpos, buflen, pos, node->data,
     115                            size, TMPFS_BLOCK_SIZE))
    121116                                return false;
    122117                       
     
    133128                        }
    134129                       
    135                         if (!blockread(phone, block, bufpos, buflen, pos, fname,
    136                             entry.len, TMPFS_BLOCK_SIZE)) {
     130                        if (!block_read(dev, bufpos, buflen, pos,
     131                            fname, entry.len, TMPFS_BLOCK_SIZE)) {
    137132                                ops->destroy((void *) node);
    138133                                free(fname);
     
    148143                        free(fname);
    149144                       
    150                         if (!tmpfs_restore_recursion(phone, block, bufpos,
    151                             buflen, pos, node))
     145                        if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos,
     146                            node))
    152147                                return false;
    153148                       
     
    164159{
    165160        libfs_ops_t *ops = &tmpfs_libfs_ops;
     161        int rc;
    166162
    167         void *block = mmap(NULL, TMPFS_BLOCK_SIZE,
    168             PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
    169        
    170         if (block == NULL)
    171                 return false;
    172        
    173         int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    174             DEVMAP_CONNECT_TO_DEVICE, dev);
    175 
    176         if (phone < 0) {
    177                 munmap(block, TMPFS_BLOCK_SIZE);
    178                 return false;
    179         }
    180        
    181         if (ipc_share_out_start(phone, block, AS_AREA_READ | AS_AREA_WRITE) !=
    182             EOK)
    183                 goto error;
     163        rc = block_init(dev, TMPFS_BLOCK_SIZE, 0, 0);
     164        if (rc != EOK)
     165                return false;
    184166       
    185167        off_t bufpos = 0;
     
    188170       
    189171        char tag[6];
    190         if (!blockread(phone, block, &bufpos, &buflen, &pos, tag, 5,
     172        if (!block_read(dev, &bufpos, &buflen, &pos, tag, 5,
    191173            TMPFS_BLOCK_SIZE))
    192174                goto error;
     
    196178                goto error;
    197179       
    198         if (!tmpfs_restore_recursion(phone, block, &bufpos, &buflen, &pos,
     180        if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos,
    199181            ops->root_get(dev)))
    200182                goto error;
    201183               
    202         ipc_hangup(phone);
    203         munmap(block, TMPFS_BLOCK_SIZE);
     184        block_fini(dev);
    204185        return true;
    205186       
    206187error:
    207         ipc_hangup(phone);
    208         munmap(block, TMPFS_BLOCK_SIZE);
     188        block_fini(dev);
    209189        return false;
    210190}
Note: See TracChangeset for help on using the changeset viewer.