View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000255 | file | General | public | 2021-04-02 04:49 | 2022-12-26 18:43 |
Reporter | joveler | Assigned To | christos | ||
Priority | high | Severity | block | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 5.40 | ||||
Summary | 0000255: file 5.40 compile error on MinGW/MSYS2 | ||||
Description | file 5.40 cannot be compiled on MinGW/MSYS2, due to ioctl / fnctl calls. [*] fnctl calls In funcs.c and magic.c, file calls fcntl with F_SETFD. fcntl(fds[1], F_SETFD, FD_CLOEXEC); MinGW does not support F_SETFD, thus fails to compile the code. [*] ioctl calls This issue had been already described in 0000163 (https://bugs.astron.com/view.php?id=163). MinGW does not support ioctl call and produce compile error. If the library is configured with `--disable-xzlib --disable-bzlib`, the code is excluded and does not block the build. [*] Solution I attached the diff file which excludes these code paths on MinGW build. | ||||
Tags | build, patch | ||||
|
MinGW_fnctl_fix.diff (1,055 bytes)
diff --git a/src/funcs.c b/src/funcs.c index b926625d..642fd3ac 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -812,6 +812,10 @@ file_print_guid(char *str, size_t len, const uint64_t *guid) protected int file_pipe_closexec(int *fds) { +#ifdef WIN32 + // F_SETFD is not supported on Windows + return 0; +#else #ifdef HAVE_PIPE2 return pipe2(fds, O_CLOEXEC); #else @@ -821,11 +825,17 @@ file_pipe_closexec(int *fds) (void)fcntl(fds[1], F_SETFD, FD_CLOEXEC); return 0; #endif +#endif } protected int file_clear_closexec(int fd) { +#ifdef WIN32 + // F_SETFD is not supported on Windows + return 0; +#else return fcntl(fd, F_SETFD, 0); +#endif; } protected char * diff --git a/src/magic.c b/src/magic.c index 81a0840f..5457d359 100644 --- a/src/magic.c +++ b/src/magic.c @@ -460,7 +460,8 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) rv = 0; goto done; } -#if O_CLOEXEC == 0 +#if O_CLOEXEC == 0 && !defined(WIN32) + // F_SETFD is not supported on Windows (void)fcntl(fd, F_SETFD, FD_CLOEXEC); #endif } MinGW_ioctl_fix.diff (648 bytes)
diff --git a/src/compress.c b/src/compress.c index 9f65e4fa..6b3b1b95 100644 --- a/src/compress.c +++ b/src/compress.c @@ -380,7 +380,7 @@ protected ssize_t sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__))) { ssize_t rv; -#ifdef FIONREAD +#if defined(FIONREAD) && !defined(WIN32) int t = 0; #endif size_t rn = n; @@ -388,7 +388,7 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__))) if (fd == STDIN_FILENO) goto nocheck; -#ifdef FIONREAD +#if defined(FIONREAD) && !defined(WIN32) if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) { #ifdef FD_ZERO ssize_t cnt; |
|
[*] Additional info of compile environment - Platform: Windows 10 with MSYS2 - Tested Target Arch : I686, x86_64, aarch64 - Shell: MINGW32(i686) / MINGW64(x86_64, aarch64) shell of MSYS2 - Toolchain: (1) MinGW-w64 of MSYS2 (i686/x86_64) (2) llvm-mingw (aarch64) |
|
Better use __MINGW32__? |
|
Please close the issue, as the follow-up issue report for 5.43 ( https://bugs.astron.com/view.php?id=412 ) is available. |
|
moved to PR/412 |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-04-02 04:49 | joveler | New Issue | |
2021-04-02 04:49 | joveler | File Added: MinGW_fnctl_fix.diff | |
2021-04-02 04:49 | joveler | File Added: MinGW_ioctl_fix.diff | |
2021-04-02 04:49 | joveler | Tag Attached: build | |
2021-04-02 04:49 | joveler | Tag Attached: patch | |
2021-04-02 11:04 | joveler | Note Added: 0003581 | |
2021-04-19 16:50 | administrator | Assigned To | => administrator |
2021-04-19 16:50 | administrator | Status | new => assigned |
2021-04-19 16:51 | administrator | Assigned To | administrator => christos |
2021-04-19 16:51 | administrator | Status | assigned => feedback |
2021-04-19 16:51 | administrator | Note Added: 0003587 | |
2022-12-26 18:39 | joveler | Note Added: 0003873 | |
2022-12-26 18:39 | joveler | Status | feedback => assigned |
2022-12-26 18:43 | christos | Status | assigned => closed |
2022-12-26 18:43 | christos | Resolution | open => fixed |
2022-12-26 18:43 | christos | Note Added: 0003874 |