Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Blocksync-fast uses the Libgcrypt library and supports many hashing algorithms,
## Installation

```console
$ ./configure
$ CFLAGS="-Wall -Werror -D_FILE_OFFSET_BITS=64" LIBS="-lm" ./configure
$ make
$ make install
```
Expand Down
29 changes: 14 additions & 15 deletions src/blocksync-fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ void print_help(void)

fprintf(flag.prst, "\n");

fprintf(flag.prst, "Usage:\n",
process_name);
fprintf(flag.prst, "Usage:\n");

fprintf(flag.prst, " %s [options]\n",
process_name);
Expand Down Expand Up @@ -252,9 +251,9 @@ void print_summary(void)
if (flag.progress > 0)
fprintf(flag.prst, "\n");

fprintf(flag.prst, "%s: %zu/%zu blocks, %zu/%zu bytes.\n",
fprintf(flag.prst, "%s: %zu/%zu blocks, %zu/%llu bytes.\n",
flag.oper_mode == MAKEDIGEST ? (IS_MODE(digest.open_mode, READ) ? "Updated" : "Created") : (IS_MODE(dst.open_mode, READ) ? "Updated" : "Copied"),
prog.wri_blocks, param.num_blocks, prog.wri_bytes, param.data_size);
prog.wri_blocks, param.num_blocks, prog.wri_bytes, (unsigned long long)param.data_size);

if ( flag.oper_mode == BLOCKSYNC && IS_MODE(src.open_mode, PIPE_R) ) {

Expand Down Expand Up @@ -747,11 +746,11 @@ void make_digest(void)

void init_params(void)
{
if (flag.oper_mode == MAKEDELTA && delta.path == NULL || flag.oper_mode == MAKEDIGEST && digest.path == NULL)
if ((flag.oper_mode == MAKEDELTA && delta.path == NULL) || (flag.oper_mode == MAKEDIGEST && digest.path == NULL))
flag.prst = stderr;

if (flag.silent)
freopen("/dev/null", "w", flag.prst) != NULL;
freopen("/dev/null", "w", flag.prst);

init_map_methods();

Expand Down Expand Up @@ -781,7 +780,7 @@ void init_params(void)
if (digest.path != NULL)
init_digest_file();
else
fprintf(flag.prst, "Warning: works without digest file.\n", process_name);
fprintf(flag.prst, "Warning: %s works without digest file.\n", process_name);

if (IS_MODE(digest.open_mode, READ))
dst.open_mode ^= READ;
Expand Down Expand Up @@ -816,7 +815,7 @@ void init_params(void)
}

if (digest.path == NULL)
fprintf(flag.prst, "Warning: works without digest file.\n", process_name);
fprintf(flag.prst, "Warning: %s works without digest file.\n", process_name);

if (param.hash_algo != NULL)
check_algo_param();
Expand Down Expand Up @@ -887,7 +886,7 @@ void init_params(void)
dst.buf_size = (dst.data_size < dst.max_buf_size ? dst.data_size : dst.max_buf_size);
}

bool buf_adj_delta = false;
__attribute__((unused))bool buf_adj_delta = false;

if (flag.oper_mode == MAKEDELTA)
{
Expand Down Expand Up @@ -924,7 +923,7 @@ void init_params(void)
{
digest.block_size = param.algo.size;
digest.max_buf_size = (src.max_buf_size / src.block_size) * digest.block_size;
bool buf_adj_digest = adjust_buffer(&digest.max_buf_size, digest.block_size);
__attribute__((unused))bool buf_adj_digest = adjust_buffer(&digest.max_buf_size, digest.block_size);

if (IS_MODE(digest.open_mode, DIRECT) || IS_MODE(digest.open_mode, PIPE))
digest.buf_data = realloc(digest.buf_data, digest.max_buf_size);
Expand All @@ -933,8 +932,8 @@ void init_params(void)
}

if (param.block_size < src.stat.st_blksize)
fprintf(flag.prst, "Warning: given block size is smaller than the block size of the source device, which is %zu bytes\n",
src.stat.st_blksize);
fprintf(flag.prst, "Warning: given block size is smaller than the block size of the source device, which is %llu bytes\n",
(unsigned long long)src.stat.st_blksize);
}

if (flag.oper_mode == BLOCKSYNC || flag.oper_mode == APPLYDELTA)
Expand All @@ -954,14 +953,14 @@ void init_params(void)
param.algo.symbol, param.algo.size);

