version 1.1, 2019/02/10 23:18:28 |
version 1.2, 2019/02/10 23:24:14 |
|
|
blk_match_send(struct sess *sess, const char *path, int fd, |
blk_match_send(struct sess *sess, const char *path, int fd, |
const void *buf, off_t size, const struct blkset *blks) |
const void *buf, off_t size, const struct blkset *blks) |
{ |
{ |
off_t offs, last, end, fromcopy = 0, fromdown = 0, |
off_t offs, last, end, fromcopy = 0, fromdown = 0, |
total = 0, sz; |
total = 0, sz; |
int32_t tok; |
int32_t tok; |
struct blk *blk; |
struct blk *blk; |
|
|
blk_match(struct sess *sess, int fd, |
blk_match(struct sess *sess, int fd, |
const struct blkset *blks, const char *path) |
const struct blkset *blks, const char *path) |
{ |
{ |
int nfd, rc = 0, c; |
int nfd, rc = 0, c; |
struct stat st; |
struct stat st; |
void *map = MAP_FAILED; |
void *map = MAP_FAILED; |
size_t mapsz; |
size_t mapsz; |
|
|
"upload ratio", path, (intmax_t)st.st_size); |
"upload ratio", path, (intmax_t)st.st_size); |
} |
} |
|
|
/* |
/* |
* Now write the full file hash. |
* Now write the full file hash. |
* Since we're seeding the hash, this always gives us some sort |
* Since we're seeding the hash, this always gives us some sort |
* of data even if the file's zero-length. |
* of data even if the file's zero-length. |
|
|
} |
} |
} |
} |
|
|
/* |
/* |
* Read each block individually. |
* Read each block individually. |
* FIXME: read buffer and unbuffer. |
* FIXME: read buffer and unbuffer. |
*/ |
*/ |
|
|
/* Put the entire send routine into a buffer. */ |
/* Put the entire send routine into a buffer. */ |
|
|
sz = sizeof(int32_t) + /* identifier */ |
sz = sizeof(int32_t) + /* identifier */ |
sizeof(int32_t) + /* block count */ |
sizeof(int32_t) + /* block count */ |
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t) + /* block remainder */ |
sizeof(int32_t) + /* block remainder */ |
p->blksz * |
p->blksz * |
(sizeof(int32_t) + /* short checksum */ |
(sizeof(int32_t) + /* short checksum */ |
p->csum); /* long checksum */ |
p->csum); /* long checksum */ |
|
|
if (NULL == (buf = malloc(sz))) { |
if (NULL == (buf = malloc(sz))) { |
ERR(sess, "malloc"); |
ERR(sess, "malloc"); |
|
|
io_buffer_int(sess, buf, &pos, sz, p->rem); |
io_buffer_int(sess, buf, &pos, sz, p->rem); |
|
|
for (i = 0; i < p->blksz; i++) { |
for (i = 0; i < p->blksz; i++) { |
io_buffer_int(sess, buf, &pos, |
io_buffer_int(sess, buf, &pos, |
sz, p->blks[i].chksum_short); |
sz, p->blks[i].chksum_short); |
io_buffer_buf(sess, buf, &pos, sz, |
io_buffer_buf(sess, buf, &pos, sz, |
p->blks[i].chksum_long, p->csum); |
p->blks[i].chksum_long, p->csum); |
} |
} |
|
|