1
0
mirror of https://github.com/containers/podman.git synced 2026-02-05 15:45:08 +01:00
Files
podman/test/apiv2/44-mounts.at
ArthurWuTW 2825521337 tmpfs: Add support for noatime mount option
'noatime' flag disables updates to file access times when files are read. This can reduce unnecessary writes and improve performance, especially in read-heavy workloads. Previously, tmpfs did not recognize the 'noatime' mount option and would return an error.

With this change, tmpfs now properly accepts and handles the 'noatime' option.

Fixes: #26102

Signed-off-by: Arthur Wu <lion811004@gmail.com>
2025-06-06 22:21:45 -04:00

40 lines
1.4 KiB
Bash

# -*- sh -*-
podman pull $IMAGE &>/dev/null
# Test various HostConfig options
tmpfs_name="/mytmpfs"
t POST containers/create?name=hostconfig_test \
Image=$IMAGE \
Cmd='["df","-P","'$tmpfs_name'"]' \
HostConfig='{"Binds":["/tmp/doesnotexist:/test1"]' \
TmpFs="{\"$tmpfs_name\":\"rw,noatime\"}}" \
201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
# Prior to #9512, the tmpfs would be called '/mytmpfs=rw', with the '=rw'
t GET containers/${cid}/json 200 \
.HostConfig.Tmpfs[\"${tmpfs_name}\"]~rw,
# Run the container, verify output
t POST containers/${cid}/start 204
t POST containers/${cid}/wait 200
t GET containers/${cid}/logs?stdout=true 200
# /logs returns application/octet-stream, which our test helper saves in
# an outfile rather than returning in $output. That's why we can't test
# this directly in the /logs test above; instead, we rely on knowing the
# path to the stored results. The 'tr' is needed because there may be
# null bytes in the outfile.
like "$(tr -d \\0 <$WORKDIR/curl.result.out)" ".* ${tmpfs_name}" \
"'df' output includes tmpfs name"
# Reject 'noatime' for bind mount
t POST libpod/containers/create \
Image=$IMAGE \
Mounts='[{"type":"bind","source":"/nosuchdir","destination":"/data","options":["noatime"]}]' \
500 \
.cause="invalid mount option" \
.message~"the 'noatime' option is only allowed with tmpfs mounts"