From 736a6a291cf0fc9ab9410f300174a70e868e4122 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Fri, 11 Jan 2002 07:15:16 +0000 Subject: [PATCH] In protocol version 26, always send 64-bit ino_t and dev_t. We also need to try to use 64-bit ino_t internally *even if* this platform does not have 64-bit inums itself, because we need to find duplicate inums when coming from a larger platform with --hardlinks. --- flist.c | 35 +++++++++++++++++++++++++++++------ options.c | 12 ++++++++++-- rsync.h | 18 +++++++++--------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/flist.c b/flist.c index 0b0fd233..fcc6a53a 100644 --- a/flist.c +++ b/flist.c @@ -1,7 +1,7 @@ /* Copyright (C) Andrew Tridgell 1996 Copyright (C) Paul Mackerras 1996 - Copyright (C) 2001 by Martin Pool + Copyright (C) 2001, 2002 by Martin Pool 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 @@ -18,7 +18,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* generate and receive file lists */ +/** @file flist.c + * Generate and receive file lists + * + * @todo Get rid of the string_area optimization. Efficiently + * allocating blocks is the responsibility of the system's malloc + * library, not of rsync. + * + **/ #include "rsync.h" @@ -297,8 +304,15 @@ static void send_file_entry(struct file_struct *file,int f,unsigned base_flags) #if SUPPORT_HARD_LINKS if (preserve_hard_links && S_ISREG(file->mode)) { - write_int(f,(int)file->dev); - write_int(f,(int)file->inode); + if (remote_version < 26) { + /* 32-bit dev_t and ino_t */ + write_int(f,(int)file->dev); + write_int(f,(int)file->inode); + } else { + /* 64-bit dev_t and ino_t */ + write_longint(f, (int64) file->dev); + write_longint(f, (int64) file->inode); + } } #endif @@ -409,8 +423,13 @@ static void receive_file_entry(struct file_struct **fptr, #if SUPPORT_HARD_LINKS if (preserve_hard_links && S_ISREG(file->mode)) { - file->dev = read_int(f); - file->inode = read_int(f); + if (remote_version < 26) { + file->dev = read_int(f); + file->inode = read_int(f); + } else { + file->dev = read_longint(f); + file->inode = read_longint(f); + } } #endif @@ -1085,6 +1104,10 @@ static void clean_flist(struct file_list *flist, int strip_root) } } + /* FIXME: There is a bug here when filenames are repeated more + * than once, because we don't handle freed files when doing + * the comparison. */ + if (strip_root) { /* we need to strip off the root directory in the case of relative paths, but this must be done _after_ diff --git a/options.c b/options.c index 8893195a..4bc482e6 100644 --- a/options.c +++ b/options.c @@ -1,7 +1,7 @@ /* -*- c-file-style: "linux" -*- Copyright (C) 1998-2001 by Andrew Tridgell - Copyright (C) 2000-2001 by Martin Pool + Copyright (C) 2000, 2001, 2002 by Martin Pool 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 @@ -122,6 +122,7 @@ static void print_rsync_version(enum logcode f) char const *hardlinks = "no "; char const *links = "no "; char const *ipv6 = "no "; + STRUCT_STAT *dumstat; #ifdef HAVE_SOCKETPAIR got_socketpair = ""; @@ -145,10 +146,17 @@ static void print_rsync_version(enum logcode f) "Copyright (C) 1996-2001 by Andrew Tridgell and others\n"); rprintf(f, "\n"); rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, " - "%shard links, %ssymlinks, batchfiles, %sIPv6\n\n", + "%shard links, %ssymlinks, batchfiles, %sIPv6,\n", (int) (sizeof(OFF_T) * 8), got_socketpair, hardlinks, links, ipv6); + /* Note that this field may not have type ino_t. It depends + * on the complicated interaction between largefile feature + * macros. */ + rprintf(f, " %d-bit inums, %d-bit INO_T\n", + (int) (sizeof(dumstat->st_ino) * 8), + (int) (sizeof(INO_T) * 8)); + #ifdef NO_INT64 rprintf(f, "WARNING: no 64-bit integers on this platform!\n"); #endif diff --git a/rsync.h b/rsync.h index d7db3cd4..72176449 100644 --- a/rsync.h +++ b/rsync.h @@ -1,7 +1,7 @@ /* Copyright (C) by Andrew Tridgell 1996, 2000 Copyright (C) Paul Mackerras 1996 - Copyright (C) 2001 by Martin Pool + Copyright (C) 2001, 2002 by Martin Pool 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 @@ -49,7 +49,7 @@ #define SAME_TIME (1<<7) /* update this if you make incompatible changes */ -#define PROTOCOL_VERSION 25 +#define PROTOCOL_VERSION 26 /* We refuse to interoperate with versions that are not in this range. * Note that we assume we'll work with later versions: the onus is on @@ -263,17 +263,17 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 }; #elif HAVE_LONGLONG #define int64 long long #else +/* As long as it gets... */ #define int64 off_t #define NO_INT64 #endif -#if HAVE_SHORT_INO_T -# define INO_T uint32 -#elif HAVE_INO_T -# define INO_T ino_t -#else -# define INO_T unsigned -#endif +/* We want to manipulate 64-bit inums. On some systems + * STRUCT_STAT.st_ino can be bigger than an ino_t depending on the + * combination of largefile feature macros. Rather than try to guess, + * we just internally store them in the largest know type. Hopefully + * it's enough. */ +#define INO_T int64 #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) -- 2.34.1