Decided to hold off on the potential memory savings of indexed
authorWayne Davison <wayned@samba.org>
Wed, 25 Jan 2006 17:10:29 +0000 (17:10 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 25 Jan 2006 17:10:29 +0000 (17:10 +0000)
uid/gid pairs until the next release.

flist.c
generator.c
rsync.c
rsync.h
uidlist.c

diff --git a/flist.c b/flist.c
index 277750c..87a2ba7 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -362,14 +362,14 @@ static void send_file_entry(struct file_struct *file, int f)
                                flags |= XMIT_RDEV_MINOR_IS_SMALL;
                }
        }
-       if (file->ids->uid == uid)
+       if (file->uid == uid)
                flags |= XMIT_SAME_UID;
        else
-               uid = file->ids->uid;
-       if (file->ids->gid == gid)
+               uid = file->uid;
+       if (file->gid == gid)
                flags |= XMIT_SAME_GID;
        else
-               gid = file->ids->gid;
+               gid = file->gid;
        if (file->modtime == modtime)
                flags |= XMIT_SAME_TIME;
        else
@@ -622,7 +622,8 @@ static struct file_struct *receive_file_entry(struct file_list *flist,
        file->modtime = modtime;
        file->length = file_length;
        file->mode = mode;
-       file->ids = id_pair(uid, gid);
+       file->uid = uid;
+       file->gid = gid;
 
        if (dirname_len) {
                file->dirname = lastdir = bp;
@@ -878,7 +879,8 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
        file->modtime = st.st_mtime;
        file->length = st.st_size;
        file->mode = st.st_mode;
-       file->ids = id_pair(st.st_uid, st.st_gid);
+       file->uid = st.st_uid;
+       file->gid = st.st_gid;
 
 #ifdef SUPPORT_HARD_LINKS
        if (flist && flist->hlink_pool) {
@@ -945,7 +947,8 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
                        file->modtime = st2.st_mtime;
                        file->length = st2.st_size;
                        file->mode = st2.st_mode;
-                       file->ids = id_pair(st2.st_uid, st2.st_gid);
+                       file->uid = st2.st_uid;
+                       file->gid = st2.st_gid;
                        file->u.link = NULL;
                } else
                        file->mode = save_mode;
@@ -1389,7 +1392,7 @@ struct file_list *recv_file_list(int f)
        clean_flist(flist, relative_paths, 1);
 
        if (f >= 0) {
-               recv_uid_list(f);
+               recv_uid_list(f, flist);
 
                /* Recv the io_error flag */
                if (lp_ignore_errors(module_id) || ignore_errors)
@@ -1616,11 +1619,11 @@ static void output_flist(struct file_list *flist)
        for (i = 0; i < flist->count; i++) {
                file = flist->files[i];
                if ((am_root || am_sender) && preserve_uid)
-                       sprintf(uidbuf, " uid=%ld", (long)file->ids->uid);
+                       sprintf(uidbuf, " uid=%ld", (long)file->uid);
                else
                        *uidbuf = '\0';
-               if (preserve_gid && file->ids->gid != GID_NONE)
-                       sprintf(gidbuf, " gid=%ld", (long)file->ids->gid);
+               if (preserve_gid && file->gid != GID_NONE)
+                       sprintf(gidbuf, " gid=%ld", (long)file->gid);
                else
                        *gidbuf = '\0';
                if (!am_sender)
index 0a63f00..fb0bc2d 100644 (file)
@@ -325,10 +325,10 @@ int unchanged_attrs(struct file_struct *file, STRUCT_STAT *st)
         && (st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS))
                return 0;
 
-       if (am_root && preserve_uid && st->st_uid != file->ids->uid)
+       if (am_root && preserve_uid && st->st_uid != file->uid)
                return 0;
 
-       if (preserve_gid && file->ids->gid != GID_NONE && st->st_gid != file->ids->gid)
+       if (preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid)
                return 0;
 
        return 1;
@@ -351,10 +351,10 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
                if (preserve_perms
                 && (file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
                        iflags |= ITEM_REPORT_PERMS;
-               if (preserve_uid && am_root && file->ids->uid != st->st_uid)
+               if (preserve_uid && am_root && file->uid != st->st_uid)
                        iflags |= ITEM_REPORT_OWNER;
-               if (preserve_gid && file->ids->gid != GID_NONE
-                   && st->st_gid != file->ids->gid)
+               if (preserve_gid && file->gid != GID_NONE
+                   && st->st_gid != file->gid)
                        iflags |= ITEM_REPORT_GROUP;
        } else
                iflags |= ITEM_IS_NEW;
diff --git a/rsync.c b/rsync.c
index d78a085..9964c67 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -82,9 +82,9 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
                        updated = 1;
        }
 
-       change_uid = am_root && preserve_uid && st->st_uid != file->ids->uid;
-       change_gid = preserve_gid && file->ids->gid != GID_NONE
-               && st->st_gid != file->ids->gid;
+       change_uid = am_root && preserve_uid && st->st_uid != file->uid;
+       change_gid = preserve_gid && file->gid != GID_NONE
+               && st->st_gid != file->gid;
 #if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
        if (S_ISLNK(st->st_mode))
                ;
@@ -96,18 +96,18 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
                                rprintf(FINFO,
                                        "set uid of %s from %ld to %ld\n",
                                        fname,
-                                       (long)st->st_uid, (long)file->ids->uid);
+                                       (long)st->st_uid, (long)file->uid);
                        }
                        if (change_gid) {
                                rprintf(FINFO,
                                        "set gid of %s from %ld to %ld\n",
                                        fname,
-                                       (long)st->st_gid, (long)file->ids->gid);
+                                       (long)st->st_gid, (long)file->gid);
                        }
                }
                if (do_lchown(fname,
-                   change_uid ? file->ids->uid : st->st_uid,
-                   change_gid ? file->ids->gid : st->st_gid) != 0) {
+                   change_uid ? file->uid : st->st_uid,
+                   change_gid ? file->gid : st->st_gid) != 0) {
                        /* shouldn't have attempted to change uid or gid
                         * unless have the privilege */
                        rsyserr(FERROR, errno, "%s %s failed",
diff --git a/rsync.h b/rsync.h
index dcc0799..e6bff06 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -493,11 +493,6 @@ struct hlink {
        int hlindex;
 };
 
-struct id_pair {
-       uid_t uid;
-       gid_t gid;
-};
-
 #define F_DEV  link_u.idev->dev
 #define F_INODE        link_u.idev->inode
 
@@ -521,9 +516,10 @@ struct file_struct {
                struct idev *idev;
                struct hlink *links;
        } link_u;
-       struct id_pair *ids;
        time_t modtime;
        mode_t mode;
+       uid_t uid;
+       gid_t gid;
        uchar flags;    /* this item MUST remain last */
 };
 
index 0f7d0c8..1747c83 100644 (file)
--- a/uidlist.c
+++ b/uidlist.c
@@ -46,9 +46,6 @@ struct idlist {
 static struct idlist *uidlist;
 static struct idlist *gidlist;
 
-static struct id_pair *pair_list;
-static int pair_cnt = 0, pair_alloc = 0;
-
 static struct idlist *add_to_list(struct idlist **root, int id, char *name,
                                  int id2)
 {
@@ -310,7 +307,7 @@ void send_uid_list(int f)
 
 /* recv a complete uid/gid mapping from the peer and map the uid/gid
  * in the file list to local names */
-void recv_uid_list(int f)
+void recv_uid_list(int f, struct file_list *flist)
 {
        int id, i;
        char *name;
@@ -339,42 +336,13 @@ void recv_uid_list(int f)
                }
        }
 
-       /* Now convert the id_pair array over to mapped uid/gid values. */
+       /* Now convert all the uids/gids from sender values to our values. */
        if (am_root && preserve_uid && !numeric_ids) {
-               for (i = 0; i < pair_cnt; i++)
-                       pair_list[i].uid = match_uid(pair_list[i].uid);
+               for (i = 0; i < flist->count; i++)
+                       flist->files[i]->uid = match_uid(flist->files[i]->uid);
        }
        if (preserve_gid && (!am_root || !numeric_ids)) {
-               for (i = 0; i < pair_cnt; i++)
-                       pair_list[i].gid = match_gid(pair_list[i].gid);
-       }
-}
-
-struct id_pair *id_pair(uid_t uid, gid_t gid)
-{
-       static int j = 0;
-
-       if (pair_cnt) {
-               int start = j;
-               /* We start our search where we left off because
-                * the IDs usually come in clumps. */
-               do {
-                       if (uid == pair_list[j].uid && gid == pair_list[j].gid)
-                               return pair_list + j;
-                       if (++j == pair_cnt)
-                               j = 0;
-               } while (j != start);
+               for (i = 0; i < flist->count; i++)
+                       flist->files[i]->gid = match_gid(flist->files[i]->gid);
        }
-
-       if (pair_cnt == pair_alloc) {
-               pair_alloc += 128;
-               pair_list = realloc_array(pair_list, struct id_pair,
-                                         pair_alloc);
-       }
-
-       j = pair_cnt++;
-       pair_list[j].uid = uid;
-       pair_list[j].gid = gid;
-
-       return pair_list + j;
 }