From a66315d292ab9aa7550cd6e39bfd26232b7c3efe Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 20 Dec 2020 12:28:59 +0100 Subject: [PATCH] Revert "Improve compatibility with old (ancient) kernels" --- src/shmem.c | 64 ++++++++--------------------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/src/shmem.c b/src/shmem.c index dfd6a1ff..4d0b8362 100644 --- a/src/shmem.c +++ b/src/shmem.c @@ -513,35 +513,12 @@ SharedMemory create_shm(const char *name, const size_t size, bool create_new) // Using fallocate() will ensure that there's actually space for // this file. Otherwise we end up with a sparse file that can give // SIGBUS if we run out of space while writing to it. - int ret = fallocate(fd, 0, 0U, size); - const int fallocate_errno = errno; + const int ret = fallocate(fd, 0, 0U, size); if(ret != 0) { - // Try again with ftruncate() if fallocate() failed with - // "Operation not supported" - if(errno == ENOTSUP) - { - ret = ftruncate(fd, size); - - // Report info that space has only been reserved, not - // really allocated - if(ret == 0) - { - logg("INFO: create_shm(): Failed to allocate %zu bytes for \"%s\" (%s, %i), "\ - "space has only been reserved.", - size, sharedMemory.name, strerror(errno), errno); - } - } - if(ret != 0) - { - logg("FATAL: create_shm(): Failed to resize \"%s\" (%i) to %zu:", - sharedMemory.name, fd, size); - logg(" fallocate returned: %s (%i)", - strerror(fallocate_errno), fallocate_errno); - logg(" ftruncate returned: %s (%i)", - strerror(errno), errno); - exit(EXIT_FAILURE); - } + logg("FATAL: create_shm(): Failed to resize \"%s\" (%i) to %zu: %s (%i)", + sharedMemory.name, fd, size, strerror(errno), ret); + exit(EXIT_FAILURE); } // Create shared memory mapping @@ -660,35 +637,12 @@ bool realloc_shm(SharedMemory *sharedMemory, const size_t size1, const size_t si // Using fallocate() will ensure that there's actually space for // this file. Otherwise we end up with a sparse file that can give // SIGBUS if we run out of space while writing to it. - int ret = fallocate(fd, 0, 0U, size); - const int fallocate_errno = errno; - if(ret == -1) + const int ret = fallocate(fd, 0, 0U, size); + if(ret != 0) { - // Try again with ftruncate() if fallocate() failed with - // "Operation not supported" - if(errno == ENOTSUP) - { - ret = ftruncate(fd, size); - - // Report info that space has only been reserved, not - // really allocated - if(ret == 0) - { - logg("INFO: realloc_shm(): Failed to allocate %zu bytes for \"%s\" (%s), "\ - "space has only been reserved.", - size, sharedMemory->name, strerror(errno)); - } - } - if(ret == -1) - { - logg("FATAL: realloc_shm(): Failed to resize \"%s\" (%i) to %zu:", - sharedMemory->name, fd, size); - logg(" fallocate returned: %s (%i)", - strerror(fallocate_errno), fallocate_errno); - logg(" ftruncate returned: %s (%i)", - strerror(errno), errno); - exit(EXIT_FAILURE); - } + logg("FATAL: realloc_shm(): Failed to resize \"%s\" (%i) to %zu: %s (%i)", + sharedMemory->name, fd, size, strerror(errno), ret); + exit(EXIT_FAILURE); } // Close shared memory object file descriptor as it is no longer