Skip to content

docs(debt): record the openat, mkdirat, unlinkat and renameat results on firmware 11.60 - #22638

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-sys-at-family-console-1160
Nov 18, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-sys-at-family-console-1160

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

What

The entries for openat/_openat, mkdirat, readlinkat, unlinkat and renameat in docs/dev/debt/libkernel_sys.md describe how AnyPS5 passes AT_FDCWD and absolute paths to the plain calls, joins other relative paths to the descriptor's host directory and returns EBADF and ENOTDIR, and each ends with "Console behaviour is unverified". A probe has now called the four calls that libkernel.sprx exports on firmware 11.60, from a payload process, inside a directory it created. The pull request replaces that last sentence in each entry through one debt fragment, as the contribution rules ask; no code changes.

openat with O_CREAT|O_EXCL created a file (case 2.1, line 5) and returned EEXIST for the same name again (2.2, line 6); an absolute path with AT_FDCWD opened the same file (2.3, line 7), and an absolute path with the descriptor 999, which is not open, also succeeded (2.4, line 8). A relative path with the descriptor -1 or 999 returned EBADF (2.5 and 2.6, lines 9 and 10) and one with the descriptor of a file returned ENOTDIR (2.7, line 11). mkdirat created a directory (3.1, line 12), returned EEXIST for an existing name (3.2, line 13) and ENOENT for a missing parent (3.3, line 14). openat of SUB returned ENOENT where the directory had been created as sub (3.4, line 15), and .. and ../.. opened the parent folders (4.1 and 4.2, lines 16 and 17). renameat renamed a file within a directory descriptor (5.1, line 18), returned ENOENT for a missing source (5.2, line 19), moved a file into a second directory descriptor, where openat then found it (5.3 and 5.4, lines 20 and 21), and returned EBADF for the descriptor 999 (5.5, line 22). unlinkat of a directory without AT_REMOVEDIR returned EPERM (6.1, line 23), of a directory that is not empty ENOTEMPTY (6.2, line 24), of . and .. with AT_REMOVEDIR EINVAL (6.3 and 6.4, lines 25 and 26) and with the flag 0x1 EINVAL (6.5, line 27). readlinkat is not exported by libkernel.sprx on this firmware (line 3), so it could not be measured; AnyPS5 exports it.

When the code is read, AnyPS5 answers the same for these cases: openat_nid_postfix (libkernel_sys/Export.cpp, lines 968 to 990) sends absolute paths and AT_FDCWD to open without looking at the descriptor (line 986) and other paths to OpenInDirectory_nid_no_patch; mkdirat (lines 1011 to 1045) gives EEXIST and ENOENT for the Windows cases at lines 1025 to 1031; unlinkat (lines 1151 to 1238) gives EINVAL for the flag (line 1152) and for . and .. (line 1166), ENOTEMPTY for a directory that is not empty (line 1181) and EPERM for a directory without AT_REMOVEDIR (line 1216); renameat (lines 1250 to 1300) returns EBADF for a descriptor that is not open (lines 1264 and 1265) and ENOENT for a missing source (lines 1276 and 1277). The descriptor lookup gives EBADF and ENOTDIR (libkernel/File/src/DirectoryDescriptor.cpp, lines 487 to 501). The rename itself after line 1300 and the tests were not read or compared, and the emulator was not run for this pull request.

Two results are not compared. The console treated SUB and sub as different names; here a relative path is joined to the descriptor's host directory, so the answer follows the host's name matching, which was not checked. And .. led to the parent folders on the console, which has no guest root in a payload process, so the entry's remark that .. is not kept inside the guest root cannot be checked against it.

Not measured: _openat, invalid descriptors for mkdirat and unlinkat, symbolic links, readlinkat (not exported), and a title process.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that loads libkernel.sprx and takes the five functions with dlsym (line 3 shows readlinkat was not found), on 2026-11-17 at 22:05 UTC. A title process may differ. The cases are 0 to 9, lines 2 to 29 of the raw output in the first comment.

