freebsd-ports/devel/pmdk/files/patch-src_common_os__posix.c
Mateusz Piotrowski e778bc9aa1 New port: devel/pmdk: Libraries and tools to manage and access persistent memory devices
The Persistent Memory Development Kit (PMDK) is a collection of libraries
and tools for System Administrators and Application Developers to simplify
managing and accessing persistent memory devices.

WWW: https://pmem.io/pmdk/

PR:		232690
Submitted by:	D Scott Phillips <d.scott.phillips@intel.com>
Reviewed by:	mat, ndowens@yahoo.com (previous version)
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D18009
2018-12-07 13:41:26 +00:00

14 lines
575 B
C

--- src/common/os_posix.c.orig 2018-10-26 15:43:47 UTC
+++ src/common/os_posix.c
@@ -200,9 +200,8 @@ os_posix_fallocate(int fd, os_off_t offset, off_t len)
if (fstatfs(fd, &fsbuf) == -1 || fstat(fd, &fbuf) == -1)
return errno;
- size_t reqd_blocks =
- (((size_t)len + (fsbuf.f_bsize - 1)) / fsbuf.f_bsize)
- - (size_t)fbuf.st_blocks;
+ size_t reqd_blocks = (((size_t)len + (fsbuf.f_bsize - 1)) / fsbuf.f_bsize);
+ reqd_blocks -= fbuf.st_blocks > reqd_blocks ? reqd_blocks : fbuf.st_blocks;
if (reqd_blocks > (size_t)fsbuf.f_bavail)
return ENOSPC;
}