aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
authorTom Jones <thj@freebsd.org>2024-01-31 10:44:14 +0000
committerFlorin Coras <florin.coras@gmail.com>2024-02-23 18:48:29 +0000
commiteceef16b5c5963ed27aa16b2ead4654b5a7dd391 (patch)
tree545fc8d3004f550f04a7c7ccb8877b82fbe3f668 /src/svm
parentb613d411a4c76ca69b1a57d239ec617d1e4f410e (diff)
svm: Use ftruncate to expand svm on FreeBSD
Linux doesn't support the Linux idiom of using lseek and a write to set the size of a file, instead use ftruncate to accomplish the same effect. This change is taken from the Nanoteq VPP port commit: https://github.com/ftk-ntq/vpp/commit/04a1b19b37e791accc61b91f3f413d8bc8b1ff8f Type: improvement Change-Id: Ie0b83e751b8b8f20b6814e5c9f760035747dfad9 Signed-off-by: Tom Jones <thj@freebsd.org>
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/svm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/svm/svm.c b/src/svm/svm.c
index 0a910558f6e..5580808909a 100644
--- a/src/svm/svm.c
+++ b/src/svm/svm.c
@@ -551,7 +551,6 @@ svm_map_region (svm_map_region_args_t * a)
int svm_fd;
svm_region_t *rp;
int deadman = 0;
- u8 junk = 0;
void *oldheap;
int rv;
int pid_holding_region_lock;
@@ -582,6 +581,15 @@ svm_map_region (svm_map_region_args_t * a)
vec_free (shm_name);
+#ifdef __FreeBSD__
+ if (ftruncate (svm_fd, a->size) < 0)
+ {
+ clib_warning ("ftruncate region size");
+ close (svm_fd);
+ return (0);
+ }
+#else
+ u8 junk = 0;
if (lseek (svm_fd, a->size, SEEK_SET) == (off_t) - 1)
{
clib_warning ("seek region size");
@@ -594,6 +602,7 @@ svm_map_region (svm_map_region_args_t * a)
close (svm_fd);
return (0);
}
+#endif /* __FreeBSD__ */
rp = mmap (uword_to_pointer (a->baseva, void *), a->size,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, svm_fd, 0);