Call PS5 payload process, firmware 11.60 AnyPS5 main (code read, not run) in the entry
openat O_CREAT|O_EXCL, again file created; EEXIST (lines 5, 6) host open now stated
openat absolute path, descriptor 999 not open succeeds (line 8) succeeds (line 986) now stated
openat relative, descriptor -1 or 999; renameat descriptor 999 EBADF (lines 9, 10, 22) EBADF now stated
openat relative, descriptor of a file ENOTDIR (line 11) ENOTDIR now stated
openat SUB for sub; .., ../.. ENOENT; parent folders (lines 15 to 17) follows the host; not compared now stated
mkdirat new, existing, missing parent 0, EEXIST, ENOENT (lines 12 to 14) same (Windows branch) now stated
renameat within, into a second descriptor; missing source 0, 0 and found; ENOENT (lines 18 to 21) ENOENT; the rename not read now stated
unlinkat directory without AT_REMOVEDIR; not empty EPERM; ENOTEMPTY (lines 23, 24) EPERM; ENOTEMPTY now stated
unlinkat ., .. with AT_REMOVEDIR; flag 0x1 EINVAL (lines 25 to 27) EINVAL now stated
readlinkat not exported (line 3) exported now stated

tools/check_conventions.py --base upstream/main passes with no error and no warning (the five entries are now 941, 737, 624, 956 and 738 characters, up from 600, 532, 507, 725 and 521). This is a documentation change, so no test was added or run, and no GPU test applies. Not tested: the emulator against these calls, a title process, other firmware, and the cases listed above as not measured.

Overlap: the other open pull requests that change the file of this branch (the fragment docs/dev/debt/changes/docs-libkernel-sys-at-family-console-1160.md, a new file), core/libs/prx/libkernel_sys/Export.cpp or core/libs/prx/libkernel/File/src/DirectoryDescriptor.cpp, which the entries and the text name, or the five debt entries they change, found by reading the changed files of all 1779 open pull requests at about 23:11 to 23:28 UTC, by reading what they change in docs/dev/debt/libkernel_sys.md and the fragments under docs/dev/debt/changes/ for openat, mkdirat, readlinkat, unlinkat and renameat, and by searching their titles and branch names for the same names (no hit), were test-merged on 2026-11-17 at about 23:34 UTC against main 21f76fe3981 together with this head; the branch is based on 68071834eeb, an ancestor of it, merges into main without a conflict, and tools/debt_fold.py --check applies the fragment to the libkernel_sys debt file of main without an error (checked without the fragments libressl3-20171-inventory.md, fix-libc-hypotl-msun-ld80.md, fix-libc-ld80-inverse-hyperbolic.md and fix-libc-jnf-ynf-msun.md, which already conflict with other fragments or with the libc debt file on main and are not part of this change), each of the five texts the change names occurs in exactly one entry, and no other fragment changes those entries. Twenty-two pull requests list one of the three files, most of them for other functions; as this branch adds only a fragment, none of them conflicts only with this change. #18190 changes calls in Export.cpp to their _nid_no_patch forms, among them lines inside openat, _openat and unlinkat, and does not change the entries of this branch; #21464, #12642, #12315 and #12130 carry the readlinkat entry, #9302 and #9297 the renameat entry and #17936 the entries around them as unchanged context lines of their own hunks; none of them changes a line of the five entries of this branch or any line that names openat, mkdirat, readlinkat, unlinkat or renameat in them. The merged result was not built or run; this is a documentation change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (documentation only)
  • AI-assisted: yes

… on firmware 11.60

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk v0.45; PROBE_BUILD is the first 12 hex digits of the source's SHA-256, c6442ebf44c9) and its raw output from the run on 2026-11-17 at 22:05 UTC. The clock in the PROBE line is the console's own clock. The probe loads libkernel.sprx and takes openat, mkdirat, unlinkat, renameat and readlinkat with dlsym (readlinkat is not exported). In a directory it creates, it makes a file and two folders, opens, renames and removes them through directory descriptors, tries invalid descriptors and flags, and finally removes every name it made and the directory itself; every call is guarded against signals and by a self limit. An internal probe number in the header comment was removed; the code is unchanged, and the build ID is the hash of the original file.

