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
- Use as little memory as possible for the file_struct (saves another 3
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
e6b1463
..
a14320d
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-69,10
+69,20
@@
extern struct exclude_struct **local_exclude_list;
int io_error;
static char empty_sum[MD4_SUM_LENGTH];
int io_error;
static char empty_sum[MD4_SUM_LENGTH];
+static unsigned int min_file_struct_len;
static void clean_flist(struct file_list *flist, int strip_root, int no_dups);
static void clean_flist(struct file_list *flist, int strip_root, int no_dups);
+void init_flist(void)
+{
+ struct file_struct f;
+
+ /* Figure out how big the file_struct is without trailing padding */
+ min_file_struct_len = ((char*)&f.flags - (char*)&f) + sizeof f.flags;
+}
+
+
static int show_filelist_p(void)
{
return verbose && (recurse || files_from) && !am_server;
static int show_filelist_p(void)
{
return verbose && (recurse || files_from) && !am_server;
@@
-498,7
+508,7
@@
void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
char thisname[MAXPATHLEN];
unsigned int l1 = 0, l2 = 0;
int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
char thisname[MAXPATHLEN];
unsigned int l1 = 0, l2 = 0;
int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
- int
idev_len, idev_pad
;
+ int
file_struct_len, idev_len
;
OFF_T file_length;
char *basename, *dirname, *bp;
struct file_struct *file;
OFF_T file_length;
char *basename, *dirname, *bp;
struct file_struct *file;
@@
-602,19
+612,15
@@
void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
idev_len = 0;
sum_len = always_checksum && S_ISREG(mode) ? MD4_SUM_LENGTH : 0;
idev_len = 0;
sum_len = always_checksum && S_ISREG(mode) ? MD4_SUM_LENGTH : 0;
+ file_struct_len = idev_len? sizeof file[0] : min_file_struct_len;
- alloc_len = sizeof file[0] + dirname_len + basename_len
- + linkname_len + sum_len;
- if (idev_len) {
- idev_pad = (4 - (alloc_len % 4)) % 4;
- alloc_len += idev_pad + idev_len;
- } else
- idev_pad = 0;
+ alloc_len = file_struct_len + dirname_len + basename_len
+ + linkname_len + sum_len + idev_len;
if (!(bp = new_array(char, alloc_len)))
out_of_memory("receive_file_entry");
file = *fptr = (struct file_struct *)bp;
if (!(bp = new_array(char, alloc_len)))
out_of_memory("receive_file_entry");
file = *fptr = (struct file_struct *)bp;
- memset(bp, 0,
sizeof file[0]
);
- bp +=
sizeof file[0]
;
+ memset(bp, 0,
min_file_struct_len
);
+ bp +=
file_struct_len
;
file->flags = flags & XMIT_TOP_DIR ? FLAG_TOP_DIR : 0;
file->modtime = modtime;
file->flags = flags & XMIT_TOP_DIR ? FLAG_TOP_DIR : 0;
file->modtime = modtime;
@@
-623,6
+629,13
@@
void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
file->uid = uid;
file->gid = gid;
file->uid = uid;
file->gid = gid;
+#if SUPPORT_HARD_LINKS
+ if (idev_len) {
+ file->link_u.idev = (struct idev *)bp;
+ bp += idev_len;
+ }
+#endif
+
if (dirname_len) {
file->dirname = lastdir = bp;
lastdir_len = dirname_len - 1;
if (dirname_len) {
file->dirname = lastdir = bp;
lastdir_len = dirname_len - 1;
@@
-651,8
+664,6
@@
void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
#if SUPPORT_HARD_LINKS
if (idev_len) {
#if SUPPORT_HARD_LINKS
if (idev_len) {
- file->link_u.idev = (struct idev *)(bp + idev_pad);
- bp += idev_pad + idev_len;
if (protocol_version < 26) {
dev = read_int(f);
file->F_INODE = read_int(f);
if (protocol_version < 26) {
dev = read_int(f);
file->F_INODE = read_int(f);
@@
-715,7
+726,7
@@
struct file_struct *make_file(char *fname, int exclude_level)
char thisname[MAXPATHLEN];
char linkname[MAXPATHLEN];
int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
char thisname[MAXPATHLEN];
char linkname[MAXPATHLEN];
int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
- int
idev_len, idev_pad
;
+ int
file_struct_len, idev_len
;
char *basename, *dirname, *bp;
unsigned short flags = 0;
char *basename, *dirname, *bp;
unsigned short flags = 0;
@@
-808,19
+819,15
@@
struct file_struct *make_file(char *fname, int exclude_level)
idev_len = 0;
sum_len = always_checksum && S_ISREG(st.st_mode) ? MD4_SUM_LENGTH : 0;
idev_len = 0;
sum_len = always_checksum && S_ISREG(st.st_mode) ? MD4_SUM_LENGTH : 0;
+ file_struct_len = idev_len? sizeof file[0] : min_file_struct_len;
- alloc_len = sizeof file[0] + dirname_len + basename_len
- + linkname_len + sum_len;
- if (idev_len) {
- idev_pad = (4 - (alloc_len % 4)) % 4;
- alloc_len += idev_pad + idev_len;
- } else
- idev_pad = 0;
+ alloc_len = file_struct_len + dirname_len + basename_len
+ + linkname_len + sum_len + idev_len;
if (!(bp = new_array(char, alloc_len)))
out_of_memory("receive_file_entry");
file = (struct file_struct *)bp;
if (!(bp = new_array(char, alloc_len)))
out_of_memory("receive_file_entry");
file = (struct file_struct *)bp;
- memset(bp, 0,
sizeof file[0]
);
- bp +=
sizeof file[0]
;
+ memset(bp, 0,
min_file_struct_len
);
+ bp +=
file_struct_len
;
file->flags = flags;
file->modtime = st.st_mtime;
file->flags = flags;
file->modtime = st.st_mtime;
@@
-829,6
+836,15
@@
struct file_struct *make_file(char *fname, int exclude_level)
file->uid = st.st_uid;
file->gid = st.st_gid;
file->uid = st.st_uid;
file->gid = st.st_gid;
+#if SUPPORT_HARD_LINKS
+ if (idev_len) {
+ file->link_u.idev = (struct idev *)bp;
+ bp += idev_len;
+ file->F_DEV = st.st_dev;
+ file->F_INODE = st.st_ino;
+ }
+#endif
+
if (dirname_len) {
file->dirname = lastdir = bp;
lastdir_len = dirname_len - 1;
if (dirname_len) {
file->dirname = lastdir = bp;
lastdir_len = dirname_len - 1;
@@
-855,15
+871,6
@@
struct file_struct *make_file(char *fname, int exclude_level)
}
#endif
}
#endif
-#if SUPPORT_HARD_LINKS
- if (idev_len) {
- file->link_u.idev = (struct idev *)(bp + idev_pad);
- bp += idev_pad + idev_len;
- file->F_DEV = st.st_dev;
- file->F_INODE = st.st_ino;
- }
-#endif
-
if (sum_len) {
file->u.sum = bp;
file_checksum(thisname, bp, st.st_size);
if (sum_len) {
file->u.sum = bp;
file_checksum(thisname, bp, st.st_size);