mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Fixes compilation in Windows.
This commit is contained in:
parent
0200a2b7fa
commit
10db41c732
4 changed files with 17 additions and 17 deletions
18
handle.c
18
handle.c
|
|
@ -109,7 +109,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* stdout)
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE
|
|||
handle->f = -1;
|
||||
handle->valid_size = 0;
|
||||
|
||||
fprintf(stdout, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
fprintf(out, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE
|
|||
/* get the stat info */
|
||||
ret = fstat(handle->f, &handle->st);
|
||||
if (ret != 0) {
|
||||
fprintf(stdout, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
fprintf(out, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE
|
|||
/* advise sequential access */
|
||||
ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (ret != 0) {
|
||||
fprintf(stdout, "Error advising file '%s'. %s.\n", handle->path, strerror(ret));
|
||||
fprintf(out, "Error advising file '%s'. %s.\n", handle->path, strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -186,7 +186,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, FILE* stdout)
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -197,7 +197,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= handle->valid_size) {
|
||||
fprintf(stdout, "Reading missing data from file '%s' at offset %"PRIu64".\n", handle->path, offset);
|
||||
fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", handle->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
#if !HAVE_PREAD
|
||||
if (lseek(handle->f, offset, SEEK_SET) != offset) {
|
||||
fprintf(stdout, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -220,11 +220,11 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
#endif
|
||||
|
||||
if (read_ret < 0) {
|
||||
fprintf(stdout, "Error reading file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
fprintf(out, "Error reading file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
fprintf(stdout, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
4
handle.h
4
handle.h
|
|
@ -47,7 +47,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file);
|
|||
* Opens a file.
|
||||
* The file is opened for reading.
|
||||
*/
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* stdout);
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out);
|
||||
|
||||
/**
|
||||
* Closes a file.
|
||||
|
|
@ -58,7 +58,7 @@ int handle_close(struct snapraid_handle* handle);
|
|||
* Read a block from a file.
|
||||
* If the read block is shorter, it's padded with 0.
|
||||
*/
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* stdout);
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out);
|
||||
|
||||
/**
|
||||
* Writes a block to a file.
|
||||
|
|
|
|||
10
parity.c
10
parity.c
|
|
@ -363,7 +363,7 @@ int parity_write(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* stdout)
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -373,13 +373,13 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= parity->valid_size) {
|
||||
fprintf(stdout, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset);
|
||||
fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !HAVE_PREAD
|
||||
if (lseek(parity->f, offset, SEEK_SET) != offset) {
|
||||
fprintf(stdout, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -393,11 +393,11 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
read_ret = read(parity->f, block_buffer + count, block_size - count);
|
||||
#endif
|
||||
if (read_ret < 0) {
|
||||
fprintf(stdout, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(out, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
fprintf(stdout, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
parity.h
2
parity.h
|
|
@ -68,7 +68,7 @@ int parity_close(struct snapraid_parity* parity);
|
|||
/**
|
||||
* Read a block from the parity file.
|
||||
*/
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* stdout);
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out);
|
||||
|
||||
/**
|
||||
* Writes a block in the parity file.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue