Repository navigation
Expand file tree
/
Copy pathnextbsd-e15-tickets.html
More file actions
2114 lines (1735 loc) · 365 KB
/
Copy pathnextbsd-e15-tickets.html
File metadata and controls
2114 lines (1735 loc) · 365 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>E15 ticket drafts — Disks, mounts and DiskArbitration</title>
<style>
:root {
--bg: #fbfbf8;
--fg: #1a1a1a;
--muted: #555;
--accent: #b03000;
--accent2: #0a4d68;
--ok: #1f7a1f;
--warn: #b06800;
--bad: #b00020;
--code-bg: #f0ece4;
--rule: #d6cfc0;
--card: #fff;
}
html { -webkit-text-size-adjust: 100%; }
body { margin: 0 auto; max-width: 1080px; padding: 2.5rem 1.5rem 6rem;
font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
color: var(--fg); background: var(--bg); }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .25rem; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 .75rem; padding-bottom: .25rem; border-bottom: 2px solid var(--rule); }
h3 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; color: var(--accent2); }
h4 { margin: 1.25rem 0 .35rem; }
.subtitle { color: var(--muted); font-size: 1.05rem; margin: 0 0 2rem; }
code, pre, kbd { font-family: "SF Mono", Menlo, Consolas, monospace; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 3px; font-size: .9em; }
pre { background: var(--code-bg); padding: .85rem 1rem; border-radius: 6px;
overflow-x: auto; font-size: .82rem; line-height: 1.45;
border-left: 3px solid var(--accent2); }
pre code { background: none; padding: 0; }
pre.shell { border-left-color: var(--ok); }
pre.c { border-left-color: var(--accent); }
a { color: var(--accent2); }
a:hover { color: var(--accent); }
.tldr { background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--accent2);
padding: 1rem 1.25rem; border-radius: 6px; margin-bottom: 2rem; }
.tldr h3 { margin-top: 0; color: var(--accent2); }
.pill { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px;
background: #eee; color: #333; margin-left: .35rem; vertical-align: middle;
font-weight: 600; letter-spacing: .02em; }
.pill.ok { background: #d8efd8; color: var(--ok); }
.pill.warn { background: #f6e4cb; color: var(--warn); }
.pill.bad { background: #f5d0d6; color: var(--bad); }
.pill.info { background: #d6e6f3; color: var(--accent2); }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { background: #eee5d6; }
tr:nth-child(even) td { background: #faf6ed; }
table.compact td, table.compact th { padding: .35rem .55rem; font-size: .88rem; }
.nav { position: sticky; top: 0; background: var(--bg); margin: -2.5rem -1.5rem 2rem;
padding: .75rem 1.5rem; border-bottom: 1px solid var(--rule);
font-size: .88rem; z-index: 10; }
.nav a { margin-right: .9rem; text-decoration: none; }
.gap { background: #fff5f5; border-left: 4px solid var(--bad); padding: .8rem 1rem; margin: 1rem 0; border-radius: 0 6px 6px 0; }
.gap strong { color: var(--bad); }
.resolved { background: #ecf7ec; border-left: 4px solid var(--ok); padding: .8rem 1rem; margin: 1rem 0; border-radius: 0 6px 6px 0; }
.resolved strong { color: var(--ok); }
.open-q { background: #fff8d6; border: 1px solid #e5d76b; padding: .8rem 1rem; margin: 1rem 0; border-radius: 6px; font-size: .92rem; }
.open-q strong { color: #7a5e00; }
.risk { background: #fff5f5; border: 1px solid #e7b8bf; border-left: 4px solid var(--bad); padding: .8rem 1rem; margin: 1rem 0; border-radius: 6px; font-size: .93rem; }
.risk strong { color: var(--bad); }
.ascii-diagram { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.3; white-space: pre; background: var(--code-bg); padding: 1rem; border-radius: 6px; overflow-x: auto; }
.rec { background: #eef4f8; border: 1px solid #bcd4e2; border-left: 4px solid var(--accent2); padding: 1rem 1.25rem; margin: 1.25rem 0; border-radius: 6px; }
.rec strong { color: var(--accent2); }
.yesno { font-weight: 600; }
.yesno.yes { color: var(--ok); }
.yesno.no { color: var(--bad); }
.yesno.partial { color: var(--warn); }
</style>
<style>
.tk { background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--accent2); border-radius: 6px; padding: .9rem 1.1rem .4rem; margin: 1.25rem 0; }
.tk h3 { margin-top: .1rem; }
.tk .meta { font-size: .88rem; margin: .25rem 0 .6rem; border-collapse: collapse; }
.tk .meta td { padding: .15rem .8rem .15rem 0; vertical-align: top; }
.tk .meta td:first-child { color: var(--muted); white-space: nowrap; }
.tk pre { white-space: pre-wrap; word-wrap: break-word; }
.tk-epic { border-left-color: var(--accent); }
</style>
<style>@media (max-width:640px){ body{padding:1.5rem 1rem 4rem;} .nav{margin:-1.5rem -1rem 1.5rem;padding:.6rem 1rem;} table{display:block;overflow-x:auto;} }</style>
</head><body>
<nav class="nav">
<a href="#tldr">TL;DR</a>
<a href="#before">Before filing</a>
<a href="#label">Label</a>
<a href="#epic">Epic</a>
<a href="#index">Index</a>
<a href="#tickets">Tickets</a>
<a href="#existing">Existing issues</a>
<a href="#corrections">Corrections</a>
<a href="#recreate">Recreating</a>
</nav>
<p style="font-size:.9rem;margin:0 0 1rem"><a href="nextbsd-research.html">← NextBSD Research</a></p>
<h1>E15 ticket drafts — Disks, mounts and DiskArbitration <span class="pill ok">All filed</span></h1>
<p class="subtitle"><strong>Every issue for EPIC E15, written out in full so it can be filed in GitHub later.</strong> This page is the companion to <a href="nextbsd-diskarbitration-mounts-plan.html">Mounts, fstab and DiskArbitration</a>. It records the epic, the new <code>area:storage</code> label, all 21 child tickets, 1 migration, 12 linked issues and 7 suggested correction comments: title, target repo, labels, dependencies and the exact Markdown body for each. <strong>The epic is filed as <a href="https://github.com/nextbsd/nextbsd/issues/471">nextbsd#471</a></strong>, on the <a href="https://github.com/orgs/nextbsd/projects/1/views/8">roadmap</a>, with <a href="https://github.com/nextbsd/nextbsd/issues/467">#467</a> migrated under it. <strong>All tickets are filed</strong> (links on each card) as sub-issues of #471, and the seven correction comments are posted. <strong>D3b</strong> became a NextBSD spike under E11 Desktop / Gershwin (<a href="https://github.com/nextbsd/nextbsd/issues/474">#474</a>) instead of an upstream libs-gui ticket.</p>
<section id="tldr" class="tldr">
<h3>TL;DR</h3>
<ul>
<li><strong>21 child tickets</strong> across 5 repos, plus the epic, the <code>area:storage</code> label, and the migration of <a href="https://github.com/nextbsd/nextbsd/issues/467">nextbsd#467</a>.</li>
<li><strong>Stages:</strong> A = fstab and boot · B = Linux ABI mounts · C = diskarbitrationd, the daemon · D = framework, policy, desktop.</li>
<li><strong>Stage A needs no DiskArbitration code</strong> and closes #467 on its own; it can be filed and landed first.</li>
<li><strong>Order:</strong> A2, A3 -> A1 -> A4; A5 independent. B1 with A1; B2 parked. C1 -> C2 -> C3 / C4 -> C5 -> C6; C7 independent (kernel). D1 after C1/C2 -> D2 -> D3a; D3b independent (upstream); D3c spike -> D5; D4 after C5; D5 last.</li>
<li><strong>Machine-readable:</strong> every field on this page is also embedded as JSON (<code><script id="e15-data"></code>), so the issues can be recreated by script as well as by hand.</li>
</ul>
</section>
<h2 id="before">Before filing</h2>
<div class="open-q"><strong>1. Choose A1's variant.</strong> Ship no fstab (Apple, recommended) or a comment-only one (quieter FreeBSD tooling). The A1 body is written for the first and names the second as the fallback.</div>
<div class="open-q"><strong>2. Labels.</strong> <code>area:storage</code> now exists in nextbsd, nextbsd-userland and nextbsd-kernel. <code>nextbsd-overlays</code> has no <code>area:*</code> labels at all; Gershwin repos use their own labels.</div>
<div class="open-q"><strong>3. #54 stays decided.</strong> B2 is drafted but parked until Linux support becomes default; file it as <code>status:parked</code> or hold it back.</div>
<h2 id="label">Label</h2>
<table class="compact">
<tr><td>Name</td><td><code>area:storage</code></td></tr>
<tr><td>Description</td><td>Disks, volumes, mounts, fstab and DiskArbitration</td></tr>
<tr><td>Colour</td><td><code>#8A6A3F</code></td></tr>
<tr><td>Create in</td><td><a href="https://github.com/nextbsd/nextbsd">nextbsd</a>, <a href="https://github.com/nextbsd/nextbsd-kernel">nextbsd-kernel</a>, <a href="https://github.com/nextbsd/nextbsd-overlays">nextbsd-overlays</a>, <a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
</table>
<h2 id="epic">Epic</h2>
<div class="tk tk-epic" id="e15">
<h3>EPIC: E15 Disks, mounts & DiskArbitration <span class="pill ok">filed as <a href="https://github.com/nextbsd/nextbsd/issues/471">#471</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd">nextbsd</a></td></tr>
<tr><td>Labels</td><td><code>epic</code> <code>area:storage</code></td></tr>
</table>
<pre><code>## Summary
Who mounts what on NextBSD, done the Darwin way: stop shipping `/etc/fstab`, give the Linux ABI filesystems an owner, and grow `diskarbitrationd` from an iter-1 skeleton into the daemon that mounts disks at `/Volumes/<name>` and lets the desktop unmount and eject them without `sudo`.
**Read first:** https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html
## Why
- Live media: launchctl's boot `mount -vat nonfs` tries to remount `/dev/ufs/ROOTFS` over the unionfs root (nextbsd#467).
- Apple stopped shipping `/etc/fstab` in 10.4; the vendored hook only runs if the file exists (`launchctl.c:2401`), and nothing on either medium needs the file.
- DiskArbitration today logs storage devices and sleeps. There is no framework, no mounting, no eject; Gershwin falls back to `sudo -A umount -f`.
- There is no automounter at all on NextBSD, and vermaden/automount needs `devd`, which NextBSD removed.
## Stages
- **A** -- fstab and boot -- no DiskArbitration code; closes nextbsd#467
- **B** -- Linux ABI mounts -- the manual path under no-fstab, and the parked org.nextbsd.linux one-shot
- **C** -- diskarbitrationd, the daemon -- GEOM disk model, fs bundles, mount executor, /Volumes
- **D** -- framework, policy, desktop -- client framework, unmount/eject, Gershwin bridge, console user (D3b is an E11 spike)
## Children
Replace IDs with issue numbers once filed.
- [ ] A1 Stop shipping rootfs/private/etc/fstab (closes nextbsd#467)
- [ ] A2 launchd: remount / with rw,noatime (the fstab root line was noatime's only source); CI asserts it
- [ ] A3 launchctl: compile out the dormant Darwin do_potential_fsck() path -- launchd owns root fsck and remount
- [ ] A4 Stale fstab comments in build.sh, the installer and its README; boot-test gate on the #467 strings
- [ ] A5 Decide: keep or drop empty_dir()'s force-unmount of mounts beneath /tmp and /var/run
- [ ] B1 Document the manual Linux ABI mount path under no-fstab: create /etc/fstab with the five compat lines, in order, never `late`
- [ ] B2 org.nextbsd.linux one-shot LaunchDaemon + /usr/libexec/nextbsd-linux --compat [--native] (parked until Linux support is default)
- [ ] C1 diskarbitrationd: rename the Mach service to com.apple.DiskArbitration.diskarbitrationd and drop the stale hwregd comments
- [ ] C2 diskarbitrationd: build the DADisk model from GEOM (libgeom walk on kernel-registry arrival), log-only
- [ ] C3 diskarbitrationd: adopt mounts it did not make (EVFILT_FS + getmntinfo diff -> DADiskCreateFromVolumePath)
- [ ] C4 Filesystem bundles: /System/Library/Filesystems/{msdos,exfat,ntfs,ufs,cd9660,udf}.fs with an fstyp-backed *.util shim (FSUR_* contract)
- [ ] C5 diskarbitrationd: stage machine and mount executor -- /Volumes/<name>[ N], untrusted-media defaults, no auto-repair, per-FS helper table, /Volumes owned by the OS
- [ ] C6 diskarbitrationd: /etc/fstab UUID=/LABEL=/DEVICE= mount-map overlay, exactly Apple's semantics
- [ ] C7 kernel: compile in UDF, LIBICONV and the msdosfs/cd9660/udf iconv tables so DiskArbitration can mount UDF and non-ASCII FAT names (NO_MODULES)
- [ ] D1 DiskArbitration client library: port DAServer.defs MIG and libDiskArbitration (sessions, Register* callbacks, CopyDescription, DiskListComplete/Idle replay); datest becomes a real client
- [ ] D2 diskarbitrationd: unmount and eject requests with approval broadcast, 10 s response timer, dissenters, EBUSY -> dissenter PID via libprocstat, eject via CAM START STOP UNIT / CDIOCEJECT
- [ ] D3a Workspace: DiskArbitration bridge -- post NSWorkspace mount/unmount notifications through the workspace center, replace the 1.5 s mount poll with DA callbacks, and make GWUnmountHelper call DADiskUnmount/DADiskEject instead of sudo umount -f
- [ ] D3b Spike: count volumes mounted under /Volumes as removable in GNUstep NSWorkspace (GSRemovableMediaPaths is exact-match)
- [ ] D3c Spike: disk images (dmg/iso/squashfs) as DiskArbitration disks -- how VolumeManager's darling-dmg/fuseiso/squashfuse mounts under /Volumes stop depending on vfs.usermount
- [ ] D4 Console user for diskarbitrationd: State:/Users/ConsoleUser in configd, published by LoginWindow; defer removable/external auto-mounts until login, unmount at logout; agent dialogs without XPC/CFUserNotification
- [ ] D5 Drop patch 0008 (vfs.usermount=1) once Workspace's image mounts and user unmounts go through DiskArbitration -- or narrow it if AppImage self-mounting still needs it
- [ ] nextbsd/nextbsd#467 (migrated)
## Linked, not migrated
nextbsd/nextbsd-userland#171, nextbsd/nextbsd-userland#54, nextbsd/nextbsd#460, nextbsd/nextbsd#461, nextbsd/nextbsd#278, nextbsd/nextbsd-kernel#62, gershwin-desktop/gershwin-desktop#49, gershwin-desktop/gershwin-desktop#60, gershwin-desktop/issues#22, gershwin-desktop/issues#26, gershwin-desktop/gershwin-workspace#78, https://pkgdemon.github.io/nextbsd-e14-tickets.html (E14 swap tickets, K3 and U1)
A2, A3 -> A1 -> A4; A5 independent. B1 with A1; B2 parked. C1 -> C2 -> C3 / C4 -> C5 -> C6; C7 independent (kernel). D1 after C1/C2 -> D2 -> D3a; D3b independent (upstream); D3c spike -> D5; D4 after C5; D5 last.
</code></pre>
</div>
<h2 id="index">Index</h2>
<table class="compact">
<tr><th>ID</th><th>Ticket</th><th>Repo</th><th>Depends on</th><th>Status</th></tr>
<tr><td><a href="#a1"><strong>A1</strong></a></td><td>Stop shipping rootfs/private/etc/fstab (closes nextbsd#467)</td><td><a href="https://github.com/nextbsd/nextbsd-overlays">nextbsd-overlays</a></td><td><a href="#a2">A2</a>, <a href="#a3">A3</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-overlays/issues/4">nextbsd-overlays#4</a></span></td></tr>
<tr><td><a href="#a2"><strong>A2</strong></a></td><td>launchd: remount / with rw,noatime (the fstab root line was noatime's only source); CI asserts it</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/185">nextbsd-userland#185</a></span></td></tr>
<tr><td><a href="#a3"><strong>A3</strong></a></td><td>launchctl: compile out the dormant Darwin do_potential_fsck() path -- launchd owns root fsck and remount</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/186">nextbsd-userland#186</a></span></td></tr>
<tr><td><a href="#a4"><strong>A4</strong></a></td><td>Stale fstab comments in build.sh, the installer and its README; boot-test gate on the #467 strings</td><td><a href="https://github.com/nextbsd/nextbsd">nextbsd</a></td><td><a href="#a1">A1</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd/issues/472">nextbsd#472</a></span></td></tr>
<tr><td><a href="#a5"><strong>A5</strong></a></td><td>Decide: keep or drop empty_dir()'s force-unmount of mounts beneath /tmp and /var/run</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/187">nextbsd-userland#187</a></span></td></tr>
<tr><td><a href="#b1"><strong>B1</strong></a></td><td>Document the manual Linux ABI mount path under no-fstab: create /etc/fstab with the five compat lines, in order, never `late`</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/189">nextbsd-userland#189</a></span></td></tr>
<tr><td><a href="#b2"><strong>B2</strong></a></td><td>org.nextbsd.linux one-shot LaunchDaemon + /usr/libexec/nextbsd-linux --compat [--native] (parked until Linux support is default)</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#b1">B1</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/190">nextbsd-userland#190</a></span></td></tr>
<tr><td><a href="#c1"><strong>C1</strong></a></td><td>diskarbitrationd: rename the Mach service to com.apple.DiskArbitration.diskarbitrationd and drop the stale hwregd comments</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/191">nextbsd-userland#191</a></span></td></tr>
<tr><td><a href="#c2"><strong>C2</strong></a></td><td>diskarbitrationd: build the DADisk model from GEOM (libgeom walk on kernel-registry arrival), log-only</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c1">C1</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/192">nextbsd-userland#192</a></span></td></tr>
<tr><td><a href="#c3"><strong>C3</strong></a></td><td>diskarbitrationd: adopt mounts it did not make (EVFILT_FS + getmntinfo diff -> DADiskCreateFromVolumePath)</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c2">C2</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/193">nextbsd-userland#193</a></span></td></tr>
<tr><td><a href="#c4"><strong>C4</strong></a></td><td>Filesystem bundles: /System/Library/Filesystems/{msdos,exfat,ntfs,ufs,cd9660,udf}.fs with an fstyp-backed *.util shim (FSUR_* contract)</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c2">C2</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/194">nextbsd-userland#194</a></span></td></tr>
<tr><td><a href="#c5"><strong>C5</strong></a></td><td>diskarbitrationd: stage machine and mount executor -- /Volumes/<name>[ N], untrusted-media defaults, no auto-repair, per-FS helper table, /Volumes owned by the OS</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c2">C2</a>, <a href="#c4">C4</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/195">nextbsd-userland#195</a></span></td></tr>
<tr><td><a href="#c6"><strong>C6</strong></a></td><td>diskarbitrationd: /etc/fstab UUID=/LABEL=/DEVICE= mount-map overlay, exactly Apple's semantics</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c5">C5</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/196">nextbsd-userland#196</a></span></td></tr>
<tr><td><a href="#c7"><strong>C7</strong></a></td><td>kernel: compile in UDF, LIBICONV and the msdosfs/cd9660/udf iconv tables so DiskArbitration can mount UDF and non-ASCII FAT names (NO_MODULES)</td><td><a href="https://github.com/nextbsd/nextbsd-kernel">nextbsd-kernel</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-kernel/issues/228">nextbsd-kernel#228</a></span></td></tr>
<tr><td><a href="#d1"><strong>D1</strong></a></td><td>DiskArbitration client library: port DAServer.defs MIG and libDiskArbitration (sessions, Register* callbacks, CopyDescription, DiskListComplete/Idle replay); datest becomes a real client</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#c1">C1</a>, <a href="#c2">C2</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/197">nextbsd-userland#197</a></span></td></tr>
<tr><td><a href="#d2"><strong>D2</strong></a></td><td>diskarbitrationd: unmount and eject requests with approval broadcast, 10 s response timer, dissenters, EBUSY -> dissenter PID via libprocstat, eject via CAM START STOP UNIT / CDIOCEJECT</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#d1">D1</a>, <a href="#c5">C5</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/198">nextbsd-userland#198</a></span></td></tr>
<tr><td><a href="#d3a"><strong>D3a</strong></a></td><td>Workspace: DiskArbitration bridge -- post NSWorkspace mount/unmount notifications through the workspace center, replace the 1.5 s mount poll with DA callbacks, and make GWUnmountHelper call DADiskUnmount/DADiskEject instead of sudo umount -f</td><td><a href="https://github.com/gershwin-desktop/gershwin-workspace">gershwin-workspace</a></td><td><a href="#d1">D1</a>, <a href="#d2">D2</a></td><td><span class="pill ok">filed <a href="https://github.com/gershwin-desktop/gershwin-workspace/issues/119">gershwin-workspace#119</a></span></td></tr>
<tr><td><a href="#d3b"><strong>D3b</strong></a></td><td>Spike: count volumes mounted under /Volumes as removable in GNUstep NSWorkspace (GSRemovableMediaPaths is exact-match)</td><td><a href="https://github.com/nextbsd/nextbsd">nextbsd</a></td><td>—</td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd/issues/474">nextbsd#474</a></span></td></tr>
<tr><td><a href="#d3c"><strong>D3c</strong></a></td><td>Spike: disk images (dmg/iso/squashfs) as DiskArbitration disks -- how VolumeManager's darling-dmg/fuseiso/squashfuse mounts under /Volumes stop depending on vfs.usermount</td><td><a href="https://github.com/gershwin-desktop/gershwin-workspace">gershwin-workspace</a></td><td><a href="#d1">D1</a>, <a href="#d2">D2</a></td><td><span class="pill ok">filed <a href="https://github.com/gershwin-desktop/gershwin-workspace/issues/120">gershwin-workspace#120</a></span></td></tr>
<tr><td><a href="#d4"><strong>D4</strong></a></td><td>Console user for diskarbitrationd: State:/Users/ConsoleUser in configd, published by LoginWindow; defer removable/external auto-mounts until login, unmount at logout; agent dialogs without XPC/CFUserNotification</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td><td><a href="#d1">D1</a>, <a href="#d2">D2</a>, <a href="#c5">C5</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/199">nextbsd-userland#199</a></span></td></tr>
<tr><td><a href="#d5"><strong>D5</strong></a></td><td>Drop patch 0008 (vfs.usermount=1) once Workspace's image mounts and user unmounts go through DiskArbitration -- or narrow it if AppImage self-mounting still needs it</td><td><a href="https://github.com/nextbsd/nextbsd-kernel">nextbsd-kernel</a></td><td><a href="#d1">D1</a>, <a href="#d2">D2</a>, <a href="#d3a">D3a</a>, <a href="#d3c">D3c</a></td><td><span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-kernel/issues/229">nextbsd-kernel#229</a></span></td></tr>
</table>
<h2 id="tickets">Tickets</h2>
<h3 style="color:var(--accent)">Stage A — fstab and boot -- no DiskArbitration code; closes nextbsd#467</h3>
<div class="tk" id="a1">
<h3>A1 · Stop shipping rootfs/private/etc/fstab (closes nextbsd#467) <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-overlays/issues/4">nextbsd-overlays#4</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-overlays">nextbsd-overlays</a></td></tr>
<tr><td>Labels</td><td><code>bug</code> <code>area:storage</code></td></tr>
<tr><td>Depends on</td><td><a href="#a2">A2</a>, <a href="#a3">A3</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Delete `rootfs/private/etc/fstab` from the overlay seed (plan option A). This is the overlays-side change that closes nextbsd/nextbsd#467: with no `/etc/fstab`, launchctl's boot-time `mount -vat nonfs` (`src/launchd/support/launchctl.c:2401-2403`, gated on `path_check("/etc/fstab")`) never runs, so it can never try to union-mount `/dev/ufs/ROOTFS` over the live union.
The file has one commit (c0d0d1f) and one line:
```
/dev/ufs/ROOTFS / ufs rw,noatime 1 1
```
Both claims in its header are false: root comes from the kernel's `ROOTDEVNAME` (nextbsd-kernel `config/NEXTBSD:15`, nextbsd#188), not `loader.conf`, and launchctl does run `mount -a` (#467, nextbsd-userland#171).
## Why
#467 has the failure analysis; this ticket only records why removing the file is safe. Every consumer of `/etc/fstab` on a NextBSD image was checked (plan section 3):
- **launchd's root remount** -- `launchd_root_make_writable()` (`src/launchd/src/launchd.c:443-475`) resolves `/` with `statfs()` and runs `fsck -p /` then `mount -uw /`. FreeBSD `fsck(8)` with an operand uses `getmntpoint()` and defaults to `ufs` when there is no fstab entry (`sbin/fsck/fsck.c:206-217`); `mount -u` takes the device from `getmntpoint()` in the `have_fstab == 0` branch (`sbin/mount/mount.c:357-393`). Same result without the file.
- **The loader** -- `getrootmount()` (`stand/common/boot.c:320-407`) reads `/etc/fstab` off the root device and sets `vfs.root.mountfrom` and `vfs.root.mountfrom.options` from the root line. That is why the CI kernel prints `Trying to mount root from ufs:/dev/ufs/ROOTFS [rw,noatime]` (run 35544120227, img-test). Without the file it sets nothing and the kernel falls through to `ROOTDEVNAME` (`sys/kern/vfs_mountroot.c:930-932`), or to the `vfs.root.mountfrom` the installer writes to `loader.conf` on EFI installs (`do-install.sh:300`). The Pi has no loader. Root discovery is unchanged on all three.
- **`df`, `mount` with no arguments, shutdown** -- `getmntinfo()` and `reboot(2)`; not fstab readers.
- **The installer** -- clones the running root with cpdup and only edits fstab `[ -f ]` (`do-install.sh:288`). Installs made from a fstab-less live root simply have no fstab. Existing installs keep theirs: the overlay is not package-owned (nextbsd `build.sh:7-9`), so `pkg upgrade` never touches it.
- **`swapon -a`, `umount -a`, bare `fsck`** -- nothing runs them at boot. Run by hand they print `fstab: /etc/fstab:0: No such file or directory` (libc `gen/fstab.c:264, 286-293`). launchd's own tools also trigger that line inside `getfsfile()`, but `launchd_run_tool()` logs a tool's stderr only on non-zero exit (`launchd.c:434-437`), so the console stays quiet.
Apple stopped shipping `/etc/fstab` on Macs in 10.4; the file is an admin overlay read by `diskarbitrationd`, `fsck`, `mount` and `umount`, never a boot mount list (plan section 2).
What the root line provides today, and what replaces it:
| Provided by the root line | After removal |
|---|---|
| `noatime` on `/` (via the loader, via `mount -uw /` merging fstab options at `mount.c:385-387`, and via `mount -vat`) | **A2**: launchd remounts with `-o rw,noatime` |
| a second-chance `fsck -fy` + `mount -uw /` in launchctl if launchd's remount failed (`launchctl.c:4060-4111`) | **A3**: that dormant Darwin path is compiled out; without fstab it would halt the machine instead |
## Design
**Option A (recommended): remove the file.** `git rm rootfs/private/etc/fstab`. Nothing else in this repo references it (the tree holds only `rootfs/boot/loader.conf.d/nextbsd.conf` and this file under `rootfs/`). This is what every Mac since 10.4 ships.
**Option B (fallback the maintainer may prefer): comment-only file.** Same effect on #467; `mount -vat nonfs` runs and mounts nothing; FreeBSD tools run by hand stop printing the "No such file" line, and admins have an obvious place for their own lines. Suggested content:
```
# /etc/fstab -- admin-maintained, optional. The kernel mounts the root
# filesystem (ROOTDEVNAME, or vfs.root.mountfrom from loader.conf) and
# launchd remounts it read-write; do not list / here. Lines added here are
# mounted in file order by `mount -vat nonfs` during launchctl bootstrap
# (support/launchctl.c). `late` entries are never mounted.
```
Not chosen: #467's option A (`noauto` on the root line) keeps an entry that names the wrong device on live media; #467's option B (live-only override) leaves the disk image and the install medium with different fstabs.
## Scope
One file. Image behaviour changes only for images built after this lands.
## Before starting
- [ ] A2 is merged and in the NextBSD-userland package the image build installs, so installed disks keep `noatime`
- [ ] A3 is merged, or explicitly accepted as a follow-up (it only changes the path taken when launchd's remount has already failed)
## Acceptance
- [ ] `rootfs/private/etc/fstab` is gone (A) or comment-only with no root line (B); `git grep fstab` in this repo finds nothing else
- [ ] CI iso-test transcript (amd64 and arm64) contains neither `Cannot union mount root filesystem` nor `fwexec(mount_tool` (A4 adds the gate)
- [ ] CI img-test transcript shows `/dev/ufs/ROOTFS on / (ufs, local, noatime, soft-updates` and the kernel line reads `Trying to mount root from ufs:/dev/ufs/ROOTFS []` (ROOTDEVNAME path); boot reaches `login:`
- [ ] A fresh install from the new live medium boots to `login:` with `/` read-write; `df /` and `mount` still show `/dev/ufs/NEXTBSD`
- [ ] nextbsd/nextbsd#467 is closed by the merging PR; its "header comment describes what processes the file" acceptance line is met by there being no header (A) or by the text above (B)
## Note
This repo has **no `area:*` labels** (GitHub defaults only). Create `area:storage` here before filing.
## Refs
Plan sections 1, 3, 7 (Stage A), 8: https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html. nextbsd/nextbsd#467, nextbsd/nextbsd-userland#171, nextbsd/nextbsd#188. `launchctl.c:2401-2403`, `launchd.c:443-475`, `stand/common/boot.c:320-407`, `sbin/mount/mount.c:357-393`, `sbin/fsck/fsck.c:206-217`, `do-install.sh:288, 300`.</code></pre>
</div>
<div class="tk" id="a2">
<h3>A2 · launchd: remount / with rw,noatime (the fstab root line was noatime's only source); CI asserts it <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/185">nextbsd-userland#185</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:boot</code></td></tr>
<tr><td>Depends on</td><td>—</td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
`launchd_root_make_writable()` remounts the root with `/sbin/mount -uw /` (`src/launchd/src/launchd.c:446`). Today `/` ends up `noatime` only because the shipped fstab root line says so. When A1 removes that line, `noatime` is lost. Move it into launchd:
```c
const char *mount_argv[] = { "/sbin/mount", "-u", "-o", "rw,noatime", "/", NULL };
```
and make CI assert it on the `/` mount line of the disk image.
## Why
Observed today (CI run 35544120227, img-test amd64 and arm64): `/dev/ufs/ROOTFS on / (ufs, local, noatime, soft-updates, ...)`. Three things put `noatime` there, and all three read the fstab root line:
1. The loader's `getrootmount()` (`stand/common/boot.c:320-407`) copies the line's options into `vfs.root.mountfrom.options`, so the kernel's initial read-only root mount already carries `noatime` (`vfs_mountroot.c:789-790, 1124-1166`: `rw` is dropped, other options pass through). Hence `Trying to mount root from ufs:/dev/ufs/ROOTFS [rw,noatime]` in the log.
2. `mount -uw /` finds the fstab entry for `/` and merges its options (`sbin/mount/mount.c:369-387`, `update_options(options, fs->fs_mntops, ...)`).
3. launchctl's `mount -vat nonfs` re-applies the line (`launchctl.c:2401-2403`).
Without the file, 1 and 3 do nothing and 2 passes only `noro` (`mount.c:388-391`, `update_options(options, NULL, ...)`). An `MNT_UPDATE` mount clears every `MNT_UPDATEMASK` flag that is not re-specified, and `MNT_NOATIME` is in that mask (`sys/kern/vfs_mount.c:1423-1430`; `sys/sys/mount.h:442-448`). So even a kernel-side `noatime` would not survive launchd's remount. The option has to be on launchd's command line.
This is also the Darwin shape: Apple keeps boot-critical mount options in boot code, not in fstab (plan section 2).
## Design
- `launchd.c:446`: `-u -o rw,noatime` in place of `-uw`. `rw` is `noro` to the kernel (`vfs_mount.c:930-937`); `noatime` sets `MNT_NOATIME` (`vfs_mount.c:894-895`). Stays filesystem-agnostic: both are generic `nmount` options.
- Optionally extend the `root-rw: / remounted read-write` notice (`launchd.c:471-472`) to say `read-write,noatime`, so the transcript shows the intent as well as the result.
- Works with the fstab still present (the merged options are identical) and without it, so this can land before A1.
**CI assertion.** The disk-image harness already runs `mount | grep ' / '` after login (nextbsd `tests/img-boot-test.sh:105-109`), but its `-re "ufs"` match fires on the echoed device name -- in the last run it printed `OK: ROOT-IS-UFS` after seeing `/dev/ufs/R` and before the rest of the line arrived -- so it proves nothing about mount flags. Add a transcript check in the verdict section of `tests/img-boot-test.sh` (lines 121-130, after `echo "==> verdict"` and before the `login:` check), in the same shape as the `DARWIN-SYSCTL-NOISE` gate in this repo's `tests/boot-test.sh:1527-1533` (`grep -aE` over `$LOG`, `echo "FAIL: MARKER -- reason"`, `exit 1`, else `echo "OK: MARKER"`):
```sh
# / must be mounted noatime by launchd's own remount, not by an fstab line
# (nextbsd-userland A2; the overlay ships no fstab after A1).
if ! grep -aE ' on / \(ufs, local, noatime' "$LOG"; then
echo "FAIL: ROOT-NOATIME -- / is mounted without noatime"
exit 1
fi
echo "OK: ROOT-NOATIME"
```
`$LOG` is `tests/img-boot.log` (`img-boot-test.sh:32`), the serial transcript, where the line is intact. The live ISO is out of scope: its `/` is `<above>:/cow on / (unionfs, local)`. This repo's own `tests/boot-test.sh` boots a native disk image but runs no `mount` command; adding one there is optional.
## Acceptance
- [ ] `launchd.c:446` passes `rw,noatime`; `grep -n '"-uw"' src/launchd/src/launchd.c` is empty
- [ ] With the current fstab still present, img-test shows `/dev/ufs/ROOTFS on / (ufs, local, noatime, soft-updates` (no behaviour change)
- [ ] With `/etc/fstab` absent, the same line still shows `noatime`
- [ ] `root-rw: / remounted read-write` is still logged once and no `root-rw: ... stderr:` line appears
- [ ] nextbsd `tests/img-boot-test.sh` fails when the `/` line lacks `noatime` (test by temporarily reverting the option) and passes otherwise
## Refs
Plan sections 1, 3 (recommendation, companion change 1): https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html. nextbsd/nextbsd#467. `launchd.c:443-475`, `stand/common/boot.c:320-407`, `sbin/mount/mount.c:357-393`, `sys/kern/vfs_mount.c:894-895, 930-937, 1423-1430`, `sys/sys/mount.h:442-448`, nextbsd `tests/img-boot-test.sh:105-130`.</code></pre>
</div>
<div class="tk" id="a3">
<h3>A3 · launchctl: compile out the dormant Darwin do_potential_fsck() path -- launchd owns root fsck and remount <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/186">nextbsd-userland#186</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:boot</code></td></tr>
<tr><td>Depends on</td><td>—</td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Two pieces of code want to fsck and remount `/`:
- launchd (PID 1): `launchd_root_make_writable()` runs `fsck -p /` and `mount -uw /` before any job (`src/launchd/src/launchd.c:313, 443-475`). NextBSD-local, valid FreeBSD flags, runs first.
- launchctl (`bootstrap -S System`): `system_specific_bootstrap()` calls `do_potential_fsck()` (`src/launchd/support/launchctl.c:2357`). The function (`launchctl.c:4019-4115`) is byte-identical to Apple launchd-842.92.1 `support/launchctl.c:3992` and its flags are Darwin's.
Keep launchd's. Compile launchctl's out on FreeBSD, the way nextbsd-userland#176 did for `is_safeboot()` / `is_netboot()`.
## Why
`do_potential_fsck()` returns at `launchctl.c:4036-4038` because launchd already made `/` read-write. It only runs its body when launchd's remount failed (`launchd.c:467-469`, `mount -uw / exited N -- / left read-only`), and on FreeBSD that body is wrong twice:
1. `fsck -q` (`launchctl.c:4024, 4048`). FreeBSD `fsck(8)` accepts `BCdvpfFnyl:t:T:c:` (`sbin/fsck/fsck.c:111`); there is no `-q`, so `usage()` exits 1 (`fsck.c:573-581`). launchctl logs `fsck exited with status: 1` and falls through to
2. `fsck -fy` with no operand (`launchctl.c:4023, 4060`). With no operand fsck runs `checkfstab()` (`fsck.c:184-185`). With no `/etc/fstab` (A1) `preen.c:99-101` prints `Can't open checklist file` and returns 8; launchctl logs `Safe fsck exited with status: 8`, then `fsck failed! Shutting down in 3 seconds.` and `reboot(RB_HALT)` (`launchctl.c:4076-4078`). A read-only-root boot becomes a halt.
With today's fstab the same path instead fscks the root line and retries `mount -uw /` (`launchctl.c:4111`) -- a second-chance remount launchd's error path does not get. Removing the fstab removes that second chance, so this must be decided together with A1. A single owner is also what Apple's launchd did: the Mac's fsck/remount lived in one place (launchctl), never two.
Stale comments to fix in the same change: `launchd.c:307-312` ("Apple does this in launchctl's do_potential_fsck() ahead of the scan") and `launchd.c:381-392` ("this port dropped that bootstrapper. Restore the step here"). The bootstrapper is back (`launchd.c:355-373`); the comments should say launchd owns the transition and launchctl's Darwin path is compiled out.
## Design
**Option 1 (recommended): `#ifdef __FreeBSD__` inside the function.** Match `is_safeboot()` (`launchctl.c:4208-4212`) and `is_netboot()` (`launchctl.c:4228-4232`): FreeBSD body first, Apple's under `#else`, one comment naming this ticket. FreeBSD body: `statfs("/")`; if not `MNT_RDONLY` return; otherwise `launchctl_log(LOG_ERR, "/ is still read-only after launchd's remount (see root-rw: in the console log); continuing")` and return. No fsck, no remount, no halt. Leave the call at `launchctl.c:2357` alone to keep the diff against Apple small.
**Option 2: delete the function and the call.** Larger diff from upstream; nothing gained.
**Not: fix the flags** (`fsck -p /`, `fsck -fy /`). That keeps two owners and a second `fsck` of a filesystem launchd already checked.
Add a row for `do_potential_fsck()` to `docs/launchd-darwin-probes.md` (the disposition table at lines 15-27) so the dormant path is listed with the other stubbed Darwin probes.
## Scope
~15 lines in `launchctl.c`, comment edits in `launchd.c`, one doc row.
## Acceptance
- [ ] On FreeBSD builds launchctl never execs `fsck`: `grep -n 'fsck' src/launchd/support/launchctl.c` shows the strings only under `#else` / Apple's branch
- [ ] Forced failure test (e.g. make `/sbin/mount` non-executable in a scratch image): boot reaches `login:` with `/` read-only, the console shows launchd's `root-rw: mount -uw / exited` line and launchctl's new line, and the machine does not halt
- [ ] Normal boot unchanged: `root-rw: / remounted read-write` once; CI img-test and iso-test green
- [ ] `launchd.c:307-312` and `381-392` describe the current ownership
- [ ] `docs/launchd-darwin-probes.md` lists `do_potential_fsck()` with its disposition
## Refs
Plan section 3 (companion change 2) and section 1 step 3b: https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html. nextbsd/nextbsd-userland#176, nextbsd/nextbsd#324. `launchctl.c:2357, 4019-4115`, `launchd.c:307-313, 381-392, 443-475`, `sbin/fsck/fsck.c:111, 184-185, 573-581`, `sbin/fsck/preen.c:99-101`.</code></pre>
</div>
<div class="tk" id="a4">
<h3>A4 · Stale fstab comments in build.sh, the installer and its README; boot-test gate on the #467 strings <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd/issues/472">nextbsd#472</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd">nextbsd</a></td></tr>
<tr><td>Labels</td><td><code>documentation</code> <code>area:storage</code> <code>area:live-media</code> <code>area:ci</code></td></tr>
<tr><td>Depends on</td><td><a href="#a1">A1</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Two parts, one PR per repo:
1. Comments in nextbsd `build.sh` and in nextbsd-userland's installer say the shipped `/etc/fstab` is where the root entry lives. After A1 there is no such file, and the claims were already wrong (root comes from the kernel's `ROOTDEVNAME`, nextbsd#188).
2. The live-ISO harness gets a regression gate that fails on the two #467 strings, so the root remount can never come back unnoticed.
## Comments
nextbsd (this repo):
- `build.sh:7` -- the list of overlay-seeded `/etc` files names `fstab`. Drop it.
- `build.sh:318-319` -- "No /etc/fstab heredoc -- the nextbsd-overlays seed (rootfs/private/etc/fstab) carries the real root entry, and nextbsd-overlays rootfs/boot/loader.conf.d/ carries the loader settings". The root entry is `ROOTDEVNAME` in nextbsd-kernel `config/NEXTBSD:15`; `loader.conf.d/nextbsd.conf` says itself that `vfs.root.mountfrom` is gone (#188). Say: no fstab is shipped; the kernel mounts root from `ROOTDEVNAME`, launchd remounts it `rw,noatime` (A2).
- `build.sh:356-357` -- `"ROOTFS" matches loader.conf.d's vfs.root.mountfrom and the the nextbsd-overlays seed (rootfs/private/etc/fstab) entry`. It matches `ROOTDEVNAME`. Also "the the".
nextbsd-userland (`src/nextbsd-installer/`):
- `engine/do-install.sh:14-15` -- "the shipped /etc/fstab (ufs/ROOTFS) and the kernel's baked-in ufs:/dev/ufs/ROOTFS root both resolve with NO edits". Only the kernel default remains.
- `engine/do-install.sh:45` -- "The cloned fstab + a loader.conf override (step 5b) point the target here". Only the `loader.conf` override (EFI) or `cmdline.txt` (Pi, lines 353-388) does.
- `engine/do-install.sh:238-239` -- "the mount + fstab steps below".
- `engine/do-install.sh:282-291` -- step 5b's comment ("cpdup copied the source's fstab ... Repoint both") and the `sed` at line 288. The clone carries no fstab (under option B it carries no root line), so the `sed` is dead: remove it and reword the comment around the `loader.conf` override at line 300. The Pi paragraph at 289-291 ("the label in fstab above plus the kernel's compiled-in ROOTDEVNAME") becomes ROOTDEVNAME alone.
- `README.md:13-15` -- same claim as `do-install.sh:14-15`.
`build.sh:885-975` (the live `/init`) and `do-install.sh:300` are correct and need no change.
## Gate
The strings, verbatim from CI run 35544120227 (iso-test amd64 and arm64):
```
mount: /dev/ufs/ROOTFS: Cannot union mount root filesystem: Operation not supported
posix_assumes_zero: fwexec(mount_tool, NULL) == -1 (errno 2) at launchctl.c:2403
```
The first is mount(8) printing the kernel's nmount error; the second is launchctl's assert on the failed `mount -vat nonfs` (`launchctl.c:2403`).
Where: `tests/iso-boot-test.sh` verdict section (lines 130-140), which already greps the serial transcript `$LOG` (`tests/iso-boot.log`, line 25) for the pivot marker and `login:`. Match the shape of the `DARWIN-SYSCTL-NOISE` gate in nextbsd-userland `tests/boot-test.sh:1527-1533` -- `grep -aE` over `$LOG`, `echo "FAIL: MARKER -- reason"`, `exit 1`, else `echo "OK: MARKER"` -- and place it after `echo "==> verdict"` and before the PASS check:
```sh
# launchctl's boot-time `mount -vat nonfs` must never touch / (nextbsd#467).
if grep -aE 'Cannot union mount root filesystem|fwexec\(mount_tool' "$LOG"; then
echo "FAIL: FSTAB-ROOT-REMOUNT -- launchctl mount -a tried to remount / on the live union (nextbsd#467)"
exit 1
fi
echo "OK: FSTAB-ROOT-QUIET"
```
Add the same block to `tests/img-boot-test.sh` (verdict at lines 121-130, `$LOG` = `tests/img-boot.log`); the `fwexec(mount_tool` half catches any other `mount -a` failure on the disk image. Do not touch `tests/boot-test.sh`: `build.yml` runs only `img-boot-test.sh` (line 395) and `iso-boot-test.sh` (line 454).
The gate is red until A1 lands, so file it together with A1 or merge the comment fixes first and the gate with A1.
## Acceptance
- [ ] `grep -n fstab build.sh` in nextbsd and `grep -rn fstab src/nextbsd-installer` in nextbsd-userland list no line that presents fstab as the source of the root entry; `do-install.sh:288` is gone
- [ ] `tests/iso-boot-test.sh` and `tests/img-boot-test.sh` fail on either #467 string (verified by running the harness against an ISO built with the old fstab) and print `OK: FSTAB-ROOT-QUIET` on main after A1
- [ ] CI green on amd64 and arm64 for both harnesses
## Refs
Plan sections 1, 7 (Stage A), 8: https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html. nextbsd/nextbsd#467, nextbsd/nextbsd#188. `build.sh:7, 318-319, 356-357`, `do-install.sh:14-15, 45, 238-239, 282-291, 300`, `README.md:13-15`, `tests/iso-boot-test.sh:130-140`, `tests/img-boot-test.sh:121-130`, nextbsd-userland `tests/boot-test.sh:1527-1533`.</code></pre>
</div>
<div class="tk" id="a5">
<h3>A5 · Decide: keep or drop empty_dir()'s force-unmount of mounts beneath /tmp and /var/run <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/187">nextbsd-userland#187</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>area:storage</code> <code>area:boot</code> <code>area:research</code></td></tr>
<tr><td>Depends on</td><td>—</td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
During `launchctl bootstrap -S System`, right after the fstab pass (`support/launchctl.c:2401-2403`), `empty_dir(_PATH_VARRUN)` and `empty_dir(_PATH_TMP)` run (`launchctl.c:2432-2433`). `empty_dir()` (`launchctl.c:4246-4316`, identical to Apple launchd-842.92.1 `support/launchctl.c:4207`) force-unmounts any entry whose `st_dev` differs from the directory's (`launchctl.c:4288-4289`, `unmount(de->d_name, MNT_FORCE)`), then deletes everything underneath. Decide whether NextBSD keeps that behaviour or skips mount points.
## What it does, precisely
- The baseline device is the directory itself (`lstat(thedir)`, `launchctl.c:4252-4258`). A tmpfs mounted **on** `/tmp` or `/var/run` is therefore not unmounted; it is just emptied (nothing to empty on a fresh tmpfs). The plan's section 1 line "an fstab tmpfs on /tmp is undone one step after it is mounted" overstates this.
- Anything mounted **beneath** them (`/tmp/scratch`, `/var/run/foo`) is force-unmounted; after a successful unmount the mount-point directory itself is kept (`launchctl.c:4294-4300`). This is the case that hits nextbsd-userland#171's suggested verification ("tmpfs on /tmp/scratch in fstab") -- it is mounted at line 2402 and unmounted at line 2433, and only a failed unmount would print anything.
Apple: 10.4-10.9 launchctl did exactly this. 10.10+ moved the sweep to a `dirs_cleaner` boot task (closed source). The plan says modern `dirs_cleaner` skips mount points; that is not verifiable from open source and should be treated as unconfirmed.
NextBSD today: nothing mounts beneath either path. The live `/init` mounts `/media`, `/rofs`, `/cow` and `/rofs/dev` (`build.sh:906-964`); no LaunchDaemon plist mounts; the installer scrubs the same directories at install time (`do-install.sh:274-277`). After A1 the only way for a mount to be there before `empty_dir()` runs is an admin `/etc/fstab` line.
## Options
**1. Keep Apple's behaviour and document it.** Zero code. Add a paragraph to `docs/launchd-darwin-probes.md` (or a new `docs/launchd-boot-sequence.md`) and to the fstab guidance B1 writes for #54/#171: "mounts beneath /tmp and /var/run are unmounted at boot; mount tmpfs on them, not under them".
**2. Skip mount points.** In `empty_dir()`, under `#ifdef __FreeBSD__`, when `psb->st_dev != sb.st_dev` log and `continue` instead of unmounting and recursing. About five lines. An fstab tmpfs on `/tmp/x` or `/var/run/x` then survives; whatever is on it is that mount's own business (a fresh tmpfs is empty anyway).
**3. Reorder: sweep before the fstab pass.** Considered and rejected: on a fresh boot there is no stale mount to catch, so it buys nothing over 2 while departing from Apple's sequence.
## Recommendation
Option 1 now. There is no consumer, a tmpfs on `/tmp` itself already works, and it keeps `empty_dir()` byte-identical to upstream. Revisit if a real requirement for a mount beneath `/var/run` or `/tmp` appears (Stage C/D do not add one: DiskArbitration mounts under `/Volumes`); option 2 is then a five-line change.
## Acceptance
- [ ] Decision recorded: a comment at `launchctl.c:2432` naming this issue, plus the doc paragraph
- [ ] #171's verification instruction is corrected (B1) so it does not test with a mount under `/tmp`
- [ ] If option 2 is chosen: a boot with `tmpfs /tmp/x tmpfs rw 0 0` in `/etc/fstab` leaves `/tmp/x` mounted and CI stays green
## Refs
Plan sections 1 (step 3e), 2, 7 (Stage A), 8: https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html. nextbsd/nextbsd-userland#171, nextbsd/nextbsd-userland#54. `launchctl.c:2401-2403, 2432-2433, 4246-4316`; Apple launchd-842.92.1 `support/launchctl.c:2432-2433, 4207`.</code></pre>
</div>
<h3 style="color:var(--accent)">Stage B — Linux ABI mounts -- the manual path under no-fstab, and the parked org.nextbsd.linux one-shot</h3>
<div class="tk" id="b1">
<h3>B1 · Document the manual Linux ABI mount path under no-fstab: create /etc/fstab with the five compat lines, in order, never `late` <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/189">nextbsd-userland#189</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>documentation</code> <code>area:linux</code> <code>area:storage</code></td></tr>
<tr><td>Depends on</td><td>—</td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Write down the supported manual path for the Linux ABI filesystems now that the image ships no `/etc/fstab` (E15 A1): **an admin who wants the Linuxulator mounts creates `/etc/fstab` with the five compat lines below, in this order, and never uses `late`.** Optionally add the four native-root lines for AppImages. Nothing else is needed: `launchctl bootstrap` already runs `mount -vat nonfs` whenever the file exists.
This is the documentation half of the #54 decision ("no LaunchDaemon at this time -- mounts stay manual"). It does not change that decision; it makes the manual path correct, complete and findable. B2 is the parked Darwin-shaped upgrade.
## Why
- #54 and #460 both say `/etc/fstab` is inert on NextBSD. It is not: `support/launchctl.c:2400-2405` runs `mount -vat nonfs` inside `if (path_check("/etc/fstab"))`, as Apple's launchd-842 did. #171's own reboot evidence (five compat mounts present after a reboot with no manual mount) is this code path working.
- #460's recorded fstab block carries a `lindebugfs ... rw,late` line that will never mount, and a header that says nothing runs `mount -a`. #54's procedure says "everything here is lost on reboot", which is only true for the by-hand `mount` commands, not for fstab lines.
- Under A1 the stock image ships no fstab at all, so "append these lines" becomes "create the file". Apple's admin hook is exactly this: `[ -f /etc/fstab ] && mount -vat nonfs`, skipped on every stock Mac (plan section 2).
## Design
The document says, in this order:
**1. The compat set (rc.d/linux's five mounts, `libexec/rc/rc.d/linux:74-80` in releng/15.0).** Create `/etc/fstab` (or append, on a system that still has one) with exactly:
```
linprocfs /compat/linux/proc linprocfs rw,nocover 0 0
linsysfs /compat/linux/sys linsysfs rw,nocover 0 0
devfs /compat/linux/dev devfs rw,nocover 0 0
fdescfs /compat/linux/dev/fd fdescfs rw,nocover,linrdlnk 0 0
tmpfs /compat/linux/dev/shm tmpfs rw,nocover,mode=1777 0 0
```
- **Order matters and file order is mount order.** `mount -a` walks `getfsent()` sequentially (`sbin/mount/mount.c:300-323`), so `devfs` on `/compat/linux/dev` is mounted before `fdescfs` on `/compat/linux/dev/fd` (devfs supplies the `fd` directory) and before the tmpfs on `/compat/linux/dev/shm` (`linux_dev_shm_create()` puts `shm/` into every devfs instance at ABI init, `sys/compat/linux/linux.c:699-709`, so no `mkdir` is needed for either).
- **`linrdlnk` is not optional** (#54: Bun resolves cwd through `readlink("/dev/fd/N")`).
- **`nocover`** is what rc.d/linux passes; it keeps a second `mount -a` (or a stray manual mount) from stacking a filesystem on top of a live one. Optional but recommended.
- `/compat/linux/proc` and `/compat/linux/sys` must exist as directories: `linux_base-rl9` provides them (#171 observed them empty), `mount -a` does not `mkdir`.
- Optional: `failok` on each line keeps `launchctl`'s `posix_assumes_zero(fwexec(mount_tool))` quiet when `/compat/linux` is absent (`mount.c:311-314`: a `failok` line's failure does not set the exit status).
**2. Never `late`.** launchctl runs plain `-a`; `mount.c:307-310` skips any line carrying `late` unless `-l`/`-L` was given (`mount.c:226-243`), and nothing on NextBSD ever passes them. The FreeBSD Handbook's `late` on these lines exists to sequence against rc.d ordering, which NextBSD does not have. Also drop the `lindebugfs ... late` line from #460 (it never mounts; nothing in rc.d/linux mounts it either).
**3. The native set (optional, for AppImages; #54's "canonical" AppImage configuration).** After `mkdir -p /proc /sys`:
```
linprocfs /proc linprocfs rw,nocover 0 0
linsysfs /sys linsysfs rw,nocover 0 0
fdescfs /dev/fd fdescfs rw,nocover,linrdlnk 0 0
tmpfs /dev/shm tmpfs rw,nocover,mode=1777 0 0
```
with the warning #54 already records: `linprocfs` on the real `/proc` is a system-wide change that native binaries see too. Say so and leave it opt-in. (No `devfs` line: the kernel already mounts `/dev`; `/dev/fd` and `/dev/shm` exist inside it.)
**4. What runs, and when.** Step by step, cited: launchd remounts `/` rw (`src/launchd.c:443-475`); `launchctl bootstrap` applies `/etc/sysctl.conf` (`launchctl.c:2326`), runs `mount -vat nonfs` if fstab exists (`launchctl.c:2400-2405`), force-unmounts anything under `/var/run` and `/tmp` (`launchctl.c:2432-2433` -- so never put a tmpfs on `/tmp` in fstab), then `load -D all` starts the LaunchDaemons (`launchctl.c:2469-2476`). There is no in-process plist scan any more (`src/launchd.c:352-372`).
**5. After `pkg install linux_base-rl9` on a running system:** `mount -a` by hand is idempotent (`ismounted()` skips mounted lines, `mount.c:315-318`, and `nocover` refuses to stack), or `mount /compat/linux/proc` etc. by mount point. Chrome/claude-code need the mounts before they start.
**6. No sysctl is needed.** `kern.elf64.fallback_brand` is already 3 by kernel default (nextbsd-kernel patch 0009 / kernel#68). If an admin wants to change it, `/etc/sysctl.conf` is applied at bootstrap (`launchctl.c:2326`, `4330-4365`) -- mark this "not verified on a running box" until someone has.
**7. What is deliberately not done**: no LaunchDaemon (#54 decision), no autofs, no WatchPaths (inert on this launchd; see B2). Point at B2 as the path when Linux support becomes default.
### Where it lives
`nextbsd-userland/docs/linux-abi-mounts.md`, next to `docs/launchd-darwin-probes.md`. Reasons: the behaviour being documented is `launchctl bootstrap`'s (this repo); `docs/` already holds launchd behaviour notes in this format; a man page would be for a tool that does not exist under option H; the wiki is unused. Two pointers elsewhere: a paragraph in the `nextbsd-overlays` README (it owns `/etc` and says "mounts" are admin-owned) linking to the doc, and an edit to the top of #54 replacing the "everything here is lost on reboot" procedure with the fstab form and a link. The `nextbsd-overlays` fstab header fix itself is A1/A4, not this ticket.
## Scope
One Markdown file, one README paragraph, one issue edit, plus the #171/#460 corrections listed in the epic. No code.
## Before starting
- [ ] Decide A vs B for A1 (no file vs comment-only file), so the doc says "create" or "append" correctly. Draft it to work either way ("create `/etc/fstab` if it does not exist").
## Acceptance
- [ ] `docs/linux-abi-mounts.md` exists with the five compat lines verbatim, the ordering rule, the `late` rule, and the `launchctl.c` citations above.
- [ ] On a fresh image with `linux_base-rl9` installed and only those five lines in `/etc/fstab`, a reboot yields all five in `mount` output with no manual command; `sh -c 'exec 9</etc/passwd; readlink /dev/fd/9'` run under the Linuxulator returns a path (#54's check).
- [ ] The same file with a `late` line added: that line is absent from `mount` after reboot (documents the rule by test).
- [ ] `mount -a` run twice by hand does not stack mounts (`nocover`) and exits 0.
- [ ] `nextbsd-overlays` README and #54's top section link to the doc; #460's fstab block is marked superseded by it.
## Refs
Plan sections 1 (boot sequence), 3 (fstab audit), 5 (option H), 8 (corrections). `support/launchctl.c:2326, 2400-2405, 2432-2433, 2469-2476`; `src/launchd.c:352-372, 443-475`; FreeBSD `sbin/mount/mount.c:226-243, 300-323`; `libexec/rc/rc.d/linux:74-80`; `sys/compat/linux/linux.c:699-709`. nextbsd-userland#54, #171; nextbsd#460, #461.</code></pre>
</div>
<div class="tk" id="b2">
<h3>B2 · org.nextbsd.linux one-shot LaunchDaemon + /usr/libexec/nextbsd-linux --compat [--native] (parked until Linux support is default) <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/190">nextbsd-userland#190</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:linux</code> <code>area:storage</code> <code>status:parked</code></td></tr>
<tr><td>Depends on</td><td><a href="#b1">B1</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
**Parked.** The maintainer decision in #54 is "no LaunchDaemon at this time -- mounts stay manual" (B1 documents that path). This ticket records the Darwin-shaped design for when Linux support becomes default, so it is not re-derived from scratch. Do not start it until that decision is revisited.
`org.nextbsd.linux`: a one-shot LaunchDaemon (`RunAtLoad`, no `KeepAlive`) that runs `/usr/libexec/nextbsd-linux --compat [--native]`, the NextBSD owner of what `rc.d/linux` does on FreeBSD. It is idempotent, a no-op when `/compat/linux` is absent, ships in the package so installs get it on upgrade, and is re-run after a package install with `launchctl start org.nextbsd.linux`.
## Why
- Apple's pattern everywhere is that the daemon that switches a subsystem on also provisions its mounts and registers its exec handler: `vminitd` mounts proc/sysfs/devtmpfs/`/dev/shm`/devpts per container (`apple/containerization`, `Sources/Containerization/LinuxContainer.swift:445-456`, `defaultMounts()`), and the Rosetta guest agent mounts the virtiofs share and then writes the binfmt_misc registration (`Sources/Containerization/Vminitd+Rosetta.swift:21-34`, `Sources/ContainerizationOS/Linux/Binfmt.swift:73-82`). That registration is the analogue of `kern.elf64.fallback_brand`.
- On FreeBSD the same job is `libexec/rc/rc.d/linux` (releng/15.0): module loads (`:34-63`, gone on NextBSD -- the Linuxulator, linprocfs, linsysfs and fdescfs are static), `fallback_brand` only if `-1` (`:66-72`), and the five mounts with `nocover` (`:74-80`, gated by `linux_mounts_enable`).
- A fstab line is Apple's admin hook, not a product default. A shipped default belongs to the subsystem's own job, which reaches installed systems through `pkg upgrade` (the overlays repo is seed-once and never does).
- NextBSD precedent for an `org.nextbsd.*` daemon that owns an rc.d job's work: `overlay/System/Library/LaunchDaemons/org.nextbsd.wland.plist` (VAP creation was rc.conf's job on FreeBSD; its header explains the label choice -- ours, not `com.apple.*`, because Apple ships no such daemon).
## Design
### The tool: `/usr/libexec/nextbsd-linux`
A `/bin/sh` script is acceptable here (precedent: `overlay/usr/libexec/sshd-keygen-wrapper`). Behaviour:
1. `emul=$(sysctl -n compat.linux.emul_path)`; if `$emul` is not a directory, exit 0 silently. (Evaluation criterion 1 in #54: clean no-op with no Linux userland.)
2. `--compat`: for each of `rc.d/linux:75-79`, in that order:
`linprocfs $emul/proc nocover`; `linsysfs $emul/sys nocover`; `devfs $emul/dev nocover`; `fdescfs $emul/dev/fd nocover,linrdlnk`; `tmpfs $emul/dev/shm nocover,mode=1777`.
Idempotency has two layers: first `statfs(2)` on the mount point (skip if `f_fstypename` already matches, the `mount | grep` check of `rc.d/linux:22`), then `-o nocover` as the belt-and-braces guard, with `EBUSY` from `nocover` treated as "already mounted", exit 0. `mkdir -p` the two directory mount points only; `/dev/fd` and `/dev/shm` come from devfs (`sys/compat/linux/linux.c:699-709`).
3. `--native` (optional flag; off by default because it is a system-wide change, #54): `mkdir -p /proc /sys`, then `linprocfs /proc`, `linsysfs /sys`, `fdescfs /dev/fd linrdlnk`, `tmpfs /dev/shm mode=1777`, same guards. No devfs on `/dev` (kernel-mounted).
4. Re-assert `kern.elf64.fallback_brand=3` **only if it reads `-1`** (`rc.d/linux:66-68`), so a `loader.conf` override sticks. Never touch `kern.elf32.fallback_brand` (no 32-bit ABI is compiled in; kernel#68).
5. Exit non-zero only on a real mount failure; log one line per action to stderr.
### The plist: `overlay/System/Library/LaunchDaemons/org.nextbsd.linux.plist`
```
Label org.nextbsd.linux
ProgramArguments /usr/libexec/nextbsd-linux --compat (add --native only by admin edit)
RunAtLoad true
KeepAlive (absent -- one-shot; true would respawn every ThrottleInterval, see #54 option A)
StandardOutPath /var/log/nextbsd-linux.stderr
StandardErrorPath /var/log/nextbsd-linux.stderr (wland/ipconfigd log convention)
```
Header comment in the `org.nextbsd.wland.plist` style: why the label is ours, what the job replaces (`rc.d/linux`), and that there is no launchd ordering on this port, so the tool must not assume anything else is up.
### Ordering, races and re-runs
- RunAtLoad jobs are dispatched by `launchctl bootstrap`'s `load -D all` (`support/launchctl.c:2469-2476`), which runs **after** `mount -vat nonfs` (`:2400-2405`) and after the `/var/run`/`/tmp` force-unmounts (`:2432-2433`); there is no in-process plist scan any more (`src/launchd.c:352-372`). So an admin who also has B1's fstab lines gets no race: the tool's `statfs` check skips them.
- **After a package install** (the case that prompted #54): `launchctl start org.nextbsd.linux`. This launchctl is the launchd-842 CLI (`support/launchctl.c:233-264`); it has **no `kickstart`** subcommand, so the plan page's `launchctl kickstart -k system/org.nextbsd.linux` must read `launchctl start org.nextbsd.linux` (`LAUNCH_KEY_STARTJOB`, `launchctl.c:2858-2865` -> `src/ipc.c:406`). Optionally a pkg trigger `/usr/local/share/pkg/triggers/nextbsd-linux.ucl` with `path: ["/compat/linux"]` running that command, shipped by NextBSD's own base package rather than by the upstream `linux_base` port (#54 option D's ownership question).
- **WatchPaths is not an option on NextBSD.** `distill_fsevents()` (`support/launchctl.c:1611-1648`) rewrites `WatchPaths`, `QueueDirectories` and `KeepAlive.PathState` into `com.apple.fsevents.matching` LaunchEvents, and nothing delivers those: `semaphore_reason_t` in `src/core.c:322-332` has only `NETWORK_*`, `*_EXIT`, `CRASHED`/`DID_NOT_CRASH` and `OTHER_JOB_*` -- no `PATH_*` -- and the only file in the tree that mentions `com.apple.fsevents` is `launchctl.c` itself. #54 option B and nextbsd#278 "Lever D" both assumed otherwise.
- **Opt-in shipping**: `Disabled=true` plus `launchctl load -w` (overrides db) is the launchd-842 way to ship a job off. The getty plist header says the old in-process boot scan ignored `Disabled`; that scan is gone (`src/launchd.c:352-372`), so this needs re-testing under `load -D all` before being relied on.
### Relationship to fstab and DiskArbitration
The job does not read fstab and DiskArbitration will not either for these (plan section 4.1: `__DAMountMapCreate1` accepts only `UUID=`/`LABEL=`/`DEVICE=` specs, so a `linprocfs` line means nothing to it). If a `nullfs` projection of the native set into `/compat/linux` (#54 idea 3) is ever proven, the tool is the one place to switch it on.
## Scope
One shell tool (~80 lines), one plist, one optional pkg trigger, a CI boot-test line. No kernel or launchd change.
## Before starting
- [ ] The #54 decision is revisited: Linux support becomes a default feature (or the maintainer schedules this explicitly). Until then this ticket stays `status:parked`.
- [ ] B1 has landed (the manual path is the documented fallback and the doc gains a "or let org.nextbsd.linux do it" paragraph).
- [ ] Decide whether `--native` is ever on by default (plan section 9, open question 2: `linprocfs` on the real `/proc` is system-wide).
## Acceptance
- [ ] Fresh image, no `linux_base`: boot log shows the job ran and exited 0 with no mounts and no assert noise.
- [ ] `pkg install linux_base-rl9` then `launchctl start org.nextbsd.linux`: all five compat mounts present, in order, `linrdlnk` on fdescfs, `mode=1777` on shm; `launchctl start` a second time changes nothing and exits 0.
- [ ] Reboot with `linux_base` present: same five mounts, no fstab involved (`ls /etc/fstab` fails).
- [ ] With `kern.elf64.fallback_brand=-1` set in `loader.conf`, the job leaves it alone; with the kernel default 3 it is untouched.
- [ ] `--native` variant: `/proc`, `/sys`, `/dev/fd`, `/dev/shm` mounted; an AppImage from #460's test payload runs (the AppImage half stays with #460).
- [ ] CI boot test greps `org.nextbsd.linux` ran and asserts no `fwexec` failure.
## Refs
Plan sections 5.1 (Apple precedent), 5.2 option a, 8 (WatchPaths correction). `support/launchctl.c:233-264, 1611-1648, 2400-2405, 2432-2433, 2469-2476, 2858-2865`; `src/core.c:322-332`; `src/ipc.c:406`; `src/launchd.c:352-372`; `overlay/System/Library/LaunchDaemons/org.nextbsd.wland.plist`; `overlay/usr/libexec/sshd-keygen-wrapper`. FreeBSD `libexec/rc/rc.d/linux:22, 66-80`; `sys/compat/linux/linux.c:699-709`. apple/containerization `LinuxContainer.swift:445-456`, `Vminitd+Rosetta.swift:21-34`, `Binfmt.swift:73-82`. nextbsd-userland#54 (options A/B/D), #53 (unmerged draft), #171; nextbsd#278, #460, #461.</code></pre>
</div>
<h3 style="color:var(--accent)">Stage C — diskarbitrationd, the daemon -- GEOM disk model, fs bundles, mount executor, /Volumes</h3>
<div class="tk" id="c1">
<h3>C1 · diskarbitrationd: rename the Mach service to com.apple.DiskArbitration.diskarbitrationd and drop the stale hwregd comments <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/191">nextbsd-userland#191</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:mach</code></td></tr>
<tr><td>Depends on</td><td>—</td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
The iter-1 skeleton checks in as `com.apple.DiskArbitration` (`src/DiskArbitration/diskarbitrationd.c:97-104`, plist `MachServices` key at `overlay/System/Library/LaunchDaemons/com.apple.DiskArbitration.plist:35`, `datest.c:19-27`). Apple's name is `com.apple.DiskArbitration.diskarbitrationd` (`diskarbitrationd/DAInternal.h:41`, `_kDADaemonName`). Rename it now, before any client code exists, and refresh the comments that still describe the retired hwregd path.
## Why
The client framework looks the daemon up by that exact string: `DiskArbitration/DASession.c:530` and `:604` call `bootstrap_look_up2(bootstrapPort, _kDADaemonName, ...)`, and the daemon side checks in with the same constant (`DAServer.c:3483`). Apple's `SCDynamicStoreCreate` session is also named with it (`DAMain.c:481`). When D1 ports `DASession.c`, every lookup will fail against the current name. A one-string rename today costs nothing; a rename after D1 lands touches the framework, its tests and the CI markers at once.
Stale text: the plist header (`:9-16`) still says "iter 2 subscribes to hwregd's storage device class events" and cites hwregd's log convention; `da_iokit_subscribe.h:13-19` still says the caller "falls back to the legacy hwreg_subscribe_start() ... hwreg_subscribe.c stays compiled"; `Makefile:8` and `:27` still name "hwregd subscription" and `hwreg_subscribe.c` (the file no longer exists, `SRCS` at `:18` is `diskarbitrationd.c da_iokit_subscribe.c`); `da_iokit_subscribe.c:66-67` and `:89-90` still describe hwregd's pub/sub events; `diskarbitrationd.c:16-17` cites the retired 2026-05 plan URL. `da_iokit_subscribe.c:20-24` already says the truth ("No fallback ... hwregd was retired in #218").
## Design
- `diskarbitrationd.c`: `bootstrap_check_in(bootstrap_port, "com.apple.DiskArbitration.diskarbitrationd", &svc)`; define the string once (`#define _kDADaemonName`, same spelling as Apple's `DAInternal.h:41`) in a small `DAInternal.h` so C2+ and D1 include it.
- `datest.c`: look up the new name. Keep the `DA-BOOT-OK` / `DA-BOOT-FAIL` tokens unchanged (the gates grep only the token: `overlay/usr/tests/freebsd-launchd-mach/run.sh:1593-1600`, `tests/boot-test.sh:1178-1194` here and `tests/boot-test.sh:1076-1092` in nextbsd/nextbsd); update the parenthetical text in the `puts` lines.
- plist: `MachServices` key -> `com.apple.DiskArbitration.diskarbitrationd`. Keep `Label` = `com.apple.DiskArbitration` (it is what `run.sh:784` `LAUNCHD_REQUIRED` and `wedge-check.sh:150,156` key on; Apple's label is `com.apple.diskarbitrationd`, `com.apple.diskarbitrationd.plist`, and the vendored man page `diskarbitrationd.8:62` already cites that file name -- either leave the man page or rename the label in a later CI-touching change, not here). Rewrite the header comment: kernel registry via `/dev/ioregistry`, no hwregd, `RunAtLoad` + `KeepAlive` (Apple has `KeepAlive` and no `RunAtLoad`; keep ours, the daemon must exist before Stage C mounts anything).
- Comment refresh in `da_iokit_subscribe.h`, `Makefile`, `da_iokit_subscribe.c`, `diskarbitrationd.c` header (point at `https://pkgdemon.github.io/nextbsd-diskarbitration-mounts-plan.html` and this epic).
- `wedge-check.sh:150` comment: "no client tool on the image" stays true until D1; mention the new service name.
## Scope
Strings and comments only; no behaviour change. ~40 lines across 6 files plus the two `boot-test.sh` copies.
## Acceptance
- [ ] `grep -rn '"com.apple.DiskArbitration"' src/DiskArbitration overlay` returns only the plist `Label`
- [ ] CI boot test still prints `DA-BOOT-OK` (datest reaches the renamed service) and `DA-IOKIT-OK`
- [ ] `grep -rn hwreg src/DiskArbitration overlay/System/Library/LaunchDaemons/com.apple.DiskArbitration.plist` returns only historical references that say hwregd is retired
- [ ] `launchctl list` on the booted image still shows `com.apple.DiskArbitration` (label unchanged, `run.sh:784` untouched)
## Refs
Plan section 4.3 ("Mach service" row) and section 8 (2026-05 plan corrections). Apple DiskArbitration-535.120.1.0.1: `diskarbitrationd/DAInternal.h:41`, `DAServer.c:3483`, `DiskArbitration/DASession.c:530,604`, `diskarbitrationd/com.apple.diskarbitrationd.plist`.</code></pre>
</div>
<div class="tk" id="c2">
<h3>C2 · diskarbitrationd: build the DADisk model from GEOM (libgeom walk on kernel-registry arrival), log-only <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/192">nextbsd-userland#192</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:base</code></td></tr>
<tr><td>Depends on</td><td><a href="#c1">C1</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Give the daemon a disk model. On every storage arrival the `/dev/ioregistry` watch already delivers (`da_iokit_subscribe.c:145-160`, `da_handle_storage`), walk the GEOM graph with libgeom and create one `DADisk` per DISK-class provider (whole disk) and per PART-class provider (partition), each carrying Apple's `kDADiskDescription*` dictionary. Log only: no probe, no mount. Apple's model is `diskarbitrationd/DADisk.c:261-983` (`DADiskCreateFromIOMedia`), which reads one `IOMedia` object plus its `IOBlockStorageDevice` parent and its device-tree bus node; this ticket is that function with GEOM and CAM as the sources.
## Why
Every later stage keys on this dictionary: C4 matches fs bundles on `Content Hint` / `Leaf` / `Whole` (`DAProbe.c:100-106`), C5 chooses trust and defer from `MediaRemovable` / `DeviceInternal` (`DAMount.c:940-972`) and `MediaWritable` (`:1527-1531`), and the D1 framework serialises exactly this dictionary to clients. Getting the key set and its sources right now means C3-C5 and D1 add behaviour without reshaping data.
## Design
**Trigger.** `da_handle_storage(verb="arrival", name, class)` (`da_iokit_subscribe.c:146`) -> `geom_gettree()` (`lib/libgeom/libgeom.h:138`) -> for each `DISK` geom whose provider name matches the arriving unit (`da0`, `ada0`, `nda0`/`nvd0`, `cd0`, `mmcsd0`, `vtbd0`; the registry reports the newbus driver `umass`/`ahcich`/`nvme`/`mmc`/`vtblk` per `da_iokit_subscribe.c:99-119`, so map driver -> CAM/disk units by walking `kern.disks` or re-walking the whole tree and diffing against the disk list) -> create the whole-disk `DADisk`, then one per `PART` provider hanging off it (recursively: GPT inside MBR slice, BSD label inside slice). Departures remove the disks whose provider vanished from the tree. Re-walk the tree on `GEOM::attachment`-less classes (`MD`) is out of scope.
**Identity.** `DADiskGetID` is the device path, `/dev/<provider>` (Apple: `_PATH_DEV` + `kIOBSDNameKey`, `DADisk.c:296-304`). `LABEL`-class providers (`/dev/gpt/EFI`, `/dev/ufs/NEXTBSD`) are aliases of a PART provider: record them as `_deviceLink` (Apple's `dev-name` link, `DADisk.c:938-960`), not as separate disks.
**Key table.** Sources are the libgeom `lg_config` XML keys that `g_part` and `geom_disk` emit, plus CAM.
| Key (Apple) | Type | NextBSD source |
|---|---|---|
| `DAMediaBSDName` | string | provider `lg_name` (`da0`, `da0p1`) |
| `DAMediaBSDUnit` | int | unit digits of the DISK provider; partitions inherit |
| `DAMediaBSDMajor`/`Minor` | int | `stat(/dev/<name>)` `st_rdev` (Apple: `kIOBSDMajorKey`, `DADisk.c:340-350`) |
| `DAMediaSize` | int64 | provider `lg_mediasize` (`DIOCGMEDIASIZE`, `disk.h:35`) |
| `DAMediaBlockSize` | int | provider `lg_sectorsize` (`DIOCGSECTORSIZE`, `disk.h:28`) |
| `DAMediaWhole` | bool | geom class == `DISK` (Apple: `kIOMediaWholeKey`, `:531-534`) |
| `DAMediaLeaf` | bool | provider has no consumer geoms of class `PART` below it (Apple: `kIOMediaLeafKey`, `:460-463`); a whole disk with a partition table is not a leaf |
| `DAMediaContent` | string | PART: `rawtype` (`g_part_gpt.c:786-788`, `g_part_mbr.c:335-336`) mapped as below; whole disk with a table: the scheme (`GUID_partition_scheme` / `FDisk_partition_scheme`, Apple's spelling); no table: empty string |
| `DAMediaUUID` | CFUUID | GPT `rawuuid` (`g_part_gpt.c:789-791`); absent for MBR/BSD and whole disks |
| `DAMediaName` | string | GPT `label` (`g_part_gpt.c:772-775`) if set, else the gpart alias `type` (`freebsd-ufs`, `ms-basic-data`; names at `g_part.c:66-`), else `GEOM::descr` for whole disks |
| `DAMediaPath` | string | `IORegistryEntryGetPath` of the newbus node the arrival came from + `/` + provider name; `DIOCGPHYSPATH` (`disk.h:105`) when set |
| `DAMediaKind` | string | `IOMedia`; `IOCDMedia` for `cd*` (Apple: `:400-453`) |
| `DAMediaRemovable` | bool | `da`: `kern.cam.da.<unit>.flags` contains `PACK_REMOVABLE` (`sys/cam/scsi/scsi_da.c:107`, string table `:132`, sysctl `:2401`); `cd*`, `mmcsd*`: true; `ada`/`nda`/`nvd`/`vtbd`: false |
| `DAMediaEjectable` | bool | same as removable (Apple: `kIOMediaEjectableKey`) |
| `DAMediaWritable` | bool | `open(O_RDWR)` on the provider succeeds; `cd*`: false |
| `DADeviceVendor`/`Model`/`Revision` | string | `GEOM::descr` via `DIOCGATTR` (how `diskinfo -v` prints "Disk descr", `usr.sbin/diskinfo/diskinfo.c:255-258`); CAM builds it as vendor + product; split on the CAM inquiry fields when available, else whole string in Model |
| `DADeviceInternal` | bool | bus driver: `umass` -> false; `ahcich`, `nvme`, `mmc`, `vtblk` -> true (Apple: `Physical Interconnect Location` Internal/External, `:591-606`) |
| `DADeviceProtocol` | string | `umass` -> `USB`; `ahcich` -> `SATA`; `nvme` -> `PCI-Express`; `mmc` -> `Secure Digital`; `vtblk` -> `Virtual Interface` (Apple's `kIOPropertyPhysicalInterconnectType*` strings) |
| `DADevicePath` | string | registry path of the newbus parent |
| `DADeviceUnit` | int | unit from `GEOM::attachment` (`geom_disk.c:531-532`; CAM sets it to `<sim><unit>`, `scsi_da.c:3033-3034`) |
| `DABusName`/`DABusPath` | string | newbus parent driver name and registry path (Apple: device-tree node, `:758-787`) |
| `DAAppearanceTime` | double | `CFAbsoluteTimeGetCurrent()` at creation (`:795-803`) |
| `DAVolumeNetwork` | bool | false (`:316`) |
Not produced: `DAMediaIcon`, `DAMediaType` (CD/DVD media type), `DADeviceGUID`, `DADeviceTDMLocked`. Volume keys (`DAVolumeKind/Name/UUID/Path/Mountable`) are C4 and C3.
**Content hint.** GPT: gpart prints `rawtype` in lower case (`sys/kern/kern_uuid.c:277`, `%08x-%04x-...`); Apple's `IOGUIDPartitionScheme.cpp:648` uses `uuid_unparse`, which on Darwin is upper case, and every fs-bundle key is upper case (`EBD0A0A2-B9E5-4433-87C0-68B6B72699C7`). Upper-case the string. MBR: `rawtype` is the decimal `dp_typ` (`g_part_mbr.c:335-336`); Apple names them through the `IOFDiskPartitionScheme` `Content Table` (IOStorageFamily `Info.plist`), falling back to `0x%02X` (`IOFDiskPartitionScheme.cpp:560-577`). Ship that table verbatim:
| `dp_typ` | Apple content hint |
|---|---|
| 1 | `DOS_FAT_12` |
| 4 | `DOS_FAT_16_S` |
| 6 | `DOS_FAT_16` |
| 7 | `Windows_NTFS` |
| 11 | `DOS_FAT_32` |
| 12 | `Windows_FAT_32` |
| 14 | `Windows_FAT_16` |
| 20 | `DOS_FAT_16_S_Hidden` |
| 22 | `DOS_FAT_16_Hidden` |
| 66 | `Windows_LDM` |
| 130 | `Linux_Swap` |
| 131 | `Linux` |
| 142 | `Linux_LVM` |
| 165 | `FreeBSD` |
| 166 | `OpenBSD` |
| 167 | `Apple_Rhapsody_UFS` |
| 168 | `Apple_UFS` |
| 169 | `NetBSD` |
| 171 | `Apple_Boot` |
| 174 | `Apple_Encrypted` |
| 175 | `Apple_HFS` |
| 253 | `Linux_RAID` |
| other | `0x%02X` |
BSD-label partitions (`da0s1a`, scheme `BSD`, `rawtype` = decimal `fs_type`) have no Apple equivalent; emit NextBSD-local `BSD_FFS` (7) and `BSD_Swap` (1), else `BSD_0x%02X`.
**Struct sketch** (C, CF-backed like Apple's `struct __DADisk`, `DADisk.c:50-78`):
```c
struct da_disk {
TAILQ_ENTRY(da_disk) link; /* gDADiskList */
char *id; /* "/dev/da0p1" (DADiskGetID) */
CFMutableDictionaryRef description; /* kDADiskDescription* keys above */
uint32_t state; /* kDADiskStateStaged*, RequireRepair ... (Apple DADisk.h:43-66) */
char *device_link[2];/* /dev/gpt/EFI, /dev/ufs/NEXTBSD aliases */
struct da_disk *whole; /* the DISK-class disk this partition sits on; NULL if whole */
char *geom_class; /* "DISK" | "PART" */
char *ioreg_path; /* newbus node the arrival came from */
uid_t user_uid; /* owner for mounts (C5); 0 until a console user exists */
gid_t user_gid;
};
```
**Log line and marker.** One line per disk: `DA-DISK: <id> whole=<0|1> leaf=<0|1> content=<hint> size=<bytes> removable=<0|1> internal=<0|1> bus=<driver> name="<DAMediaName>"`. New one-shot CI marker `DA-GEOM-OK: <n> disks from libgeom` after the first walk that yields at least one DISK-class disk (the qemu `vtbd0` root disk); `DA-GEOM-FAIL` if `geom_gettree` fails. Wire it into `run.sh`'s `da_iokit_gate` style (one definite marker, never blocks) and both `boot-test.sh` copies as a non-fatal `expect` block, like `DA-IOKIT` (`run.sh:1602-1660`).
**Reference code.** The installer already enumerates the same things in shell: `src/nextbsd-installer/engine/probe-disks.sh:46-60` (`kern.disks`, `diskinfo`, `gpart show -l`, `glabel status` at `:28`). Do it through libgeom's tree instead of parsing tool output.
## Scope
New `src/DiskArbitration/DADisk.[ch]` and `DAGeom.[ch]` (~600 lines), `-lgeom -lsbuf -lbsdxml` in the Makefile (`LIBADD+= geom`), marker plumbing in `run.sh` and the two `boot-test.sh` files.
## Acceptance
- [ ] on the CI image the log shows a `DA-DISK:` line for `vtbd0` (whole, not leaf, content `GUID_partition_scheme`) and one per partition, each with an upper-case GPT `rawtype` as content and a `DAMediaUUID`
- [ ] the ISO image logs `cd0` as whole+leaf, `IOCDMedia`, removable, not writable
- [ ] unplugging a USB stick removes its disks; re-plugging recreates them with a new `DAAppearanceTime`
- [ ] a `/dev/ufs/NEXTBSD` label appears as `_deviceLink` of the right partition, not as a disk
- [ ] `DA-GEOM-OK` is asserted by `boot-test.sh` in both repos
## Refs
Plan section 4.3 ("IOMedia -> GEOM mapping") and section 7 C2. Apple: `diskarbitrationd/DADisk.c:261-983`, `:50-78`, `DADisk.h:43-66`; IOStorageFamily `IOFDiskPartitionScheme.cpp:560-577`, `IOGUIDPartitionScheme.cpp:648`, `Info.plist` (`IOFDiskPartitionScheme` `Content Table`). FreeBSD releng/15.0: `lib/libgeom/libgeom.h:56,138`, `sys/geom/part/g_part_gpt.c:772-791`, `g_part_mbr.c:335-336`, `g_part.c:66`, `sys/kern/kern_uuid.c:277`, `sys/geom/geom_disk.c:531-532`, `sys/sys/disk.h:28,35,66,87,105`, `sys/cam/scsi/scsi_da.c:107,132,2401,3033-3034`, `usr.sbin/diskinfo/diskinfo.c:255-266`. NextBSD: `src/DiskArbitration/da_iokit_subscribe.c:99-160`, `src/nextbsd-installer/engine/probe-disks.sh:28,46-60`, `overlay/usr/tests/freebsd-launchd-mach/run.sh:1602-1660`.</code></pre>
</div>
<div class="tk" id="c3">
<h3>C3 · diskarbitrationd: adopt mounts it did not make (EVFILT_FS + getmntinfo diff -> DADiskCreateFromVolumePath) <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/193">nextbsd-userland#193</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:base</code></td></tr>
<tr><td>Depends on</td><td><a href="#c2">C2</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Apple's daemon learns about mounts it did not perform (NFS, SMB, disk images, anything mounted by hand) and turns each into a `DADisk` whose ID is the mount point, so clients see every volume, not only the ones it mounted. Port that: watch the VFS with `kqueue(2)` `EVFILT_FS`, on `VQ_MOUNT` walk `getmntinfo(3)` and create a disk for every mount that is not already known; on `VQ_UNMOUNT` refresh the known volumes and drop the gone ones. Also seed the list at startup from `statfs("/")`.
## Why
Gershwin's Workspace polls `getmntinfo` every 1.5 s today (plan section 6.2) and nothing posts `NSWorkspaceDidMountNotification`. D3's bridge needs a single source of truth for "what is mounted", including union, tmpfs and network mounts that DiskArbitration will never initiate (plan section 4.2: "DiskArbitration never initiates network or pseudo-filesystem mounts"). This is also how the daemon notices `mount -vat nonfs` mounts from an admin fstab and its own C5 mounts completing.
## Design
Apple, macOS build: `notify_register_mach_port(kNotifyVFSMount/Unmount/Update)` (`DAMain.c:613-657`). Apple, embedded build: `dispatch_source_create(DISPATCH_SOURCE_TYPE_VFS, 0, DISPATCH_VFS_MOUNT|UNMOUNT|UPDATE, ...)` and `if (event_flags & VQ_MOUNT) _DAVolumeMountedCallback()` (`DAMain.c:659-676`). `DISPATCH_SOURCE_TYPE_VFS` is `EVFILT_FS` underneath, so the embedded branch is the one to port; NextBSD's libdispatch may or may not expose the VFS source type, so use a raw `kqueue` on the daemon's dispatch queue via `DISPATCH_SOURCE_TYPE_READ` on the kq fd, or a dedicated thread.
`_DAVolumeMountedCallback` (`DAServer.c:3362-3405`): `getmntinfo(&list, MNT_NOWAIT)`; for each entry look the disk up by `_DAVolumeGetID(fs)` (`DAInternal.c:591-614`: `f_mntfromname` when it starts with `/dev/`, else `"<f_mntonname>?owner=<f_owner>"`); if known and it has no `DAVolumePath` yet, refresh it (that is how a C5 mount completes); if unknown, skip `MNT_UNION` and `devfs` and call `_DADiskCreateFromFSStat` (`:3328-3357`) -> `DADiskCreateFromVolumePath(allocator, fs)` (`DADisk.c:985-1139`), which sets `DAVolumePath`, `DAVolumeMountable=true`, `DAVolumeKind=f_fstypename`, `DAVolumeName` (from the fs probe; until C4 use the last path component), `DAMediaBSDMajor/Minor` from `f_fsid`, `DAVolumeNetwork` from `!(f_flags & MNT_LOCAL)`, marks all stages done (`Probe|Peek|Mount`), and takes `_userUID` from `f_owner`. `_DAVolumeUnmountedCallback` (`:3407-3420`) refreshes every disk that has a volume path; the refresh drops the path when the mount is gone. Startup seed: `DAMain.c:138-146`.
NextBSD specifics:
- FreeBSD only signals two events: `vfs_event_signal(NULL, VQ_MOUNT, 0)` at the end of `vfs_domount_first` (`sys/kern/vfs_mount.c:1286`) and `VQ_UNMOUNT` in `dounmount` (`:2408`). `mount -u` (`vfs_domount_update`) signals nothing, so there is no `VQ_UPDATE`; a remount rw->ro is only seen at the next event or by a periodic refresh.
- `EVFILT_FS` knotes are `EV_CLEAR` and accumulate `fflags` (`sys/kern/vfs_subr.c:6535-6552`); `ident` is ignored; register once with `fflags = VQ_MOUNT|VQ_UNMOUNT` (`sys/sys/mount.h:734-735`).
- Skip the same pseudo mounts Apple skips plus NextBSD's: `devfs`, `MNT_UNION` (the live-media `/cow`+`/rofs` union), `fdescfs`, `linprocfs`, `linsysfs`, `procfs`, `tmpfs` on `/tmp`? No: Apple only skips devfs and union mounts; keep parity and let D1 clients filter, but log them at debug level only.
- Fallback if VQ_MOUNT does not arrive (see Before starting): FreeBSD also emits `devctl_notify("VFS", "FS", "MOUNT"/"UNMOUNT"/"REMOUNT", ...)` (`vfs_mount.c:2969-3009`; call sites `:1290`, `:2404`). With devd gone (`nextbsd-freebsd-compat scripts/superseded:17`), `/dev/devctl` has no reader, but it is single-consumer, and E14's K7/U1 plan a devctl reader for swap events; if DA needs it, the two must share one reader. Prefer `EVFILT_FS`.
## Before starting
- [ ] Verify `VQ_MOUNT` delivery on a NextBSD kernel. The claim "GhostBSD reported EVFILT_FS not working" is not what gershwin-desktop/issues#22 says: that code uses `EVFILT_VNODE` on the mount directory plus polling, and leaves "monitor mount/unmount events with pure kqueue" as a TODO. Nobody has tested `EVFILT_FS` on NextBSD. Build and run this on the CI image (or under `run.sh` as a `DA-VFSWATCH` probe):
```c
/* vfswatch.c -- cc -o vfswatch vfswatch.c; ./vfswatch & mount -t tmpfs t /mnt; umount /mnt */
#include <sys/types.h>
#include <sys/event.h>
#include <sys/mount.h>
#include <err.h>
#include <stdio.h>
int main(void)
{
struct kevent kev, ev;
int kq = kqueue();
if (kq < 0) err(1, "kqueue");
EV_SET(&kev, 0, EVFILT_FS, EV_ADD | EV_CLEAR, VQ_MOUNT | VQ_UNMOUNT, 0, NULL);
if (kevent(kq, &kev, 1, NULL, 0, NULL) < 0) err(1, "kevent EV_ADD EVFILT_FS");
printf("VFSWATCH-ARMED\n"); fflush(stdout);
for (;;) {
if (kevent(kq, NULL, 0, &ev, 1, NULL) < 0) err(1, "kevent wait");
printf("VFSWATCH: fflags=0x%x%s%s\n", (unsigned)ev.fflags,
(ev.fflags & VQ_MOUNT) ? " VQ_MOUNT" : "",
(ev.fflags & VQ_UNMOUNT) ? " VQ_UNMOUNT" : "");
fflush(stdout);
}
}
```
Expected: one `VQ_MOUNT` line after the mount and one `VQ_UNMOUNT` after the umount. If `EV_ADD` fails with `EINVAL`, check that the userland `<sys/event.h>` the daemon compiles against (freebsd-shims vs sysroot) has the same `EVFILT_FS` number as the kernel; nextbsd-kernel patch `0003-kqueue-reserve-evfilt-machport.patch` touches the filter table (`sys/kern/kern_event.c:355-375`).
- [ ] Decide whether NextBSD's libdispatch exposes `DISPATCH_SOURCE_TYPE_VFS`; if not, the kq-on-dispatch shape above.
## Acceptance
- [ ] `mount -t tmpfs t /mnt` from a shell produces a new disk with id `/mnt?owner=0`, `DAVolumeKind=tmpfs`, `DAVolumeNetwork=false`, logged within 1 s without polling; `umount /mnt` removes it
- [ ] an NFS mount produces a disk with `DAVolumeNetwork=true`
- [ ] the live ISO's union root and `devfs` mounts are not adopted
- [ ] after C5 mounts a stick, the same disk (id `/dev/da0p1`) gains `DAVolumePath` rather than a second disk appearing
- [ ] the `vfswatch` result (works / does not) is recorded in this issue before the code lands
## Refs
Plan section 4.2 ("Mounts it didn't make") and section 9 (EVFILT_FS open question). Apple: `diskarbitrationd/DAServer.c:3328-3420`, `DADisk.c:985-1139`, `DAInternal.c:563-614`, `DAMain.c:138-146,613-676`. FreeBSD releng/15.0: `sys/sys/mount.h:734-735`, `sys/kern/vfs_subr.c:6507-6552`, `sys/kern/vfs_mount.c:1286,1290,2404,2408,2969-3009`, `sys/kern/kern_event.c:355-375`. gershwin-desktop/issues#22.</code></pre>
</div>
<div class="tk" id="c4">
<h3>C4 · Filesystem bundles: /System/Library/Filesystems/{msdos,exfat,ntfs,ufs,cd9660,udf}.fs with an fstyp-backed *.util shim (FSUR_* contract) <span class="pill ok">filed <a href="https://github.com/nextbsd/nextbsd-userland/issues/194">nextbsd-userland#194</a></span></h3>
<table class="meta">
<tr><td>Repo</td><td><a href="https://github.com/nextbsd/nextbsd-userland">nextbsd-userland</a></td></tr>
<tr><td>Labels</td><td><code>enhancement</code> <code>area:storage</code> <code>area:base</code></td></tr>
<tr><td>Depends on</td><td><a href="#c2">C2</a></td></tr>
<tr><td>Parent</td><td><a href="#e15">E15</a></td></tr>
</table>
<pre><code>## Summary
Ship Apple's filesystem-bundle layout so the daemon's probe stage can be ported unchanged: one `<name>.fs/Contents/Info.plist` per filesystem under `/System/Library/Filesystems` (`FS_DIR_LOCATION`, `sys/loadable_fs.h:59`), each naming a `Contents/Resources/<name>.util` probe helper that follows the `FSUC_*` command / `FSUR_*` exit-code contract (`loadable_fs.h:66-98`). On FreeBSD the helper is one shared shim around `fstyp(8)` plus a small on-disk "is clean" check. Also add the probe stage itself (`DAProbe.c`, `DAFileSystem.c` probe path) so C2's disks gain `DAVolumeKind`, `DAVolumeName`, `DAVolumeUUID`, `DAVolumeMountable`; still no mount.
## Why
Apple's daemon does not know any filesystem. `DAFileSystemListRefresh` walks `*.fs` directories (`DASupport.m:400-470`, also `/Library/Filesystems`, `DABase.h:39`), builds a probe list from every `FSMediaTypes` entry sorted by `FSProbeOrder` (`:388-397`), and `DAProbe` runs the candidates whose `FSMediaProperties` match the disk's `Content Hint` / `Leaf` / `Whole` (`DAProbe.c:94-106`). Keeping that data-driven shape means adding a filesystem is a plist plus a helper, third parties can drop bundles into `/Library/Filesystems`, and Disk Utility-style tools read the same `FSPersonalities` (format name, `FSFormatExecutable`) Apple's do.
## Design
**Directory names** stay Apple's (`msdos.fs`, `exfat.fs`, `ntfs.fs`, `ufs.fs`, `cd9660.fs`, `udf.fs`) so anything written against macOS finds them. `CFBundleName` is the *FreeBSD vfs type*, because it is what the daemon passes to `mount -t` (`DAFileSystem.c:573-576` `DAFileSystemGetKind` = `CFBundleName`; `:745-778` `mount -t <kind> ...`) and what a fstab `vfstype` filter compares against (`DAMount.c:1325-1337`): `msdosfs`, `exfat`, `ntfs`, `ufs`, `cd9660`, `udf`.
**Probe protocol** (what C5's executor and this ticket's probe stage run, `DAFileSystem.c:917-928`, `:292-302`, `:359-387`, `DACommand.c:329`):
- `<name>.util -p <devname> removable readonly` -> stdout = volume name (trimmed, `:257-278`), exit `FSUR_RECOGNIZED` (-1) or `FSUR_UNRECOGNIZED` (-2). Apple passes the literal words `removable readonly` regardless of the media (`:925-926`); the shim ignores them. `DACommandExecute` reads the status as `(char)WEXITSTATUS` (`DACommand.c:329`), so `exit(-1)` (status 255) is read back as -1.
- `<name>.util -k <devname>` -> stdout = UUID string, exit `FSUR_IO_SUCCESS` (-3) (`:322-343`; Apple documents that the value is "a unique 64-bit number" it folds into a CFUUID via `___CFUUIDCreateFromString`).
- `<repair executable> -q <devpath>` -> exit 0 = clean, else dirty (`:359-387`; `DAStage.c:755-777` sets `kDADiskStateRequireRepair` when non-zero, and forces clean when the media is not writable).
- `-y` (repair) exists in the contract (`:1091-1108`) but C5 never runs it automatically.
**The shim** (`src/DiskArbitration/fsutil/fsutil.c`, installed as each bundle's `<name>.util` via symlink, dispatching on `argv[0]`):
- `-p`: run `fstyp -l /dev/<devname>` (`usr.sbin/fstyp/fstyp.c:168-171`, `:261-282`; `-l` appends the label, exit 1 when unrecognised); recognised iff `fstyp`'s first word equals the bundle's vfs type (`fstyp` names: `ufs`, `cd9660`, `hfs+`, `ext2fs`, `befs`, `apfs`, `exfat`, `hammer`, `hammer2`, `msdosfs`, `ntfs`, `zfs`, `fstyp.c:76-108`; `udf` is not in that table, so `udf.util` reads the UDF anchor at sector 256 itself, or returns unrecognised until `fstyp` grows it). Print the label; empty label -> print nothing and let the daemon use "Untitled" (`DAMount.c:754-757`).
- `-k`: print a UUID. v1: the GPT partition `rawuuid` from C2's model when the device is a GPT partition (passed in via `DA_PARTITION_UUID` env or a `-U` extra arg), else a name-based UUID v5 over `<disk ident>:<partition index>:<fstyp label>`. Real volume serials (FAT BPB volume id, UFS `fs_id`, NTFS/exFAT serial) are a follow-up; note it in the shim.
- `-q`: per type, read-only: `ufs` -> superblock `fs_clean` via libufs `sbread` (`fsck_ufs -p` would *repair* a dirty volume, and `-n` is a full scan); `msdosfs` -> FAT[1] clean-shutdown bit (FAT32 bit 27, FAT16 bit 15) from the BPB; `ntfs` -> `$Volume` dirty flag (or always "dirty" and let ntfs-3g decide); `exfat` -> `VolumeFlags` bit 1; `cd9660`/`udf` -> always clean. Exit 0 clean, 1 dirty, `FSUR_IO_FAIL` on I/O error.
- `-y`: exec the real checker (`fsck_msdosfs -y`, `fsck_ufs -y`, `fsck.exfat -y`) so a later explicit-repair request (D2) works; never invoked by the automatic path.
**`FSMediaTypes` per bundle** (`Content Hint` strings exactly as C2 emits them; `Partitionless` = `Leaf` + `Whole`, the whole-disk-no-table case, Apple's own key name):
| Bundle | `Content Hint` keys (FSProbeOrder) |
|---|---|
| `msdos.fs` | `EBD0A0A2-B9E5-4433-87C0-68B6B72699C7` (2000), `C12A7328-F81F-11D2-BA4B-00A0C93EC93B` (1000, `autodiskmount=false`: EFI system partitions are recognised but never auto-mounted, `DAProbe.c:113-117`), `DOS_FAT_12`, `DOS_FAT_16_S`, `DOS_FAT_16`, `DOS_FAT_32`, `Windows_FAT_32`, `Windows_FAT_16` (1000), `Partitionless` (4000) |
| `exfat.fs` | `EBD0A0A2-...` (2000), `Windows_NTFS` (2000), `Partitionless` (4000) |
| `ntfs.fs` | `EBD0A0A2-...` (2000), `Windows_NTFS` (1000), `Partitionless` (4000) |
| `ufs.fs` | `516E7CB6-6ECF-11D6-8FF8-00022D09712B` (freebsd-ufs, 1000), `BSD_FFS` (1000, NextBSD-local from C2), `Partitionless` (4000) |
| `cd9660.fs` | `Partitionless` (3000) -- `cd0` is a whole, leaf provider; Apple's `CD_ROM_Mode_1`/`CD_ROM_Mode_2_Form_1` hints come from a CD partition scheme FreeBSD does not have |
| `udf.fs` | `Partitionless` (1000) -- probes before cd9660 so UDF bridge discs mount as UDF, as on macOS |
These are the host macOS bundles' keys minus the Apple-only ones, checked against `/System/Library/Filesystems/{msdos,exfat,ntfs,udf,cd9660}.fs/Contents/Info.plist` on macOS 27.
**Complete example, `msdos.fs/Contents/Info.plist`** (Apple's, with FreeBSD helper names; the `FSMountExecutable` is consumed by C5 as `mount -o mountprog=`):
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key> <string>English</string>
<key>CFBundleIdentifier</key> <string>org.nextbsd.filesystems.msdosfs</string>
<key>CFBundleInfoDictionaryVersion</key> <string>6.0</string>
<key>CFBundleName</key> <string>msdosfs</string>
<key>CFBundlePackageType</key> <string>fs </string>
<key>CFBundleShortVersionString</key> <string>1.0</string>
<key>CFBundleVersion</key> <string>1.0</string>
<key>FSImplementation</key> <array><string>kernel</string></array>
<key>FSMediaTypes</key>
<dict>
<key>EBD0A0A2-B9E5-4433-87C0-68B6B72699C7</key>
<dict>
<key>FSMediaProperties</key>
<dict>
<key>Content Hint</key> <string>EBD0A0A2-B9E5-4433-87C0-68B6B72699C7</string>
<key>Leaf</key> <true/>
</dict>
<key>FSProbeArguments</key> <string>-p</string>
<key>FSProbeExecutable</key> <string>msdos.util</string>
<key>FSProbeOrder</key> <integer>2000</integer>
</dict>
<key>C12A7328-F81F-11D2-BA4B-00A0C93EC93B</key>
<dict>
<key>FSMediaProperties</key>
<dict>
<key>Content Hint</key> <string>C12A7328-F81F-11D2-BA4B-00A0C93EC93B</string>
<key>Leaf</key> <true/>
</dict>
<key>FSProbeArguments</key> <string>-p</string>
<key>FSProbeExecutable</key> <string>msdos.util</string>