McdeSys: the NetBSD disk and mount errors in the catalog (t0282)

disk_netbsd.c (16 calls) and mount_netbsd.c (2) are catalogued now: messages
218-233 for the new sentences (no hw.disknames, a %s partition cannot be
mounted/checked, no %s here, the name rule with blanks and 32 characters, the
new partition did not appear, no /etc/mtree, repairing permissions needs the
administrator, no mount table) and the numbers that already existed for the
same texts as on Linux (no disk %s, not mounted, the system's, erasing needs
the administrator, no drive, holds the system, mounted on, no room for the
mounts).  German copy in
programs/localized/de_DE.UTF-8/msg/mcdesys.msg with the same numbers.

Verification: both files pass
x86_64--netbsd-gcc -std=gnu11 -fsyntax-only -Wall with the tree's sysroot
(they are only compiled on NetBSD).  The catalog was measured through
mcde_sys_msg (the function the backend calls): LANG=C "No list of disks
(hw.disknames).", "A name has letters, digits, blanks, - and _, at most 32.",
"Only the administrator can repair permissions."; LANG=de_DE.UTF-8 "Keine
Plattenliste (hw.disknames).", "Ein Name hat Buchstaben, Ziffern, Leerzeichen,
- und _, höchstens 32.", "Nur der Administrator kann die Rechte reparieren."

make mcde-linux was refused by the build lock: another session holds it
(tools/build-lock.sh tools/userland.sh, pid 3102819) -- one build at a time,
root AGENTS.md.  The two changed sources are NetBSD-only, so the Linux
library is unaffected; the Linux build, check and plist run follows when the
lock is free.
This commit is contained in:
lotherk committed 2026-11-16 12:12:39 +00:00
1 parent 5f1d166ac8
commit ff3e93ee10
5 files changed
+47 -27

No files matched your search

