Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From 8a08d3583d77bebeb1763fb9b378899201ce5afa Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 15 Dec 2022 12:11:13 -0800 |
| 4 | Subject: [PATCH] shm.c: Replace stat64/fstat64/ftruncate64mmap64 with normal functions |
| 5 | |
| 6 | These functions were needed when _FILE_OFFSET_BITS was not 64, using |
| 7 | AC_SYS_LARGEFILE will detect it correctly and make the normal variants |
| 8 | of these functions behave same as their *64 counterparts. |
| 9 | |
| 10 | Upstream-Status: Backport [https://github.com/numactl/numactl/pull/159] |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | --- |
| 13 | shm.c | 10 +++++----- |
| 14 | 1 file changed, 5 insertions(+), 5 deletions(-) |
| 15 | |
| 16 | diff --git a/shm.c b/shm.c |
| 17 | index 20537d9..5d0d1ab 100644 |
| 18 | --- a/shm.c |
| 19 | +++ b/shm.c |
| 20 | @@ -24,8 +24,8 @@ |
| 21 | #include <sys/mman.h> |
| 22 | #include <sys/ipc.h> |
| 23 | #include <sys/shm.h> |
| 24 | -#include <sys/fcntl.h> |
| 25 | #include <sys/stat.h> |
| 26 | +#include <fcntl.h> |
| 27 | #include <stdarg.h> |
| 28 | #include <errno.h> |
| 29 | #include <unistd.h> |
| 30 | @@ -135,7 +135,7 @@ void attach_sysvshm(char *name, char *opt) |
| 31 | /* Attach a shared memory file. */ |
| 32 | void attach_shared(char *name, char *opt) |
| 33 | { |
| 34 | - struct stat64 st; |
| 35 | + struct stat st; |
| 36 | |
| 37 | shmfd = open(name, O_RDWR); |
| 38 | if (shmfd < 0) { |
| 39 | @@ -146,14 +146,14 @@ void attach_shared(char *name, char *opt) |
| 40 | if (shmfd < 0) |
| 41 | nerror("cannot create file %s", name); |
| 42 | } |
| 43 | - if (fstat64(shmfd, &st) < 0) |
| 44 | + if (fstat(shmfd, &st) < 0) |
| 45 | err("shm stat"); |
| 46 | /* the file size must be larger than mmap shmlen + shmoffset, otherwise SIGBUS |
| 47 | * will be caused when we access memory, because mmaped memory is no longer in |
| 48 | * the range of the file laster. |
| 49 | */ |
| 50 | if ((shmlen + shmoffset) > st.st_size) { |
| 51 | - if (ftruncate64(shmfd, shmlen + shmoffset) < 0) { |
| 52 | + if (ftruncate(shmfd, shmlen + shmoffset) < 0) { |
| 53 | /* XXX: we could do it by hand, but it would it |
| 54 | would be impossible to apply policy then. |
| 55 | need to fix that in the kernel. */ |
| 56 | @@ -168,7 +168,7 @@ void attach_shared(char *name, char *opt) |
| 57 | |
| 58 | /* RED-PEN For shmlen > address space may need to map in pieces. |
| 59 | Left for some poor 32bit soul. */ |
| 60 | - shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset); |
| 61 | + shmptr = mmap(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset); |
| 62 | if (shmptr == (char*)-1) |
| 63 | err("shm mmap"); |
| 64 | } |