snapraid/cmdline/import.h

67 lines
1.8 KiB
C
Raw Permalink Normal View History

// SPDX-License-Identifier: GPL-3.0-or-later
2026-04-02 16:25:49 +02:00
// Copyright (C) 2013 Andrea Mazzoleni
2013-02-28 22:35:52 +01:00
#ifndef IMPORT_H
#define IMPORT_H
2013-02-28 22:35:52 +01:00
#include "elem.h"
#include "state.h"
/****************************************************************************/
/* import */
/**
* Import block.
* Block used to import data external when recovering by hash.
*/
struct snapraid_import_block {
struct snapraid_import_file* file; /**< Back pointer to the file owning this block. */
2026-06-04 00:34:51 +02:00
size_t size; /**< Size of the block. */
2013-02-28 22:35:52 +01:00
data_off_t offset; /**< Position of the block in the file. */
unsigned char hash[HASH_MAX]; /**< Hash of the block. */
unsigned char prevhash[HASH_MAX]; /**< Previous hash of the block. Valid only if we are in rehash state. */
2013-02-28 22:35:52 +01:00
/* nodes for data structures */
tommy_hashdyn_node nodeset;
2013-07-01 23:08:25 +02:00
tommy_hashdyn_node prevnodeset;
2013-02-28 22:35:52 +01:00
};
/**
* Import file.
* File used to import data external when recovering by hash.
*/
struct snapraid_import_file {
data_off_t size; /**< Size of the file. */
struct snapraid_import_block* blockimp; /**< All the blocks of the file. */
2013-02-28 22:35:52 +01:00
block_off_t blockmax; /**< Number of blocks. */
char* path; /**< Full path of the file. */
int is_runtime; /**< If the hash was obtained at runtime */
2013-02-28 22:35:52 +01:00
/* nodes for data structures */
tommy_node nodelist;
};
/**
2015-10-07 22:07:20 +02:00
* Deallocate an import file.
2013-02-28 22:35:52 +01:00
*/
void import_file_free(void* void_file);
2013-02-28 22:35:52 +01:00
/**
* Fetch a block from the specified hash.
* Return ==0 if the block is found, and copied into buffer.
*/
int state_import_fetch(struct snapraid_state* state, int prevhash, struct snapraid_block* missing_block, unsigned char* buffer);
2013-02-28 22:35:52 +01:00
/**
* Import files from the specified directory.
*/
void state_import(struct snapraid_state* state, const char* dir);
/**
* Import files from the dealloc list.
*/
void state_dealloc(struct snapraid_state* state, const char* dir, tommy_list* dealloclist);
2013-02-28 22:35:52 +01:00
#endif