Matt McCutchen's Web Site
/
rsync
/
rsync-patches.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9aab301
)
More improvements from both Wesley and me.
author
Wayne Davison
<wayned@samba.org>
Wed, 17 Oct 2007 22:56:21 +0000
(22:56 +0000)
committer
Wayne Davison
<wayned@samba.org>
Wed, 17 Oct 2007 22:56:21 +0000
(22:56 +0000)
osx-create-time.diff
patch
|
blob
|
blame
|
history
diff --git
a/osx-create-time.diff
b/osx-create-time.diff
index
5fa24cb
..
c2c77ff
100644
(file)
--- a/
osx-create-time.diff
+++ b/
osx-create-time.diff
@@
-10,7
+10,7
@@
To use this patch, run these commands for a successful build:
--- old/lib/sysxattrs.c
+++ new/lib/sysxattrs.c
--- old/lib/sysxattrs.c
+++ new/lib/sysxattrs.c
-@@ -52,29 +52,1
06
@@ ssize_t sys_llistxattr(const char *path,
+@@ -52,29 +52,1
18
@@ ssize_t sys_llistxattr(const char *path,
#elif HAVE_OSX_XATTRS
#elif HAVE_OSX_XATTRS
@@
-22,73
+22,82
@@
To use this patch, run these commands for a successful build:
+
+struct CreationTime {
+ unsigned long length;
+
+struct CreationTime {
+ unsigned long length;
-+ struct timespec
dat
e;
++ struct timespec
crtim
e;
+};
+
+};
+
-+static s
size_t getCreationTime(const char *path, char *buf, size_t size
)
++static s
truct timespec *getCreationTime(const char *path
)
+{
+{
++ static struct CreationTime attrBuf;
+ struct attrlist attrList;
+ struct attrlist attrList;
-+ struct CreationTime attrBuf;
++
++ memset(&attrList, 0, sizeof attrList);
++ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
++ attrList.commonattr = ATTR_CMN_CRTIME;
++ if (getattrlist(path, &attrList, &attrBuf, sizeof attrBuf, FSOPT_NOFOLLOW) < 0)
++ return NULL;
++ return &attrBuf.crtime;
++}
++
++static ssize_t get_crtime_xattr(const char *path, char *buf, size_t size)
++{
++ struct timespec *crtime_p;
+
+ if (buf == NULL)
+ return CRTIME_XATTR_LEN;
+ if (size < CRTIME_XATTR_LEN)
+ return -1; /* Doesn't happen with rsync code... */
+
+
+ if (buf == NULL)
+ return CRTIME_XATTR_LEN;
+ if (size < CRTIME_XATTR_LEN)
+ return -1; /* Doesn't happen with rsync code... */
+
-+ memset(&attrList, 0, sizeof attrList);
-+ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
-+ attrList.commonattr = ATTR_CMN_CRTIME;
-+ if (getattrlist(path, &attrList, &attrBuf, sizeof attrBuf, FSOPT_NOFOLLOW) < 0)
++ if ((crtime_p = getCreationTime(path)) == NULL)
+ return -1;
+
+ return -1;
+
-+ SIVAL(buf, 0,
attrBuf.date.
tv_sec);
++ SIVAL(buf, 0,
crtime_p->
tv_sec);
+#if SIZEOF_TIME_T > 4
+#if SIZEOF_TIME_T > 4
-+ SIVAL(buf, 4,
attrBuf.date.
tv_sec >> 32);
++ SIVAL(buf, 4,
crtime_p->
tv_sec >> 32);
+#else
+ SIVAL(buf, 4, 0);
+#endif
+#else
+ SIVAL(buf, 4, 0);
+#endif
-+ SIVAL(buf, 8,
attrBuf.date.
tv_nsec);
++ SIVAL(buf, 8,
crtime_p->
tv_nsec);
+
+ return CRTIME_XATTR_LEN;
+}
+
+
+ return CRTIME_XATTR_LEN;
+}
+
-+static int set
CreationTime
(const char *path, const char *buf, size_t size)
++static int set
_crtime_xattr
(const char *path, const char *buf, size_t size)
+{
+ struct attrlist attrList;
+{
+ struct attrlist attrList;
-+ struct timespec
dat
e;
++ struct timespec
crtim
e;
+
+ if (size != CRTIME_XATTR_LEN)
+ return -1;
+
+
+ if (size != CRTIME_XATTR_LEN)
+ return -1;
+
-+
dat
e.tv_sec = IVAL(buf, 0);
++
crtim
e.tv_sec = IVAL(buf, 0);
+#if SIZEOF_TIME_T > 4
+#if SIZEOF_TIME_T > 4
-+
dat
e.tv_sec += (time_t)IVAL(buf, 4) << 32;
++
crtim
e.tv_sec += (time_t)IVAL(buf, 4) << 32;
+#endif
+#endif
-+
dat
e.tv_nsec = IVAL(buf, 8);
++
crtim
e.tv_nsec = IVAL(buf, 8);
+
+ memset(&attrList, 0, sizeof attrList);
+ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+ attrList.commonattr = ATTR_CMN_CRTIME;
+
+ memset(&attrList, 0, sizeof attrList);
+ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+ attrList.commonattr = ATTR_CMN_CRTIME;
-+ return setattrlist(path, &attrList, &
date, sizeof dat
e, FSOPT_NOFOLLOW);
++ return setattrlist(path, &attrList, &
crtime, sizeof crtim
e, FSOPT_NOFOLLOW);
+}
+
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
{
+ if (IS_CRTIME(name))
+}
+
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
{
+ if (IS_CRTIME(name))
-+ return get
CreationTime
(path, value, size);
++ return get
_crtime_xattr
(path, value, size);
return getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
{
return getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
{
-+ /* XXX Figure out how to get creation
dat
e from an open filedes? */
++ /* XXX Figure out how to get creation
tim
e from an open filedes? */
return fgetxattr(filedes, name, value, size, 0, 0);
}
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size)
{
+ if (IS_CRTIME(name))
return fgetxattr(filedes, name, value, size, 0, 0);
}
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size)
{
+ if (IS_CRTIME(name))
-+ return set
CreationTime
(path, value, size);
++ return set
_crtime_xattr
(path, value, size);
return setxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
return setxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
@@
-106,13
+115,16
@@
To use this patch, run these commands for a successful build:
+ ssize_t ret = listxattr(path, list, size, XATTR_NOFOLLOW);
+ if (ret < 0)
+ return ret;
+ ssize_t ret = listxattr(path, list, size, XATTR_NOFOLLOW);
+ if (ret < 0)
+ return ret;
-+ ret += sizeof CRTIME_XATTR;
-+ if (list) {
-+ if ((size_t)ret > size) {
-+ errno = ERANGE;
-+ return -1;
++ if (getCreationTime(path) != NULL) {
++ ret += sizeof CRTIME_XATTR;
++ if (list) {
++ if ((size_t)ret > size) {
++ errno = ERANGE;
++ return -1;
++ }
++ memcpy(list + ret - sizeof CRTIME_XATTR,
++ CRTIME_XATTR, sizeof CRTIME_XATTR);
+ }
+ }
-+ memcpy(list + ret - sizeof CRTIME_XATTR, CRTIME_XATTR, sizeof CRTIME_XATTR);
+ }
+ return ret;
}
+ }
+ return ret;
}