Implement fs::file::get_id()

File descripor ID with 2 provided ways to compare between them:
1. is_mirror_of():
 Test if identical:
  For example: when LHS writes one byte to a file at X offset, RHS file be able to read that exact byte at X offset)

2. is_coherent_with():
 Test if both files point to the same file:
  For example: if a file descriptor pointing to the complete file exists and is being truncated to 0 bytes from non-
  -zero size state: this has to affect both RHS and LHS files.
This commit is contained in:
Eladash 2021-09-21 16:17:45 +03:00 committed by Elad Ashkenazi
parent e27e6c0b2d
commit eecadab387
4 changed files with 152 additions and 0 deletions

View file

@ -143,4 +143,11 @@ public:
}
u64 size() override { return file_size; }
fs::file_id get_id() override
{
fs::file_id id = edata_file.get_id();
id.type.insert(0, "EDATADecrypter: "sv);
return id;
}
};

View file

@ -641,6 +641,18 @@ struct lv2_file::file_view : fs::file_base
{
return m_file->file.size();
}
fs::file_id get_id() override
{
fs::file_id id = m_file->file.get_id();
be_t<u64> off = m_off;
const auto ptr = reinterpret_cast<u8*>(&off);
id.data.insert(id.data.end(), ptr, ptr + sizeof(off));
id.type.insert(0, "lv2_file::file_view: "sv);
return id;
}
};
fs::file lv2_file::make_view(const std::shared_ptr<lv2_file>& _file, u64 offset)