Unix.symlink and Unix.stat

A newly created symlink seems to be of type Unix.S_REG, not Unix.S_LNK?

I am on

$ opam switch show
4.10.0+musl+static+flambda
$ uname -sm
Linux x86_64

and do

utop # Unix.symlink "../etc/passwd" "/tmp/passwd";;
- : unit = ()
─( 21:11:30 )─< command 0 >─────────────────────────────────────────────────────────{ counter: 0 }─
utop # (Unix.stat "/tmp/passwd").st_kind;;
- : Unix.file_kind = Unix.S_REG
─( 21:12:00 )─< command 1 >─────────────────────────────────────────────────────────{ counter: 0 }─
utop #

How can that be?

You are looking for Unix.lstat.

1 Like