Rev 3252 | Rev 3530 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3252 | Rev 3521 | ||
|---|---|---|---|
| Line 43... | Line 43... | ||
| 43 | #include <errno.h> |
43 | #include <errno.h> |
| 44 | #include <stdlib.h> |
44 | #include <stdlib.h> |
| 45 | #include <string.h> |
45 | #include <string.h> |
| 46 | #include <sys/types.h> |
46 | #include <sys/types.h> |
| 47 | #include <as.h> |
47 | #include <as.h> |
| 48 | #include <libfs.h> |
48 | #include <libblock.h> |
| 49 | #include <ipc/services.h> |
49 | #include <ipc/services.h> |
| 50 | #include <ipc/devmap.h> |
50 | #include <ipc/devmap.h> |
| 51 | #include <sys/mman.h> |
51 | #include <sys/mman.h> |
| 52 | #include <byteorder.h> |
52 | #include <byteorder.h> |
| 53 | 53 | ||
| Line 68... | Line 68... | ||
| 68 | do { |
68 | do { |
| 69 | char *fname; |
69 | char *fname; |
| 70 | tmpfs_dentry_t *node; |
70 | tmpfs_dentry_t *node; |
| 71 | uint32_t size; |
71 | uint32_t size; |
| 72 | 72 | ||
| 73 | if (!libfs_blockread(phone, block, bufpos, buflen, pos, &entry, |
73 | if (!blockread(phone, block, bufpos, buflen, pos, &entry, |
| 74 | sizeof(entry), TMPFS_BLOCK_SIZE)) |
74 | sizeof(entry), TMPFS_BLOCK_SIZE)) |
| 75 | return false; |
75 | return false; |
| 76 | 76 | ||
| 77 | entry.len = uint32_t_le2host(entry.len); |
77 | entry.len = uint32_t_le2host(entry.len); |
| 78 | 78 | ||
| Line 88... | Line 88... | ||
| 88 | if (node == NULL) { |
88 | if (node == NULL) { |
| 89 | free(fname); |
89 | free(fname); |
| 90 | return false; |
90 | return false; |
| 91 | } |
91 | } |
| 92 | 92 | ||
| 93 | if (!libfs_blockread(phone, block, bufpos, buflen, pos, |
93 | if (!blockread(phone, block, bufpos, buflen, pos, fname, |
| 94 | fname, entry.len, TMPFS_BLOCK_SIZE)) { |
94 | entry.len, TMPFS_BLOCK_SIZE)) { |
| 95 | ops->destroy((void *) node); |
95 | ops->destroy((void *) node); |
| 96 | free(fname); |
96 | free(fname); |
| 97 | return false; |
97 | return false; |
| 98 | } |
98 | } |
| 99 | fname[entry.len] = 0; |
99 | fname[entry.len] = 0; |
| Line 103... | Line 103... | ||
| 103 | free(fname); |
103 | free(fname); |
| 104 | return false; |
104 | return false; |
| 105 | } |
105 | } |
| 106 | free(fname); |
106 | free(fname); |
| 107 | 107 | ||
| 108 | if (!libfs_blockread(phone, block, bufpos, buflen, pos, |
108 | if (!blockread(phone, block, bufpos, buflen, pos, &size, |
| 109 | &size, sizeof(size), TMPFS_BLOCK_SIZE)) |
109 | sizeof(size), TMPFS_BLOCK_SIZE)) |
| 110 | return false; |
110 | return false; |
| 111 | 111 | ||
| 112 | size = uint32_t_le2host(size); |
112 | size = uint32_t_le2host(size); |
| 113 | 113 | ||
| 114 | node->data = malloc(size); |
114 | node->data = malloc(size); |
| 115 | if (node->data == NULL) |
115 | if (node->data == NULL) |
| 116 | return false; |
116 | return false; |
| 117 | 117 | ||
| 118 | node->size = size; |
118 | node->size = size; |
| 119 | if (!libfs_blockread(phone, block, bufpos, buflen, pos, |
119 | if (!blockread(phone, block, bufpos, buflen, pos, |
| 120 | node->data, size, TMPFS_BLOCK_SIZE)) |
120 | node->data, size, TMPFS_BLOCK_SIZE)) |
| 121 | return false; |
121 | return false; |
| 122 | 122 | ||
| 123 | break; |
123 | break; |
| 124 | case TMPFS_DIRECTORY: |
124 | case TMPFS_DIRECTORY: |
| Line 130... | Line 130... | ||
| 130 | if (node == NULL) { |
130 | if (node == NULL) { |
| 131 | free(fname); |
131 | free(fname); |
| 132 | return false; |
132 | return false; |
| 133 | } |
133 | } |
| 134 | 134 | ||
| 135 | if (!libfs_blockread(phone, block, bufpos, buflen, pos, |
135 | if (!blockread(phone, block, bufpos, buflen, pos, fname, |
| 136 | fname, entry.len, TMPFS_BLOCK_SIZE)) { |
136 | entry.len, TMPFS_BLOCK_SIZE)) { |
| 137 | ops->destroy((void *) node); |
137 | ops->destroy((void *) node); |
| 138 | free(fname); |
138 | free(fname); |
| 139 | return false; |
139 | return false; |
| 140 | } |
140 | } |
| 141 | fname[entry.len] = 0; |
141 | fname[entry.len] = 0; |
| Line 185... | Line 185... | ||
| 185 | off_t bufpos = 0; |
185 | off_t bufpos = 0; |
| 186 | size_t buflen = 0; |
186 | size_t buflen = 0; |
| 187 | off_t pos = 0; |
187 | off_t pos = 0; |
| 188 | 188 | ||
| 189 | char tag[6]; |
189 | char tag[6]; |
| 190 | if (!libfs_blockread(phone, block, &bufpos, &buflen, &pos, tag, 5, |
190 | if (!blockread(phone, block, &bufpos, &buflen, &pos, tag, 5, |
| 191 | TMPFS_BLOCK_SIZE)) |
191 | TMPFS_BLOCK_SIZE)) |
| 192 | goto error; |
192 | goto error; |
| 193 | 193 | ||
| 194 | tag[5] = 0; |
194 | tag[5] = 0; |
| 195 | if (strcmp(tag, "TMPFS") != 0) |
195 | if (strcmp(tag, "TMPFS") != 0) |