Skip to content

Allow mk*temp on WASI #229

@RReverser

Description

@RReverser

Currently, the corresponding code for mkstemp, mkostemp and mkdtemp is commented out, so any C code relying on those functions fails to compile:

#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
int mkstemp (char *);
int mkostemp (char *, int);
char *mkdtemp (char *);
#endif

The comment says it's done because WASI doesn't have temporary directories, however (correct me if I'm wrong), unlike tmpfile, those methods don't need the concept of a system-wide temporary directory.

They accept an explicit filename template, and just generate a unique filename based on it. As such, there's no reason they shouldn't work on WASI.

For example, it should be perfectly possible to create temporary files using template like /mounted-folder/tmp-XXXXXX where /mounted-folder is a valid preopen dir.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions