imsd: List answers IOError for a store it could not read, and a scan's read error no longer ends the daemon

LoadStoredSms had no way to report a failure. A store directory that
could not be opened read as an empty store, and a record that could not
be opened read as a corrupt file and was skipped: Messaging.List
answered success with texts missing. A consumer that forgets a deleted
text's id once List no longer carries it forgets it too early then, and
imports the text again when a later List has it; and a text that
arrived while no app ran stays unseen until another List (issue #5).
The scans also walked the directory with the iterator's throwing
increment and tested each entry with is_regular_file() in its throwing
form, and nothing catches that at the start's sweep, in List's handler
or in the run loop: a read error there ended the process — in the run
loop from the count for the `stored` journal line, with a text stored
and its delivery report unsent.

The three scans now go through opendir, readdir, stat and read. What a
scan cannot read is a StoreFault, logged by the scan that met it;
List's read and the count hand theirs back as well. List answers
org.freedesktop.DBus.Error.IOError with the system's reason, the error
Delete gives for a removal that failed: no list, so a consumer takes
nothing for deleted and asks again. A store directory that does not
exist is still an empty list, and a file that reads and is no record is
still skipped with its line. The sweep logs the fault and lets the
daemon start; the `stored` line goes without its count. The journal
names what could not be read: `sms store: cannot read <path>:
<reason>`.

The Messaging interface is frozen as of 1.2.0 (AGENTS.md §8.4): no
member, signature, key, state word or error name changes; List gains a
failure answer under an error name the interface has.

Tested in dev mode on a private session bus, on the workstation's
build of this commit (the fp6 journal's 2026-11-20-issues-2-5 capture,
list-io): IOError with "Permission denied" for the store directory at
mode 000 and at mode 400 and for a record at mode 000, and with "Not a
directory" for a file in the directory's place; an empty list with no
directory; both records listed beside a file that is no record, a
directory and a dangling link named like records; a start with the
directory at mode 000 logs the sweep's fault and the daemon answers.
On the dev phone, with the binary of this range's last commit (the
capture's phone-form6): an empty list with the store directory moved
away, IOError with "Not a directory" with a file in its place, the
fault in the journal for each call it refused. Not benched: a read
that fails part-way, a file removed between the directory's read and
its own, a process out of descriptors, the `stored` line without its
count.
This commit is contained in:
Jorijn van der Graaf 2026-11-22 17:35:12 +01:00
commit 710f884575
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 187 additions and 30 deletions

View file

@ -147,15 +147,15 @@ A new desktop needs a new translation daemon, not changes here.
A second interface on the same object, for short messages over IMS
(`SMS_OVER_IMS=1`). Additive: the interface above is unchanged. Frozen as of
1.2.0: what the table lists stays as it is, and a dictionary imsd gives may
gain a key.
1.2.0: its members and their signatures stay as they are, and a dictionary
imsd gives may gain a key.
| Member | Signature |
|---|---|
| `Send(number, text, options)` | `ssa{sv} → s` (id); options: `status-report` (b, ask the SC to report delivery). Refused with `NotSupported` while SMS over IMS is off |
| `GetStatus()` | `→ a{sv}`: `enabled` (b), `smsc` (s), `ppi` (s, the own number in the daemon's last status, e.g. `tel:+31612345678`), `operator` (s, the SIM's operator id in that status), `registered` (b), `subscribers` (u) |
| `Subscribe()` | `→` nothing: the calling connection receives `Received` and `StateChanged` from now on (unicast, never broadcast: to subscribers, and a submission's `sent` / `failed` also to its `Send` caller); subscribe again when imsd's name reappears on the bus |
| `List()` | `→ a(sa{sv})`: the stored messages it can read, by the arrival second on the phone's wall clock, then within a run the sequence number (a 1970 clock before the first time sync sorts first; the SC's `timestamp` is the real chronology), each the id and the dictionary `Received` carries |
| `List()` | `→ a(sa{sv})`: the stored messages, by the arrival second on the phone's wall clock, then within a run the sequence number (a 1970 clock before the first time sync sorts first; the SC's `timestamp` is the real chronology), each the id and the dictionary `Received` carries; `IOError` when a store that is there cannot be read |
| `Delete(id)` | `s`: removes a stored message |
| `Received` | `s a{sv}` (id, message: `from`, `text`, `timestamp` (the SC's, as `2026-10-16T22:50:00+02:00`), `received` (x), `sc`, `to` (when the daemon held an own number at receipt: that number, e.g. `tel:+31612345678`), `operator` (the SIM's operator id at receipt), `class` (i, -1 none), `pid` (y), `dcs` (y), `segments` (i), `message-waiting` (b), `port-dst`/`port-src` (u, when addressed to a port), `data` (ay, 8-bit data), `pdu` (ay, the SMS-DELIVER as received; of a concatenated message, the segment that completed it)) |
| `StateChanged` | `s s s` (id, state, reason): `sent` (every segment accepted by the SC), `failed` (why), and with a status report `delivered` (every segment), `delivery-pending`, `delivery-failed` — each speaks for the whole message, never for one segment, and `delivery-pending` can come more than once |