- I decided that we should leave as much of the real mode attached
[rsync/rsync-patches.git] / atimes.diff
index beb4cfb..c0fb23b 100644 (file)
@@ -51,7 +51,7 @@ After applying this patch, run these commands for a successful build:
                        f_name(f, NULL));
        }
  }
-@@ -298,6 +307,7 @@ static void send_file_entry(struct file_
+@@ -302,6 +311,7 @@ static void send_file_entry(struct file_
  {
        unsigned short flags;
        static time_t modtime;
@@ -59,7 +59,7 @@ After applying this patch, run these commands for a successful build:
        static mode_t mode;
        static int64 dev;
        static dev_t rdev;
-@@ -313,7 +323,7 @@ static void send_file_entry(struct file_
+@@ -317,7 +327,7 @@ static void send_file_entry(struct file_
  
        if (!file) {
                write_byte(f, 0);
@@ -68,7 +68,7 @@ After applying this patch, run these commands for a successful build:
                dev = 0, rdev = MAKEDEV(0, 0);
                rdev_major = 0;
                uid = 0, gid = 0;
-@@ -323,7 +333,7 @@ static void send_file_entry(struct file_
+@@ -327,7 +337,7 @@ static void send_file_entry(struct file_
  
        f_name(file, fname);
  
@@ -77,7 +77,7 @@ After applying this patch, run these commands for a successful build:
  
        if (file->mode == mode)
                flags |= XMIT_SAME_MODE;
-@@ -359,6 +369,12 @@ static void send_file_entry(struct file_
+@@ -363,6 +373,12 @@ static void send_file_entry(struct file_
                flags |= XMIT_SAME_TIME;
        else
                modtime = file->modtime;
@@ -90,7 +90,7 @@ After applying this patch, run these commands for a successful build:
  
  #ifdef SUPPORT_HARD_LINKS
        if (file->link_u.idev) {
-@@ -412,6 +428,8 @@ static void send_file_entry(struct file_
+@@ -416,6 +432,8 @@ static void send_file_entry(struct file_
                write_int(f, modtime);
        if (!(flags & XMIT_SAME_MODE))
                write_int(f, to_wire_mode(mode));
@@ -99,7 +99,7 @@ After applying this patch, run these commands for a successful build:
        if (preserve_uid && !(flags & XMIT_SAME_UID)) {
                if (!numeric_ids)
                        add_uid(uid);
-@@ -478,6 +496,7 @@ static struct file_struct *receive_file_
+@@ -482,6 +500,7 @@ static struct file_struct *receive_file_
                                              unsigned short flags, int f)
  {
        static time_t modtime;
@@ -107,7 +107,7 @@ After applying this patch, run these commands for a successful build:
        static mode_t mode;
        static int64 dev;
        static dev_t rdev;
-@@ -496,7 +515,7 @@ static struct file_struct *receive_file_
+@@ -500,7 +519,7 @@ static struct file_struct *receive_file_
        struct file_struct *file;
  
        if (!flist) {
@@ -116,7 +116,7 @@ After applying this patch, run these commands for a successful build:
                dev = 0, rdev = MAKEDEV(0, 0);
                rdev_major = 0;
                uid = 0, gid = 0;
-@@ -552,6 +571,8 @@ static struct file_struct *receive_file_
+@@ -556,6 +575,8 @@ static struct file_struct *receive_file_
                modtime = (time_t)read_int(f);
        if (!(flags & XMIT_SAME_MODE))
                mode = from_wire_mode(read_int(f));
@@ -125,7 +125,7 @@ After applying this patch, run these commands for a successful build:
  
        if (chmod_modes && !S_ISLNK(mode))
                mode = tweak_mode(mode, chmod_modes);
-@@ -607,6 +628,8 @@ static struct file_struct *receive_file_
+@@ -611,6 +632,8 @@ static struct file_struct *receive_file_
        file->mode = mode;
        file->uid = uid;
        file->gid = gid;
@@ -134,7 +134,7 @@ After applying this patch, run these commands for a successful build:
  
        if (dirname_len) {
                file->dirname = lastdir = bp;
-@@ -632,12 +655,12 @@ static struct file_struct *receive_file_
+@@ -636,12 +659,12 @@ static struct file_struct *receive_file_
                            && lastname[del_hier_name_len-1] == '.'
                            && lastname[del_hier_name_len-2] == '/')
                                del_hier_name_len -= 2;
@@ -149,7 +149,7 @@ After applying this patch, run these commands for a successful build:
                        else
                                in_del_hier = 0;
                }
-@@ -853,12 +876,14 @@ struct file_struct *make_file(char *fnam
+@@ -858,12 +881,14 @@ struct file_struct *make_file(char *fnam
        memset(bp, 0, file_struct_len);
        bp += file_struct_len;
  
@@ -165,7 +165,7 @@ After applying this patch, run these commands for a successful build:
  
  #ifdef SUPPORT_HARD_LINKS
        if (flist && flist->hlink_pool) {
-@@ -971,7 +996,7 @@ static void send_if_directory(int f, str
+@@ -976,7 +1001,7 @@ static void send_if_directory(int f, str
        char is_dot_dir = fbuf[ol-1] == '.' && (ol == 1 || fbuf[ol-2] == '/');
  
        if (S_ISDIR(file->mode)
@@ -174,7 +174,7 @@ After applying this patch, run these commands for a successful build:
                void *save_filters;
                unsigned int len = strlen(fbuf);
                if (len > 1 && fbuf[len-1] == '/')
-@@ -1581,8 +1606,9 @@ static void clean_flist(struct file_list
+@@ -1586,8 +1611,9 @@ static void clean_flist(struct file_list
                        }
                        /* Make sure we don't lose track of a user-specified
                         * top directory. */
@@ -186,7 +186,7 @@ After applying this patch, run these commands for a successful build:
  
                        clear_file(flist->files[drop], flist);
  
-@@ -1706,7 +1732,7 @@ static void output_flist(struct file_lis
+@@ -1711,7 +1737,7 @@ static void output_flist(struct file_lis
                        file->dirname ? file->dirname : "",
                        file->dirname ? "/" : "", NS(file->basename),
                        S_ISDIR(file->mode) ? "/" : "", (int)file->mode,
@@ -282,6 +282,15 @@ After applying this patch, run these commands for a successful build:
                        if (preserve_hard_links && file->link_u.links) {
                                if (dry_run)
                                        file->link_u.links->link_dest_used = j + 1;
+@@ -930,7 +937,7 @@ static void recv_generator(char *fname, 
+                               rsyserr(FERROR, errno,
+                                       "recv_generator: mkdir %s failed",
+                                       full_fname(fname));
+-                              file->flags |= FLAG_MISSING;
++                              FFLAGS(file) |= FLAG_MISSING;
+                               if (ndx+1 < the_file_list->count
+                                && the_file_list->files[ndx+1]->dir.depth > file->dir.depth) {
+                                       rprintf(FERROR,
 @@ -944,7 +951,7 @@ static void recv_generator(char *fname, 
                    && verbose && code != FNONE && f_out != -1)
                        rprintf(code, "%s/\n", fname);
@@ -300,6 +309,15 @@ After applying this patch, run these commands for a successful build:
        }
  
        /* open the file */
+@@ -1514,7 +1521,7 @@ void generate_files(int f_out, struct fi
+                               continue;
+                       if (!need_retouch_dir_times && file->mode & S_IWUSR)
+                               continue;
+-                      if (file->flags & FLAG_MISSING) {
++                      if (FFLAGS(file) & FLAG_MISSING) {
+                               int missing = file->dir.depth;
+                               while (++i < flist->count) {
+                                       file = flist->files[i];
 --- old/hlink.c
 +++ new/hlink.c
 @@ -30,6 +30,7 @@ extern int make_backups;
@@ -310,7 +328,7 @@ After applying this patch, run these commands for a successful build:
  extern struct file_list *the_file_list;
  
  #ifdef SUPPORT_HARD_LINKS
-@@ -90,10 +91,10 @@ static void link_idev_data(void)
+@@ -91,10 +92,10 @@ static void link_idev_data(void)
                        FPTR(cur)->link_u.links = pool_talloc(hlink_pool,
                            struct hlink, 1, "hlink_list");
  
@@ -320,10 +338,10 @@ After applying this patch, run these commands for a successful build:
                        FPTR(cur)->F_NEXT = head;
 -                      FPTR(cur)->flags |= FLAG_HLINK_EOL;
 +                      FFLAGS(FPTR(cur)) |= FLAG_HLINK_EOL;
+                       FPTR(cur)->link_u.links->link_dest_used = 0;
                        hlink_list[to++] = head;
                } else
-                       FPTR(cur)->link_u.links = NULL;
-@@ -179,7 +180,7 @@ int hard_link_check(struct file_struct *
+@@ -181,7 +182,7 @@ int hard_link_check(struct file_struct *
  {
  #ifdef SUPPORT_HARD_LINKS
        int head;
@@ -332,7 +350,7 @@ After applying this patch, run these commands for a successful build:
                head = hlink_list[file->F_HLINDEX] = file->F_NEXT;
        else
                head = hlink_list[file->F_HLINDEX];
-@@ -287,8 +288,8 @@ void hard_link_cluster(struct file_struc
+@@ -289,8 +290,8 @@ void hard_link_cluster(struct file_struc
        file->F_HLINDEX = FINISHED_LINK;
        if (link_stat(f_name(file, hlink1), &st1, 0) < 0)
                return;
@@ -343,7 +361,7 @@ After applying this patch, run these commands for a successful build:
                        ndx = file->F_NEXT;
                        file = FPTR(ndx);
                }
-@@ -308,6 +309,6 @@ void hard_link_cluster(struct file_struc
+@@ -310,6 +311,6 @@ void hard_link_cluster(struct file_struc
                        send_msg(MSG_SUCCESS, numbuf, 4);
                }
                file->F_HLINDEX = FINISHED_LINK;
@@ -358,10 +376,10 @@ After applying this patch, run these commands for a successful build:
  extern int protocol_version;
  extern int preserve_times;
 +extern int preserve_atimes;
- extern int in_exit_cleanup;
  extern int stdout_format_has_i;
  extern int stdout_format_has_o_or_i;
-@@ -615,7 +616,8 @@ static void log_formatted(enum logcode c
+ extern int logfile_format_has_i;
+@@ -606,7 +607,8 @@ static void log_formatted(enum logcode c
                        n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
                        n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
                        n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
@@ -403,7 +421,7 @@ After applying this patch, run these commands for a successful build:
    {"omit-dir-times",  'O', POPT_ARG_VAL,    &omit_dir_times, 2, 0, 0 },
    {"modify-window",    0,  POPT_ARG_INT,    &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
    {"super",            0,  POPT_ARG_VAL,    &am_root, 2, 0, 0 },
-@@ -1531,6 +1536,8 @@ void server_options(char **args,int *arg
+@@ -1534,6 +1539,8 @@ void server_options(char **args,int *arg
                argstr[x++] = 'D';
        if (preserve_times)
                argstr[x++] = 't';
@@ -657,21 +675,21 @@ After applying this patch, run these commands for a successful build:
        exit(1);
  }
  
-+static void storetime(char *dest, time_t t)
++static void storetime(char *dest, time_t t, size_t destsize)
 +{
 +      if (t) {
 +              struct tm *mt = gmtime(&t);
 +
-+              sprintf(dest, "%04d-%02d-%02d %02d:%02d:%02d ",
++              snprintf(dest, destsize,
++                      "%04d-%02d-%02d %02d:%02d:%02d ",
 +                      (int)mt->tm_year + 1900,
 +                      (int)mt->tm_mon + 1,
 +                      (int)mt->tm_mday,
 +                      (int)mt->tm_hour,
 +                      (int)mt->tm_min,
 +                      (int)mt->tm_sec);
-+      } else {
-+              strcpy(dest, "                    ");
-+      }
++      } else
++              strlcpy(dest, "                    ", destsize);
 +}
 +
  static void list_file(const char *fname)
@@ -692,18 +710,18 @@ After applying this patch, run these commands for a successful build:
 -      if (buf.st_mtime) {
 -              mt = gmtime(&buf.st_mtime);
 -
--              sprintf(datebuf, "%04d-%02d-%02d %02d:%02d:%02d",
+-              snprintf(datebuf, sizeof datebuf,
+-                      "%04d-%02d-%02d %02d:%02d:%02d",
 -                      (int)mt->tm_year + 1900,
 -                      (int)mt->tm_mon + 1,
 -                      (int)mt->tm_mday,
 -                      (int)mt->tm_hour,
 -                      (int)mt->tm_min,
 -                      (int)mt->tm_sec);
--      } else {
--              strcpy(datebuf, "                   ");
--      }
-+      storetime(mtimebuf, buf.st_mtime);
-+      storetime(atimebuf, buf.st_atime);
+-      } else
+-              strlcpy(datebuf, "                   ", sizeof datebuf);
++      storetime(mtimebuf, buf.st_mtime, sizeof mtimebuf);
++      storetime(atimebuf, buf.st_atime, sizeof atimebuf);
  
        /* TODO: Perhaps escape special characters in fname? */