+16 -25
View File
@@ -123,8 +123,7 @@ mcde_sys_disks(McdeSysDisk *d, size_t max)
size_t len = sizeof names, n = 0;
if (sysctlbyname("hw.disknames", names, &len, NULL, 0) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "No list of disks "
"(hw.disknames).");
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NDISK_NO_LIST, "No list of disks (hw.disknames)."));
for (tok = strtok_r(names, " ", &last); tok != NULL && n < max;
tok = strtok_r(NULL, " ", &last)) {
McdeSysDisk *drive = &d[n];
@@ -224,7 +223,7 @@ mcde_sys_disk_mount(const char *name, char *mountpoint, size_t len)
size_t i;
if (!Find(name, &d))
return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no disk %s.",
return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_DISK_NOT_FOUND, "There is no disk %s."),
name);
if (d.mountpoint[0] != '\0') {
snprintf(mountpoint, len, "%s", d.mountpoint);
@@ -233,8 +232,7 @@ mcde_sys_disk_mount(const char *name, char *mountpoint, size_t len)
if (strcmp(d.fstype, "ffs") != 0 && strcmp(d.fstype, "msdos") != 0 &&
strcmp(d.fstype, "ext2fs") != 0 && strcmp(d.fstype, "cd9660") != 0 &&
strcmp(d.fstype, "ntfs") != 0)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "A %s partition cannot "
"be mounted.", d.fstype[0] != '\0' ? d.fstype : "blank");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NDISK_PART_MOUNT, "A %s partition cannot be mounted."), d.fstype[0] != '\0' ? d.fstype : "blank");
snprintf(prog, sizeof prog, "/sbin/mount_%s", d.fstype);
snprintf(dev, sizeof dev, strcmp(d.fstype, "cd9660") == 0 ?
"/dev/%sa" : "/dev/%s", name);
@@ -266,10 +264,10 @@ mcde_sys_disk_unmount(const char *name)
char *argv[3];
if (!Find(name, &d) || d.mountpoint[0] == '\0')
return mcde_sys_fail(MCDE_SYS_ENOENT, "%s is not mounted.",
return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_DISK_NOT_MOUNTED, "%s is not mounted."),
name);
if (d.system)
return mcde_sys_fail(MCDE_SYS_EPERM, "%s is the system's.",
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_DISK_SYSTEM, "%s is the system's."),
name);
argv[0] = "/sbin/umount";
argv[1] = d.mountpoint;
@@ -286,12 +284,11 @@ mcde_sys_disk_check(const char *name, char *log, size_t len)
log[0] = '\0';
if (!Find(name, &d))
return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no disk %s.",
return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_DISK_NOT_FOUND, "There is no disk %s."),
name);
if (strcmp(d.fstype, "ffs") != 0 && strcmp(d.fstype, "msdos") != 0 &&
strcmp(d.fstype, "ext2fs") != 0)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "A %s partition cannot "
"be checked.", d.fstype[0] != '\0' ? d.fstype : "blank");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NDISK_PART_CHECK, "A %s partition cannot be checked."), d.fstype[0] != '\0' ? d.fstype : "blank");
snprintf(prog, sizeof prog, "/sbin/fsck_%s", d.fstype);
snprintf(dev, sizeof dev, "/dev/r%s", name);
argv[0] = prog;
@@ -311,34 +308,30 @@ mcde_sys_disk_erase(const char *name, const char *fstype, const char *label,
int n, i;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can erase a disk.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_DISK_ERASE_EPERM, "Only the administrator can erase a disk."));
if (strcmp(fstype, "ffs") == 0)
gtype = "ffs";
else if (strcmp(fstype, "msdos") == 0)
gtype = "windows";
else
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "No %s here.", fstype);
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NDISK_NO_DEVICE, "No %s here."), fstype);
if (label == NULL || label[0] == '\0' || strlen(label) > 32 ||
strspn(label, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789 _-") != strlen(label))
return mcde_sys_fail(MCDE_SYS_EINVAL, "A name has letters, "
"digits, blanks, - and _, at most 32.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NDISK_BAD_NAME, "A name has letters, digits, blanks, - and _, at most 32."));
n = mcde_sys_disks(all, 64);
for (i = 0; i < n; i++)
if (strcmp(all[i].name, name) == 0)
break;
if (i == n || all[i].parent[0] != '\0')
return mcde_sys_fail(MCDE_SYS_EINVAL, "%s is no drive.", name);
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_DISK_NOT_DRIVE, "%s is no drive."), name);
if (all[i].system)
return mcde_sys_fail(MCDE_SYS_EPERM, "%s holds the system and "
"is not erased.", name);
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_DISK_HOLDS_SYSTEM, "%s holds the system and is not erased."), name);
for (i = 0; i < n; i++)
if ((strcmp(all[i].name, name) == 0 ||
strcmp(all[i].parent, name) == 0) &&
all[i].mountpoint[0] != '\0')
return mcde_sys_fail(MCDE_SYS_EPERM, "%s is mounted on "
"%s: unmount it first.", all[i].name,
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_DISK_MOUNTED, "%s is mounted on %s: unmount it first."), all[i].name,
all[i].mountpoint);
{
char *destroy[] = { gptp, "destroy", (char *) name, NULL };
@@ -356,8 +349,7 @@ mcde_sys_disk_erase(const char *name, const char *fstype, const char *label,
return MCDE_SYS_EFAIL;
}
if ((p = strstr(out, "\ndk")) == NULL)
return mcde_sys_fail(MCDE_SYS_EFAIL, "The new partition did "
"not appear.");
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NDISK_PART_MISSING, "The new partition did not appear."));
p++;
snprintf(part, len, "%.*s", (int) strcspn(p, ":"), p);
snprintf(rdev, sizeof rdev, "/dev/r%s", part);
@@ -431,11 +423,10 @@ mcde_sys_permissions(int repair, char *log, size_t len)
log[0] = '\0';
if (dir == NULL)
return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no /etc/mtree.");
return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_NDISK_NO_MTREE, "There is no /etc/mtree."));
if (repair && geteuid() != 0) {
closedir(dir);
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can repair permissions.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NDISK_FIX_EPERM, "Only the administrator can repair permissions."));
}
while ((de = readdir(dir)) != NULL) {
char full[300], spec[64], *line, *last = NULL;
+9
View File
@@ -219,3 +219,12 @@ $set 1
215 %s is mounted on %s: unmount it first.
216 This system keeps no list of how its files' permissions should be.
217 No /proc/mounts.
218 No list of disks (hw.disknames).
220 A %s partition cannot be mounted.
223 A %s partition cannot be checked.
225 No %s here.
226 A name has letters, digits, blanks, - and _, at most 32.
230 The new partition did not appear.
231 There is no /etc/mtree.
232 Only the administrator can repair permissions.
233 No mount table.
+2 -2
View File
@@ -30,9 +30,9 @@ mcde_sys_mounts_backend(McdeSysMount *m, size_t max)
int n, i;
if (m == NULL || max == 0)
return mcde_sys_fail(MCDE_SYS_EINVAL, "No room for the mounts.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_MNT_NO_ROOM, "No room for the mounts."));
if ((n = getmntinfo(&mnt, MNT_NOWAIT)) <= 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "No mount table.");
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NMNT_NO_TABLE, "No mount table."));
for (i = 0; i < n && (size_t) i < max; i++) {
McdeSysMount *x = &m[i];
+11
View File
@@ -248,6 +248,17 @@ int mcde_sys_fail(int status, const char *fmt, ...);
#define MSG_DISK_NO_PERM_LIST 216
/* mount_linux.c */
#define MSG_MNT_NO_PROC 217
/* disk_netbsd.c: hw.disknames, disklabel, newfs and the permissions */
#define MSG_NDISK_NO_LIST 218
#define MSG_NDISK_PART_MOUNT 220
#define MSG_NDISK_PART_CHECK 223
#define MSG_NDISK_NO_DEVICE 225
#define MSG_NDISK_BAD_NAME 226
#define MSG_NDISK_PART_MISSING 230
#define MSG_NDISK_NO_MTREE 231
#define MSG_NDISK_FIX_EPERM 232
/* mount_netbsd.c */
#define MSG_NMNT_NO_TABLE 233
const char *mcde_sys_msg(int n, const char *text);
/* run ARGV (an absolute path first) and wait; MCDE_SYS_OK on exit status 0 */
@@ -217,3 +217,12 @@ $set 1
215 %s ist auf %s eingehängt: zuerst aushängen.
216 Dieses System führt keine Liste, wie die Rechte seiner Dateien sein sollen.
217 Kein /proc/mounts.
218 Keine Plattenliste (hw.disknames).
220 Eine %s-Partition kann nicht eingehängt werden.
223 Eine %s-Partition kann nicht geprüft werden.
225 Kein %s hier.
226 Ein Name hat Buchstaben, Ziffern, Leerzeichen, - und _, höchstens 32.
230 Die neue Partition ist nicht erschienen.
231 Es gibt kein /etc/mtree.
232 Nur der Administrator kann die Rechte reparieren.
233 Keine Einhängetabelle.