adding a new log-format escape
Andrew Shewmaker
agshew at gmail.com
Mon Jun 27 16:56:41 GMT 2005
On 6/27/05, Wayne Davison <wayned at samba.org> wrote:
> On Mon, Jun 27, 2005 at 09:22:25AM -0700, Wayne Davison wrote:
> > so you need to be sure to check for this and print some other
> > value ("N/A") for entries with a NULL pointer.
>
> Actually, the proper fix is to check the mode using S_ISREG() and only
> ever dereference "u.sum" for a regular file (since other item types use
> that union for other purposes).
Okay, I've got it now. Thanks for your help. Here's what I ended up
with in case anyone's interested.
--- rsync-2.6.5-orig/log.c 2005-04-14 10:08:10.000000000 -0600
+++ rsync-2.6.5/log.c 2005-06-27 10:35:51.511736804 -0600
@@ -371,7 +371,7 @@
char buf[MAXPATHLEN+1024], buf2[MAXPATHLEN], fmt[32];
char *p, *s, *n;
size_t len, total;
- int64 b;
+ int64 b, j;
*fmt = '%';
@@ -483,6 +483,17 @@
snprintf(buf2, sizeof buf2, fmt, (double)b);
n = buf2;
break;
+ case 's':
+ if (S_ISREG(file->mode)) {
+ strlcat(fmt, "02x", sizeof fmt);
+ for (j = 0; j < SUM_LENGTH; j++ )
+ snprintf(buf2 + j * 2, sizeof
buf2 - j * 2, fmt, (uchar) file->u.sum[j]);
+ } else {
+ strlcat(fmt, "s", sizeof fmt);
+ snprintf(buf2, sizeof buf2, fmt, "N/A");
+ }
+ n = buf2;
+ break;
case 'i':
if (iflags & ITEM_DELETED) {
n = "*deleting";
--- rsync-2.6.5-orig/rsyncd.conf.yo 2005-06-01 21:54:45.000000000 -0600
+++ rsync-2.6.5/rsyncd.conf.yo 2005-06-27 10:52:51.754131476 -0600
@@ -406,6 +406,7 @@
it() %b for the number of bytes actually transferred
it() %c when sending files this gives the number of checksum bytes
received for this file
+ it() %s for the checksum of a file
it() %i an itemized list of what is being updated
))
--
Andrew Shewmaker
More information about the rsync
mailing list