From ab753a402f2a04a12c53af5d55f806e06cb9be78 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 28 Apr 2019 21:16:47 +0200 Subject: [PATCH] Shrink table of contents header We aren't gonna need 2^32 uids/gids, this is a package manager, not a file system. Also, mode only uses 16 of 32 bits. We can shrink the entire header to 8 bytes. Signed-off-by: David Oberhollenzer --- doc/fileformat.md | 10 ++-------- include/pkg/pkgformat.h | 7 +++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/fileformat.md b/doc/fileformat.md index 4d5dcfc..8d5a403 100644 --- a/doc/fileformat.md +++ b/doc/fileformat.md @@ -105,14 +105,10 @@ table of contents contains an entry with the following common structure: 0 1 2 3 +-------+-------+-------+-------+ - 0 | mode | + 0 | mode | user id | +-------+-------+-------+-------+ - 1 | user id | + 1 | group id | path length | +-------+-------+-------+-------+ - 2 | group id | - +-------+-------+-------+-------+ - 3 | path length | - +---------------+ The mode field contains standard UNIX permissions. The user ID and group ID fields contain the numeric IDs of the user and group respectively that own @@ -142,8 +138,6 @@ On the bit level, the mode field is structured as follows: | +------------------------- set UID bit +----------------------------- file type -The upper 16 bit of the mode filed must be set to zero. - Currently, the following file types are supported: * `S_IFCHR` with a value of 2. The entry defines a character device. diff --git a/include/pkg/pkgformat.h b/include/pkg/pkgformat.h index 345dd6e..3cfda37 100644 --- a/include/pkg/pkgformat.h +++ b/include/pkg/pkgformat.h @@ -36,10 +36,9 @@ typedef struct { } record_t; typedef struct { - uint32_t mode; - uint32_t uid; - uint32_t gid; - + uint16_t mode; + uint16_t uid; + uint16_t gid; uint16_t path_length; /* uint8_t path[]; */ } toc_entry_t;