diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-05-12 11:33:10 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-05-12 12:09:36 (EDT) |
commit | 7c30e1432bafd2c8065dddcdb99a46e64e997b18 (patch) | |
tree | 2bebb1fc282095c1abea0ae687c0f208a82e9480 | |
parent | 11a3a0252f070e0623a9bec522198d91187140c8 (diff) |
ustar: Support writing device major and minor
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/opk/write.c | 12 | ||||
-rw-r--r-- | src/ustar.c | 13 | ||||
-rw-r--r-- | src/ustar.h | 1 |
4 files changed, 18 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac index 687629e..32061bb 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,9 @@ AC_CHECK_FUNCS([getopt_long], [], if ${funcs_missing}; then AC_MSG_ERROR([required functions are missing]) fi +AC_CHECK_DECLS([[major(dev_t)], [minor(dev_t)]], [], + [AC_MSG_ERROR([required macros are missing])], + [#include <sys/sysmacros.h>]) PKG_PROG_PKG_CONFIG() PKG_CHECK_MODULES([ZLIB], [zlib]) diff --git a/src/opk/write.c b/src/opk/write.c index 7940222..b9e50c7 100644 --- a/src/opk/write.c +++ b/src/opk/write.c @@ -150,7 +150,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, if (opkg_opk_ustar_write_header(opk->inner_ustar, &child, st.st_mode & 0777, - uid, uname, gid, gname, 0, + uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'd', NULL) != OPKG_OPK_OK) { fputs(_("Error: Failed to write header\n"), @@ -177,7 +177,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, link[link_len] = '\0'; if (opkg_opk_ustar_write_header(opk->inner_ustar, &child, 0777, - uid, uname, gid, gname, 0, + uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'l', link) != OPKG_OPK_OK) { fputs(_("Error: Failed to write header\n"), @@ -195,7 +195,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, if (opkg_opk_ustar_write_header(opk->inner_ustar, &child, st.st_mode & 0777, - uid, uname, gid, gname, + uid, uname, gid, gname, 0, 0, st.st_size, opk->mtime, '-', NULL) != OPKG_OPK_OK) { @@ -316,7 +316,7 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, gname = getgrgid(gid)->gr_name; if (opkg_opk_ustar_write_header(opk->inner_ustar, &dirent, st.st_mode & 0777, uid, uname, gid, gname, 0, - opk->mtime, 'd', NULL) != OPKG_OPK_OK) { + 0, 0, opk->mtime, 'd', NULL) != OPKG_OPK_OK) { fputs(_("Error: Failed to write header\n"), stderr); goto err3; @@ -341,7 +341,7 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, dirent.name = OPKG_OPK_OPK_ARCHIVE_NAMES_[archive_type]; dirent.parent = NULL; if (opkg_opk_ustar_write_header(opk->outer_ustar, &dirent, 0644, - 0, opk->outer_uname, 0, opk->outer_gname, + 0, opk->outer_uname, 0, opk->outer_gname, 0, 0, written, opk->mtime, '-', NULL) != OPKG_OPK_OK) { fputs(_("Error: Failed to write header\n"), stderr); @@ -440,7 +440,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) dirent.name = "debian-binary"; dirent.parent = NULL; if (opkg_opk_ustar_write_header(opk->outer_ustar, &dirent, 0644, - 0, opk->outer_uname, 0, opk->outer_gname, + 0, opk->outer_uname, 0, opk->outer_gname, 0, 0, 4, opk->mtime, '-', NULL) != OPKG_OPK_OK) { fputs(_("Error: Failed to write header\n"), stderr); ret = OPKG_OPK_ERROR; diff --git a/src/ustar.c b/src/ustar.c index 359f967..669596e 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -280,6 +280,7 @@ int opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar, struct opkg_opk_dirent *dirent, uint16_t mode, uid_t uid, const char *uname, gid_t gid, const char *gname, + uint32_t devmajor, uint32_t devminor, uint64_t size, uint64_t mtime, char type, const char *linkname) { uint32_t chksum; @@ -302,11 +303,13 @@ opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar, * even checking endptr, so we have to NUL-terminate these fields. Also * parsing these fields with strtol() are our very own * _opkg_opk_ustar_next() and opkg_opk_ustar_list() above. */ - sprintf(ustar->header.mode, "%07o", mode); - sprintf(ustar->header.uid, "%07o", uid); - sprintf(ustar->header.gid, "%07o", gid); - sprintf(ustar->header.size, "%011o", size); - sprintf(ustar->header.mtime, "%011o", mtime); + sprintf(ustar->header.mode, "%07o", mode); + sprintf(ustar->header.uid, "%07o", uid); + sprintf(ustar->header.gid, "%07o", gid); + sprintf(ustar->header.size, "%011o", size); + sprintf(ustar->header.mtime, "%011o", mtime); + sprintf(ustar->header.devmajor, "%07o", devmajor); + sprintf(ustar->header.devminor, "%07o", devminor); switch (type) { case '-': /* Regular file */ *ustar->header.typeflag = '0'; diff --git a/src/ustar.h b/src/ustar.h index 8dfd771..19e6422 100644 --- a/src/ustar.h +++ b/src/ustar.h @@ -91,6 +91,7 @@ int opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar, struct opkg_opk_dirent *dirent, uint16_t mode, uid_t uid, const char *uname, gid_t gid, const char *gname, + uint32_t devmajor, uint32_t devminor, uint64_t size, uint64_t mtime, char type, const char *linkname); int |