if (param.algo.size > param.block_size)
fprintf(flag.prst, "Warning: block size '%ld' is smaller than hash '%s' size\n", param.block_size, param.algo.symbol);
fprintf(flag.prst, "Warning: block size '%zu' is smaller than hash '%s' size\n", param.block_size, param.algo.symbol);
}

if (param.data_size > (size_t)(1UL * 1024 * 1024 * 1024 * 1024)) {
if (param.data_size > (off_t)(1ULL * 1024 * 1024 * 1024 * 1024)) {
param.pro_prec = 2;
param.pro_fact = 100;
}
else if (param.data_size > (size_t)(100UL * 1024 * 1024 * 1024)) {
else if (param.data_size > (off_t)(100ULL * 1024 * 1024 * 1024)) {
param.pro_prec = 1;
param.pro_fact = 10;
}
Expand Down
4 changes: 2 additions & 2 deletions src/digest_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void digest_info(void)
digest.buf_data = malloc(digest.max_buf_size);
}

size_t dds = digest.data_size;
off_t dds = digest.data_size;
digest.data_size = HEADER_SIZE;
map_buffer(&digest);

Expand Down Expand Up @@ -158,7 +158,7 @@ void delta_info(void)
delta.buf_data = malloc(delta.max_buf_size);
}

size_t dds = delta.data_size;
off_t dds = delta.data_size;
delta.data_size = HEADER_SIZE;
map_buffer(&delta);

Expand Down
2 changes: 1 addition & 1 deletion src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void map_buffer(struct dev *dev)

if (rbytes < 0)
{
fprintf(stderr, "%s: error while reading from stdin : %s\n", process_name, dev->path, strerror(errno));
fprintf(stderr, "%s: error while reading from stdin : %s\n", process_name, strerror(errno));
cleanup(EXIT_FAILURE);
}

Expand Down
4 changes: 2 additions & 2 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extern struct dev
int fd;
struct stat stat;
off_t abs_off, buf_off, rel_off, mov_off;
size_t data_size;
off_t data_size;
size_t block_size;
size_t buf_size;
size_t max_buf_size;
Expand Down Expand Up @@ -177,7 +177,7 @@ extern struct param
size_t max_buf_size;
size_t num_blocks;
char *h_data_size;
size_t data_size;
off_t data_size;
int pro_prec;
int pro_fact;
char pro_form[20];
Expand Down
4 changes: 2 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void init_src_device(void)
src.path, format_units(src.data_size, true));
}

if (src.data_size < 1)
if (src.data_size == (off_t)-1)
{
fprintf(stderr, "%s: source device is empty\n", process_name);
cleanup(EXIT_FAILURE);
Expand Down Expand Up @@ -529,7 +529,7 @@ void init_src_delta(void)
fprintf(flag.prst, "Data to apply-delta is read from STDIN\n");
delta.fd = STDIN_FILENO;
delta.open_mode = PIPE;
delta.data_size = SIZE_MAX;
delta.data_size = LLONG_MAX;
}

delta.open_mode |= READ;
Expand Down
12 changes: 6 additions & 6 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#include "globals.h"
#include <math.h> // ceil

long parse_units(char *size)
off_t parse_units(char *size)
{
long number;
off_t number;
char *str;

number = strtoul(size, &str, 10);
number = strtoull(size, &str, 10);

if (strcasecmp(str, "k") == 0 || strcasecmp(str, "kib") == 0)
number *= 1024;
Expand All @@ -42,7 +42,7 @@ long parse_units(char *size)
return number;
}

char *format_units(long long int size, bool show_bytes)
char *format_units(off_t size, bool show_bytes)
{
char *number_str = malloc(80);

Expand All @@ -57,7 +57,7 @@ char *format_units(long long int size, bool show_bytes)
else
{
if (show_bytes)
sprintf(number_str, ("%llu bytes"), size);
sprintf(number_str, ("%llu bytes"), (unsigned long long)size);
else
sprintf(number_str, ("%.0f B"), (double)size);

Expand All @@ -68,7 +68,7 @@ char *format_units(long long int size, bool show_bytes)
{
char *number_str2 = malloc(80);
memcpy(number_str2, number_str, 80);
sprintf(number_str, ("%s, %llu bytes"), number_str2, size);
sprintf(number_str, ("%s, %llu bytes"), number_str2, (unsigned long long)size);
}

return number_str;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef UTILS_H
#define UTILS_H

long parse_units(char *size);
char *format_units(long long int size, bool show_bytes);
off_t parse_units(char *size);
char *format_units(off_t size, bool show_bytes);
off_t p2r(off_t x);

#endif