Skip to content

Commit d24920e

Browse files
committed
Add posix_mkfifo Erlang spec and export
The NIF existed but was not exported from atomvm.erl. Also tighten mode validation to reject negative values. Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent f7065c4 commit d24920e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

libs/eavmlib/src/atomvm.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
posix_pwrite/3,
4646
posix_fsync/1,
4747
posix_ftruncate/2,
48+
posix_mkfifo/2,
4849
posix_mkdir/2,
4950
posix_rmdir/1,
5051
posix_rename/2,
@@ -375,6 +376,18 @@ posix_fsync(_File) ->
375376
posix_ftruncate(_File, _Length) ->
376377
erlang:nif_error(undefined).
377378

379+
%%-----------------------------------------------------------------------------
380+
%% @param Path Path to the new FIFO special file
381+
%% @param Mode Permission bits for the new FIFO
382+
%% @returns `ok' or an error tuple
383+
%% @doc Create a FIFO special file (named pipe) using `mkfifo(2)'.
384+
%% @end
385+
%%-----------------------------------------------------------------------------
386+
-spec posix_mkfifo(Path :: iodata(), Mode :: non_neg_integer()) ->
387+
ok | {error, posix_error()}.
388+
posix_mkfifo(_Path, _Mode) ->
389+
erlang:nif_error(undefined).
390+
378391
%%-----------------------------------------------------------------------------
379392
%% @param Path Path to the directory to create
380393
%% @param Mode Permission bits for the new directory

src/libAtomVM/posix_nifs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static term nif_atomvm_posix_mkfifo(Context *ctx, int argc, term argv[])
954954
UNUSED(argc);
955955
term path_term = argv[0];
956956
term mode_term = argv[1];
957-
VALIDATE_VALUE(mode_term, term_is_integer);
957+
VALIDATE_VALUE(mode_term, term_is_non_neg_int);
958958

959959
int ok;
960960
const char *path = interop_term_to_string(path_term, &ok);

0 commit comments

Comments
 (0)