aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_namespace.c')
-rw-r--r--src/fs/fs_namespace.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 6ede02afd..f098032d7 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -195,7 +195,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
195 char *uris; 195 char *uris;
196 196
197 fn = get_update_information_directory (uig->h, &uig->ns); 197 fn = get_update_information_directory (uig->h, &uig->ns);
198 wh = GNUNET_BIO_write_open (fn); 198 wh = GNUNET_BIO_write_open_file (fn);
199 if (NULL == wh) 199 if (NULL == wh)
200 { 200 {
201 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 201 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -205,16 +205,22 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
205 GNUNET_free (fn); 205 GNUNET_free (fn);
206 return; 206 return;
207 } 207 }
208 if (GNUNET_OK != GNUNET_BIO_write_int32 (wh, uig->update_node_count)) 208 if (GNUNET_OK != GNUNET_BIO_write_int32 (wh,
209 "fs-namespace-node-count",
210 uig->update_node_count))
209 goto END; 211 goto END;
210 for (i = 0; i < uig->update_node_count; i++) 212 for (i = 0; i < uig->update_node_count; i++)
211 { 213 {
212 n = uig->update_nodes[i]; 214 n = uig->update_nodes[i];
213 uris = GNUNET_FS_uri_to_string (n->uri); 215 uris = GNUNET_FS_uri_to_string (n->uri);
214 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) || 216 struct GNUNET_BIO_WriteSpec ws[] = {
215 (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) || 217 GNUNET_BIO_write_spec_string("fs-namespace-node-id", n->id),
216 (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) || 218 GNUNET_BIO_write_spec_meta_data("fs-namespace-node-meta", n->md),
217 (GNUNET_OK != GNUNET_BIO_write_string (wh, uris))) 219 GNUNET_BIO_write_spec_string("fs-namespace-node-update", n->update),
220 GNUNET_BIO_write_spec_string("fs-namespace-uris", uris),
221 GNUNET_BIO_write_spec_end(),
222 };
223 if (GNUNET_OK != GNUNET_BIO_write_spec_commit(wh, ws))
218 { 224 {
219 GNUNET_free (uris); 225 GNUNET_free (uris);
220 break; 226 break;
@@ -222,7 +228,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
222 GNUNET_free (uris); 228 GNUNET_free (uris);
223 } 229 }
224END: 230END:
225 if (GNUNET_OK != GNUNET_BIO_write_close (wh)) 231 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
226 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 232 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
227 _ ("Failed to write `%s': %s\n"), 233 _ ("Failed to write `%s': %s\n"),
228 fn, 234 fn,
@@ -260,13 +266,14 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
260 GNUNET_free (fn); 266 GNUNET_free (fn);
261 return uig; 267 return uig;
262 } 268 }
263 rh = GNUNET_BIO_read_open (fn); 269 rh = GNUNET_BIO_read_open_file (fn);
264 if (NULL == rh) 270 if (NULL == rh)
265 { 271 {
266 GNUNET_free (fn); 272 GNUNET_free (fn);
267 return uig; 273 return uig;
268 } 274 }
269 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &count)) 275 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "fs-namespace-count",
276 (int32_t *) &count))
270 { 277 {
271 GNUNET_break (0); 278 GNUNET_break (0);
272 goto END; 279 goto END;
@@ -284,12 +291,14 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
284 for (i = 0; i < count; i++) 291 for (i = 0; i < count; i++)
285 { 292 {
286 n = GNUNET_new (struct NamespaceUpdateNode); 293 n = GNUNET_new (struct NamespaceUpdateNode);
287 if ((GNUNET_OK != 294 struct GNUNET_BIO_ReadSpec rs[] = {
288 GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) || 295 GNUNET_BIO_read_spec_string("identifier", &n->id, 1024),
289 (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) || 296 GNUNET_BIO_read_spec_meta_data("meta", &n->md),
290 (GNUNET_OK != 297 GNUNET_BIO_read_spec_string("update-id", &n->update, 1024),
291 GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) || 298 GNUNET_BIO_read_spec_string("uri", &uris, 1024 * 2),
292 (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2))) 299 GNUNET_BIO_read_spec_end(),
300 };
301 if (GNUNET_OK != GNUNET_BIO_read_spec_commit (rh, rs))
293 { 302 {
294 GNUNET_break (0); 303 GNUNET_break (0);
295 GNUNET_free_non_null (n->id); 304 GNUNET_free_non_null (n->id);