version 1.1, 2012/02/17 15:09:30
|
version 1.1.1.3, 2016/11/01 09:54:32
|
Line 3
|
Line 3
|
* |
* |
* Copyright (C) 1996 Andrew Tridgell |
* Copyright (C) 1996 Andrew Tridgell |
* Copyright (C) 1996 Paul Mackerras |
* Copyright (C) 1996 Paul Mackerras |
* Copyright (C) 2004-2009 Wayne Davison | * Copyright (C) 2004-2015 Wayne Davison |
* |
* |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
Line 23
|
Line 23
|
|
|
extern int checksum_seed; |
extern int checksum_seed; |
extern int protocol_version; |
extern int protocol_version; |
|
extern int proper_seed_order; |
|
|
/* |
/* |
a simple 32 bit checksum that can be upadted from either end |
a simple 32 bit checksum that can be upadted from either end |
Line 54 void get_checksum2(char *buf, int32 len, char *sum)
|
Line 55 void get_checksum2(char *buf, int32 len, char *sum)
|
if (protocol_version >= 30) { |
if (protocol_version >= 30) { |
uchar seedbuf[4]; |
uchar seedbuf[4]; |
md5_begin(&m); |
md5_begin(&m); |
md5_update(&m, (uchar *)buf, len); | if (proper_seed_order) { |
if (checksum_seed) { | if (checksum_seed) { |
SIVALu(seedbuf, 0, checksum_seed); | SIVALu(seedbuf, 0, checksum_seed); |
md5_update(&m, seedbuf, 4); | md5_update(&m, seedbuf, 4); |
| } |
| md5_update(&m, (uchar *)buf, len); |
| } else { |
| md5_update(&m, (uchar *)buf, len); |
| if (checksum_seed) { |
| SIVALu(seedbuf, 0, checksum_seed); |
| md5_update(&m, seedbuf, 4); |
| } |
} |
} |
md5_result(&m, (uchar *)sum); |
md5_result(&m, (uchar *)sum); |
} else { |
} else { |
Line 98 void get_checksum2(char *buf, int32 len, char *sum)
|
Line 107 void get_checksum2(char *buf, int32 len, char *sum)
|
} |
} |
} |
} |
|
|
void file_checksum(char *fname, char *sum, OFF_T size) | void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum) |
{ |
{ |
struct map_struct *buf; |
struct map_struct *buf; |
OFF_T i, len = size; | OFF_T i, len = st_p->st_size; |
md_context m; |
md_context m; |
int32 remainder; |
int32 remainder; |
int fd; |
int fd; |
Line 112 void file_checksum(char *fname, char *sum, OFF_T size)
|
Line 121 void file_checksum(char *fname, char *sum, OFF_T size)
|
if (fd == -1) |
if (fd == -1) |
return; |
return; |
|
|
buf = map_file(fd, size, MAX_MAP_SIZE, CSUM_CHUNK); | buf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK); |
|
|
if (protocol_version >= 30) { |
if (protocol_version >= 30) { |
md5_begin(&m); |
md5_begin(&m); |