Changeset a35b458 in mainline for uspace/srv/fs/tmpfs/tmpfs_dump.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_dump.c
r3061bc1 ra35b458 64 64 libfs_ops_t *ops = &tmpfs_libfs_ops; 65 65 errno_t rc; 66 66 67 67 do { 68 68 char *fname; … … 70 70 tmpfs_node_t *nodep; 71 71 uint32_t size; 72 72 73 73 if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, &entry, 74 74 sizeof(entry)) != EOK) 75 75 return false; 76 76 77 77 entry.len = uint32_t_le2host(entry.len); 78 78 79 79 switch (entry.type) { 80 80 case TMPFS_NONE: … … 84 84 if (fname == NULL) 85 85 return false; 86 86 87 87 rc = ops->create(&fn, dsid, L_FILE); 88 88 if (rc != EOK || fn == NULL) { … … 90 90 return false; 91 91 } 92 92 93 93 if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, fname, 94 94 entry.len) != EOK) { … … 98 98 } 99 99 fname[entry.len] = 0; 100 100 101 101 rc = ops->link(pfn, fn, fname); 102 102 if (rc != EOK) { … … 106 106 } 107 107 free(fname); 108 108 109 109 if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, &size, 110 110 sizeof(size)) != EOK) 111 111 return false; 112 112 113 113 size = uint32_t_le2host(size); 114 114 115 115 nodep = TMPFS_NODE(fn); 116 116 nodep->data = malloc(size); 117 117 if (nodep->data == NULL) 118 118 return false; 119 119 120 120 nodep->size = size; 121 121 if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, nodep->data, 122 122 size) != EOK) 123 123 return false; 124 124 125 125 break; 126 126 case TMPFS_DIRECTORY: … … 128 128 if (fname == NULL) 129 129 return false; 130 130 131 131 rc = ops->create(&fn, dsid, L_DIRECTORY); 132 132 if (rc != EOK || fn == NULL) { … … 134 134 return false; 135 135 } 136 136 137 137 if (block_seqread(dsid, tmpfs_buf, bufpos, buflen, pos, fname, 138 138 entry.len) != EOK) { … … 150 150 } 151 151 free(fname); 152 152 153 153 if (!tmpfs_restore_recursion(dsid, bufpos, buflen, pos, 154 154 fn)) 155 155 return false; 156 156 157 157 break; 158 158 default: … … 160 160 } 161 161 } while (entry.type != TMPFS_NONE); 162 162 163 163 return true; 164 164 } … … 173 173 if (rc != EOK) 174 174 return false; 175 175 176 176 size_t bufpos = 0; 177 177 size_t buflen = 0; 178 178 aoff64_t pos = 0; 179 179 180 180 char tag[6]; 181 181 if (block_seqread(dsid, tmpfs_buf, &bufpos, &buflen, &pos, tag, 5) != EOK) 182 182 goto error; 183 183 184 184 tag[5] = 0; 185 185 if (str_cmp(tag, "TMPFS") != 0) 186 186 goto error; 187 187 188 188 rc = ops->root_get(&fn, dsid); 189 189 if (rc != EOK) … … 192 192 if (!tmpfs_restore_recursion(dsid, &bufpos, &buflen, &pos, fn)) 193 193 goto error; 194 194 195 195 block_fini(dsid); 196 196 return true; 197 197 198 198 error: 199 199 block_fini(dsid);
Note:
See TracChangeset
for help on using the changeset viewer.