Fully support file access times
This commit is contained in:
parent
bca4b6adf9
commit
b0beb6b350
@ -26,22 +26,19 @@ namespace cryfs {
|
|||||||
*reinterpret_cast<mode_t*>(dest+offset) = mode;
|
*reinterpret_cast<mode_t*>(dest+offset) = mode;
|
||||||
offset += sizeof(mode_t);
|
offset += sizeof(mode_t);
|
||||||
|
|
||||||
//TODO Persist times, see comment in deserializeAndAddToVector()
|
static_assert(sizeof(timespec) == 16, "Ensure platform independence of the serialization");
|
||||||
//static_assert(sizeof(timespec) == 16, "Ensure platform independence of the serialization");
|
*reinterpret_cast<timespec*>(dest+offset) = lastAccessTime;
|
||||||
//*reinterpret_cast<timespec*>(dest+offset) = lastAccessTime;
|
offset += sizeof(timespec);
|
||||||
//offset += sizeof(timespec);
|
*reinterpret_cast<timespec*>(dest+offset) = lastModificationTime;
|
||||||
//*reinterpret_cast<timespec*>(dest+offset) = lastModificationTime;
|
offset += sizeof(timespec);
|
||||||
//offset += sizeof(timespec);
|
*reinterpret_cast<timespec*>(dest+offset) = lastMetadataChangeTime;
|
||||||
//*reinterpret_cast<timespec*>(dest+offset) = lastMetadataChangeTime;
|
offset += sizeof(timespec);
|
||||||
//offset += sizeof(timespec);
|
|
||||||
|
|
||||||
ASSERT(offset == serializedSize(), "Didn't write correct number of elements");
|
ASSERT(offset == serializedSize(), "Didn't write correct number of elements");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DirEntry::serializedSize() const {
|
size_t DirEntry::serializedSize() const {
|
||||||
//TODO Persist times, see comment in deserializeAndAddToVector()
|
return 1 + (name.size() + 1) + key.BINARY_LENGTH + sizeof(uid_t) + sizeof(gid_t) + sizeof(mode_t) + 3*sizeof(timespec);
|
||||||
//return 1 + (name.size() + 1) + key.BINARY_LENGTH + sizeof(uid_t) + sizeof(gid_t) + sizeof(mode_t) + 3*sizeof(timespec);
|
|
||||||
return 1 + (name.size() + 1) + key.BINARY_LENGTH + sizeof(uid_t) + sizeof(gid_t) + sizeof(mode_t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *DirEntry::deserializeAndAddToVector(const char *pos, vector<DirEntry> *result) {
|
const char *DirEntry::deserializeAndAddToVector(const char *pos, vector<DirEntry> *result) {
|
||||||
@ -66,18 +63,12 @@ namespace cryfs {
|
|||||||
mode_t mode = *(mode_t*)pos;
|
mode_t mode = *(mode_t*)pos;
|
||||||
pos += sizeof(mode_t);
|
pos += sizeof(mode_t);
|
||||||
|
|
||||||
//TODO Persist times. This breaks compatibility though - so change cryfs::InnerConfig::HEADER
|
timespec lastAccessTime = *(timespec*)pos;
|
||||||
// This is already implemented, but I commented it out for now, because it would break compatibility.
|
pos += sizeof(timespec);
|
||||||
//timespec lastAccessTime = *(timespec*)pos;
|
timespec lastModificationTime = *(timespec*)pos;
|
||||||
//pos += sizeof(timespec);
|
pos += sizeof(timespec);
|
||||||
//timespec lastModificationTime = *(timespec*)pos;
|
timespec lastMetadataChangeTime = *(timespec*)pos;
|
||||||
//pos += sizeof(timespec);
|
pos += sizeof(timespec);
|
||||||
//timespec lastMetadataChangeTime = *(timespec*)pos;
|
|
||||||
//pos += sizeof(timespec);
|
|
||||||
timespec lastAccessTime;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &lastAccessTime);
|
|
||||||
timespec lastModificationTime = lastAccessTime;
|
|
||||||
timespec lastMetadataChangeTime = lastAccessTime;
|
|
||||||
|
|
||||||
result->emplace_back(type, name, key, mode, uid, gid, lastAccessTime, lastModificationTime, lastMetadataChangeTime);
|
result->emplace_back(type, name, key, mode, uid, gid, lastAccessTime, lastModificationTime, lastMetadataChangeTime);
|
||||||
return pos;
|
return pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user