Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changed file_sync to only lseek() when needed Added strsep() replacement code Modified build process to create Win32 binaries on release Added some comments to the sample configuration file Added stub for new configuration option "NotifyServer" Made backuppcd-passwd prompt for a password to be read froms stdin |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
33d0a0970f83726bd503f41391966f97 |
User & Date: | rkeene 2006-03-11 22:02:55 |
Context
2006-03-12
| ||
02:10 | Added a "gethostname()" replacement Added "backuppcd_notify()" and related code. No authentication is currently present. Created a small example "notify-server" in Tcl. This server just manipulates the "/etc/hosts" file. check-in: 0d7a0b3376 user: rkeene tags: trunk | |
2006-03-11
| ||
22:02 | Changed file_sync to only lseek() when needed Added strsep() replacement code Modified build process to create Win32 binaries on release Added some comments to the sample configuration file Added stub for new configuration option "NotifyServer" Made backuppcd-passwd prompt for a password to be read froms stdin check-in: 33d0a0970f user: rkeene tags: trunk | |
2006-01-30
| ||
04:43 | Changed the way "file_sync" works to a less latency-driven approach. check-in: 223caea2dc user: rkeene tags: trunk | |
Changes
Changes to backuppcd-auth.c.
|
| < > | 1 2 3 4 5 6 7 8 9 | #include "compat.h" #include <libconfig.h> #include "backuppcd-auth.h" struct bpcd_auth_userinfo; struct bpcd_auth_userinfo { const char *username; const char *passhash; backuppc_privs_t privs; |
︙ | ︙ |
Changes to backuppcd-passwd.c.
1 2 3 4 | #include "compat.h" #include "sha1.h" int main(int argc, char **argv) { | > > > > | > > > > > | > > > > > > > > > | | > > > > > > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include "compat.h" #include "sha1.h" int main(int argc, char **argv) { char *plaintext; char *fgets_ret; int fail_cnt = 0; if (argc == 1) { plaintext = malloc(1024); if (!plaintext) { perror("malloc"); return(EXIT_FAILURE); } plaintext[0] = '\0'; while (plaintext[0] == '\0' && fail_cnt < 3) { printf("Password: "); fflush(stdout); fgets_ret = fgets(plaintext, 1024, stdin); if (!fgets_ret) { perror("fgets"); return(EXIT_FAILURE); } if (plaintext[strlen(plaintext) - 1] == '\n') { plaintext[strlen(plaintext) - 1] = '\0'; } fail_cnt++; } } else if (argc > 1) { plaintext = argv[1]; } else { return(EXIT_FAILURE); } if (plaintext[0] == '\0') { printf("Invalid password specified, aborting.\n"); exit(EXIT_FAILURE); } printf("%s\n", SHA1sum(plaintext)); return(EXIT_SUCCESS); } |
Changes to backuppcd.c.
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | * These variables are global because the configuration is done by a seperate * function. */ static int backuppc_port = BPC_TCP_PORT; static uint32_t backuppc_writeblock_size = 32000; static char *backuppc_updateurl = NULL; static char *backuppc_binfile = NULL; #ifdef _USE_WIN32_ /* * Win32 service stuff. */ static SC_HANDLE manager = NULL; static SC_HANDLE service = NULL; | > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | * These variables are global because the configuration is done by a seperate * function. */ static int backuppc_port = BPC_TCP_PORT; static uint32_t backuppc_writeblock_size = 32000; static char *backuppc_updateurl = NULL; static char *backuppc_binfile = NULL; static char *backuppc_notifyserv = NULL; #ifdef _USE_WIN32_ /* * Win32 service stuff. */ static SC_HANDLE manager = NULL; static SC_HANDLE service = NULL; |
︙ | ︙ | |||
231 232 233 234 235 236 237 | const char *name; char fullpathname[BPC_MAXPATH_LEN]; char *symlinkdest; char *hrdlinkdest; off_t size; dev_t dev; mode_t mode; | < < < < < | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | const char *name; char fullpathname[BPC_MAXPATH_LEN]; char *symlinkdest; char *hrdlinkdest; off_t size; dev_t dev; mode_t mode; uid_t uid; gid_t gid; uint64_t blocks; uint32_t blksize; dev_t rdev; time_t mtime; time_t ctime; int md5_set; int issparse; |
︙ | ︙ | |||
3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 | lc_register_var("UpdateURL", LC_VAR_STRING, &backuppc_updateurl, 'U'); lc_register_var("Source", LC_VAR_STRING, &update_source, 0); lc_register_var("Destination", LC_VAR_STRING, &update_dest, 0); lc_register_var("Switch", LC_VAR_BOOL_BY_EXISTANCE, &do_switch, 0); lc_register_var("DeleteFile", LC_VAR_STRING, &update_delefile, 0); lc_register_var("BinaryFile", LC_VAR_STRING, &backuppc_binfile, 0); lc_register_var("ConfigFile", LC_VAR_STRING, &config_file, 'C'); /* * Process standard config files, command line arguments, and * environment variables. */ lc_p_ret = lc_process(argc, argv, "backuppcd", LC_CONF_SPACE, SYSCONFDIR "/backuppcd.conf"); if (lc_p_ret < 0) { | > | 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 | lc_register_var("UpdateURL", LC_VAR_STRING, &backuppc_updateurl, 'U'); lc_register_var("Source", LC_VAR_STRING, &update_source, 0); lc_register_var("Destination", LC_VAR_STRING, &update_dest, 0); lc_register_var("Switch", LC_VAR_BOOL_BY_EXISTANCE, &do_switch, 0); lc_register_var("DeleteFile", LC_VAR_STRING, &update_delefile, 0); lc_register_var("BinaryFile", LC_VAR_STRING, &backuppc_binfile, 0); lc_register_var("ConfigFile", LC_VAR_STRING, &config_file, 'C'); lc_register_var("NotifyServer", LC_VAR_STRING, &backuppc_notifyserv, 'S'); /* * Process standard config files, command line arguments, and * environment variables. */ lc_p_ret = lc_process(argc, argv, "backuppcd", LC_CONF_SPACE, SYSCONFDIR "/backuppcd.conf"); if (lc_p_ret < 0) { |
︙ | ︙ |
Changes to backuppcd.conf.
1 2 3 4 5 6 | User rkeene 984816fd329622876e14907634264e6f332e9fb3 ReadWrite Port 874 WriteBufferSize 32000 UpdateURL http://www.rkeene.org/projects/rget/backuppcd-@@OSNM@@-@@OSVS@@-@@ARCH@@ | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # User rkeene 984816fd329622876e14907634264e6f332e9fb3 ReadWrite # Port 874 # WriteBufferSize 32000 # UpdateURL http://www.rkeene.org/projects/rget/backuppcd-@@OSNM@@-@@OSVS@@-@@ARCH@@ # Register our existance and name with the following server NotifyServer BackupPCServer |
Changes to build/build.sh.
1 2 3 4 5 6 7 8 9 | #! /bin/sh make distclean autoconf; autoheader rm -rf autom4te.cache ./configure gcc -DHAVE_CONFIG_H -MM *.c | sed 's@compat.h@compat.h win32.h@' > Makefile.dep.dist make distclean | > > | 1 2 3 4 5 6 7 8 9 10 11 | #! /bin/sh if [ ! -x configure ]; then cd ../; fi make distclean autoconf; autoheader rm -rf autom4te.cache ./configure gcc -DHAVE_CONFIG_H -MM *.c | sed 's@compat.h@compat.h win32.h@' > Makefile.dep.dist make distclean |
︙ | ︙ | |||
30 31 32 33 34 35 36 | sed "s@__VERS__@DEVELOPMENT SNAPSHOT FROM `date`@g" build/backuppcd.lyx > backuppcd.lyx fi lyx2pdf backuppcd.lyx backuppcd.pdf mv backuppcd.pdf doc/ rm -f backuppcd.lyx fi | < < < | | | | | | | | > | < | | | | | | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | sed "s@__VERS__@DEVELOPMENT SNAPSHOT FROM `date`@g" build/backuppcd.lyx > backuppcd.lyx fi lyx2pdf backuppcd.lyx backuppcd.pdf mv backuppcd.pdf doc/ rm -f backuppcd.lyx fi WIN32="${HOME}/root/windows-i386" CFLAGS="-I${WIN32}/include -march=i386" CPPFLAGS="${CFLAGS}" LDFLAGS="-L${WIN32}/lib" LIBS="-static -lopennet" DATE="`date +%Y%m%d%H%M`" CROSS=i586-mingw32msvc if [ ! -z "${CROSS}" ]; then CROSSCMD="${CROSS}-" fi export CFLAGS LDFLAGS CPPFLAGS LIBS make distclean ./configure --enable-static --host=${CROSS} --prefix="c:/program files/backuppcd" $* && \ make || exit 1 ${CROSSCMD}strip backuppcd.exe if [ ! "${SNAPSHOT}" = "1" ]; then cp doc/backuppcd.pdf /web/rkeene/docs/oss/backuppcd/backuppcd.pdf cp backuppcd.exe "/web/rkeene/devel/backuppcd/win32/stable/backuppcd-${VERS}.exe" || exit 1 cp backuppcd-client.exe "/web/rkeene/devel/backuppcd/win32/stable/backuppcd-client-${VERS}.exe" || exit 1 cp backuppcd-passwd.exe "/web/rkeene/devel/backuppcd/win32/stable/backuppcd-passwd-${VERS}.exe" || exit 1 ( OLDWORKDIR="`pwd`" BTMPDIR="`pwd`/win32/" mkdir -p "${BTMPDIR}" || exit 1 cp doc/backuppcd.pdf backuppcd.exe backuppcd-client.exe backuppcd-passwd.exe "${BTMPDIR}" || exit 1 if [ -f "${BTMPDIR}/readme.txt" ]; then cat "${BTMPDIR}/readme.txt" | todos > "${BTMPDIR}/readme.txt.new" mv "${BTMPDIR}/readme.txt.new" "${BTMPDIR}/readme.txt" fi man2html -H "REPLACE" -M "/ME" < backuppcd.8 | grep -iv '^Content-Type:' | sed 's@"http://REPLACE/ME?\([0-9]*\)+\([^"]*\)"@"\2.htm"@;s@http://REPLACE/ME@@g' | todos > "${BTMPDIR}"/backuppcd.htm man2html -H "REPLACE" -M "/ME" < backuppcd-client.8 | grep -iv '^Content-Type:' | sed 's@"http://REPLACE/ME?\([0-9]*\)+\([^"]*\)"@"\2.htm"@;s@http://REPLACE/ME@@g' | todos > "${BTMPDIR}"/backuppcd-client.htm man2html -H "REPLACE" -M "/ME" < backuppcd.conf.5 | grep -iv '^Content-Type:' | sed 's@"http://REPLACE/ME?\([0-9]*\)+\([^"]*\)"@"\2.htm"@;s@http://REPLACE/ME@@g' | todos > "${BTMPDIR}"/backuppcd.conf.htm cd "${BTMPDIR}" || exit 1 if [ -x configure ]; then ./configure --host=${CROSS} --prefix="c:/program files/backuppcd/" --sysconfdir="c:/program files/backuppcd/" || exit 1 fi if [ -f Makefile ]; then make || exit 1 fi if [ -x cleanup.sh ]; then ./cleanup.sh fi zip "backuppcd-${VERS}.zip" * -x "backuppcd-${VERS}.zip" cp "backuppcd-${VERS}.zip" /web/rkeene/files/oss/backuppcd/win32/ || exit 1 cd "${OLDWORKDIR}" rm -rf "${BTMPDIR}" ) else cp backuppcd.exe "/web/rkeene/devel/backuppcd/win32/devel/backuppcd-${VERS}.exe" cp backuppcd-client.exe "/web/rkeene/devel/backuppcd/win32/devel/backuppcd-client-${VERS}.exe" fi |
Changes to compat.h.
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 | #endif #ifdef HAVE_STDIO_H #include <stdio.h> #endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #ifdef HAVE_SYS_VFS_H #include <sys/vfs.h> #endif | > > > < < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #endif #ifdef HAVE_STDIO_H #include <stdio.h> #endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #ifdef HAVE_SYS_STATFS_H #include <sys/statfs.h> #else #ifdef HAVE_SYS_VFS_H #include <sys/vfs.h> #endif #endif #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #ifdef TIME_WITH_SYS_TIME #include <sys/time.h> #include <time.h> |
︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | typedef int socklen_t; #endif #endif #ifndef HAVE_HTONLL #include "htonll.h" #endif #ifndef HAVE_NTOHLL #include "ntohll.h" #endif #ifdef HAVE_STATFS /* * These constants are used to determine the filesystem type from statfs(). * Only used under Linux as other statfs() implementations return ftype == 0. */ | > > > > > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | typedef int socklen_t; #endif #endif #ifndef HAVE_HTONLL #include "htonll.h" #endif #ifndef HAVE_NTOHLL #include "ntohll.h" #endif #ifndef HAVE_STRSEP #include "strsep.h" #endif #ifdef HAVE_STATFS /* * These constants are used to determine the filesystem type from statfs(). * Only used under Linux as other statfs() implementations return ftype == 0. */ |
︙ | ︙ |
Changes to configure.ac.
︙ | ︙ | |||
10 11 12 13 14 15 16 | AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_RANLIB AC_AIX AC_GNU_SOURCE AC_CHECK_TOOL(AR, ar, true) | | | > > > > > < < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_RANLIB AC_AIX AC_GNU_SOURCE AC_CHECK_TOOL(AR, ar, true) AC_CHECK_HEADERS(stdlib.h string.h unistd.h time.h sys/time.h sys/types.h signal.h syslog.h sys/select.h netinet/in.h arpa/inet.h sys/socket.h ssl.h openssl/ssl.h ssl/ssl.h fcntl.h dirent.h ctype.h assert.h endian.h stdarg.h utime.h fnmatch.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h sys/resource.h limits.h) AC_HEADER_TIME AC_CHECK_FUNCS(sysinfo openlog syslog setsid fork fcntl stat lstat lchown symlink readlink signal getenv utime statfs getmntinfo setpriority) AC_REPLACE_FUNCS(htonll ntohll chown link fnmatch strsep) DC_DO_NETWORK dnl Check for various types we use DC_DO_TYPE(uint64_t, unsigned, 8) DC_DO_TYPE(int64_t, signed, 8) DC_DO_TYPE(uint32_t, unsigned, 4) DC_DO_TYPE(int32_t, signed, 4) DC_DO_TYPE(uint16_t, unsigned, 2) DC_DO_TYPE(int16_t, signed, 2) AC_TYPE_UID_T dnl Checks for Win32 specific things. DC_DO_WIN32 dnl Large file support AC_SYS_LARGEFILE AC_FUNC_FSEEKO AC_TYPE_OFF_T dnl Check for libopennet DC_ASK_OPTLIB(opennet, fopen_net,opennet.h, [Support opennet (required for automatic updates)], opennet, HAVE_LIBOPENNET, HAVE_OPENNET_H) dnl Check for libconfig DC_ASK_OPTLIB(config, lc_process, libconfig.h, [Process configuration files using libconfig], libconfig, HAVE_LIBCONFIG, HAVE_LIBCONFIG_H,, [ AC_MSG_ERROR([Libconfig is required. http://www.rkeene.org/oss/libconfig/]) ]) DC_ASK_OPTLIB(ssl, SSL_library_init,, [Allow encrypted connections using SSL], openssl, HAVE_LIBSSL, THIS_MAKES_STUPID_AUTOHEADER_HAPPY, [-lwsock32 -lcrypto -lgdi32]) AC_ARG_WITH(nt4, AC_HELP_STRING([--with-nt4], [Enable support for Windows NT 4 (only applies for Windows)]), [ winntfoursupport=$withval ], [ winntfoursupport=no ]) if test "$winntfoursupport" = "no"; then AC_DEFINE(NO_WIN32_NT4, [1], [Define if you wish to disallow support for Windows NT 4]) fi |
︙ | ︙ |
Changes to fnmatch.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if HAVE_CONFIG_H # include <config.h> #endif /* Enable GNU extensions in fnmatch.h. */ #ifndef _GNU_SOURCE | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "compat.h" #if HAVE_CONFIG_H # include <config.h> #endif /* Enable GNU extensions in fnmatch.h. */ #ifndef _GNU_SOURCE |
︙ | ︙ |
Added strsep.c.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* Compliments of Jay Freeman <saurik@saurik.com> */ #include <string.h> char *strsep(char **stringp, const char *delim) { char *ret = *stringp; if (ret == NULL) return(NULL); /* grrr */ if ((*stringp = strpbrk(*stringp, delim)) != NULL) { *((*stringp)++) = '\0'; } return(ret); } |
Added strsep.h.
> > > > > > > > | 1 2 3 4 5 6 7 8 | /* Compliments of Jay Freeman <saurik@saurik.com> */ #ifndef _REPL_STRSEP_H #define _REPL_STRSEP_H char *strsep(char **stringp, const char *delim); #endif |
Changes to tools/file_sync.c.
︙ | ︙ | |||
130 131 132 133 134 135 136 | if (retval > 0) { net_bytesout += retval; } return(retval); } | | > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | if (retval > 0) { net_bytesout += retval; } return(retval); } int sync_transmit(const char *host, int port, const char *file, uint64_t blocksize) { rsaref_MD4_CTX mdctx; unsigned char md4buf[16]; uint64_t filesize; uint32_t blockok_size, blockidx; uint8_t *blockok, blockok_val; ssize_t read_ret, write_ret; char *buf; off_t lseek_ret; off_t curpos, destpos; int retval = 0; int sockfd; int fd; int i; fd = open(file, O_RDONLY | O_LARGEFILE); if (fd < 0) { |
︙ | ︙ | |||
243 244 245 246 247 248 249 250 251 252 253 254 255 | read_ret = read_large_net(sockfd, blockok, blockok_size); if (read_ret != blockok_size) { retval = -1; CHECKPOINT; } } if (retval != -1) { for (blockidx = 0; blockidx < blockok_size; blockidx++) { for (i = 0; i < 8; i++) { blockok_val = blockok[blockidx] & (1<<i); if (!blockok_val) { | > > > > > > > | | | | | | > > > > > > | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | read_ret = read_large_net(sockfd, blockok, blockok_size); if (read_ret != blockok_size) { retval = -1; CHECKPOINT; } } lseek(fd, 0, SEEK_SET); curpos = 0; if (retval != -1) { for (blockidx = 0; blockidx < blockok_size; blockidx++) { for (i = 0; i < 8; i++) { blockok_val = blockok[blockidx] & (1<<i); if (!blockok_val) { destpos = (blockidx * 8 + i) * blocksize; if (curpos != destpos) { lseek_ret = lseek(fd, destpos, SEEK_SET); if (lseek_ret != destpos) { retval = -1; CHECKPOINT; break; } curpos = lseek_ret; } lseek_ret = curpos; if (lseek_ret >= filesize) { continue; } read_ret = read_large(fd, buf, blocksize); if (read_ret != blocksize) { if ((lseek_ret + read_ret) != filesize || read_ret < 0) { SPOTVAR_I(blockidx); SPOTVAR_LLU(lseek_ret); SPOTVAR_LLU(read_ret); SPOTVAR_LLU(filesize); retval = -1; CHECKPOINT; break; } } curpos += read_ret; write_ret = write_large_net(sockfd, buf, read_ret); if (write_ret != read_ret) { SPOTVAR_LLU(write_ret); SPOTVAR_LLU(read_ret); retval = -1; CHECKPOINT; |
︙ | ︙ | |||
305 306 307 308 309 310 311 312 313 314 315 316 317 318 | uint64_t filesize, filesize_s; uint32_t blocksize; uint32_t blockok_size, blockidx = 0; uint8_t *blockok, blockok_val; ssize_t cur_read_ret, read_ret, write_ret; size_t bytestowrite; off_t lseek_ret; char *buf; int sockfd, master_sockfd; int retval = 0; int fd; int skipbytes; int i = 0; | > | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | uint64_t filesize, filesize_s; uint32_t blocksize; uint32_t blockok_size, blockidx = 0; uint8_t *blockok, blockok_val; ssize_t cur_read_ret, read_ret, write_ret; size_t bytestowrite; off_t lseek_ret; off_t curpos, destpos; char *buf; int sockfd, master_sockfd; int retval = 0; int fd; int skipbytes; int i = 0; |
︙ | ︙ | |||
434 435 436 437 438 439 440 441 442 443 444 445 446 | if (retval != -1) { write_ret = write_large_net(sockfd, blockok, blockok_size); if (write_ret != blockok_size) { retval = -1; } } if (retval != -1) { for (blockidx = 0; blockidx < blockok_size; blockidx++) { for (i = 0; i < 8; i++) { blockok_val = blockok[blockidx] & (1<<i); if (!blockok_val) { | > > > > > > | | | | | | > > > > > > > > | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | if (retval != -1) { write_ret = write_large_net(sockfd, blockok, blockok_size); if (write_ret != blockok_size) { retval = -1; } } lseek(fd, 0, SEEK_SET); curpos = 0; if (retval != -1) { for (blockidx = 0; blockidx < blockok_size; blockidx++) { for (i = 0; i < 8; i++) { blockok_val = blockok[blockidx] & (1<<i); if (!blockok_val) { destpos = (blockidx * 8 + i) * blocksize; if (curpos != destpos) { lseek_ret = lseek(fd, destpos, SEEK_SET); if (lseek_ret != destpos) { retval = -1; CHECKPOINT; break; } curpos = lseek_ret; } lseek_ret = curpos; if (lseek_ret >= filesize_s) { SPOTVAR_LLU(lseek_ret); SPOTVAR_LLU(filesize_s); SPOTVAR_I(i); continue; } read_ret = read_large_net(sockfd, buf, blocksize); if (read_ret != blocksize) { if ((lseek_ret + read_ret) != filesize_s || read_ret < 0) { SPOTVAR_I(blockidx); |
︙ | ︙ | |||
470 471 472 473 474 475 476 477 478 479 480 481 482 483 | write_ret = write_large(fd, buf, read_ret); if (write_ret != read_ret) { retval = -1; CHECKPOINT; break; } } } if (retval == -1) { break; } } } | > > | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | write_ret = write_large(fd, buf, read_ret); if (write_ret != read_ret) { retval = -1; CHECKPOINT; break; } curpos += write_ret; } } if (retval == -1) { break; } } } |
︙ | ︙ | |||
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | int port; if (argc < 2) { return(print_help(EXIT_FAILURE)); } #ifdef HAVE_SIGNAL signal(SIGPIPE, SIG_IGN); #endif mode = argv[1]; if (strcmp(mode, "-t") == 0) { if (argc < 5 || argc > 6) { return(print_help(EXIT_FAILURE)); } | > > | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | int port; if (argc < 2) { return(print_help(EXIT_FAILURE)); } #ifdef HAVE_SIGNAL #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif #endif mode = argv[1]; if (strcmp(mode, "-t") == 0) { if (argc < 5 || argc > 6) { return(print_help(EXIT_FAILURE)); } |
︙ | ︙ |