blob: c0784ecc7385ab94ca2d3e37a65d554c16e50966 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From c6093ad63b92f5d25e6826d1c49dc7cee86d3747 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 20 Dec 2022 10:48:10 -0800
4Subject: [PATCH] replace stat64/lstat64 with stat/lstat
5
6lfs64 functions are not needed when off_t is 64-bit
7Additionally this fixes build with musl which does not
8export these functions without defining _LARGEFILE64_SOURCE
9
10Upstream-Status: Submitted [https://github.com/inotify-tools/inotify-tools/pull/174]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 libinotifytools/src/inotifytools.c | 8 ++++----
14 libinotifytools/src/inotifytools/inotify-nosys.h | 5 -----
15 libinotifytools/src/inotifytools/inotifytools.h | 5 -----
16 src/common.c | 4 ++--
17 src/common.h | 6 +-----
18 5 files changed, 7 insertions(+), 21 deletions(-)
19
20diff --git a/libinotifytools/src/inotifytools.c b/libinotifytools/src/inotifytools.c
21index 50f6135..3e17ac6 100644
22--- a/libinotifytools/src/inotifytools.c
23+++ b/libinotifytools/src/inotifytools.c
24@@ -1750,14 +1750,14 @@ int inotifytools_watch_recursively_with_exclude(char const* path,
25
26 static struct dirent * ent;
27 char * next_file;
28- static struct stat64 my_stat;
29+ static struct stat my_stat;
30 ent = readdir( dir );
31 // Watch each directory within this directory
32 while ( ent ) {
33 if ( (0 != strcmp( ent->d_name, "." )) &&
34 (0 != strcmp( ent->d_name, ".." )) ) {
35 nasprintf(&next_file,"%s%s", my_path, ent->d_name);
36- if ( -1 == lstat64( next_file, &my_stat ) ) {
37+ if ( -1 == lstat( next_file, &my_stat ) ) {
38 error = errno;
39 free( next_file );
40 if ( errno != EACCES ) {
41@@ -1840,9 +1840,9 @@ int inotifytools_error() {
42 * @internal
43 */
44 static int isdir( char const * path ) {
45- static struct stat64 my_stat;
46+ static struct stat my_stat;
47
48- if ( -1 == lstat64( path, &my_stat ) ) {
49+ if ( -1 == lstat( path, &my_stat ) ) {
50 if (errno == ENOENT) return 0;
51 fprintf(stderr, "Stat failed on %s: %s\n", path, strerror(errno));
52 return 0;
53diff --git a/libinotifytools/src/inotifytools/inotify-nosys.h b/libinotifytools/src/inotifytools/inotify-nosys.h
54index 01aa45e..97166d4 100644
55--- a/libinotifytools/src/inotifytools/inotify-nosys.h
56+++ b/libinotifytools/src/inotifytools/inotify-nosys.h
57@@ -13,11 +13,6 @@
58 #include <sys/syscall.h>
59 #include <unistd.h>
60
61-#ifdef __FreeBSD__
62-#define stat64 stat
63-#define lstat64 lstat
64-#endif
65-
66 /*
67 * struct inotify_event - structure read from the inotify device for each event
68 *
69diff --git a/libinotifytools/src/inotifytools/inotifytools.h b/libinotifytools/src/inotifytools/inotifytools.h
70index 49936ae..2ec4358 100644
71--- a/libinotifytools/src/inotifytools/inotifytools.h
72+++ b/libinotifytools/src/inotifytools/inotifytools.h
73@@ -1,11 +1,6 @@
74 #ifndef _inotifytools_H
75 #define _inotifytools_H
76
77-#ifdef __FreeBSD__
78-#define stat64 stat
79-#define lstat64 lstat
80-#endif
81-
82 #ifdef __cplusplus
83 extern "C"
84 {
85diff --git a/src/common.c b/src/common.c
86index 5a6fda1..885286e 100644
87--- a/src/common.c
88+++ b/src/common.c
89@@ -45,9 +45,9 @@ void print_event_descriptions() {
90 }
91
92 int isdir(char const *path) {
93- static struct stat64 my_stat;
94+ static struct stat my_stat;
95
96- if (-1 == lstat64(path, &my_stat)) {
97+ if (-1 == lstat(path, &my_stat)) {
98 if (errno == ENOENT)
99 return 0;
100 fprintf(stderr, "Stat failed on %s: %s\n", path, strerror(errno));
101diff --git a/src/common.h b/src/common.h
102index 12d3dde..7f1e34a 100644
103--- a/src/common.h
104+++ b/src/common.h
105@@ -1,13 +1,9 @@
106 #ifndef COMMON_H
107 #define COMMON_H
108
109-#ifdef __FreeBSD__
110-#define stat64 stat
111-#define lstat64 lstat
112-#ifdef ENABLE_FANOTIFY
113+#if defined(__FreeBSD__) && defined(ENABLE_FANOTIFY)
114 #error "FreeBSD does not support fanotify"
115 #endif
116-#endif
117
118 #include <stdbool.h>
119