Skip to content

Commit

Permalink
Ignore special files (BLK, CHR, FIFO, SOCKET)
Browse files Browse the repository at this point in the history
Fixes ocaml#3124, fixes ocaml#3546

TODO: we should add some tests but I'm unsure about portability here.

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
  • Loading branch information
ejgallego committed Jun 29, 2020
1 parent 47649a3 commit 08c2fac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ next
- Fix a stack overflow when displaying large outputs (including diffs) (#3537,
fixes #2767, #3490, @emillon)

- Ignore special files (BLK, CHR, FIFO, SOCKET) , fixes #3124, #3546
(#3570, @ejgallego)

2.6.0 (05/06/2020)
------------------

Expand Down
16 changes: 14 additions & 2 deletions src/dune/file_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ end = struct
|| String.is_suffix fn ~suffix:".swp"
|| String.is_suffix fn ~suffix:"~"

(* Returns [true] for special files such as character devices of sockets; see
#3124 for more on issues caused by special devices *)
let is_special (st_kind : Unix.file_kind) =
match st_kind with
| S_CHR
| S_BLK
| S_FIFO
| S_SOCK ->
true
| _ -> false

let of_source_path path =
match Path.readdir_unsorted (Path.source path) with
| Error unix_error ->
Expand All @@ -160,15 +171,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 || is_special fstat.st_kind then
Skip
else
Left fn)
Expand Down

0 comments on commit 08c2fac

Please sign in to comment.