constants for tar header offsets
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2023-04-18T15:20:06Z
Lists: pgsql-hackers
Attachments
- v1-0001-Add-and-use-symbolic-constants-for-tar-header-off.patch (application/octet-stream) patch v1-0001
Hi, We have a few different places in the code where we generate or modify tar headers or just read data out of them. The code in question uses one of my less-favorite programming things: magic numbers. The offsets of the various fields within the tar header are just hard-coded in each relevant place in our code. I think we should clean that up, as in the attached patch. I hasten to emphasize that, while I think this is an improvement, I don't think the result is particularly awesome. Even with the patch, src/port/tar.c and src/include/pgtar.h do a poor job insulating callers from the details of the tar format. However, it's also not very clear to me how to fix that. For instance, I thought about writing a function that parses a tar header into a struct and then using it in all of these places, but that seems like it would lose too much efficiency relative to the current ad-hoc coding. So for now I don't have a better idea than this. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Add and use symbolic constants for tar header offsets and file types.
- 6050b6a92d1e 17.0 landed