mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 05:23:29 -04:00
Working towards new metadata format
This commit is contained in:
parent
fe5eb38741
commit
18520de172
@ -38,7 +38,7 @@ namespace dwarfs {
|
|||||||
|
|
||||||
namespace thrift::metadata {
|
namespace thrift::metadata {
|
||||||
|
|
||||||
class entry;
|
class inode_data;
|
||||||
class metadata;
|
class metadata;
|
||||||
|
|
||||||
} // namespace thrift::metadata
|
} // namespace thrift::metadata
|
||||||
@ -78,8 +78,8 @@ class entry : public entry_interface {
|
|||||||
std::string type_string() const override;
|
std::string type_string() const override;
|
||||||
virtual void walk(std::function<void(entry*)> const& f);
|
virtual void walk(std::function<void(entry*)> const& f);
|
||||||
virtual void walk(std::function<void(const entry*)> const& f) const;
|
virtual void walk(std::function<void(const entry*)> const& f) const;
|
||||||
void
|
void pack(thrift::metadata::inode_data& entry_v2,
|
||||||
pack(thrift::metadata::entry& entry_v2, global_entry_data const& data) const;
|
global_entry_data const& data) const;
|
||||||
void update(global_entry_data& data) const;
|
void update(global_entry_data& data) const;
|
||||||
virtual void accept(entry_visitor& v, bool preorder = false) = 0;
|
virtual void accept(entry_visitor& v, bool preorder = false) = 0;
|
||||||
virtual uint32_t inode_num() const = 0;
|
virtual uint32_t inode_num() const = 0;
|
||||||
|
@ -38,8 +38,9 @@ template <typename T>
|
|||||||
class metadata_;
|
class metadata_;
|
||||||
|
|
||||||
class entry_view
|
class entry_view
|
||||||
: public ::apache::thrift::frozen::View<thrift::metadata::entry> {
|
: public ::apache::thrift::frozen::View<thrift::metadata::inode_data> {
|
||||||
using EntryView = ::apache::thrift::frozen::View<thrift::metadata::entry>;
|
using EntryView =
|
||||||
|
::apache::thrift::frozen::View<thrift::metadata::inode_data>;
|
||||||
using Meta =
|
using Meta =
|
||||||
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
|
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ class entry_view
|
|||||||
};
|
};
|
||||||
|
|
||||||
class directory_view {
|
class directory_view {
|
||||||
using EntryView = ::apache::thrift::frozen::View<thrift::metadata::entry>;
|
using EntryView =
|
||||||
|
::apache::thrift::frozen::View<thrift::metadata::inode_data>;
|
||||||
using DirView = ::apache::thrift::frozen::View<thrift::metadata::directory>;
|
using DirView = ::apache::thrift::frozen::View<thrift::metadata::directory>;
|
||||||
using Meta =
|
using Meta =
|
||||||
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
|
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
|
||||||
|
@ -101,9 +101,9 @@ void entry::update(global_entry_data& data) const {
|
|||||||
data.add_ctime(stat_.st_ctime);
|
data.add_ctime(stat_.st_ctime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void entry::pack(thrift::metadata::entry& entry_v2,
|
void entry::pack(thrift::metadata::inode_data& entry_v2,
|
||||||
global_entry_data const& data) const {
|
global_entry_data const& data) const {
|
||||||
entry_v2.name_index = has_parent() ? data.get_name_index(name_) : 0;
|
entry_v2.name_index_v2_2 = has_parent() ? data.get_name_index(name_) : 0;
|
||||||
entry_v2.mode_index = data.get_mode_index(stat_.st_mode & 0xFFFF);
|
entry_v2.mode_index = data.get_mode_index(stat_.st_mode & 0xFFFF);
|
||||||
entry_v2.owner_index = data.get_uid_index(stat_.st_uid);
|
entry_v2.owner_index = data.get_uid_index(stat_.st_uid);
|
||||||
entry_v2.group_index = data.get_gid_index(stat_.st_gid);
|
entry_v2.group_index = data.get_gid_index(stat_.st_gid);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
namespace dwarfs {
|
namespace dwarfs {
|
||||||
|
|
||||||
std::string_view entry_view::name() const {
|
std::string_view entry_view::name() const {
|
||||||
return meta_->names()[name_index()];
|
return meta_->names()[name_index_v2_2()];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t entry_view::mode() const { return meta_->modes()[mode_index()]; }
|
uint16_t entry_view::mode() const { return meta_->modes()[mode_index()]; }
|
||||||
@ -81,7 +81,7 @@ void directory_view::append_path_to(std::string& s) const {
|
|||||||
s += '/';
|
s += '/';
|
||||||
}
|
}
|
||||||
if (inode() != 0) {
|
if (inode() != 0) {
|
||||||
s += meta_->names()[entry_.name_index()];
|
s += meta_->names()[entry_.name_index_v2_2()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ struct chunk {
|
|||||||
* `metadata.entries`.
|
* `metadata.entries`.
|
||||||
*/
|
*/
|
||||||
struct directory {
|
struct directory {
|
||||||
1: required UInt32 parent_inode,
|
1: required UInt32 parent_inode, // indexes into entries
|
||||||
2: required UInt32 first_entry,
|
2: required UInt32 first_entry, // indexes into dir_entries
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,9 +51,15 @@ struct directory {
|
|||||||
* by far the most common metadata object type, so it has been
|
* by far the most common metadata object type, so it has been
|
||||||
* optimized for size.
|
* optimized for size.
|
||||||
*/
|
*/
|
||||||
struct entry {
|
struct inode_data {
|
||||||
|
/**
|
||||||
|
* =========================================================================
|
||||||
|
* NOTE: This has been deprecated with filesystem version 2.3 (DwarFS 0.5.0)
|
||||||
|
* It is still being used to read older filesystem versions.
|
||||||
|
* =========================================================================
|
||||||
|
*/
|
||||||
// index into metadata.names
|
// index into metadata.names
|
||||||
1: required UInt32 name_index,
|
1: required UInt32 name_index_v2_2,
|
||||||
|
|
||||||
// index into metadata.modes
|
// index into metadata.modes
|
||||||
2: required UInt16 mode_index,
|
2: required UInt16 mode_index,
|
||||||
@ -68,7 +74,7 @@ struct entry {
|
|||||||
* - For files, (inode - chunk_index_offset) can be
|
* - For files, (inode - chunk_index_offset) can be
|
||||||
* used as in index into metadata.chunk_table.
|
* used as in index into metadata.chunk_table.
|
||||||
*/
|
*/
|
||||||
3: required UInt32 inode,
|
3: required UInt32 inode, ///// <---------- rename to content_index
|
||||||
|
|
||||||
// index into metadata.uids
|
// index into metadata.uids
|
||||||
4: required UInt16 owner_index,
|
4: required UInt16 owner_index,
|
||||||
@ -86,6 +92,18 @@ struct entry {
|
|||||||
8: required UInt64 ctime_offset,
|
8: required UInt64 ctime_offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
////// entries can now be stored in inode-order (we don't need old_entry_table any more :-)
|
||||||
|
//////
|
||||||
|
|
||||||
|
struct dir_entry { ///// <--------- or entry?
|
||||||
|
// index into metadata.names
|
||||||
|
1: required UInt32 name_index,
|
||||||
|
|
||||||
|
// index into metadata.entries
|
||||||
|
2: required UInt32 entry_index, ///// <--------- entries (inodes) are shared for hardlinks
|
||||||
|
}
|
||||||
|
|
||||||
struct fs_options {
|
struct fs_options {
|
||||||
// file system contains only mtime time stamps
|
// file system contains only mtime time stamps
|
||||||
1: required bool mtime_only,
|
1: required bool mtime_only,
|
||||||
@ -118,7 +136,7 @@ struct metadata {
|
|||||||
* directory through `first_entry`, where the entries will be between
|
* directory through `first_entry`, where the entries will be between
|
||||||
* `directories[n].first_entry` and `directories[n+1].first_entry`.
|
* `directories[n].first_entry` and `directories[n+1].first_entry`.
|
||||||
*/
|
*/
|
||||||
3: required list<entry> entries,
|
3: required list<inode_data> entries,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chunk lookup table, indexed by (inode - chunk_index_offset).
|
* Chunk lookup table, indexed by (inode - chunk_index_offset).
|
||||||
@ -128,7 +146,12 @@ struct metadata {
|
|||||||
4: required list<UInt32> chunk_table,
|
4: required list<UInt32> chunk_table,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry index, indexed by inode
|
* =========================================================================
|
||||||
|
* NOTE: This has been deprecated with filesystem version 2.3 (DwarFS 0.5.0)
|
||||||
|
* It is still being used to read older filesystem versions.
|
||||||
|
* =========================================================================
|
||||||
|
*
|
||||||
|
* Entry lookup table, indexed by inode
|
||||||
*
|
*
|
||||||
* This list contains all inodes strictly in the following order:
|
* This list contains all inodes strictly in the following order:
|
||||||
*
|
*
|
||||||
@ -138,7 +161,7 @@ struct metadata {
|
|||||||
* - character and block devices
|
* - character and block devices
|
||||||
* - named pipes and sockets
|
* - named pipes and sockets
|
||||||
*/
|
*/
|
||||||
5: required list<UInt32> entry_table_v2_2,
|
5: required list<UInt32> entry_table_v2_2, ///// <------------ deprecate (see above)
|
||||||
|
|
||||||
// symlink lookup table, indexed by (inode - symlink_table_offset)
|
// symlink lookup table, indexed by (inode - symlink_table_offset)
|
||||||
6: required list<UInt32> symlink_table,
|
6: required list<UInt32> symlink_table,
|
||||||
@ -187,4 +210,17 @@ struct metadata {
|
|||||||
|
|
||||||
// file system options
|
// file system options
|
||||||
18: optional fs_options options,
|
18: optional fs_options options,
|
||||||
|
|
||||||
|
//=========================================================//
|
||||||
|
// fields added with dwarfs-0.5.0, file system version 2.3 //
|
||||||
|
//=========================================================//
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
19: optional list<dir_entry> dir_entries,
|
||||||
|
|
||||||
|
20: optional UInt64 timestamp,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user