Changeset 7858bc5f in mainline for uspace/srv/fs/tmpfs/tmpfs_dump.c
- Timestamp:
- 2008-10-28T15:40:19Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 916bf1a
- Parents:
- 5cf723b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_dump.c
r5cf723b r7858bc5f 39 39 #include "tmpfs.h" 40 40 #include "../../vfs/vfs.h" 41 #include <ipc/ipc.h>42 #include <async.h>43 41 #include <errno.h> 44 42 #include <stdlib.h> … … 47 45 #include <as.h> 48 46 #include <libblock.h> 49 #include <ipc/services.h>50 #include <ipc/devmap.h>51 #include <sys/mman.h>52 47 #include <byteorder.h> 53 48 … … 60 55 61 56 static bool 62 tmpfs_restore_recursion(int phone, void *block, off_t *bufpos, size_t *buflen,63 off_t *pos,tmpfs_dentry_t *parent)57 tmpfs_restore_recursion(int dev, off_t *bufpos, size_t *buflen, off_t *pos, 58 tmpfs_dentry_t *parent) 64 59 { 65 60 struct rdentry entry; … … 71 66 uint32_t size; 72 67 73 if (!block read(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)) 75 70 return false; 76 71 … … 91 86 } 92 87 93 if (!block read(phone, block, bufpos, buflen, pos, fname,88 if (!block_read(dev, bufpos, buflen, pos, fname, 94 89 entry.len, TMPFS_BLOCK_SIZE)) { 95 90 ops->destroy((void *) node); … … 106 101 free(fname); 107 102 108 if (!block read(phone, block, bufpos, buflen, pos, &size,103 if (!block_read(dev, bufpos, buflen, pos, &size, 109 104 sizeof(size), TMPFS_BLOCK_SIZE)) 110 105 return false; … … 117 112 118 113 node->size = size; 119 if (!block read(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)) 121 116 return false; 122 117 … … 133 128 } 134 129 135 if (!block read(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)) { 137 132 ops->destroy((void *) node); 138 133 free(fname); … … 148 143 free(fname); 149 144 150 if (!tmpfs_restore_recursion( phone, block, bufpos,151 buflen, pos,node))145 if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos, 146 node)) 152 147 return false; 153 148 … … 164 159 { 165 160 libfs_ops_t *ops = &tmpfs_libfs_ops; 161 int rc; 166 162 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; 184 166 185 167 off_t bufpos = 0; … … 188 170 189 171 char tag[6]; 190 if (!block read(phone, block, &bufpos, &buflen, &pos, tag, 5,172 if (!block_read(dev, &bufpos, &buflen, &pos, tag, 5, 191 173 TMPFS_BLOCK_SIZE)) 192 174 goto error; … … 196 178 goto error; 197 179 198 if (!tmpfs_restore_recursion( phone, block, &bufpos, &buflen, &pos,180 if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos, 199 181 ops->root_get(dev))) 200 182 goto error; 201 183 202 ipc_hangup(phone); 203 munmap(block, TMPFS_BLOCK_SIZE); 184 block_fini(dev); 204 185 return true; 205 186 206 187 error: 207 ipc_hangup(phone); 208 munmap(block, TMPFS_BLOCK_SIZE); 188 block_fini(dev); 209 189 return false; 210 190 }
Note:
See TracChangeset
for help on using the changeset viewer.