From b194fd0672ef7037160ed8c018a3c5821631a48e Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 11 Mar 2019 10:12:49 +0100 Subject: [PATCH] hvt: Don't use fallocate outside Linux --- tenders/hvt/hvt_module_blk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tenders/hvt/hvt_module_blk.c b/tenders/hvt/hvt_module_blk.c index 354e1bba..44decff6 100644 --- a/tenders/hvt/hvt_module_blk.c +++ b/tenders/hvt/hvt_module_blk.c @@ -77,7 +77,6 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa) { struct hvt_blkdiscard *di = HVT_CHECKED_GPA_P(hvt, gpa, sizeof (struct hvt_blkdiscard)); - ssize_t ret; off_t pos, len, end; if (di->sector >= blkinfo.num_sectors) { @@ -93,6 +92,8 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa) return; } +#if defined(__linux__) + ssize_t ret; ret = fallocate( diskfd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pos, len); if (ret != 0) @@ -104,6 +105,9 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa) } else { di->ret = 0; } +#else + di->ret = -2; +#endif } static void hypercall_blkread(struct hvt *hvt, hvt_gpa_t gpa)