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
- Got rid of "struct idev".
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
3dadeab
..
1d5fbff
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-22,6
+22,7
@@
*/
#include "rsync.h"
*/
#include "rsync.h"
+#include "rounding.h"
extern int verbose;
extern int list_only;
extern int verbose;
extern int list_only;
@@
-515,7
+516,7
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
char thisname[MAXPATHLEN];
unsigned int l1 = 0, l2 = 0;
int alloc_len, basename_len, dirname_len, linkname_len;
char thisname[MAXPATHLEN];
unsigned int l1 = 0, l2 = 0;
int alloc_len, basename_len, dirname_len, linkname_len;
- int extra_len =
(flist_extra_cnt - 1)
* EXTRA_LEN;
+ int extra_len =
flist_extra_cnt
* EXTRA_LEN;
int first_hlink_ndx = -1;
OFF_T file_length;
char *basename, *dirname, *bp;
int first_hlink_ndx = -1;
OFF_T file_length;
char *basename, *dirname, *bp;
@@
-668,11
+669,16
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
if (file_length > 0xFFFFFFFFu && S_ISREG(mode))
extra_len += EXTRA_LEN;
if (file_length > 0xFFFFFFFFu && S_ISREG(mode))
extra_len += EXTRA_LEN;
+#if EXTRA_ROUNDING > 0
+ if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
+ extra_len = (extra_len | (EXTRA_ROUNDING * EXTRA_LEN)) + EXTRA_LEN;
+#endif
+
alloc_len = FILE_STRUCT_LEN + extra_len + basename_len + dirname_len
+ linkname_len;
bp = pool_alloc(flist->file_pool, alloc_len, "recv_file_entry");
alloc_len = FILE_STRUCT_LEN + extra_len + basename_len + dirname_len
+ linkname_len;
bp = pool_alloc(flist->file_pool, alloc_len, "recv_file_entry");
- memset(bp, 0,
FILE_STRUCT_LEN + extra_len
);
+ memset(bp, 0,
extra_len + FILE_STRUCT_LEN
);
bp += extra_len;
file = (struct file_struct *)bp;
bp += FILE_STRUCT_LEN;
bp += extra_len;
file = (struct file_struct *)bp;
bp += FILE_STRUCT_LEN;
@@
-740,7
+746,7
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
#ifdef SUPPORT_LINKS
if (linkname_len) {
#ifdef SUPPORT_LINKS
if (linkname_len) {
- bp = (char*)
F_BASENAME(file)
+ basename_len;
+ bp = (char*)
file->basename
+ basename_len;
if (first_hlink_ndx >= 0) {
struct file_struct *first = flist->files[first_hlink_ndx];
memcpy(bp, F_SYMLINK(first), linkname_len);
if (first_hlink_ndx >= 0) {
struct file_struct *first = flist->files[first_hlink_ndx];
memcpy(bp, F_SYMLINK(first), linkname_len);
@@
-815,7
+821,7
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
char thisname[MAXPATHLEN];
char linkname[MAXPATHLEN];
int alloc_len, basename_len, dirname_len, linkname_len;
char thisname[MAXPATHLEN];
char linkname[MAXPATHLEN];
int alloc_len, basename_len, dirname_len, linkname_len;
- int extra_len =
(flist_extra_cnt - 1)
* EXTRA_LEN;
+ int extra_len =
flist_extra_cnt
* EXTRA_LEN;
char *basename, *dirname, *bp;
if (!flist || !flist->count) /* Ignore lastdir when invalid. */
char *basename, *dirname, *bp;
if (!flist || !flist->count) /* Ignore lastdir when invalid. */
@@
-937,6
+943,11
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode))
extra_len += EXTRA_LEN;
if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode))
extra_len += EXTRA_LEN;
+#if EXTRA_ROUNDING > 0
+ if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
+ extra_len = (extra_len | (EXTRA_ROUNDING * EXTRA_LEN)) + EXTRA_LEN;
+#endif
+
alloc_len = FILE_STRUCT_LEN + extra_len + basename_len + dirname_len
+ linkname_len;
if (flist)
alloc_len = FILE_STRUCT_LEN + extra_len + basename_len + dirname_len
+ linkname_len;
if (flist)
@@
-946,7
+957,7
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
out_of_memory("make_file");
}
out_of_memory("make_file");
}
- memset(bp, 0,
FILE_STRUCT_LEN + extra_len
);
+ memset(bp, 0,
extra_len + FILE_STRUCT_LEN
);
bp += extra_len;
file = (struct file_struct *)bp;
bp += FILE_STRUCT_LEN;
bp += extra_len;
file = (struct file_struct *)bp;
bp += FILE_STRUCT_LEN;
@@
-997,7
+1008,7
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
#ifdef SUPPORT_LINKS
if (linkname_len) {
#ifdef SUPPORT_LINKS
if (linkname_len) {
- bp = (char*)
F_BASENAME(file)
+ basename_len;
+ bp = (char*)
file->basename
+ basename_len;
memcpy(bp, linkname, linkname_len);
}
#endif
memcpy(bp, linkname, linkname_len);
}
#endif
@@
-1038,8
+1049,12
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
/* Only called for temporary file_struct entries created by make_file(). */
void unmake_file(struct file_struct *file)
{
/* Only called for temporary file_struct entries created by make_file(). */
void unmake_file(struct file_struct *file)
{
- int extra_cnt = flist_extra_cnt - 1 + LEN64_BUMP(file);
- free(file->extras - extra_cnt);
+ int extra_cnt = flist_extra_cnt + LEN64_BUMP(file);
+#if EXTRA_ROUNDING > 0
+ if (extra_cnt & EXTRA_ROUNDING)
+ extra_cnt = (extra_cnt | EXTRA_ROUNDING) + 1;
+#endif
+ free(REQ_EXTRA(file, extra_cnt));
}
static struct file_struct *send_file_name(int f, struct file_list *flist,
}
static struct file_struct *send_file_name(int f, struct file_list *flist,
@@
-1570,7
+1585,8
@@
int flist_find(struct file_list *flist, struct file_struct *f)
*/
void clear_file(struct file_struct *file)
{
*/
void clear_file(struct file_struct *file)
{
- memset((char*)file + EXTRA_LEN, 0, FILE_STRUCT_LEN - EXTRA_LEN + 1);
+ /* The +1 zeros out the first char of the basename. */
+ memset(file, 0, FILE_STRUCT_LEN + 1);
/* In an empty entry, dir.depth is an offset to the next non-empty
* entry. Likewise for len32 in the opposite direction. We assume
* that we're alone for now since flist_find() will adjust the counts
/* In an empty entry, dir.depth is an offset to the next non-empty
* entry. Likewise for len32 in the opposite direction. We assume
* that we're alone for now since flist_find() will adjust the counts
@@
-1795,7
+1811,7
@@
static void output_flist(struct file_list *flist)
dir = slash = "";
else
slash = "/";
dir = slash = "";
else
slash = "/";
- name =
F_BASENAME(file)
;
+ name =
file->basename
;
trail = S_ISDIR(file->mode) ? "/" : "";
} else
dir = slash = name = trail = "";
trail = S_ISDIR(file->mode) ? "/" : "";
} else
dir = slash = name = trail = "";
@@
-1846,7
+1862,7
@@
int f_name_cmp(struct file_struct *f1, struct file_struct *f2)
c1 = c2 = NULL;
if (!c1) {
type1 = S_ISDIR(f1->mode) ? t_path : t_ITEM;
c1 = c2 = NULL;
if (!c1) {
type1 = S_ISDIR(f1->mode) ? t_path : t_ITEM;
- c1 = (
uchar*)F_BASENAME(f1)
;
+ c1 = (
const uchar*)f1->basename
;
if (type1 == t_PATH && *c1 == '.' && !c1[1]) {
type1 = t_ITEM;
state1 = s_TRAILING;
if (type1 == t_PATH && *c1 == '.' && !c1[1]) {
type1 = t_ITEM;
state1 = s_TRAILING;
@@
-1859,7
+1875,7
@@
int f_name_cmp(struct file_struct *f1, struct file_struct *f2)
}
if (!c2) {
type2 = S_ISDIR(f2->mode) ? t_path : t_ITEM;
}
if (!c2) {
type2 = S_ISDIR(f2->mode) ? t_path : t_ITEM;
- c2 = (
uchar*)F_BASENAME(f2)
;
+ c2 = (
const uchar*)f2->basename
;
if (type2 == t_PATH && *c2 == '.' && !c2[1]) {
type2 = t_ITEM;
state2 = s_TRAILING;
if (type2 == t_PATH && *c2 == '.' && !c2[1]) {
type2 = t_ITEM;
state2 = s_TRAILING;
@@
-1883,7
+1899,7
@@
int f_name_cmp(struct file_struct *f1, struct file_struct *f2)
break;
case s_SLASH:
type1 = S_ISDIR(f1->mode) ? t_path : t_ITEM;
break;
case s_SLASH:
type1 = S_ISDIR(f1->mode) ? t_path : t_ITEM;
- c1 = (
uchar*)F_BASENAME(f1)
;
+ c1 = (
const uchar*)f1->basename
;
if (type1 == t_PATH && *c1 == '.' && !c1[1]) {
type1 = t_ITEM;
state1 = s_TRAILING;
if (type1 == t_PATH && *c1 == '.' && !c1[1]) {
type1 = t_ITEM;
state1 = s_TRAILING;
@@
-1913,7
+1929,7
@@
int f_name_cmp(struct file_struct *f1, struct file_struct *f2)
break;
case s_SLASH:
type2 = S_ISDIR(f2->mode) ? t_path : t_ITEM;
break;
case s_SLASH:
type2 = S_ISDIR(f2->mode) ? t_path : t_ITEM;
- c2 = (
uchar*)F_BASENAME(f2)
;
+ c2 = (
const uchar*)f2->basename
;
if (type2 == t_PATH && *c2 == '.' && !c2[1]) {
type2 = t_ITEM;
state2 = s_TRAILING;
if (type2 == t_PATH && *c2 == '.' && !c2[1]) {
type2 = t_ITEM;
state2 = s_TRAILING;
@@
-1968,9
+1984,9
@@
char *f_name(struct file_struct *f, char *fbuf)
int len = strlen(f->dirname);
memcpy(fbuf, f->dirname, len);
fbuf[len] = '/';
int len = strlen(f->dirname);
memcpy(fbuf, f->dirname, len);
fbuf[len] = '/';
- strlcpy(fbuf + len + 1,
F_BASENAME(f)
, MAXPATHLEN - (len + 1));
+ strlcpy(fbuf + len + 1,
f->basename
, MAXPATHLEN - (len + 1));
} else
} else
- strlcpy(fbuf,
F_BASENAME(f)
, MAXPATHLEN);
+ strlcpy(fbuf,
f->basename
, MAXPATHLEN);
return fbuf;
}
return fbuf;
}