probe.c
/* openat, mkdirat, unlinkat, renameat and readlinkat with a directory descriptor, payload process, firmware 11.60 (debt
   libkernel_sys.md entries for these five: AnyPS5 passes AT_FDCWD (-100) and absolute paths to the plain call; any other relative
   path is joined to the descriptor's host directory, found the same way as for fchdir, so guest path aliases and case-insensitive
   name matching do not apply to it and a ".." component is not kept inside the guest root; EBADF for a descriptor that is not
   open and ENOTDIR for one that is not a directory; unlinkat without AT_REMOVEDIR on a directory fails with EPERM, "." or ".."
   with AT_REMOVEDIR fails with EINVAL, other flags fail with EINVAL; console behaviour unverified). Prototypes: int openat(int,
   const char*, int, mode_t), int mkdirat(int, const char*, mode_t), int unlinkat(int, const char*, int), int renameat(int,
   const char*, int, const char*), ssize_t readlinkat(int, const char*, char*, size_t). All five are looked up with dlsym in
   libkernel.sprx. Everything happens below the probe directory's own subdirectory /data/anyps5_probe/n2_12_bo3 (created and removed
   by the probe). Only return codes, errno and equalities of inode numbers are printed. Cases: open the directory with
   O_DIRECTORY; openat creating a file with O_EXCL twice (EEXIST), the same file through the absolute path with AT_FDCWD (same
   inode), an absolute path with an invalid descriptor, relative paths with descriptors -1 and 999 and with a file descriptor;
   mkdirat twice and with a missing parent, a name in different letter case; ".." and "../.." through a descriptor against the
   absolute path of the same directory; renameat inside the directory, with a missing source, into a second directory descriptor and
   with an invalid descriptor; unlinkat of a directory without AT_REMOVEDIR, of a non-empty directory with AT_REMOVEDIR, "." and
   ".." with AT_REMOVEDIR (the directory is not empty, nothing can be removed) and an invalid flag; readlinkat on a regular
   file and with an invalid descriptor. No symbolic link is created, nothing outside the probe directory is touched, no chdir.
   Cleanup is mandatory: every file and directory made is removed with unlinkat and the directory with rmdir; the
   return codes are logged. Nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h>   /* only for kernel_get_fw_version() */

#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
   itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif

static volatile int g_handle = -1;
static int (*volatile g_setmargins)(int, int, int) = 0; /* unused here */
static void reset_rate(void) {
  if (g_setmargins && g_handle >= 0) g_setmargins(g_handle, 0, 0);
}

static void probe_alarm(int sig) {
  static const char msg[] = "TIMEOUT\tprobe self limit\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
}

/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
   thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
   as a second safeguard. */
static void* probe_watchdog(void* arg) {
  static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
  unsigned left = PROBE_MAX_S;
  (void)arg;
  while (left) left = sleep(left);
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
  return 0;
}

static void probe_watchdog_start(void) {
  pthread_t t;
  if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}

static int cases = 0;

static void probe_header(void) {
  char utc[32];
  time_t now = time(0);
  probe_watchdog_start();
  struct tm tmv;
  gmtime_r(&now, &tmv);
  strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
  printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
         getpid(), utc);
  fflush(stdout);
}

static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
  printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
  fflush(stdout);
  cases++;
}

static void probe_end(void) {
  printf("END\t%d\n", cases);
  fflush(stdout);
}



#include <fcntl.h>
#include <sys/stat.h>
#define ATFD (-100)
#define ATRM 0x800

typedef int (*fn_openat)(int, const char*, int, mode_t);
typedef int (*fn_mkdirat)(int, const char*, mode_t);
typedef int (*fn_unlinkat)(int, const char*, int);
typedef int (*fn_renameat)(int, const char*, int, const char*);
typedef long (*fn_readlinkat)(int, const char*, char*, size_t);

static fn_openat f_open;
static fn_mkdirat f_mkdir;
static fn_unlinkat f_unlink;
static fn_renameat f_rename;
static fn_readlinkat f_readlink;

static void fault(int sig) {
  static const char msg[] = "FAULT\tsignal in the call\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  _exit(125);
}

static void res(const char* id, const char* label, long r, int e, const char* more) {
  char extra[200];
  snprintf(extra, sizeof extra, "rc=%ld errno=%d%s%s", r, e, more[0] ? " " : "", more);
  probe_case(id, label, r, e, extra);
}

static long ino_of(int fd) {
  struct stat st;
  if (fstat(fd, &st) != 0) return -1;
  return (long)st.st_ino;
}

