id_access *ida;
size_t count = idal->count;
- write_abbrevint(f, idal->count);
+ write_varint(f, idal->count);
for (ida = idal->idas; count--; ida++) {
char *name = user_names ? add_uid(ida->id) : add_gid(ida->id);
- write_abbrevint(f, ida->id);
+ write_varint(f, ida->id);
if (inc_recurse && name) {
int len = strlen(name);
write_byte(f, ida->access | (uchar)0x80);
int ndx = find_matching_rsync_acl(racl, type, racl_list);
/* Send 0 (-1 + 1) to indicate that literal ACL data follows. */
- write_abbrevint(f, ndx + 1);
+ write_varint(f, ndx + 1);
if (ndx < 0) {
rsync_acl *new_racl = EXPAND_ITEM_LIST(racl_list, rsync_acl, 1000);
static uchar recv_ida_entries(ida_entries *ent, int user_names, int f)
{
uchar computed_mask_bits = 0;
- int i, count = read_abbrevint(f);
+ int i, count = read_varint(f);
if (count) {
if (!(ent->idas = new_array(id_access, ent->count)))
for (i = 0; i < count; i++) {
uchar has_name;
- id_t id = read_abbrevint(f);
+ id_t id = read_varint(f);
int access = recv_acl_access(&has_name, f);
if (has_name) {
uchar computed_mask_bits = 0;
acl_duo *duo_item;
uchar flags;
- int ndx = read_abbrevint(f);
+ int ndx = read_varint(f);
if (ndx < 0 || (size_t)ndx > racl_list->count) {
rprintf(FERROR, "recv_acl_index: %s ACL index %d > %d\n",
if (flags & XMIT_SAME_NAME)
write_byte(f, l1);
if (flags & XMIT_LONG_NAME)
- write_abbrevint30(f, l2);
+ write_varint30(f, l2);
else
write_byte(f, l2);
write_buf(f, fname + l1, l2);
if (first_hlink_ndx >= 0) {
- write_abbrevint30(f, first_hlink_ndx);
+ write_varint30(f, first_hlink_ndx);
goto the_end;
}
if (protocol_version < 30)
write_int(f, uid);
else {
- write_abbrevint(f, uid);
+ write_varint(f, uid);
if (flags & XMIT_USER_NAME_FOLLOWS) {
int len = strlen(user_name);
write_byte(f, len);
if (protocol_version < 30)
write_int(f, gid);
else {
- write_abbrevint(f, gid);
+ write_varint(f, gid);
if (flags & XMIT_GROUP_NAME_FOLLOWS) {
int len = strlen(group_name);
write_byte(f, len);
write_int(f, (int)rdev);
} else {
if (!(flags & XMIT_SAME_RDEV_MAJOR))
- write_abbrevint30(f, major(rdev));
+ write_varint30(f, major(rdev));
if (protocol_version >= 30)
- write_abbrevint(f, minor(rdev));
+ write_varint(f, minor(rdev));
else if (flags & XMIT_RDEV_MINOR_8_pre30)
write_byte(f, minor(rdev));
else
if (preserve_links && S_ISLNK(mode)) {
const char *sl = F_SYMLINK(file);
int len = strlen(sl);
- write_abbrevint30(f, len);
+ write_varint30(f, len);
write_buf(f, sl, len);
}
#endif
l1 = read_byte(f);
if (flags & XMIT_LONG_NAME)
- l2 = read_abbrevint30(f);
+ l2 = read_varint30(f);
else
l2 = read_byte(f);
if (protocol_version >= 30
&& BITS_SETnUNSET(flags, XMIT_HLINKED, XMIT_HLINK_FIRST)) {
struct file_struct *first;
- first_hlink_ndx = read_abbrevint30(f);
+ first_hlink_ndx = read_varint30(f);
if (first_hlink_ndx < 0 || first_hlink_ndx >= flist->count) {
rprintf(FERROR,
"hard-link reference out of range: %d (%d)\n",
if (protocol_version < 30)
uid = (uid_t)read_int(f);
else {
- uid = (uid_t)read_abbrevint(f);
+ uid = (uid_t)read_varint(f);
if (flags & XMIT_USER_NAME_FOLLOWS)
uid = recv_user_name(f, uid);
else if (inc_recurse && am_root && !numeric_ids)
if (protocol_version < 30)
gid = (gid_t)read_int(f);
else {
- gid = (gid_t)read_abbrevint(f);
+ gid = (gid_t)read_varint(f);
if (flags & XMIT_GROUP_NAME_FOLLOWS)
gid = recv_group_name(f, gid);
else if (inc_recurse && (!am_root || !numeric_ids))
} else {
uint32 rdev_minor;
if (!(flags & XMIT_SAME_RDEV_MAJOR))
- rdev_major = read_abbrevint30(f);
+ rdev_major = read_varint30(f);
if (protocol_version >= 30)
- rdev_minor = read_abbrevint(f);
+ rdev_minor = read_varint(f);
else if (flags & XMIT_RDEV_MINOR_8_pre30)
rdev_minor = read_byte(f);
else
#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(mode)) {
- linkname_len = read_abbrevint30(f) + 1; /* count the '\0' */
+ linkname_len = read_varint30(f) + 1; /* count the '\0' */
if (linkname_len <= 0 || linkname_len > MAXPATHLEN) {
rprintf(FERROR, "overflow: linkname_len=%d\n",
linkname_len - 1);
return (UVAL(b, 1) << 8) + UVAL(b, 0);
}
-int32 read_abbrevint(int f)
+int32 read_varint(int f)
{
int32 num;
char b[5];
writefd(f, b, 2);
}
-void write_abbrevint(int f, int32 x)
+void write_varint(int f, int32 x)
{
char b[5];
if ((uint32)x < ((uint32)1<<(1*8-1))) {
extern int protocol_version;
static inline int32
-read_abbrevint30(int f)
+read_varint30(int f)
{
if (protocol_version < 30)
return read_int(f);
- return read_abbrevint(f);
+ return read_varint(f);
}
static inline void
-write_abbrevint30(int f, int32 x)
+write_varint30(int f, int32 x)
{
if (protocol_version < 30)
write_int(f, x);
else
- write_abbrevint(f, x);
+ write_varint(f, x);
}
if (!list->name)
continue;
len = strlen(list->name);
- write_abbrevint30(f, list->id);
+ write_varint30(f, list->id);
write_byte(f, len);
write_buf(f, list->name, len);
}
/* terminate the uid list with a 0 uid. We explicitly exclude
* 0 from the list */
- write_abbrevint30(f, 0);
+ write_varint30(f, 0);
}
if (preserve_gid || preserve_acls) {
if (!list->name)
continue;
len = strlen(list->name);
- write_abbrevint30(f, list->id);
+ write_varint30(f, list->id);
write_byte(f, len);
write_buf(f, list->name, len);
}
- write_abbrevint30(f, 0);
+ write_varint30(f, 0);
}
}
if ((preserve_uid || preserve_acls) && !numeric_ids) {
/* read the uid list */
- while ((id = read_abbrevint30(f)) != 0)
+ while ((id = read_varint30(f)) != 0)
recv_user_name(f, (uid_t)id);
}
if ((preserve_gid || preserve_acls) && !numeric_ids) {
/* read the gid list */
- while ((id = read_abbrevint30(f)) != 0)
+ while ((id = read_varint30(f)) != 0)
recv_group_name(f, (gid_t)id);
}
int ndx = find_matching_xattr(sxp->xattr);
/* Send 0 (-1 + 1) to indicate that literal xattr data follows. */
- write_abbrevint(f, ndx + 1);
+ write_varint(f, ndx + 1);
if (ndx < 0) {
rsync_xa *rxa;
int count = sxp->xattr->count;
- write_abbrevint(f, count);
+ write_varint(f, count);
for (rxa = sxp->xattr->items; count--; rxa++) {
#ifdef HAVE_LINUX_XATTRS
- write_abbrevint(f, rxa->name_len);
- write_abbrevint(f, rxa->datum_len);
+ write_varint(f, rxa->name_len);
+ write_varint(f, rxa->datum_len);
write_buf(f, rxa->name, rxa->name_len);
#else
/* We strip the rsync prefix from disguised namespaces
* and put everything else in the user namespace. */
if (HAS_PREFIX(rxa->name, RSYNC_PREFIX)
&& rxa->name[RPRE_LEN] != '%') {
- write_abbrevint(f, rxa->name_len - RPRE_LEN);
- write_abbrevint(f, rxa->datum_len);
+ write_varint(f, rxa->name_len - RPRE_LEN);
+ write_varint(f, rxa->datum_len);
write_buf(f, rxa->name + RPRE_LEN, rxa->name_len - RPRE_LEN);
} else {
- write_abbrevint(f, rxa->name_len + UPRE_LEN);
- write_abbrevint(f, rxa->datum_len);
+ write_varint(f, rxa->name_len + UPRE_LEN);
+ write_varint(f, rxa->datum_len);
write_buf(f, USER_PREFIX, UPRE_LEN);
write_buf(f, rxa->name, rxa->name_len);
}
/* Flag that we handled this abbreviated item. */
rxa->datum[0] = XSTATE_DONE;
- write_abbrevint(f_out, j - prior_req);
+ write_varint(f_out, j - prior_req);
prior_req = j;
if (fname) {
if (!(ptr = get_xattr_data(fname, rxa->name, &len, 0)))
continue;
- write_abbrevint(f_out, len); /* length might have changed! */
+ write_varint(f_out, len); /* length might have changed! */
write_buf(f_out, ptr, len);
free(ptr);
}
cnt = lst->count;
rxa = lst->items;
rxa -= 1;
- while ((rel_pos = read_abbrevint(f_in)) != 0) {
+ while ((rel_pos = read_varint(f_in)) != 0) {
rxa += rel_pos;
cnt -= rel_pos;
if (cnt < 0 || rxa->datum_len <= MAX_FULL_DATUM
}
old_datum = rxa->datum;
- rxa->datum_len = read_abbrevint(f_in);
+ rxa->datum_len = read_varint(f_in);
if (rxa->name_len + rxa->datum_len < rxa->name_len)
out_of_memory("recv_xattr_request"); /* overflow */
{
static item_list temp_xattr = EMPTY_ITEM_LIST;
int count;
- int ndx = read_abbrevint(f);
+ int ndx = read_varint(f);
if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) {
rprintf(FERROR, "receive_xattr: xa index %d out of"
return;
}
- if ((count = read_abbrevint(f)) != 0) {
+ if ((count = read_varint(f)) != 0) {
(void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count);
temp_xattr.count = 0;
}
while (count--) {
char *ptr, *name;
rsync_xa *rxa;
- size_t name_len = read_abbrevint(f);
- size_t datum_len = read_abbrevint(f);
+ size_t name_len = read_varint(f);
+ size_t datum_len = read_varint(f);
size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len;
#ifdef HAVE_LINUX_XATTRS
size_t extra_len = 0;