OFF_T get_device_size(int fd, const char *fname)
{
	OFF_T off = lseek(fd, 0, SEEK_END);

	if (off == (OFF_T) -1) {
		rsyserr(FERROR, errno, "failed to get device size via seek: %s", fname);
		return 0;
	}
	if (lseek(fd, 0, SEEK_SET) != 0)
		rsyserr(FERROR, errno, "failed to seek device back to start: %s", fname);

	return off;
}
OFF_T get_device_size(int fd, const char *fname)
{
	OFF_T off = lseek(fd, 0, SEEK_END);

	if (off == (OFF_T) -1) {
		rsyserr(FERROR, errno, "failed to get device size via seek: %s", fname);
		return 0;
	}
	if (lseek(fd, 0, SEEK_SET) != 0)
		rsyserr(FERROR, errno, "failed to seek device back to start: %s", fname);

	return off;
}