I had noticed for years that eeprom(8) always reported failure when
attempting to change OpenFirmware environment variables on macppc.

Upon further examination, it doesn't - the variables get changed, but
error is reported. This is caused by a difference in implementation
behaviour between Apple's OpenFirmware and Sun's.

Suggested diff below; clue from NetBSD.

Before:
# eeprom boot-command
boot-command=mac-boot
# eeprom boot-command=boot
eeprom: invalid keyword: boot-command
# eeprom boot-command
boot-command=boot                   <-- yet the value has been changed

After:
# eeprom boot-command
boot-command=mac-boot
# eeprom boot-command=boot
# eeprom boot-command
boot-command=boot


Index: openprom.c
===================================================================
RCS file: /OpenBSD/src/sys/arch/macppc/macppc/openprom.c,v
retrieving revision 1.4
diff -u -p -r1.4 openprom.c
--- openprom.c  19 Sep 2015 21:07:04 -0000      1.4
+++ openprom.c  20 Sep 2020 17:56:35 -0000
@@ -186,7 +186,11 @@ openpromioctl(dev_t dev, u_long cmd, cad
                strlcpy(buf, name, 32); /* XXX */
                len = OF_setprop(node, buf, value, op->op_buflen + 1);
                splx(s);
-               if (len != op->op_buflen)
+               /*
+                * For string properties, the Apple OpenFirmware implementation
+                * returns the buffer length including the trailing NUL.
+                */
+               if (len != op->op_buflen && len != op->op_buflen + 1)
                        error = EINVAL;
                break;
 

Reply via email to