mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-28 19:06:42 -05:00
Suppress missing file warnings if -m is specified
This commit is contained in:
parent
a5a72f4a31
commit
adbc74f862
10 changed files with 57 additions and 16 deletions
|
|
@ -148,11 +148,14 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out)
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
||||
if (!out_missing)
|
||||
out_missing = out;
|
||||
|
||||
/* if already opened, nothing to do */
|
||||
if (handle->file == file && handle->f != -1) {
|
||||
return 0;
|
||||
|
|
@ -179,7 +182,10 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
handle->f = -1;
|
||||
handle->valid_size = 0;
|
||||
|
||||
out("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
if (errno == ENOENT)
|
||||
out_missing("Missing file '%s'.\n", handle->path);
|
||||
else
|
||||
out("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +248,7 @@ int handle_close(struct snapraid_handle* handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, fptr* out)
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -251,9 +257,16 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
offset = block_file_pos(block) * (data_off_t)block_size;
|
||||
|
||||
if (!out_missing)
|
||||
out_missing = out;
|
||||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= handle->valid_size) {
|
||||
out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
/* if the file is missing, it's at 0 size, or it's rebuilt while reading */
|
||||
if (offset == handle->valid_size || handle->valid_size == 0)
|
||||
out_missing("Reading data from missing file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
else
|
||||
out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue