while (pos != NULL)
{
if ((GNUNET_OK !=
- GNUNET_BIO_write (wh,
- &pos->file_id,
- sizeof (GNUNET_HashCode))) ||
+ GNUNET_BIO_write (wh, &pos->file_id, sizeof (GNUNET_HashCode))) ||
(GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename)))
break;
pos = pos->next;
return;
}
while ((GNUNET_OK ==
- GNUNET_BIO_read (rh,
- "Hash of indexed file",
- &hc,
+ GNUNET_BIO_read (rh, "Hash of indexed file", &hc,
sizeof (GNUNET_HashCode))) &&
(GNUNET_OK ==
- GNUNET_BIO_read_string (rh,
- "Name of indexed file",
- &fname, 1024 * 16)) && (fname != NULL))
+ GNUNET_BIO_read_string (rh, "Name of indexed file", &fname,
+ 1024 * 16)) && (fname != NULL))
{
slen = strlen (fname) + 1;
pos = GNUNET_malloc (sizeof (struct IndexInfo) + slen);
pos->filename = (const char *) &pos[1];
memcpy (&pos[1], fname, slen);
if (GNUNET_SYSERR ==
- GNUNET_CONTAINER_multihashmap_put (ifm,
- &hc,
- (void *) pos->filename,
+ GNUNET_CONTAINER_multihashmap_put (ifm, &hc, (void *) pos->filename,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
GNUNET_free (pos);
signal_index_ok (struct IndexInfo *ii)
{
if (GNUNET_SYSERR ==
- GNUNET_CONTAINER_multihashmap_put (ifm,
- &ii->file_id,
+ GNUNET_CONTAINER_multihashmap_put (ifm, &ii->file_id,
(void *) ii->filename,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
ii->next = indexed_files;
indexed_files = ii;
write_index_list ();
- GNUNET_SERVER_transmit_context_append_data (ii->tc,
- NULL, 0,
+ GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK);
GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
ii->tc = NULL;
_
("Hash mismatch trying to index file `%s' which has hash `%s'\n"),
ii->filename, GNUNET_h2s (res));
-#if DEBUG_FS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Wanted `%s'\n", GNUNET_h2s (&ii->file_id));
-#endif
- GNUNET_SERVER_transmit_context_append_data (ii->tc,
- NULL, 0,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wanted `%s'\n",
+ GNUNET_h2s (&ii->file_id));
+ GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED);
GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
GNUNET_free (ii);
* @param message the actual message
*/
void
-GNUNET_FS_handle_index_start (void *cls,
- struct GNUNET_SERVER_Client *client,
+GNUNET_FS_handle_index_start (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct IndexStartMessage *ism;
ii->filename = (const char *) &ii[1];
memcpy (&ii[1], fn, slen);
ii->file_id = ism->file_id;
-#if DEBUG_FS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message for file `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for file `%s'\n",
"START_INDEX", ii->filename);
-#endif
-
ii->tc = GNUNET_SERVER_transmit_context_create (client);
mydev = 0;
myino = 0;
- if (((dev != 0) ||
- (ino != 0)) &&
- (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn,
- &mydev,
- &myino)) &&
+ if (((dev != 0) || (ino != 0)) &&
+ (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn, &mydev, &myino)) &&
((dev == mydev) && (ino == myino)))
{
/* fast validation OK! */
GNUNET_free (fn);
return;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
- (unsigned long long) ino,
- (unsigned long long) myino,
+ (unsigned long long) ino, (unsigned long long) myino,
(unsigned int) dev, (unsigned int) mydev);
-#endif
/* slow validation, need to hash full file (again) */
- ii->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
- fn,
- HASHING_BLOCKSIZE,
- &hash_for_index_val, ii);
+ ii->fhc =
+ GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, fn,
+ HASHING_BLOCKSIZE, &hash_for_index_val, ii);
if (ii->fhc == NULL)
hash_for_index_val (ii, NULL);
GNUNET_free (fn);
* @param message the actual message
*/
void
-GNUNET_FS_handle_index_list_get (void *cls,
- struct GNUNET_SERVER_Client *client,
+GNUNET_FS_handle_index_list_get (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVER_TransmitContext *tc;
GNUNET_SERVER_transmit_context_append_message (tc, &iim->header);
pos = pos->next;
}
- GNUNET_SERVER_transmit_context_append_data (tc,
- NULL, 0,
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES);
}
* @param message the actual message
*/
void
-GNUNET_FS_handle_unindex (void *cls,
- struct GNUNET_SERVER_Client *client,
+GNUNET_FS_handle_unindex (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct UnindexMessage *um;
else
prev->next = next;
GNUNET_break (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_remove (ifm,
- &pos->file_id,
+ GNUNET_CONTAINER_multihashmap_remove (ifm, &pos->file_id,
(void *)
pos->filename));
GNUNET_free (pos);
}
pos = next;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client requested unindexing of file `%s': %s\n",
GNUNET_h2s (&um->file_id), found ? "found" : "not found");
-#endif
if (GNUNET_YES == found)
write_index_list ();
tc = GNUNET_SERVER_transmit_context_create (client);
- GNUNET_SERVER_transmit_context_append_data (tc,
- NULL, 0,
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES);
}
*
* @param cls unused
* @param success did the deletion work?
+ * @param min_expiration minimum expiration time required for content to be stored
* @param msg error message
*/
static void
-remove_cont (void *cls, int success, const char *msg)
+remove_cont (void *cls, int success,
+ struct GNUNET_TIME_Absolute min_expiration,
+ const char *msg)
{
if (GNUNET_OK != success)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
* @return GNUNET_OK on success
*/
int
-GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- enum GNUNET_BLOCK_Type type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
- expiration, uint64_t uid,
+GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, uint32_t size,
+ const void *data, enum GNUNET_BLOCK_Type type,
+ uint32_t priority, uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration,
+ uint64_t uid,
GNUNET_DATASTORE_DatumProcessor cont,
void *cont_cls)
{
if (size != sizeof (struct OnDemandBlock))
{
GNUNET_break (0);
- GNUNET_DATASTORE_remove (dsh,
- key,
- size,
- data,
- -1, -1,
+ GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
return GNUNET_SYSERR;
}
odb = (const struct OnDemandBlock *) data;
off = GNUNET_ntohll (odb->offset);
fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id);
- fh = NULL;
- if ((NULL == fn) ||
- (NULL == (fh = GNUNET_DISK_file_open (fn,
- GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_NONE))) ||
- (off !=
- GNUNET_DISK_file_seek (fh,
- off,
- GNUNET_DISK_SEEK_SET)) ||
+ if ((NULL == fn) || (0 != ACCESS (fn, R_OK)))
+ {
+ GNUNET_STATISTICS_update (GSF_stats,
+ gettext_noop
+ ("# index blocks removed: original file inaccessible"),
+ 1, GNUNET_YES);
+ GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
+ GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
+ return GNUNET_SYSERR;
+ }
+ if ((NULL ==
+ (fh =
+ GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE))) ||
+ (off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)) ||
(-1 == (nsize = GNUNET_DISK_file_read (fh, ndata, sizeof (ndata)))))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
(fn == NULL) ? _("not indexed") : STRERROR (errno));
if (fh != NULL)
GNUNET_DISK_file_close (fh);
- GNUNET_DATASTORE_remove (dsh,
- key,
- size,
- data,
- -1, -1,
+ GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
return GNUNET_SYSERR;
}
if (0 != memcmp (&query, key, sizeof (GNUNET_HashCode)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Indexed file `%s' changed at offset %llu\n"),
- fn, (unsigned long long) off);
- GNUNET_DATASTORE_remove (dsh,
- key,
- size,
- data,
- -1, -1,
+ _("Indexed file `%s' changed at offset %llu\n"), fn,
+ (unsigned long long) off);
+ GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
return GNUNET_SYSERR;
}
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"On-demand encoded block for query `%s'\n", GNUNET_h2s (key));
-#endif
- cont (cont_cls,
- key,
- nsize,
- edata,
- GNUNET_BLOCK_TYPE_FS_DBLOCK, priority, anonymity, expiration, uid);
+ cont (cont_cls, key, nsize, edata, GNUNET_BLOCK_TYPE_FS_DBLOCK, priority,
+ anonymity, expiration, uid);
return GNUNET_OK;
}