[BACK]Return to flist.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rsync

Diff for /src/usr.bin/rsync/flist.c between version 1.25 and 1.26

version 1.25, 2019/05/08 20:00:25 version 1.26, 2019/05/08 21:30:11
Line 68 
Line 68 
  * Returns zero on failure, non-zero on success.   * Returns zero on failure, non-zero on success.
  */   */
 static int  static int
 flist_dedupe(struct sess *sess, struct flist **fl, size_t *sz)  flist_dedupe(struct flist **fl, size_t *sz)
 {  {
         size_t           i, j;          size_t           i, j;
         struct flist    *new;          struct flist    *new;
Line 282 
Line 282 
                  */                   */
   
                 if (sess->mplex_reads &&                  if (sess->mplex_reads &&
                     io_read_check(sess, fdin) &&                      io_read_check(fdin) &&
                      !io_read_flush(sess, fdin)) {                       !io_read_flush(sess, fdin)) {
                         ERRX1("io_read_flush");                          ERRX1("io_read_flush");
                         goto out;                          goto out;
Line 334 
Line 334 
                                 ERRX1("io_write_uint");                                  ERRX1("io_write_uint");
                                 goto out;                                  goto out;
                         }                          }
                         if (!idents_add(sess, 0, &uids, &uidsz, f->st.uid)) {                          if (!idents_add(0, &uids, &uidsz, f->st.uid)) {
                                 ERRX1("idents_add");                                  ERRX1("idents_add");
                                 goto out;                                  goto out;
                         }                          }
Line 347 
Line 347 
                                 ERRX1("io_write_uint");                                  ERRX1("io_write_uint");
                                 goto out;                                  goto out;
                         }                          }
                         if (!idents_add(sess, 1, &gids, &gidsz, f->st.gid)) {                          if (!idents_add(1, &gids, &gidsz, f->st.gid)) {
                                 ERRX1("idents_add");                                  ERRX1("idents_add");
                                 goto out;                                  goto out;
                         }                          }
Line 514 
Line 514 
  * Returns zero on failure, non-zero on success.   * Returns zero on failure, non-zero on success.
  */   */
 static int  static int
 flist_realloc(struct sess *sess, struct flist **fl, size_t *sz, size_t *max)  flist_realloc(struct flist **fl, size_t *sz, size_t *max)
 {  {
         void    *pp;          void    *pp;
   
Line 541 
Line 541 
  * Returns zero on failure, non-zero on success.   * Returns zero on failure, non-zero on success.
  */   */
 static int  static int
 flist_append(struct sess *sess, struct flist *f, struct stat *st,  flist_append(struct flist *f, struct stat *st, const char *path)
     const char *path)  
 {  {
   
         /*          /*
Line 571 
Line 570 
         /* Optionally copy link information. */          /* Optionally copy link information. */
   
         if (S_ISLNK(st->st_mode)) {          if (S_ISLNK(st->st_mode)) {
                 f->link = symlink_read(sess, f->path);                  f->link = symlink_read(f->path);
                 if (f->link == NULL) {                  if (f->link == NULL) {
                         ERRX1("symlink_read");                          ERRX1("symlink_read");
                         return 0;                          return 0;
Line 609 
Line 608 
                 } else if (flag == 0)                  } else if (flag == 0)
                         break;                          break;
   
                 if (!flist_realloc(sess, &fl, &flsz, &flmax)) {                  if (!flist_realloc(&fl, &flsz, &flmax)) {
                         ERRX1("flist_realloc");                          ERRX1("flist_realloc");
                         goto out;                          goto out;
                 }                  }
Line 824 
Line 823 
                 ERR("%s: lstat", root);                  ERR("%s: lstat", root);
                 return 0;                  return 0;
         } else if (S_ISREG(st.st_mode)) {          } else if (S_ISREG(st.st_mode)) {
                 if (!flist_realloc(sess, fl, sz, max)) {                  if (!flist_realloc(fl, sz, max)) {
                         ERRX1("flist_realloc");                          ERRX1("flist_realloc");
                         return 0;                          return 0;
                 }                  }
                 f = &(*fl)[(*sz) - 1];                  f = &(*fl)[(*sz) - 1];
                 assert(f != NULL);                  assert(f != NULL);
   
                 if (!flist_append(sess, f, &st, root)) {                  if (!flist_append(f, &st, root)) {
                         ERRX1("flist_append");                          ERRX1("flist_append");
                         return 0;                          return 0;
                 }                  }
Line 844 
Line 843 
                 if (!sess->opts->preserve_links) {                  if (!sess->opts->preserve_links) {
                         WARNX("%s: skipping symlink", root);                          WARNX("%s: skipping symlink", root);
                         return 1;                          return 1;
                 } else if (!flist_realloc(sess, fl, sz, max)) {                  } else if (!flist_realloc(fl, sz, max)) {
                         ERRX1("flist_realloc");                          ERRX1("flist_realloc");
                         return 0;                          return 0;
                 }                  }
                 f = &(*fl)[(*sz) - 1];                  f = &(*fl)[(*sz) - 1];
                 assert(f != NULL);                  assert(f != NULL);
   
                 if (!flist_append(sess, f, &st, root)) {                  if (!flist_append(f, &st, root)) {
                         ERRX1("flist_append");                          ERRX1("flist_append");
                         return 0;                          return 0;
                 }                  }
Line 958 
Line 957 
   
                 /* Allocate a new file entry. */                  /* Allocate a new file entry. */
   
                 if (!flist_realloc(sess, fl, sz, max)) {                  if (!flist_realloc(fl, sz, max)) {
                         ERRX1("flist_realloc");                          ERRX1("flist_realloc");
                         goto out;                          goto out;
                 }                  }
Line 986 
Line 985 
                 /* Optionally copy link information. */                  /* Optionally copy link information. */
   
                 if (S_ISLNK(ent->fts_statp->st_mode)) {                  if (S_ISLNK(ent->fts_statp->st_mode)) {
                         f->link = symlink_read(sess, f->path);                          f->link = symlink_read(f->path);
                         if (f->link == NULL) {                          if (f->link == NULL) {
                                 ERRX1("symlink_read");                                  ERRX1("symlink_read");
                                 goto out;                                  goto out;
Line 1102 
Line 1101 
                         ERR("%s: unveil", argv[i]);                          ERR("%s: unveil", argv[i]);
                         goto out;                          goto out;
                 }                  }
                 if (!flist_append(sess, f, &st, argv[i])) {                  if (!flist_append(f, &st, argv[i])) {
                         ERRX1("flist_append");                          ERRX1("flist_append");
                         goto out;                          goto out;
                 }                  }
Line 1149 
Line 1148 
   
         qsort(*flp, *sz, sizeof(struct flist), flist_cmp);          qsort(*flp, *sz, sizeof(struct flist), flist_cmp);
   
         if (flist_dedupe(sess, flp, sz)) {          if (flist_dedupe(flp, sz)) {
                 flist_topdirs(sess, *flp, *sz);                  flist_topdirs(sess, *flp, *sz);
                 return 1;                  return 1;
         }          }
Line 1333 
Line 1332 
   
                 /* Not found: we'll delete it. */                  /* Not found: we'll delete it. */
   
                 if (!flist_realloc(sess, fl, sz, &max)) {                  if (!flist_realloc(fl, sz, &max)) {
                         ERRX1("flist_realloc");                          ERRX1("flist_realloc");
                         goto out;                          goto out;
                 }                  }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26