PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <sys/stat.h>
#include <ctype.h>
#include <limits.h>
#include <unistd.h>
#include "common/file_utils.h"
#include "fe_utils/string_utils.h"
#include "pg_backup_archiver.h"
#include "pg_backup_tar.h"
#include "pg_backup_utils.h"
#include "pgtar.h"
Go to the source code of this file.
Data Structures | |
struct | TAR_MEMBER |
struct | lclContext |
struct | lclTocEntry |
Macros | |
#define | K_STD_BUF_SIZE 1024 |
Functions | |
static void | _ArchiveEntry (ArchiveHandle *AH, TocEntry *te) |
static void | _StartData (ArchiveHandle *AH, TocEntry *te) |
static void | _WriteData (ArchiveHandle *AH, const void *data, size_t dLen) |
static void | _EndData (ArchiveHandle *AH, TocEntry *te) |
static int | _WriteByte (ArchiveHandle *AH, const int i) |
static int | _ReadByte (ArchiveHandle *AH) |
static void | _WriteBuf (ArchiveHandle *AH, const void *buf, size_t len) |
static void | _ReadBuf (ArchiveHandle *AH, void *buf, size_t len) |
static void | _CloseArchive (ArchiveHandle *AH) |
static void | _PrintTocData (ArchiveHandle *AH, TocEntry *te) |
static void | _WriteExtraToc (ArchiveHandle *AH, TocEntry *te) |
static void | _ReadExtraToc (ArchiveHandle *AH, TocEntry *te) |
static void | _PrintExtraToc (ArchiveHandle *AH, TocEntry *te) |
static void | _StartLOs (ArchiveHandle *AH, TocEntry *te) |
static void | _StartLO (ArchiveHandle *AH, TocEntry *te, Oid oid) |
static void | _EndLO (ArchiveHandle *AH, TocEntry *te, Oid oid) |
static void | _EndLOs (ArchiveHandle *AH, TocEntry *te) |
static void | _LoadLOs (ArchiveHandle *AH, TocEntry *te) |
static TAR_MEMBER * | tarOpen (ArchiveHandle *AH, const char *filename, char mode) |
static void | tarClose (ArchiveHandle *AH, TAR_MEMBER *th) |
static int | tarPrintf (TAR_MEMBER *th, const char *fmt,...) pg_attribute_printf(2 |
static int static void | _tarAddFile (ArchiveHandle *AH, TAR_MEMBER *th) |
static TAR_MEMBER * | _tarPositionTo (ArchiveHandle *AH, const char *filename) |
static size_t | tarRead (void *buf, size_t len, TAR_MEMBER *th) |
static size_t | tarWrite (const void *buf, size_t len, TAR_MEMBER *th) |
static void | _tarWriteHeader (TAR_MEMBER *th) |
static int | _tarGetHeader (ArchiveHandle *AH, TAR_MEMBER *th) |
static size_t | _tarReadRaw (ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh) |
static size_t | _scriptOut (ArchiveHandle *AH, const void *buf, size_t len) |
void | InitArchiveFmt_Tar (ArchiveHandle *AH) |
static void | _PrintFileData (ArchiveHandle *AH, char *filename) |
bool | isValidTarHeader (char *header) |
#define K_STD_BUF_SIZE 1024 |
Definition at line 63 of file pg_backup_tar.c.
|
static |
Definition at line 234 of file pg_backup_tar.c.
References _tocEntry::dataDumper, _tocEntry::dumpId, lclTocEntry::filename, fn(), _tocEntry::formatData, K_STD_BUF_SIZE, pg_malloc0_object, pg_strdup(), snprintf, and lclTocEntry::TH.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 769 of file pg_backup_tar.c.
References _scriptOut(), archModeWrite, _archiveHandle::CustomOutPtr, Archive::dopt, _archiveHandle::FH, lclContext::FH, _archiveHandle::formatData, fsync_fname(), i, if(), lclContext::isSpecialScript, _archiveHandle::mode, NewRestoreOptions(), _archiveHandle::public, RestoreArchive(), Archive::ropt, lclContext::scriptTH, SetArchiveOptions(), TAR_BLOCK_SIZE, tarClose(), lclContext::tarFH, tarOpen(), tarPrintf(), Archive::verbose, WRITE_ERROR_EXIT, WriteDataChunks(), WriteHead(), and WriteToc().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 549 of file pg_backup_tar.c.
References _tocEntry::formatData, tarClose(), and lclTocEntry::TH.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 922 of file pg_backup_tar.c.
References _tocEntry::formatData, tarClose(), and lclTocEntry::TH.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 936 of file pg_backup_tar.c.
References _archiveHandle::formatData, lclContext::loToc, and tarClose().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 643 of file pg_backup_tar.c.
References ahwrite(), atooid, buf, _restoreOptions::dropSchema, EndRestoreLO(), EndRestoreLOs(), lclContext::FH, _archiveHandle::formatData, K_VERS_1_16, pg_log_info, _archiveHandle::public, Archive::ropt, snprintf, StartRestoreLO(), StartRestoreLOs(), _tocEntry::tag, tarClose(), TAR_MEMBER::targetFile, tarOpen(), tarRead(), and _archiveHandle::version.
Referenced by _PrintTocData().
|
static |
Definition at line 285 of file pg_backup_tar.c.
References ahprintf(), lclTocEntry::filename, _tocEntry::formatData, if(), _archiveHandle::public, and Archive::verbose.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 562 of file pg_backup_tar.c.
References ahwrite(), buf, lclContext::FH, filename, _archiveHandle::formatData, if(), tarClose(), tarOpen(), and tarRead().
Referenced by _PrintTocData().
|
static |
Definition at line 589 of file pg_backup_tar.c.
References _LoadLOs(), _PrintFileData(), ahprintf(), ahwrite(), _tocEntry::copyStmt, _tocEntry::desc, _archiveHandle::formatData, _tocEntry::formatData, lclContext::isSpecialScript, and pg_fatal.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 757 of file pg_backup_tar.c.
References buf, lclContext::FH, lclContext::filePos, _archiveHandle::formatData, if(), len, pg_fatal, and tarRead().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 731 of file pg_backup_tar.c.
References lclContext::FH, lclContext::filePos, _archiveHandle::formatData, pg_fatal, res, and tarRead().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 265 of file pg_backup_tar.c.
References lclTocEntry::filename, _tocEntry::formatData, free, if(), pg_malloc0_object, ReadStr(), and lclTocEntry::TH.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 857 of file pg_backup_tar.c.
References buf, _archiveHandle::formatData, len, lclContext::scriptTH, and tarWrite().
Referenced by _CloseArchive().
|
static |
Definition at line 294 of file pg_backup_tar.c.
References lclTocEntry::filename, _tocEntry::formatData, tarOpen(), and lclTocEntry::TH.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 896 of file pg_backup_tar.c.
References pg_compress_specification::algorithm, _archiveHandle::compression_spec, _archiveHandle::formatData, _tocEntry::formatData, lclContext::loToc, PG_COMPRESSION_NONE, pg_fatal, sprintf, tarOpen(), and tarPrintf().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 879 of file pg_backup_tar.c.
References _tocEntry::dumpId, _archiveHandle::formatData, K_STD_BUF_SIZE, lclContext::loToc, sprintf, and tarOpen().
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 1014 of file pg_backup_tar.c.
References _tarWriteHeader(), buf, TAR_MEMBER::fileLen, _archiveHandle::formatData, fseeko, ftello, i, if(), len, pg_fatal, pgoff_t, READ_ERROR_EXIT, res, TAR_MEMBER::tarFH, lclContext::tarFHpos, tarPaddingBytesRequired(), TAR_MEMBER::tmpFH, and WRITE_ERROR_EXIT.
Referenced by tarClose().
|
static |
Definition at line 1140 of file pg_backup_tar.c.
References _tarReadRaw(), TAR_MEMBER::fileLen, _archiveHandle::formatData, ftello, i, len, ngettext, pg_fatal, pg_log_debug, pg_strdup(), pgoff_t, read_tar_number(), strlcpy(), TAR_BLOCK_SIZE, TAR_OFFSET_CHECKSUM, TAR_OFFSET_NAME, TAR_OFFSET_SIZE, tarChecksum(), lclContext::tarFH, lclContext::tarFHpos, TAR_MEMBER::targetFile, and while().
Referenced by _tarPositionTo().
|
static |
Definition at line 1066 of file pg_backup_tar.c.
References _tarGetHeader(), _tarReadRaw(), TAR_MEMBER::AH, TAR_MEMBER::fileLen, filename, _archiveHandle::formatData, free, i, len, pg_fatal, pg_log_debug, pg_malloc0_object, TAR_MEMBER::pos, REQ_DATA, TAR_BLOCK_SIZE, lclContext::tarFH, lclContext::tarFHpos, TAR_MEMBER::targetFile, lclContext::tarNextMember, tarPaddingBytesRequired(), and TocIDRequired().
Referenced by tarOpen().
|
static |
Definition at line 462 of file pg_backup_tar.c.
References Assert, buf, _archiveHandle::formatData, len, _archiveHandle::lookahead, _archiveHandle::lookaheadLen, _archiveHandle::lookaheadPos, TAR_MEMBER::nFH, READ_ERROR_EXIT, res, and lclContext::tarFHpos.
Referenced by _tarGetHeader(), _tarPositionTo(), and tarRead().
|
static |
Definition at line 1212 of file pg_backup_tar.c.
References TAR_MEMBER::fileLen, TAR_BLOCK_SIZE, tarCreateHeader(), TAR_MEMBER::tarFH, TAR_MEMBER::targetFile, and WRITE_ERROR_EXIT.
Referenced by _tarAddFile().
|
static |
Definition at line 746 of file pg_backup_tar.c.
References buf, lclContext::FH, lclContext::filePos, _archiveHandle::formatData, if(), len, tarWrite(), and WRITE_ERROR_EXIT.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 718 of file pg_backup_tar.c.
References b, lclContext::FH, lclContext::filePos, _archiveHandle::formatData, i, if(), tarWrite(), and WRITE_ERROR_EXIT.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 540 of file pg_backup_tar.c.
References _archiveHandle::currToc, data, _tocEntry::formatData, if(), tarWrite(), lclTocEntry::TH, and WRITE_ERROR_EXIT.
Referenced by InitArchiveFmt_Tar().
|
static |
Definition at line 254 of file pg_backup_tar.c.
References lclTocEntry::filename, _tocEntry::formatData, if(), and WriteStr().
Referenced by InitArchiveFmt_Tar().
void InitArchiveFmt_Tar | ( | ArchiveHandle * | AH | ) |
Definition at line 121 of file pg_backup_tar.c.
References _ArchiveEntry(), _CloseArchive(), _EndData(), _EndLO(), _EndLOs(), _PrintExtraToc(), _PrintTocData(), _ReadBuf(), _ReadByte(), _ReadExtraToc(), _StartData(), _StartLO(), _StartLOs(), _WriteBuf(), _WriteByte(), _WriteData(), _WriteExtraToc(), archModeWrite, checkSeek(), lclContext::FH, lclContext::filePos, lclContext::hasSeek, lclContext::isSpecialScript, PG_BINARY_R, PG_BINARY_W, PG_COMPRESSION_NONE, pg_fatal, pg_malloc0_object, ReadHead(), ReadToc(), generate_unaccent_rules::stdout, tarClose(), lclContext::tarFH, lclContext::tarFHpos, and tarOpen().
Referenced by _allocAH().
bool isValidTarHeader | ( | char * | header | ) |
Definition at line 988 of file pg_backup_tar.c.
References read_tar_number(), TAR_OFFSET_CHECKSUM, TAR_OFFSET_MAGIC, TAR_OFFSET_VERSION, and tarChecksum().
Referenced by _discoverArchiveFormat().
|
static |
Definition at line 398 of file pg_backup_tar.c.
References _tarAddFile(), pg_compress_specification::algorithm, _archiveHandle::compression_spec, free, TAR_MEMBER::mode, TAR_MEMBER::nFH, PG_COMPRESSION_NONE, pg_fatal, and TAR_MEMBER::targetFile.
Referenced by _CloseArchive(), _EndData(), _EndLO(), _EndLOs(), _LoadLOs(), _PrintFileData(), and InitArchiveFmt_Tar().
|
static |
Definition at line 302 of file pg_backup_tar.c.
References _tarPositionTo(), pg_compress_specification::algorithm, _archiveHandle::compression_spec, fd(), filename, _archiveHandle::formatData, free, if(), mode, name, PG_COMPRESSION_NONE, pg_fatal, pg_malloc0_object, pg_strdup(), S_IRUSR, S_IRWXG, S_IRWXO, S_IWUSR, lclContext::tarFH, and tm.
Referenced by _CloseArchive(), _LoadLOs(), _PrintFileData(), _StartData(), _StartLO(), _StartLOs(), and InitArchiveFmt_Tar().
|
static |
Definition at line 954 of file pg_backup_tar.c.
References generate_unaccent_rules::args, fmt, free, len, pg_malloc(), pvsnprintf(), tarWrite(), va_end(), and va_start().
Referenced by _CloseArchive(), and _StartLO().
|
static |
Definition at line 511 of file pg_backup_tar.c.
References _tarReadRaw(), TAR_MEMBER::AH, buf, TAR_MEMBER::fileLen, len, TAR_MEMBER::pos, and res.
Referenced by _LoadLOs(), _PrintFileData(), _ReadBuf(), and _ReadByte().
|
static |
Definition at line 529 of file pg_backup_tar.c.
References buf, len, TAR_MEMBER::nFH, TAR_MEMBER::pos, and res.
Referenced by _scriptOut(), _WriteBuf(), _WriteByte(), _WriteData(), and tarPrintf().