mirror of
https://review.haiku-os.org/haiku
synced 2025-02-02 11:46:25 +01:00
1f633814fa
Instead of handling compression for individual file/attribute data we do now compress the whole heap where they are stored. This significantly improves compression ratios. We still divide the uncompressed data into 64 KiB chunks and use a chunk offset array for the compressed chunks to allow for quick random access without too much overhead. The tradeoff is a limited possible compression ratio -- i.e. we won't be as good as tar.gz (though surprisingly with my test archives we did better than zip). The other package file sections (package attributes and TOC) are no longer compressed individually. Their uncompressed data are simply pushed onto the heap where the usual compression strategy applies. To simplify things the repository format has been changed in the same manner although it doesn't otherwise use the heap, since it only stores meta data. Due to the data compression having been exposed in public and private API, this change touches a lot of package kit using code, including packagefs and the boot loader packagefs support. The latter two haven't been tested yet. Moreover packagefs needs a new kind of cache so we avoid re-reading the same heap chunk for two different data items it contains.
116 lines
2.0 KiB
C++
116 lines
2.0 KiB
C++
/*
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|
|
#define _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <package/hpkg/HPKGDefs.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
namespace BHPKG {
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
// package file header
|
|
struct hpkg_header {
|
|
uint32 magic; // "hpkg"
|
|
uint16 header_size;
|
|
uint16 version;
|
|
uint64 total_size;
|
|
|
|
// heap
|
|
uint32 heap_compression;
|
|
uint32 heap_chunk_size;
|
|
uint64 heap_size_compressed;
|
|
uint64 heap_size_uncompressed;
|
|
|
|
// package attributes section
|
|
uint32 attributes_length;
|
|
uint32 attributes_strings_length;
|
|
uint32 attributes_strings_count;
|
|
|
|
// TOC section
|
|
uint64 toc_length;
|
|
uint64 toc_strings_length;
|
|
uint64 toc_strings_count;
|
|
};
|
|
|
|
|
|
// repository file header
|
|
struct hpkg_repo_header {
|
|
uint32 magic; // "hpkr"
|
|
uint16 header_size;
|
|
uint16 version;
|
|
uint64 total_size;
|
|
|
|
// heap
|
|
uint32 heap_compression;
|
|
uint32 heap_chunk_size;
|
|
uint64 heap_size_compressed;
|
|
uint64 heap_size_uncompressed;
|
|
|
|
// repository info section
|
|
uint32 info_length;
|
|
|
|
// package attributes section
|
|
uint64 packages_length;
|
|
uint64 packages_strings_length;
|
|
uint64 packages_strings_count;
|
|
};
|
|
|
|
|
|
// attribute tag arithmetics
|
|
// (using 6 bits for id, 3 for type, 1 for hasChildren and 2 for encoding)
|
|
static inline uint16
|
|
compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren)
|
|
{
|
|
return ((encoding << 10) | (uint16(hasChildren ? 1 : 0) << 9) | (type << 6)
|
|
| id)
|
|
+ 1;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_encoding(uint16 tag)
|
|
{
|
|
return ((tag - 1) >> 10) & 0x3;
|
|
}
|
|
|
|
|
|
static inline bool
|
|
attribute_tag_has_children(uint16 tag)
|
|
{
|
|
return (((tag - 1) >> 9) & 0x1) != 0;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_type(uint16 tag)
|
|
{
|
|
return ((tag - 1) >> 6) & 0x7;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_id(uint16 tag)
|
|
{
|
|
return (tag - 1) & 0x3f;
|
|
}
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
} // namespace BHPKG
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|