0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::fs: Use lseek() for size(fd) overload.

This commit is contained in:
Jason Volk 2018-08-23 21:25:05 -07:00
parent 79d4c15ff5
commit e3827124e9

View file

@ -575,10 +575,19 @@ ircd::fs::uuid(const fd &fd,
size_t size_t
ircd::fs::size(const fd &fd) ircd::fs::size(const fd &fd)
{ {
struct stat stat; const off_t cur
syscall(::fstat, fd, &stat); {
return stat.st_size; syscall(::lseek, fd, 0, SEEK_CUR)
}; };
const off_t end
{
syscall(::lseek, fd, 0, SEEK_END)
};
syscall(::lseek, fd, cur, SEEK_SET);
return end;
}
uint uint
ircd::fs::posix_flags(const std::ios::open_mode &mode) ircd::fs::posix_flags(const std::ios::open_mode &mode)