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 <[email protected]>
  • Loading branch information
ejgallego committed Jun 23, 2020
1 parent 0160bfd commit 87d8a13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ 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, #3546
(#3570, @ejgallego)

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

Expand Down
5 changes: 3 additions & 2 deletions src/dune/file_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/stdune/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/stdune/path.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 87d8a13

Please sign in to comment.