summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-12-08 14:24:58 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-12-08 14:24:58 +0000
commit94b9efc401b9ca9332aeef1a4adcf522a96e76a9 (patch)
treeab720c2990cda2c09788666de1282db9033bfaea
parentAssign an id to the root project (diff)
downloadnetfs-main.tar.bz2
netfs-main.tar.xz
netfs-main.zip
memcpy inode numberHEADnetfs-1.5.2main
Supports true 64 bit inode numbers, even if they're represented differently one the wire
-rw-r--r--netfs/ice/typeConverter.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/netfs/ice/typeConverter.cpp b/netfs/ice/typeConverter.cpp
index 5f3b668..90fa439 100644
--- a/netfs/ice/typeConverter.cpp
+++ b/netfs/ice/typeConverter.cpp
@@ -7,9 +7,10 @@ struct stat
EntryTypeConverter::convert(const NetFS::Attr & a) const
{
auto map = mapper->mapTransport(a.uid, a.gid);
- struct stat s { };
+ struct stat s {};
+ static_assert(sizeof(s.st_ino) == sizeof(a.inode));
s.st_dev = safe {a.dev};
- s.st_ino = safe {a.inode};
+ std::memcpy(&s.st_ino, &a.inode, sizeof(s.st_ino));
s.st_mode = safe {a.mode & ~map.mask};
s.st_nlink = safe {a.links};
s.st_uid = safe {map.uid};
@@ -27,7 +28,7 @@ EntryTypeConverter::convert(const NetFS::Attr & a) const
struct statvfs
TypeConverter::convert(const NetFS::VFS & v) const
{
- struct statvfs vfs { };
+ struct statvfs vfs {};
vfs.f_bsize = safe {v.blockSize};
vfs.f_frsize = safe {v.fragmentSize};
vfs.f_blocks = safe {v.blocks};
@@ -46,8 +47,9 @@ EntryTypeConverter::convert(const struct stat & s) const
{
auto map = mapper->mapFileSystem(safe {s.st_uid}, safe {s.st_gid});
NetFS::Attr a {};
+ static_assert(sizeof(s.st_ino) == sizeof(a.inode));
a.dev = safe {s.st_dev};
- a.inode = safe {s.st_ino};
+ std::memcpy(&a.inode, &s.st_ino, sizeof(a.inode));
a.mode = safe {s.st_mode & static_cast<decltype(s.st_mode)>(~map.mask)};
a.links = safe {s.st_nlink};
a.uid = std::move(map.username);