mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 20:12:56 -04:00
More naming cleanup
This commit is contained in:
parent
514b644358
commit
a00d3dd863
@ -61,7 +61,7 @@ class global_entry_data {
|
||||
uint16_t get_mode_index(uint16_t mode) const;
|
||||
|
||||
uint32_t get_name_index(std::string const& name) const;
|
||||
uint32_t get_symlink_index(std::string const& link) const;
|
||||
uint32_t get_symlink_table_entry(std::string const& link) const;
|
||||
|
||||
uint64_t get_mtime_offset(uint64_t time) const;
|
||||
uint64_t get_atime_offset(uint64_t time) const;
|
||||
|
@ -100,7 +100,7 @@ uint32_t global_entry_data::get_name_index(std::string const& name) const {
|
||||
return DWARFS_NOTHROW(names_.at(name));
|
||||
}
|
||||
|
||||
uint32_t global_entry_data::get_symlink_index(std::string const& link) const {
|
||||
uint32_t global_entry_data::get_symlink_table_entry(std::string const& link) const {
|
||||
return DWARFS_NOTHROW(symlinks_.at(link));
|
||||
}
|
||||
|
||||
|
@ -115,43 +115,43 @@ class metadata_ final : public metadata_v2::impl {
|
||||
, root_(meta_.entries()[meta_.entry_index()[0]], &meta_)
|
||||
, log_(lgr)
|
||||
, inode_offset_(inode_offset)
|
||||
, symlink_index_offset_(find_index_offset(inode_rank::INO_LNK))
|
||||
, chunk_index_offset_(find_index_offset(inode_rank::INO_REG))
|
||||
, symlink_table_offset_(find_index_offset(inode_rank::INO_LNK))
|
||||
, file_index_offset_(find_index_offset(inode_rank::INO_REG))
|
||||
, dev_index_offset_(find_index_offset(inode_rank::INO_DEV))
|
||||
, nlinks_(build_nlinks(options))
|
||||
, options_(options) {
|
||||
LOG_DEBUG << "symlink index offset: " << symlink_index_offset_;
|
||||
LOG_DEBUG << "chunk index offset: " << chunk_index_offset_;
|
||||
LOG_DEBUG << "symlink table offset: " << symlink_table_offset_;
|
||||
LOG_DEBUG << "chunk index offset: " << file_index_offset_;
|
||||
LOG_DEBUG << "device index offset: " << dev_index_offset_;
|
||||
|
||||
if (int(meta_.directories().size() - 1) != symlink_index_offset_) {
|
||||
if (int(meta_.directories().size() - 1) != symlink_table_offset_) {
|
||||
DWARFS_THROW(
|
||||
runtime_error,
|
||||
fmt::format("metadata inconsistency: number of directories ({}) does "
|
||||
"not match link index ({})",
|
||||
meta_.directories().size() - 1, symlink_index_offset_));
|
||||
meta_.directories().size() - 1, symlink_table_offset_));
|
||||
}
|
||||
|
||||
if (int(meta_.symlink_index().size()) !=
|
||||
(chunk_index_offset_ - symlink_index_offset_)) {
|
||||
if (int(meta_.symlink_table().size()) !=
|
||||
(file_index_offset_ - symlink_table_offset_)) {
|
||||
DWARFS_THROW(
|
||||
runtime_error,
|
||||
fmt::format(
|
||||
"metadata inconsistency: number of symlinks ({}) does not match "
|
||||
"chunk/symlink index delta ({} - {} = {})",
|
||||
meta_.symlink_index().size(), chunk_index_offset_,
|
||||
symlink_index_offset_, chunk_index_offset_ - symlink_index_offset_));
|
||||
"chunk/symlink table delta ({} - {} = {})",
|
||||
meta_.symlink_table().size(), file_index_offset_,
|
||||
symlink_table_offset_, file_index_offset_ - symlink_table_offset_));
|
||||
}
|
||||
|
||||
if (int(meta_.chunk_index().size() - 1) !=
|
||||
(dev_index_offset_ - chunk_index_offset_)) {
|
||||
(dev_index_offset_ - file_index_offset_)) {
|
||||
DWARFS_THROW(
|
||||
runtime_error,
|
||||
fmt::format(
|
||||
"metadata inconsistency: number of files ({}) does not match "
|
||||
"device/chunk index delta ({} - {} = {})",
|
||||
meta_.chunk_index().size() - 1, dev_index_offset_,
|
||||
chunk_index_offset_, dev_index_offset_ - chunk_index_offset_));
|
||||
file_index_offset_, dev_index_offset_ - file_index_offset_));
|
||||
}
|
||||
|
||||
if (auto devs = meta_.devices()) {
|
||||
@ -324,7 +324,7 @@ class metadata_ final : public metadata_v2::impl {
|
||||
std::string modestring(uint16_t mode) const;
|
||||
|
||||
size_t reg_file_size(entry_view entry) const {
|
||||
auto inode = entry.inode() - chunk_index_offset_;
|
||||
auto inode = entry.inode() - file_index_offset_;
|
||||
uint32_t cur = meta_.chunk_index()[inode];
|
||||
uint32_t end = meta_.chunk_index()[inode + 1];
|
||||
if (cur > end) {
|
||||
@ -395,7 +395,7 @@ class metadata_ final : public metadata_v2::impl {
|
||||
|
||||
std::string_view link_value(entry_view entry) const {
|
||||
return meta_
|
||||
.symlinks()[meta_.symlink_index()[entry.inode() - symlink_index_offset_]];
|
||||
.symlinks()[meta_.symlink_table()[entry.inode() - symlink_table_offset_]];
|
||||
}
|
||||
|
||||
uint64_t get_device_id(int inode) const {
|
||||
@ -412,10 +412,10 @@ class metadata_ final : public metadata_v2::impl {
|
||||
if (options.enable_nlink) {
|
||||
auto ti = LOG_TIMED_DEBUG;
|
||||
|
||||
nlinks.resize(dev_index_offset_ - chunk_index_offset_);
|
||||
nlinks.resize(dev_index_offset_ - file_index_offset_);
|
||||
|
||||
for (auto e : meta_.entries()) {
|
||||
auto index = int(e.inode()) - chunk_index_offset_;
|
||||
auto index = int(e.inode()) - file_index_offset_;
|
||||
if (index >= 0 && index < int(nlinks.size())) {
|
||||
++DWARFS_NOTHROW(nlinks.at(index));
|
||||
}
|
||||
@ -433,8 +433,8 @@ class metadata_ final : public metadata_v2::impl {
|
||||
entry_view root_;
|
||||
log_proxy<LoggerPolicy> log_;
|
||||
const int inode_offset_;
|
||||
const int symlink_index_offset_;
|
||||
const int chunk_index_offset_;
|
||||
const int symlink_table_offset_;
|
||||
const int file_index_offset_;
|
||||
const int dev_index_offset_;
|
||||
const std::vector<uint32_t> nlinks_;
|
||||
const metadata_options options_;
|
||||
@ -455,8 +455,8 @@ void metadata_<LoggerPolicy>::dump(
|
||||
}
|
||||
|
||||
if (S_ISREG(mode)) {
|
||||
uint32_t beg = meta_.chunk_index()[inode - chunk_index_offset_];
|
||||
uint32_t end = meta_.chunk_index()[inode - chunk_index_offset_ + 1];
|
||||
uint32_t beg = meta_.chunk_index()[inode - file_index_offset_];
|
||||
uint32_t end = meta_.chunk_index()[inode - file_index_offset_ + 1];
|
||||
os << " [" << beg << ", " << end << "]";
|
||||
os << " " << file_size(entry, mode) << "\n";
|
||||
if (detail_level > 3) {
|
||||
@ -774,7 +774,7 @@ int metadata_<LoggerPolicy>::getattr(entry_view entry,
|
||||
: resolution * (timebase + entry.ctime_offset());
|
||||
stbuf->st_nlink =
|
||||
options_.enable_nlink && S_ISREG(mode)
|
||||
? DWARFS_NOTHROW(nlinks_.at(inode - chunk_index_offset_))
|
||||
? DWARFS_NOTHROW(nlinks_.at(inode - file_index_offset_))
|
||||
: 1;
|
||||
|
||||
if (S_ISBLK(mode) || S_ISCHR(mode)) {
|
||||
@ -903,7 +903,7 @@ template <typename LoggerPolicy>
|
||||
std::optional<chunk_range>
|
||||
metadata_<LoggerPolicy>::get_chunks(int inode) const {
|
||||
std::optional<chunk_range> rv;
|
||||
inode -= inode_offset_ + chunk_index_offset_;
|
||||
inode -= inode_offset_ + file_index_offset_;
|
||||
if (inode >= 0 &&
|
||||
inode < (static_cast<int>(meta_.chunk_index().size()) - 1)) {
|
||||
uint32_t begin = meta_.chunk_index()[inode];
|
||||
|
@ -506,7 +506,7 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
||||
global_entry_data ge_data(options_);
|
||||
thrift::metadata::metadata mv2;
|
||||
|
||||
mv2.symlink_index.resize(first_file_inode - first_link_inode);
|
||||
mv2.symlink_table.resize(first_file_inode - first_link_inode);
|
||||
|
||||
LOG_INFO << "assigning device inodes...";
|
||||
uint32_t first_device_inode = first_file_inode + im.count();
|
||||
@ -532,8 +532,8 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
||||
root->walk([&](entry* ep) {
|
||||
ep->update(ge_data);
|
||||
if (auto lp = dynamic_cast<link*>(ep)) {
|
||||
DWARFS_NOTHROW(mv2.symlink_index.at(ep->inode_num() - first_link_inode)) =
|
||||
ge_data.get_symlink_index(lp->linkname());
|
||||
DWARFS_NOTHROW(mv2.symlink_table.at(ep->inode_num() - first_link_inode)) =
|
||||
ge_data.get_symlink_table_entry(lp->linkname());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -138,10 +138,11 @@ struct metadata {
|
||||
* - character and block devices
|
||||
* - named pipes and sockets
|
||||
*/
|
||||
5: required list<UInt32> entry_index, ///// <------------ deprecate (see above)
|
||||
5: required list<UInt32> entry_index,
|
||||
|
||||
// link index, indexed by (inode - link_index_offset)
|
||||
6: required list<UInt32> symlink_index,
|
||||
// symlink lookup table, indexed by (inode - link_index_offset)
|
||||
6: required list<UInt32> symlink_table,
|
||||
|
||||
// user ids, for lookup by index in entry.owner
|
||||
7: required list<UInt16> uids,
|
||||
@ -155,7 +156,7 @@ struct metadata {
|
||||
// entry names, for lookup by index in entry.name_index
|
||||
10: required list<string> names,
|
||||
|
||||
// link targets, for lookup by index from symlink_index
|
||||
// link targets, for lookup by index from symlink_table
|
||||
11: required list<string> symlinks,
|
||||
|
||||
// timestamp base for all entry timestamps
|
||||
|
Loading…
x
Reference in New Issue
Block a user