~ubuntu-branches/ubuntu/lucid/rsync/lucid

« back to all changes in this revision

Viewing changes to xattrs.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Slootman
  • Date: 2009-06-17 13:43:12 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090617134312-aopuowraetuj41s8
Tags: 3.0.6-1
* new upstream release.
* Manpage now states that MD5 is used for protocol version 30 and higher.
  closes:#520330
* Updated to standards version 3.8.2. Added debian/README.source .
* Added lintian override for embedded-zlib, as this is a modified version
  optimized for the rsync protocol. I.e. the standard zlib version will not
  work as well.
* Added a 'status' option to the init.d script.
  closes:#492138
* Manpage now declares --delete-during to be the default in the summary.
  closes:#472767,#476368

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Written by Jay Fenlason, vaguely based on the ACLs patch.
4
4
 *
5
5
 * Copyright (C) 2004 Red Hat, Inc.
6
 
 * Copyright (C) 2006-2008 Wayne Davison
 
6
 * Copyright (C) 2006-2009 Wayne Davison
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
81
81
static item_list empty_xattr = EMPTY_ITEM_LIST;
82
82
static item_list rsync_xal_l = EMPTY_ITEM_LIST;
83
83
 
 
84
static size_t prior_xattr_count = (size_t)-1;
 
85
 
84
86
/* ------------------------------------------------------------------------- */
85
87
 
86
88
static void rsync_xal_free(item_list *xalp)
724
726
 
725
727
/* Turn the xattr data in stat_x into cached xattr data, setting the index
726
728
 * values in the file struct. */
727
 
void cache_xattr(struct file_struct *file, stat_x *sxp)
 
729
void cache_tmp_xattr(struct file_struct *file, stat_x *sxp)
728
730
{
729
731
        int ndx;
730
732
 
731
733
        if (!sxp->xattr)
732
734
                return;
733
735
 
 
736
        if (prior_xattr_count == (size_t)-1)
 
737
                prior_xattr_count = rsync_xal_l.count;
734
738
        ndx = find_matching_xattr(sxp->xattr);
735
739
        if (ndx < 0)
736
740
                rsync_xal_store(sxp->xattr); /* adds item to rsync_xal_l */
738
742
        F_XATTR(file) = ndx;
739
743
}
740
744
 
 
745
void uncache_tmp_xattrs(void)
 
746
{
 
747
        if (prior_xattr_count != (size_t)-1) {
 
748
                item_list *xattr_item = rsync_xal_l.items;
 
749
                item_list *xattr_start = xattr_item + prior_xattr_count;
 
750
                xattr_item += rsync_xal_l.count;
 
751
                rsync_xal_l.count = prior_xattr_count;
 
752
                while (xattr_item-- > xattr_start) {
 
753
                        rsync_xal_free(xattr_item);
 
754
                        free(xattr_item);
 
755
                }
 
756
                prior_xattr_count = (size_t)-1;
 
757
        }
 
758
}
 
759
 
741
760
static int rsync_xal_set(const char *fname, item_list *xalp,
742
761
                         const char *fnamecmp, stat_x *sxp)
743
762
{
970
989
        fst.st_mode &= (_S_IFMT | CHMOD_BITS);
971
990
        fmode = new_mode & (_S_IFMT | CHMOD_BITS);
972
991
 
973
 
        if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) {
 
992
        if (IS_DEVICE(fmode)) {
974
993
                uint32 *devp = F_RDEV_P(file);
975
994
                rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
976
995
        } else
981
1000
             | (S_ISDIR(fst.st_mode) ? 0700 : 0600);
982
1001
        if (fst.st_mode != mode)
983
1002
                do_chmod(fname, mode);
984
 
        if (!IS_DEVICE(fst.st_mode) && !IS_SPECIAL(fst.st_mode))
 
1003
        if (!IS_DEVICE(fst.st_mode))
985
1004
                fst.st_rdev = 0; /* just in case */
986
1005
 
987
1006
        if (mode == fmode && fst.st_rdev == rdev