postgresql-tar.patch
application/octet-stream
Filename: postgresql-tar.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Subject: Minimal changes necessary to complie with tar spec
| File | + | − |
|---|---|---|
| src/backend/replication/basebackup.c | 7 | 13 |
From 9815e5b49a291bfd6175823f2f386ccef8e74ece Mon Sep 17 00:00:00 2001
From: Brian Weaver <cmdrclueless@gmail.com>
Date: Thu, 27 Sep 2012 21:32:07 -0400
Subject: [PATCH] Minimal changes necessary to complie with tar spec
Made the absolute minimal so that the output is compliant
with the tar specification.
---
src/backend/replication/basebackup.c | 20 +++++++-------------
1 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 4aaa9e3..0ef3c92 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -765,9 +765,8 @@ _tarChecksum(char *header)
sum = 0;
for (i = 0; i < 512; i++)
- if (i < 148 || i >= 156)
sum += 0xFF & header[i];
- return sum + 256; /* Assume 8 blanks in checksum field */
+ return sum;
}
/* Given the member, write the TAR header & send the file */
@@ -846,8 +845,6 @@ _tarWriteHeader(const char *filename, const char *linktarget,
struct stat * statbuf)
{
char h[512];
- int lastSum = 0;
- int sum;
memset(h, 0, sizeof(h));
@@ -871,7 +868,7 @@ _tarWriteHeader(const char *filename, const char *linktarget,
sprintf(&h[108], "%07o ", statbuf->st_uid);
/* Group 8 */
- sprintf(&h[117], "%07o ", statbuf->st_gid);
+ sprintf(&h[116], "%07o ", statbuf->st_gid);
/* File size 12 - 11 digits, 1 space, no NUL */
if (linktarget != NULL || S_ISDIR(statbuf->st_mode))
@@ -884,8 +881,8 @@ _tarWriteHeader(const char *filename, const char *linktarget,
/* Mod Time 12 */
sprintf(&h[136], "%011o ", (int) statbuf->st_mtime);
- /* Checksum 8 */
- sprintf(&h[148], "%06o ", lastSum);
+ /* Checksum 8 "12345678" */
+ sprintf(&h[148], " ");
if (linktarget != NULL)
{
@@ -903,7 +900,8 @@ _tarWriteHeader(const char *filename, const char *linktarget,
/* Link tag 100 (NULL) */
/* Magic 6 + Version 2 */
- sprintf(&h[257], "ustar00");
+ sprintf(&h[257], "ustar");
+ sprintf(&h[263], "00");
/* User 32 */
/* XXX: Do we need to care about setting correct username? */
@@ -919,11 +917,7 @@ _tarWriteHeader(const char *filename, const char *linktarget,
/* Min Dev 8 */
sprintf(&h[337], "%6o ", 0);
- while ((sum = _tarChecksum(h)) != lastSum)
- {
- sprintf(&h[148], "%06o ", sum);
- lastSum = sum;
- }
+ sprintf(&h[148], "%06o ", _tarChecksum(h));
pq_putmessage('d', h, 512);
}
--
1.7.7.5 (Apple Git-26)