Unindex file. More...
#include "platform.h"#include "gnunet_constants.h"#include "gnunet_fs_service.h"#include "gnunet_protocols.h"#include "fs_api.h"#include "fs_tree.h"#include "block_fs.h"#include "fs_publish_ublock.h"Go to the source code of this file.
Functions | |
| static size_t | unindex_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) |
| Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the tree). | |
| void | GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset) |
| Fill in all of the generic fields for an unindex event and call the callback. | |
| static void | unindex_progress (void *cls, uint64_t offset, const void *pt_block, size_t pt_size, unsigned int depth) |
| Function called with information about our progress in computing the tree encoding. | |
| static void | signal_unindex_error (struct GNUNET_FS_UnindexContext *uc) |
| We've encountered an error during unindexing. | |
| static void | process_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
| Continuation called to notify client about result of the datastore removal operation. | |
| static void | unindex_process (void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size) |
| Function called asking for the current (encoded) block to be processed. | |
| static void | handle_unindex_response (void *cls, const struct GNUNET_MessageHeader *msg) |
| Function called with the response from the FS service to our unindexing request. | |
| static void | unindex_mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
| Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. | |
| static void | unindex_finish (struct GNUNET_FS_UnindexContext *uc) |
| Function called when we are done with removing UBlocks. | |
| static void | unindex_directory_scan_cb (void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason) |
| Function called by the directory scanner as we extract keywords that we will need to remove UBlocks. | |
| void | GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc) |
| If necessary, connect to the datastore and remove the UBlocks. | |
| static void | continue_after_remove (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
| Continuation called to notify client about result of the remove operation for the UBlock. | |
| static void | process_kblock_for_unindex (void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
| Function called from datastore with result from us looking for a UBlock. | |
| void | GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) |
| If necessary, connect to the datastore and remove the KBlocks. | |
| static void | unindex_extract_keywords (void *cls) |
| Function called when the tree encoder has processed all blocks. | |
| void | GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) |
| Connect to the datastore and remove the blocks. | |
| void | GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode *file_id) |
| Function called once the hash of the file that is being unindexed has been computed. | |
| void | GNUNET_FS_unindex_signal_suspend_ (void *cls) |
| Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal). | |
| struct GNUNET_FS_UnindexContext * | GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename, void *cctx) |
| Unindex a file. | |
| void | GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc) |
| Clean up after completion of an unindex operation. | |
Unindex file.
Definition in file fs_unindex.c.
|
static |
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the tree).
| cls | our publishing context |
| offset | identifies which block to get |
| max | (maximum) number of bytes to get; returning fewer will also cause errors |
| buf | where to copy the plaintext buffer |
| emsg | location to store an error message (on error) |
Definition at line 52 of file fs_unindex.c.
References _, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::file_size, GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_SEEK_SET, GNUNET_MIN, GNUNET_strdup, max, and uc.
Referenced by GNUNET_FS_unindex_do_remove_().
| void GNUNET_FS_unindex_make_status_ | ( | struct GNUNET_FS_ProgressInfo * | pi, |
| struct GNUNET_FS_UnindexContext * | uc, | ||
| uint64_t | offset | ||
| ) |
Fill in all of the generic fields for an unindex event and call the callback.
| pi | structure to fill in |
| uc | overall unindex context |
| offset | where we are in the file (for progress) |
Definition at line 85 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::start_time, uc, GNUNET_FS_ProgressInfo::unindex, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, and GNUNET_FS_ProgressInfo::value.
Referenced by deserialize_unindex_file(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_start(), GNUNET_FS_unindex_stop(), handle_unindex_response(), signal_unindex_error(), and unindex_progress().
|
static |
Function called with information about our progress in computing the tree encoding.
| cls | closure |
| offset | where are we in the file |
| pt_block | plaintext of the currently processed block |
| pt_size | size of pt_block |
| depth | depth of the block in the tree, 0 for DBLOCK |
Definition at line 114 of file fs_unindex.c.
References GNUNET_FS_ProgressInfo::depth, GNUNET_FS_STATUS_UNINDEX_PROGRESS, GNUNET_FS_unindex_make_status_(), GNUNET_FS_ProgressInfo::offset, GNUNET_FS_ProgressInfo::status, uc, GNUNET_FS_ProgressInfo::unindex, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_unindex_do_remove_(), and unindex_finish().
|
static |
We've encountered an error during unindexing.
Signal the client.
| uc | context for the failed unindexing operation |
Definition at line 139 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::emsg, GNUNET_FS_STATUS_UNINDEX_ERROR, GNUNET_FS_unindex_make_status_(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_FS_ProgressInfo::status, uc, GNUNET_FS_ProgressInfo::unindex, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_unindex_process_hash_(), process_cont(), unindex_finish(), and unindex_mq_error_handler().
|
static |
Continuation called to notify client about result of the datastore removal operation.
| cls | closure |
| success | GNUNET_SYSERR on failure |
| min_expiration | minimum expiration time required for content to be stored |
| msg | NULL on success, otherwise an error message |
Definition at line 160 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::emsg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_tree_encoder_next(), GNUNET_log, GNUNET_strdup, GNUNET_SYSERR, msg, signal_unindex_error(), GNUNET_FS_UnindexContext::tc, and uc.
Referenced by unindex_process().
|
static |
Function called asking for the current (encoded) block to be processed.
After processing the client should either call "GNUNET_FS_tree_encode_next" or (on error) "GNUNET_FS_tree_encode_finish".
| cls | closure |
| chk | content hash key for the block (key for lookup in the datastore) |
| offset | offset of the block |
| depth | depth of the block, 0 for DBLOCK |
| type | type of the block (IBLOCK or DBLOCK) |
| block | the (encrypted) block |
| block_size | size of block (in bytes) |
Definition at line 194 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::chk, data, GNUNET_FS_UnindexContext::dsh, OnDemandBlock::file_id, GNUNET_FS_UnindexContext::file_id, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_DATASTORE_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_log, OnDemandBlock::offset, process_cont(), ContentHashKey::query, size, type, and uc.
Referenced by GNUNET_FS_unindex_do_remove_().
|
static |
Function called with the response from the FS service to our unindexing request.
| cls | closure, unindex context |
| msg | the response |
Definition at line 235 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::file_size, GNUNET_FS_STATUS_UNINDEX_COMPLETED, GNUNET_FS_unindex_make_status_(), GNUNET_FS_unindex_sync_(), GNUNET_MQ_destroy(), GNUNET_TIME_UNIT_ZERO, GNUNET_FS_UnindexContext::mq, GNUNET_FS_UnindexContext::state, GNUNET_FS_ProgressInfo::status, uc, GNUNET_FS_ProgressInfo::unindex, UNINDEX_STATE_COMPLETE, and GNUNET_FS_ProgressInfo::value.
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
| cls | closure with the struct GNUNET_FS_UnindexContext * |
| error | error code |
Definition at line 265 of file fs_unindex.c.
References _, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_unindex_sync_(), GNUNET_MQ_destroy(), GNUNET_strdup, GNUNET_FS_UnindexContext::mq, signal_unindex_error(), GNUNET_FS_UnindexContext::state, uc, and UNINDEX_STATE_ERROR.
Referenced by unindex_finish().
|
static |
Function called when we are done with removing UBlocks.
Disconnect from datastore and notify FS service about the unindex event.
| uc | our unindexing context |
Definition at line 290 of file fs_unindex.c.
References _, GNUNET_FS_Handle::cfg, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, env, GNUNET_FS_UnindexContext::fh, UnindexMessage::file_id, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_UnindexContext::file_size, GNUNET_CLIENT_connect(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_unindex_sync_(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_UNINDEX, GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_strdup, GNUNET_FS_UnindexContext::h, handlers, GNUNET_FS_UnindexContext::mq, UnindexMessage::reserved, signal_unindex_error(), GNUNET_FS_UnindexContext::state, GNUNET_FS_UnindexContext::tc, uc, unindex_mq_error_handler(), unindex_progress(), UNINDEX_STATE_ERROR, and UNINDEX_STATE_FS_NOTIFY.
Referenced by GNUNET_FS_unindex_do_remove_kblocks_(), and unindex_directory_scan_cb().
|
static |
Function called by the directory scanner as we extract keywords that we will need to remove UBlocks.
| cls | the 'struct GNUNET_FS_UnindexContext *' |
| filename | which file we are making progress on |
| is_directory | GNUNET_YES if this is a directory, GNUNET_NO if this is a file GNUNET_SYSERR if it is neither (or unknown) |
| reason | kind of progress we are making |
Definition at line 355 of file fs_unindex.c.
References _, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::filename, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_directory_scan_abort(), GNUNET_FS_directory_scan_get_result(), GNUNET_FS_DIRSCANNER_FINISHED, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR, GNUNET_FS_share_tree_free(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_unindex_sync_(), GNUNET_FS_uri_dup(), GNUNET_log, GNUNET_strdup, GNUNET_FS_ShareTreeItem::ksk_uri, GNUNET_FS_UnindexContext::ksk_uri, GNUNET_FS_UnindexContext::state, uc, unindex_finish(), and UNINDEX_STATE_DS_REMOVE_KBLOCKS.
Referenced by GNUNET_FS_unindex_do_extract_keywords_().
| void GNUNET_FS_unindex_do_extract_keywords_ | ( | struct GNUNET_FS_UnindexContext * | uc | ) |
If necessary, connect to the datastore and remove the UBlocks.
Extract the keywords for KBlock removal.
| uc | context for the unindex operation. |
Definition at line 407 of file fs_unindex.c.
References GNUNET_FS_Handle::cfg, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::filename, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_FS_directory_scan_start(), GNUNET_NO, GNUNET_OK, GNUNET_FS_UnindexContext::h, uc, and unindex_directory_scan_cb().
Referenced by deserialize_unindex_file(), and unindex_extract_keywords().
|
static |
Continuation called to notify client about result of the remove operation for the UBlock.
| cls | the 'struct GNUNET_FS_UnindexContext *' |
| success | GNUNET_SYSERR on failure (including timeout/queue drop) GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success |
| min_expiration | minimum expiration time required for 0-priority content to be stored by the datacache at this time, zero for unknown, forever if we have no space for 0-priority content |
| msg | NULL on success, otherwise an error message |
Definition at line 437 of file fs_unindex.c.
References _, GNUNET_FS_UnindexContext::dqe, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_log, GNUNET_YES, GNUNET_FS_UnindexContext::ksk_offset, msg, and uc.
Referenced by process_kblock_for_unindex().
|
static |
Function called from datastore with result from us looking for a UBlock.
There are four cases: 1) no result, means we move on to the next keyword 2) data hash is the same as an already seen data hash, means we move on to next keyword 3) UBlock for a different CHK, means we keep looking for more 4) UBlock is for our CHK, means we remove the block and then move on to the next keyword
| cls | the 'struct GNUNET_FS_UnindexContext *' |
| key | key for the content |
| size | number of bytes in data |
| data | content stored |
| type | type of the content |
| priority | priority of the content |
| anonymity | anonymity-level for the content |
| replication | replication-level for the content |
| expiration | expiration time for the content |
| uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 477 of file fs_unindex.c.
References FileIdentifier::chk, GNUNET_FS_Uri::chk, GNUNET_FS_UnindexContext::chk, continue_after_remove(), data, GNUNET_FS_Uri::data, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dsh, GNUNET_assert, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_remove(), GNUNET_FS_ublock_decrypt_(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), key, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_UnindexContext::ksk_offset, GNUNET_FS_UnindexContext::ksk_uri, process_kblock_for_unindex(), size, type, uc, GNUNET_FS_UnindexContext::uquery, and UBlock::verification_key.
Referenced by GNUNET_FS_unindex_do_remove_kblocks_(), and process_kblock_for_unindex().
| void GNUNET_FS_unindex_do_remove_kblocks_ | ( | struct GNUNET_FS_UnindexContext * | uc | ) |
If necessary, connect to the datastore and remove the KBlocks.
| uc | context for the unindex operation. |
Definition at line 581 of file fs_unindex.c.
References _, GNUNET_FS_Handle::cfg, GNUNET_FS_Uri::data, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_DATASTORE_connect(), GNUNET_DATASTORE_get_key(), GNUNET_FS_unindex_sync_(), GNUNET_strdup, GNUNET_FS_UnindexContext::h, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_UnindexContext::ksk_offset, GNUNET_FS_UnindexContext::ksk_uri, process_kblock_for_unindex(), signal_unindex_error(), GNUNET_FS_UnindexContext::state, uc, unindex_finish(), UNINDEX_STATE_ERROR, and GNUNET_FS_UnindexContext::uquery.
Referenced by continue_after_remove(), deserialize_unindex_file(), process_kblock_for_unindex(), and unindex_directory_scan_cb().
|
static |
Function called when the tree encoder has processed all blocks.
Clean up.
| cls | our unindexing context |
Definition at line 634 of file fs_unindex.c.
References GNUNET_FS_unindex_do_extract_keywords_(), GNUNET_FS_unindex_sync_(), GNUNET_FS_UnindexContext::state, uc, and UNINDEX_STATE_EXTRACT_KEYWORDS.
Referenced by GNUNET_FS_unindex_do_remove_().
| void GNUNET_FS_unindex_do_remove_ | ( | struct GNUNET_FS_UnindexContext * | uc | ) |
Connect to the datastore and remove the blocks.
| uc | context for the unindex operation. |
Definition at line 650 of file fs_unindex.c.
References _, GNUNET_FS_Handle::cfg, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_DATASTORE_connect(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_FS_tree_encoder_create(), GNUNET_FS_tree_encoder_next(), GNUNET_FS_unindex_sync_(), GNUNET_NO, GNUNET_strdup, GNUNET_FS_UnindexContext::h, signal_unindex_error(), GNUNET_FS_UnindexContext::state, GNUNET_FS_UnindexContext::tc, uc, unindex_extract_keywords(), unindex_process(), unindex_progress(), unindex_reader(), and UNINDEX_STATE_ERROR.
Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_process_hash_().
| void GNUNET_FS_unindex_process_hash_ | ( | void * | cls, |
| const struct GNUNET_HashCode * | file_id | ||
| ) |
Function called once the hash of the file that is being unindexed has been computed.
| cls | closure, unindex context |
| file_id | computed hash, NULL on error |
Definition at line 695 of file fs_unindex.c.
References _, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_stop(), GNUNET_FS_unindex_sync_(), GNUNET_strdup, signal_unindex_error(), GNUNET_FS_UnindexContext::state, uc, UNINDEX_STATE_DS_REMOVE, UNINDEX_STATE_ERROR, and UNINDEX_STATE_HASHING.
Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_start().
| void GNUNET_FS_unindex_signal_suspend_ | ( | void * | cls | ) |
Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal).
| cls | the struct GNUNET_FS_UnindexContext to signal for |
Definition at line 728 of file fs_unindex.c.
References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_break, GNUNET_CRYPTO_hash_file_cancel(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_free, GNUNET_FS_directory_scan_abort(), GNUNET_FS_end_top(), GNUNET_FS_STATUS_UNINDEX_SUSPEND, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_unindex_make_status_(), GNUNET_FS_uri_destroy(), GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::ksk_uri, GNUNET_FS_UnindexContext::mq, GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::state, GNUNET_FS_ProgressInfo::status, GNUNET_FS_UnindexContext::tc, GNUNET_FS_UnindexContext::top, uc, and UNINDEX_STATE_COMPLETE.
Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_start().