From: Michael Jeanson Date: Wed, 4 Nov 2020 20:42:15 +0000 (-0500) Subject: port: fsync(2) on a POSIX shm fd returns EINVAL on FreeBSD X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-ust.git;a=commitdiff_plain;h=71be0c5340258bbb9fe728451790dd113be2f1ec port: fsync(2) on a POSIX shm fd returns EINVAL on FreeBSD The POSIX shared memory object implementation on FreeBSD is not file based and doesn't support fsync(2). Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Change-Id: Ie170254122aeab858a12c0522dc4e78075f243f9 --- diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index 566ed467..1ac59f9e 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -149,12 +149,14 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table, PERROR("zero_file"); goto error_zero_file; } + /* * Also ensure the file metadata is synced with the storage by using - * fsync(2). + * fsync(2). Some platforms don't allow fsync on POSIX shm fds, ignore + * EINVAL accordingly. */ ret = fsync(shmfd); - if (ret) { + if (ret && errno != EINVAL) { PERROR("fsync"); goto error_fsync; }