| 2029 | |
| 2030 | |
| 2031 | static int64 |
| 2032 | _tarWriteHeader(const char *filename, const char *linktarget, |
| 2033 | struct stat *statbuf, bool sizeonly) |
| 2034 | { |
| 2035 | char h[TAR_BLOCK_SIZE]; |
| 2036 | enum tarError rc; |
| 2037 | |
| 2038 | if (!sizeonly) |
| 2039 | { |
| 2040 | rc = tarCreateHeader(h, filename, linktarget, statbuf->st_size, |
| 2041 | statbuf->st_mode, statbuf->st_uid, statbuf->st_gid, |
| 2042 | statbuf->st_mtime); |
| 2043 | |
| 2044 | switch (rc) |
| 2045 | { |
| 2046 | case TAR_OK: |
| 2047 | break; |
| 2048 | case TAR_NAME_TOO_LONG: |
| 2049 | ereport(ERROR, |
| 2050 | (errmsg("file name too long for tar format: \"%s\"", |
| 2051 | filename))); |
| 2052 | break; |
| 2053 | case TAR_SYMLINK_TOO_LONG: |
| 2054 | ereport(ERROR, |
| 2055 | (errmsg("symbolic link target too long for tar format: " |
| 2056 | "file name \"%s\", target \"%s\"", |
| 2057 | filename, linktarget))); |
| 2058 | break; |
| 2059 | default: |
| 2060 | elog(ERROR, "unrecognized tar error: %d", rc); |
| 2061 | } |
| 2062 | |
| 2063 | pq_putmessage('d', h, sizeof(h)); |
| 2064 | update_basebackup_progress(sizeof(h)); |
| 2065 | } |
| 2066 | |
| 2067 | return sizeof(h); |
| 2068 | } |
| 2069 | |
| 2070 | /* |
| 2071 | * Write tar header for a directory. If the entry in statbuf is a link then |
no test coverage detected