From 310a5f81a1ee621331c35ccecbc850f56613f773 Mon Sep 17 00:00:00 2001 From: Emilio Jesus Gallego Arias Date: Mon, 22 Jun 2020 16:13:46 +0200 Subject: [PATCH] Ignore special files (BLK, CHR, FIFO, SOCKET) Fixes #3124 TODO: we should add some tests but I'm unsure about portability here. Signed-off-by: Emilio Jesus Gallego Arias --- CHANGES.md | 2 ++ src/dune/file_tree.ml | 5 +++-- src/stdune/path.ml | 9 +++++++++ src/stdune/path.mli | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7a9a206eae84..60c7c7340fea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,8 @@ next - Improve error message when invalid package names (such as the empty string) are passed to `dune build -p`. (#3561, @emillon) +- Ignore special files (BLK, CHR, FIFO, SOCKET) , fixes #3124 (# ???, @ejgallego) + 2.6.0 (05/06/2020) ------------------ diff --git a/src/dune/file_tree.ml b/src/dune/file_tree.ml index 5b338e70ff0b..a1003dc5b9a7 100644 --- a/src/dune/file_tree.ml +++ b/src/dune/file_tree.ml @@ -160,15 +160,16 @@ end = struct if Path.Source.is_in_build_dir path then Skip else + let fstat = Path.stat (Path.source path) in let is_directory, file = - match Path.stat (Path.source path) with + match fstat with | exception _ -> (false, File.dummy) | { st_kind = S_DIR; _ } as st -> (true, File.of_stats st) | _ -> (false, File.dummy) in if is_directory then Right (fn, path, file) - else if is_temp_file fn then + else if is_temp_file fn || Path.is_special fstat then Skip else Left fn) diff --git a/src/stdune/path.ml b/src/stdune/path.ml index 055f6e2d058f..3ec4291db0c9 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -1279,6 +1279,15 @@ let local_part = function let stat t = Unix.stat (to_string t) +let is_special { Unix.st_kind; _ } = + match st_kind with + | S_CHR + | S_BLK + | S_FIFO + | S_SOCK -> + true + | _ -> false + include (Comparator.Operators (T) : Comparator.OPS with type t := t) let path_of_local = of_local diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 91787734c218..fe86a2b348f7 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -349,6 +349,9 @@ val local_part : t -> Local.t val stat : t -> Unix.stats +(** special files such as fifos and sockets should be ignored *) +val is_special : Unix.stats -> bool + (* it would be nice to call this [Set.of_source_paths], but it's annoying to change the [Set] signature because then we don't comply with [Path_intf.S] *) val set_of_source_paths : Source.Set.t -> Set.t