From 94b9efc401b9ca9332aeef1a4adcf522a96e76a9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 8 Dec 2024 14:24:58 +0000 Subject: memcpy inode number Supports true 64 bit inode numbers, even if they're represented differently one the wire --- netfs/ice/typeConverter.cpp | 10 ++++++---- 1 file 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(~map.mask)}; a.links = safe {s.st_nlink}; a.uid = std::move(map.username); -- cgit v1.2.3