Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
4c8d59f
..
fad433a
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-21,6
+21,8
@@
#include "rsync.h"
#include "rsync.h"
+extern int csum_length;
+
extern int verbose;
extern int am_server;
extern int always_checksum;
extern int verbose;
extern int am_server;
extern int always_checksum;
@@
-71,22
+73,21
@@
static void send_directory(int f,struct file_list *flist,char *dir);
static char *flist_dir = NULL;
static char *flist_dir = NULL;
-#define FILE_VALID 1
-#define SAME_MODE (1<<1)
-#define SAME_DEV (1<<2)
-#define SAME_UID (1<<3)
-#define SAME_GID (1<<4)
-#define SAME_DIR (1<<5)
+extern void (*send_file_entry)(struct file_struct *file,int f);
+extern void (*receive_file_entry)(struct file_struct *file,
+ unsigned char flags,int f);
+
-
static void send_file_entry
(struct file_struct *file,int f)
+
void send_file_entry_v11
(struct file_struct *file,int f)
{
unsigned char flags;
{
unsigned char flags;
+ static time_t last_time=0;
static mode_t last_mode=0;
static dev_t last_dev=0;
static uid_t last_uid=0;
static gid_t last_gid=0;
static mode_t last_mode=0;
static dev_t last_dev=0;
static uid_t last_uid=0;
static gid_t last_gid=0;
- static char last
dir
[MAXPATHLEN]="";
-
char *p=NULL
;
+ static char last
name
[MAXPATHLEN]="";
+
int l1,l2
;
if (f == -1) return;
if (f == -1) return;
@@
-101,19
+102,26
@@
static void send_file_entry(struct file_struct *file,int f)
if (file->dev == last_dev) flags |= SAME_DEV;
if (file->uid == last_uid) flags |= SAME_UID;
if (file->gid == last_gid) flags |= SAME_GID;
if (file->dev == last_dev) flags |= SAME_DEV;
if (file->uid == last_uid) flags |= SAME_UID;
if (file->gid == last_gid) flags |= SAME_GID;
+ if (file->modtime == last_time) flags |= SAME_TIME;
+
+ for (l1=0;lastname[l1] && file->name[l1] == lastname[l1];l1++) ;
+ l2 = strlen(file->name) - l1;
+
+ if (l1 > 0) flags |= SAME_NAME;
+ if (l2 > 255) flags |= LONG_NAME;
- if (strncmp(file->name,lastdir,strlen(lastdir)) == 0) {
- flags |= SAME_DIR;
- p = file->name + strlen(lastdir);
- } else {
- p = file->name;
- }
+ write_byte(f,flags);
+ if (flags & SAME_NAME)
+ write_byte(f,l1);
+ if (flags & LONG_NAME)
+ write_int(f,l2);
+ else
+ write_byte(f,l2);
+ write_buf(f,file->name+l1,l2);
- write_byte(f,flags);
- write_byte(f,strlen(p));
- write_buf(f,p,strlen(p));
- write_int(f,(int)file->modtime);
write_int(f,(int)file->length);
write_int(f,(int)file->length);
+ if (!(flags & SAME_TIME))
+ write_int(f,(int)file->modtime);
if (!(flags & SAME_MODE))
write_int(f,(int)file->mode);
if (preserve_uid && !(flags & SAME_UID))
if (!(flags & SAME_MODE))
write_int(f,(int)file->mode);
if (preserve_uid && !(flags & SAME_UID))
@@
-131,51
+139,49
@@
static void send_file_entry(struct file_struct *file,int f)
#endif
if (always_checksum) {
#endif
if (always_checksum) {
- write_buf(f,file->sum,
SUM_LENGTH
);
+ write_buf(f,file->sum,
csum_length
);
}
last_mode = file->mode;
last_dev = file->dev;
last_uid = file->uid;
last_gid = file->gid;
}
last_mode = file->mode;
last_dev = file->dev;
last_uid = file->uid;
last_gid = file->gid;
- p = strrchr(file->name,'/');
- if (p) {
- int l = (int)(p - file->name) + 1;
- strncpy(lastdir,file->name,l);
- lastdir[l] = 0;
- } else {
- strcpy(lastdir,"");
- }
+ last_time = file->modtime;
+
+ strcpy(lastname,file->name);
+ lastname[255] = 0;
}
}
-
static void receive_file_entry
(struct file_struct *file,
-
unsigned char flags,int f)
+
void receive_file_entry_v11
(struct file_struct *file,
+ unsigned char flags,int f)
{
{
+ static mode_t last_time=0;
static mode_t last_mode=0;
static dev_t last_dev=0;
static uid_t last_uid=0;
static gid_t last_gid=0;
static mode_t last_mode=0;
static dev_t last_dev=0;
static uid_t last_uid=0;
static gid_t last_gid=0;
- static char lastdir[MAXPATHLEN]="";
- char *p=NULL;
- int l1,l2;
+ static char lastname[MAXPATHLEN]="";
+ int l1=0,l2=0;
- l1 = read_byte(f);
- if (flags & SAME_DIR)
- l2 = strlen(lastdir);
+ if (flags & SAME_NAME)
+ l1 = read_byte(f);
+
+ if (flags & LONG_NAME)
+ l2 = read_int(f);
else
else
- l2 =
0
;
+ l2 =
read_byte(f)
;
file->name = (char *)malloc(l1+l2+1);
if (!file->name) out_of_memory("receive_file_entry");
file->name = (char *)malloc(l1+l2+1);
if (!file->name) out_of_memory("receive_file_entry");
- strncpy(file->name,last
dir,l2
);
- read_buf(f,file->name+l
2,l1
);
+ strncpy(file->name,last
name,l1
);
+ read_buf(f,file->name+l
1,l2
);
file->name[l1+l2] = 0;
file->name[l1+l2] = 0;
- file->modtime = (time_t)read_int(f);
file->length = (off_t)read_int(f);
file->length = (off_t)read_int(f);
+ file->modtime = (flags & SAME_TIME) ? last_time : (time_t)read_int(f);
file->mode = (flags & SAME_MODE) ? last_mode : (mode_t)read_int(f);
if (preserve_uid)
file->uid = (flags & SAME_UID) ? last_uid : (uid_t)read_int(f);
file->mode = (flags & SAME_MODE) ? last_mode : (mode_t)read_int(f);
if (preserve_uid)
file->uid = (flags & SAME_UID) ? last_uid : (uid_t)read_int(f);
@@
-195,23
+201,20
@@
static void receive_file_entry(struct file_struct *file,
#endif
if (always_checksum)
#endif
if (always_checksum)
- read_buf(f,file->sum,
SUM_LENGTH
);
+ read_buf(f,file->sum,
csum_length
);
last_mode = file->mode;
last_dev = file->dev;
last_uid = file->uid;
last_gid = file->gid;
last_mode = file->mode;
last_dev = file->dev;
last_uid = file->uid;
last_gid = file->gid;
- p = strrchr(file->name,'/');
- if (p) {
- int l = (int)(p - file->name) + 1;
- strncpy(lastdir,file->name,l);
- lastdir[l] = 0;
- } else {
- strcpy(lastdir,"");
- }
+ last_time = file->modtime;
+
+ strcpy(lastname,file->name);
+ lastname[255] = 0;
}
}
+
static struct file_struct *make_file(int recurse,char *fname)
{
static struct file_struct file;
static struct file_struct *make_file(int recurse,char *fname)
{
static struct file_struct file;
@@
-408,7
+411,7
@@
struct file_list *send_file_list(int f,int recurse,int argc,char *argv[])
if (dir && *dir) {
if (getcwd(dbuf,MAXPATHLEN-1) == NULL) {
fprintf(stderr,"getwd : %s\n",strerror(errno));
if (dir && *dir) {
if (getcwd(dbuf,MAXPATHLEN-1) == NULL) {
fprintf(stderr,"getwd : %s\n",strerror(errno));
- exit(1);
+ exit
_cleanup
(1);
}
if (chdir(dir) != 0) {
fprintf(stderr,"chdir %s : %s\n",dir,strerror(errno));
}
if (chdir(dir) != 0) {
fprintf(stderr,"chdir %s : %s\n",dir,strerror(errno));
@@
-421,7
+424,7
@@
struct file_list *send_file_list(int f,int recurse,int argc,char *argv[])
flist_dir = NULL;
if (chdir(dbuf) != 0) {
fprintf(stderr,"chdir %s : %s\n",dbuf,strerror(errno));
flist_dir = NULL;
if (chdir(dbuf) != 0) {
fprintf(stderr,"chdir %s : %s\n",dbuf,strerror(errno));
- exit(1);
+ exit
_cleanup
(1);
}
continue;
}
}
continue;
}