clsync / clsync

file live sync daemon based on inotify/kqueue/bsm (Linux, FreeBSD), written in GNU C

Home Page:http://ut.mephi.ru/oss/clsync

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mon_gio: lstat overrides global lstat func from sys/stat.h [portability, musl]

jirutka opened this issue · comments

mon_gio fails to compile on musl libc based system, because in the function gio_handle (mon_gio.c:319) you overrides global lstat function by a local variable.

POSIX standard defines only function lstat, not lstat64 – glibc extension. musl libc provides lstat64 for compatibility with glibc, but it’s declared using macro: #define lstat64 lstat.

Well, it's a bug of musl, IMHO: variable name "lstat" is valid. However I changed the variable name.

Please try branch "musl". If doesn't work then please provide the compiler log.

Hmm, looks like under some unlikely conditions we may have lstat defined in glibc as well:
sys/stat.h:255

#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
# ifndef __USE_FILE_OFFSET64
/* Get file attributes about FILE and put them in BUF.
   If FILE is a symbolic link, do not follow it.  */
extern int lstat (const char *__restrict __file,
          struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
# else
#  ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
               (const char *__restrict __file,
                struct stat *__restrict __buf), lstat64)
     __nonnull ((1, 2));
#  else
#   define lstat lstat64
#  endif
# endif
# ifdef __USE_LARGEFILE64
extern int lstat64 (const char *__restrict __file,
            struct stat64 *__restrict __buf)
     __THROW __nonnull ((1, 2));
# endif
#endif

I'll try to build a musl Gentoo container in a week or so to see and test related issues.