int main(void) {
  signal(SIGALRM, probe_alarm);
  signal(SIGSEGV, fault);
  signal(SIGBUS, fault);
  alarm(PROBE_MAX_S);
  probe_header();
  char extra[200];

  errno = 0;
  void* lk = dlopen("libkernel.sprx", RTLD_LAZY);
  probe_case("0", "load libkernel.sprx", lk ? 0 : -1, errno, lk ? "loaded" : dlerror());
  if (!lk) { probe_end(); return 0; }
  f_open = (fn_openat)dlsym(lk, "openat");
  f_mkdir = (fn_mkdirat)dlsym(lk, "mkdirat");
  f_unlink = (fn_unlinkat)dlsym(lk, "unlinkat");
  f_rename = (fn_renameat)dlsym(lk, "renameat");
  f_readlink = (fn_readlinkat)dlsym(lk, "readlinkat"); /* optional: the first run found it not exported in libkernel.sprx */
  snprintf(extra, sizeof extra, "openat=%d mkdirat=%d unlinkat=%d renameat=%d readlinkat=%d", f_open != 0, f_mkdir != 0, f_unlink != 0,
           f_rename != 0, f_readlink != 0);
  probe_case("0b", "dlsym of the functions", 0, 0, extra);
  if (!f_open || !f_mkdir || !f_unlink || !f_rename) { probe_end(); return 0; }

  errno = 0;
  int mk = mkdir("/data/anyps5_probe/n2_12_bo3", 0700);
  int mke = errno;
  res("1", "mkdir(probe subdirectory)", mk, mke, "");
  int dirfd = open("/data/anyps5_probe/n2_12_bo3", O_RDONLY | O_DIRECTORY);
  int fd1 = -1, dirfd2 = -1;
  if (dirfd < 0) {
    res("1b", "open the probe subdirectory with O_DIRECTORY", dirfd, errno, "");
    goto cleanup;
  }

  /* a) openat */
  errno = 0;
  fd1 = f_open(dirfd, "f1", O_CREAT | O_RDWR | O_EXCL, 0600);
  res("2.1", "openat(dirfd, \"f1\", O_CREAT|O_RDWR|O_EXCL)", fd1, errno, fd1 >= 0 ? "created=1" : "created=0");
  errno = 0;
  int x = f_open(dirfd, "f1", O_CREAT | O_RDWR | O_EXCL, 0600);
  res("2.2", "openat(dirfd, \"f1\", O_CREAT|O_EXCL) again", x, errno, "");
  if (x >= 0) close(x);
  errno = 0;
  int xa = f_open(ATFD, "/data/anyps5_probe/n2_12_bo3/f1", O_RDONLY, 0);
  snprintf(extra, sizeof extra, "same_inode_as_f1=%d", xa >= 0 && fd1 >= 0 && ino_of(xa) == ino_of(fd1));
  res("2.3", "openat(AT_FDCWD, absolute path of f1, O_RDONLY)", xa, errno, extra);
  if (xa >= 0) close(xa);
  errno = 0;
  x = f_open(999, "/data/anyps5_probe/n2_12_bo3/f1", O_RDONLY, 0);
  res("2.4", "openat(999, absolute path of f1) invalid descriptor, absolute path", x, errno, "");
  if (x >= 0) close(x);
  errno = 0;
  x = f_open(-1, "f1", O_RDONLY, 0);
  res("2.5", "openat(-1, \"f1\") relative", x, errno, "");
  if (x >= 0) close(x);
  errno = 0;
  x = f_open(999, "f1", O_RDONLY, 0);
  res("2.6", "openat(999, \"f1\") relative", x, errno, "");
  if (x >= 0) close(x);
  if (fd1 >= 0) {
    errno = 0;
    x = f_open(fd1, "x", O_RDONLY, 0);
    res("2.7", "openat(fd of f1, \"x\") descriptor is a file", x, errno, "");
    if (x >= 0) close(x);
  }

  /* b) mkdirat */
  errno = 0;
  int r = f_mkdir(dirfd, "sub", 0700);
  res("3.1", "mkdirat(dirfd, \"sub\")", r, errno, "");
  errno = 0;
  r = f_mkdir(dirfd, "sub", 0700);
  res("3.2", "mkdirat(dirfd, \"sub\") again", r, errno, "");
  errno = 0;
  r = f_mkdir(dirfd, "sub/a/b", 0700);
  res("3.3", "mkdirat(dirfd, \"sub/a/b\") missing parent", r, errno, "");
  errno = 0;
  x = f_open(dirfd, "SUB", O_RDONLY | O_DIRECTORY, 0);
  res("3.4", "openat(dirfd, \"SUB\", O_DIRECTORY) other letter case", x, errno, "");
  if (x >= 0) close(x);

  /* c) dot-dot */
  struct stat s1, s2;
  int sr = stat("/data/anyps5_probe", &s1), sp = stat("/data/anyps5_probe/..", &s2);
  errno = 0;
  x = f_open(dirfd, "..", O_RDONLY | O_DIRECTORY, 0);
  snprintf(extra, sizeof extra, "same_inode_as_probe_root=%d", x >= 0 && sr == 0 && ino_of(x) == (long)s1.st_ino);
  res("4.1", "openat(dirfd, \"..\", O_DIRECTORY)", x, errno, extra);
  if (x >= 0) close(x);
  errno = 0;
  x = f_open(dirfd, "../..", O_RDONLY | O_DIRECTORY, 0);
  snprintf(extra, sizeof extra, "same_inode_as_parent_of_probe_root=%d", x >= 0 && sp == 0 && ino_of(x) == (long)s2.st_ino);
  res("4.2", "openat(dirfd, \"../..\", O_DIRECTORY)", x, errno, extra);
  if (x >= 0) close(x);

  /* d) renameat */
  if (fd1 >= 0) { close(fd1); fd1 = -1; }
  errno = 0;
  r = f_rename(dirfd, "f1", dirfd, "f2");
  res("5.1", "renameat(dirfd, \"f1\", dirfd, \"f2\")", r, errno, "");
  errno = 0;
  r = f_rename(dirfd, "f1", dirfd, "f9");
  res("5.2", "renameat(dirfd, \"f1\" missing, dirfd, \"f9\")", r, errno, "");
  dirfd2 = open("/data/anyps5_probe/n2_12_bo3/sub", O_RDONLY | O_DIRECTORY);
  if (dirfd2 >= 0) {
    errno = 0;
    r = f_rename(dirfd, "f2", dirfd2, "f3");
    res("5.3", "renameat(dirfd, \"f2\", dirfd of sub, \"f3\")", r, errno, "");
    errno = 0;
    x = f_open(dirfd2, "f3", O_RDONLY, 0);
    res("5.4", "openat(dirfd of sub, \"f3\") after the move", x, errno, "");
    if (x >= 0) close(x);
  } else {
    res("5.3", "open the subdirectory with O_DIRECTORY", dirfd2, errno, "");
  }
  errno = 0;
  r = f_rename(999, "f2", dirfd, "f8");
  res("5.5", "renameat(999, \"f2\", dirfd, \"f8\") invalid descriptor", r, errno, "");

  /* e) unlinkat */
  errno = 0;
  r = f_unlink(dirfd, "sub", 0);
  res("6.1", "unlinkat(dirfd, \"sub\", 0) directory without AT_REMOVEDIR", r, errno, "");
  errno = 0;
  r = f_unlink(dirfd, "sub", ATRM);
  res("6.2", "unlinkat(dirfd, \"sub\", AT_REMOVEDIR) not empty", r, errno, "");
  errno = 0;
  r = f_unlink(dirfd, ".", ATRM);
  res("6.3", "unlinkat(dirfd, \".\", AT_REMOVEDIR)", r, errno, "");
  errno = 0;
  r = f_unlink(dirfd, "..", ATRM);
  res("6.4", "unlinkat(dirfd, \"..\", AT_REMOVEDIR)", r, errno, "");
  errno = 0;
  r = f_unlink(dirfd, "zzz_not_here", 1);
  res("6.5", "unlinkat(dirfd, \"zzz_not_here\", flag 0x1) invalid flag", r, errno, "");

  /* f) readlinkat */
  errno = 0;
  int f4 = f_open(dirfd, "f4", O_CREAT | O_RDWR | O_EXCL, 0600);
  if (f4 >= 0) close(f4);
  char buf[64];
  if (f_readlink) {
    errno = 0;
    long rl = f_readlink(dirfd, "f4", buf, sizeof buf);
    res("7.1", "readlinkat(dirfd, \"f4\") regular file", rl, errno, "");
    errno = 0;
    rl = f_readlink(999, "f4", buf, sizeof buf);
    res("7.2", "readlinkat(999, \"f4\") invalid descriptor", rl, errno, "");
  } else {
    probe_case("7", "readlinkat", 0, 0, "not exported in libkernel.sprx: cases skipped");
  }

cleanup:
  if (fd1 >= 0) close(fd1);
  {
    int c1 = -99, c2 = -99, c3 = -99, c4 = -99, c5 = -99, c6 = -99, c7 = -99, c8 = -99;
    if (dirfd2 >= 0) { c1 = f_unlink(dirfd2, "f3", 0); close(dirfd2); }
    if (dirfd >= 0) {
      c2 = f_unlink(dirfd, "f1", 0);
      c3 = f_unlink(dirfd, "f2", 0);
      c4 = f_unlink(dirfd, "f4", 0);
      c5 = f_unlink(dirfd, "f8", 0);
      c6 = f_unlink(dirfd, "f9", 0);
      c7 = f_unlink(dirfd, "sub", ATRM);
      close(dirfd);
    }
    c8 = rmdir("/data/anyps5_probe/n2_12_bo3");
    snprintf(extra, sizeof extra, "f3=%d f1=%d f2=%d f4=%d f8=%d f9=%d sub=%d rmdir=%d (-99 = not tried, -1 = nothing to remove)", c1, c2, c3, c4, c5,
             c6, c7, c8);
    probe_case("9", "cleanup: unlinkat of every name made, rmdir of the probe subdirectory", c8, 0, extra);
  }

  probe_end();
  return 0;
}
stdout
PROBE	openat_family2	fw=0x11600005	build=c6442ebf44c9	pid=240	utc=2026-11-17T23:47:48Z
CASE	0	load libkernel.sprx	0	2	loaded
CASE	0b	dlsym of the functions	0	0	openat=1 mkdirat=1 unlinkat=1 renameat=1 readlinkat=0
CASE	1	mkdir(probe subdirectory)	0	0	rc=0 errno=0
CASE	2.1	openat(dirfd, "f1", O_CREAT|O_RDWR|O_EXCL)	8	0	rc=8 errno=0 created=1
CASE	2.2	openat(dirfd, "f1", O_CREAT|O_EXCL) again	-1	17	rc=-1 errno=17
CASE	2.3	openat(AT_FDCWD, absolute path of f1, O_RDONLY)	9	0	rc=9 errno=0 same_inode_as_f1=1
CASE	2.4	openat(999, absolute path of f1) invalid descriptor, absolute path	9	0	rc=9 errno=0
CASE	2.5	openat(-1, "f1") relative	-1	9	rc=-1 errno=9
CASE	2.6	openat(999, "f1") relative	-1	9	rc=-1 errno=9
CASE	2.7	openat(fd of f1, "x") descriptor is a file	-1	20	rc=-1 errno=20
CASE	3.1	mkdirat(dirfd, "sub")	0	0	rc=0 errno=0
CASE	3.2	mkdirat(dirfd, "sub") again	-1	17	rc=-1 errno=17
CASE	3.3	mkdirat(dirfd, "sub/a/b") missing parent	-1	2	rc=-1 errno=2
CASE	3.4	openat(dirfd, "SUB", O_DIRECTORY) other letter case	-1	2	rc=-1 errno=2
CASE	4.1	openat(dirfd, "..", O_DIRECTORY)	9	0	rc=9 errno=0 same_inode_as_probe_root=1
CASE	4.2	openat(dirfd, "../..", O_DIRECTORY)	9	0	rc=9 errno=0 same_inode_as_parent_of_probe_root=1
CASE	5.1	renameat(dirfd, "f1", dirfd, "f2")	0	0	rc=0 errno=0
CASE	5.2	renameat(dirfd, "f1" missing, dirfd, "f9")	-1	2	rc=-1 errno=2
CASE	5.3	renameat(dirfd, "f2", dirfd of sub, "f3")	0	0	rc=0 errno=0
CASE	5.4	openat(dirfd of sub, "f3") after the move	9	0	rc=9 errno=0
CASE	5.5	renameat(999, "f2", dirfd, "f8") invalid descriptor	-1	9	rc=-1 errno=9
CASE	6.1	unlinkat(dirfd, "sub", 0) directory without AT_REMOVEDIR	-1	1	rc=-1 errno=1
CASE	6.2	unlinkat(dirfd, "sub", AT_REMOVEDIR) not empty	-1	66	rc=-1 errno=66
CASE	6.3	unlinkat(dirfd, ".", AT_REMOVEDIR)	-1	22	rc=-1 errno=22
CASE	6.4	unlinkat(dirfd, "..", AT_REMOVEDIR)	-1	22	rc=-1 errno=22
CASE	6.5	unlinkat(dirfd, "zzz_not_here", flag 0x1) invalid flag	-1	22	rc=-1 errno=22
CASE	7	readlinkat	0	0	not exported in libkernel.sprx: cases skipped
CASE	9	cleanup: unlinkat of every name made, rmdir of the probe subdirectory	0	0	f3=0 f1=-1 f2=-1 f4=0 f8=-1 f9=-1 sub=0 rmdir=0 (-99 = not tried, -1 = nothing to remove)
END	28

AI-assisted (Claude Code).

@oneandonlydean
oneandonlydean merged commit 0008e5a into boykopovar:main Nov 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants