0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +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
ircd::fs::size(const fd &fd)
{
struct stat stat;
syscall(::fstat, fd, &stat);
return stat.st_size;
};
const off_t cur
{
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
ircd::fs::posix_flags(const std::ios::open_mode &mode)