Rev 3535 | Rev 3588 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3535 | Rev 3561 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | do { |
63 | do { |
64 | char *fname; |
64 | char *fname; |
65 | tmpfs_dentry_t *node; |
65 | tmpfs_dentry_t *node; |
66 | uint32_t size; |
66 | uint32_t size; |
67 | 67 | ||
68 | if (!block_read(dev, bufpos, buflen, pos, &entry, sizeof(entry), |
68 | if (block_read(dev, bufpos, buflen, pos, &entry, sizeof(entry), |
69 | TMPFS_BLOCK_SIZE)) |
69 | TMPFS_BLOCK_SIZE) != EOK) |
70 | return false; |
70 | return false; |
71 | 71 | ||
72 | entry.len = uint32_t_le2host(entry.len); |
72 | entry.len = uint32_t_le2host(entry.len); |
73 | 73 | ||
74 | switch (entry.type) { |
74 | switch (entry.type) { |
Line 83... | Line 83... | ||
83 | if (node == NULL) { |
83 | if (node == NULL) { |
84 | free(fname); |
84 | free(fname); |
85 | return false; |
85 | return false; |
86 | } |
86 | } |
87 | 87 | ||
88 | if (!block_read(dev, bufpos, buflen, pos, fname, |
88 | if (block_read(dev, bufpos, buflen, pos, fname, |
89 | entry.len, TMPFS_BLOCK_SIZE)) { |
89 | entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
90 | ops->destroy((void *) node); |
90 | ops->destroy((void *) node); |
91 | free(fname); |
91 | free(fname); |
92 | return false; |
92 | return false; |
93 | } |
93 | } |
94 | fname[entry.len] = 0; |
94 | fname[entry.len] = 0; |
Line 98... | Line 98... | ||
98 | free(fname); |
98 | free(fname); |
99 | return false; |
99 | return false; |
100 | } |
100 | } |
101 | free(fname); |
101 | free(fname); |
102 | 102 | ||
103 | if (!block_read(dev, bufpos, buflen, pos, &size, |
103 | if (block_read(dev, bufpos, buflen, pos, &size, |
104 | sizeof(size), TMPFS_BLOCK_SIZE)) |
104 | sizeof(size), TMPFS_BLOCK_SIZE) != EOK) |
105 | return false; |
105 | return false; |
106 | 106 | ||
107 | size = uint32_t_le2host(size); |
107 | size = uint32_t_le2host(size); |
108 | 108 | ||
109 | node->data = malloc(size); |
109 | node->data = malloc(size); |
110 | if (node->data == NULL) |
110 | if (node->data == NULL) |
111 | return false; |
111 | return false; |
112 | 112 | ||
113 | node->size = size; |
113 | node->size = size; |
114 | if (!block_read(dev, bufpos, buflen, pos, node->data, |
114 | if (block_read(dev, bufpos, buflen, pos, node->data, |
115 | size, TMPFS_BLOCK_SIZE)) |
115 | size, TMPFS_BLOCK_SIZE) != EOK) |
116 | return false; |
116 | return false; |
117 | 117 | ||
118 | break; |
118 | break; |
119 | case TMPFS_DIRECTORY: |
119 | case TMPFS_DIRECTORY: |
120 | fname = malloc(entry.len + 1); |
120 | fname = malloc(entry.len + 1); |
Line 125... | Line 125... | ||
125 | if (node == NULL) { |
125 | if (node == NULL) { |
126 | free(fname); |
126 | free(fname); |
127 | return false; |
127 | return false; |
128 | } |
128 | } |
129 | 129 | ||
130 | if (!block_read(dev, bufpos, buflen, pos, |
130 | if (block_read(dev, bufpos, buflen, pos, fname, |
131 | fname, entry.len, TMPFS_BLOCK_SIZE)) { |
131 | entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
132 | ops->destroy((void *) node); |
132 | ops->destroy((void *) node); |
133 | free(fname); |
133 | free(fname); |
134 | return false; |
134 | return false; |
135 | } |
135 | } |
136 | fname[entry.len] = 0; |
136 | fname[entry.len] = 0; |
Line 158... | Line 158... | ||
158 | bool tmpfs_restore(dev_handle_t dev) |
158 | bool tmpfs_restore(dev_handle_t dev) |
159 | { |
159 | { |
160 | libfs_ops_t *ops = &tmpfs_libfs_ops; |
160 | libfs_ops_t *ops = &tmpfs_libfs_ops; |
161 | int rc; |
161 | int rc; |
162 | 162 | ||
163 | rc = block_init(dev, TMPFS_BLOCK_SIZE, 0, 0); |
163 | rc = block_init(dev, TMPFS_BLOCK_SIZE); |
164 | if (rc != EOK) |
164 | if (rc != EOK) |
165 | return false; |
165 | return false; |
166 | 166 | ||
167 | off_t bufpos = 0; |
167 | off_t bufpos = 0; |
168 | size_t buflen = 0; |
168 | size_t buflen = 0; |
169 | off_t pos = 0; |
169 | off_t pos = 0; |
170 | 170 | ||
171 | char tag[6]; |
171 | char tag[6]; |
172 | if (!block_read(dev, &bufpos, &buflen, &pos, tag, 5, |
172 | if (block_read(dev, &bufpos, &buflen, &pos, tag, 5, |
173 | TMPFS_BLOCK_SIZE)) |
173 | TMPFS_BLOCK_SIZE) != EOK) |
174 | goto error; |
174 | goto error; |
175 | 175 | ||
176 | tag[5] = 0; |
176 | tag[5] = 0; |
177 | if (strcmp(tag, "TMPFS") != 0) |
177 | if (strcmp(tag, "TMPFS") != 0) |
178 | goto error; |
178 | goto error; |