Skip to content

Three enquiries a C library has no way to answer: a directory's time, how many processors, a volume's capacity #24

Description

@Sunrisepeak

Three small ones from openkal-musl 0.10.0, in descending order of how much
trouble they cause. Each is a thing every environment beneath openkal can
answer today and the interface has no word for.

1. A directory's modification time — and this one is already being worked around

kal_fs_set_modified takes a kal_file. A directory is opened by
kal_fs_open_dir, which yields a kal_dir, and there is no kal_dir form of
kal_fs_set_modified and no form taking a name
. So there is no stated route
to a directory's modification time at all, while kal_fs_info reports one
perfectly well.

A consumer met this as a lock directory it stamps to refresh the lock. Measured
directly against openkal-linux:

kal_fs_open(dir, READ|WRITE) -> 12 (kal_err_is_directory)
kal_fs_open(dir, READ)       -> 0
  kal_fs_set_modified(dir)   -> 0        <-- and the time really changes

⚠️ So openkal-musl 0.10.0 opens a directory for reading and stamps it, which
works on Linux and macOS and not on Windows (FILE_NON_DIRECTORY_FILE). That is
outside what fs.h states — the interface requires KAL_OPEN_WRITE — and it
is recorded as such rather than concealed. It is a workaround and should not
have to be one.

Asked for: a kal_dir form, or kal_fs_set_modified restated on a name.

2. How many contexts can run at once — and this one is silent

openkal.task says whether contexts run in parallel
(KAL_TASK_PROP_PARALLEL) and not how many can.

⚠️ The consequence is a wrong answer with no error attached: musl's
sysconf(_SC_NPROCESSORS_ONLN) falls back to 1, so
std::thread::hardware_concurrency() answers 1 and a program sizing a pool of
workers gets one worker and no way to know. Measured: 1 here, 32 on the host.

Every other absence in this port is loud. This one is not, which is why it is
worth a word even though nothing fails.

Asked for: an enquiry beside KAL_TASK_PROP_PARALLEL, reporting 0 for "cannot
say" so that a caller can tell that apart from 1.

3. A volume's capacity

std::filesystem::space reaches statvfs, which reports ENOSYS. There is no
operation for it. Lowest priority of the three — it is a loud absence and a
program that asks gets an error it can act on.


Also recorded in openkal-musl's divergence table, and not asked for here because
each is a genuine absence rather than a missing word: hard links
(kal_fs_link_create makes a node whose content is a name — a symbolic link),
named pipes, and a bidirectional stream pair (kal_process_channel is a pipe in
one direction, so socketpair cannot be built from one).

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