On 2021-11-15 2:41 p.m., Ted Bullock wrote:
> On 2021-11-15 2:21 p.m., Theo de Raadt wrote:
>> I do want fchmod for random reuse on most sparc64 machines. But if
>> OFW "write"
>> support isn't working on some machines, we should nop it out. Luckily
>> this is
>> in MD code.
>
> It's probably reasonable for any version older than OpenBoot 4.17.1
> should get this treatment (This is the most recent ofw for the blade
> 100/150)
>
I've had some difficulty trying to figure out how the OFW actually is
programmed, specifically how to query the PROM version.
Anyway, I've included a patch with how I think to work around the broken
prom? Does this approach work? Obviously it needs the logic to check for
the prom version and I do see some whitespace issues too.
Index: arch/sparc64/stand/ofwboot/ofdev.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/stand/ofwboot/ofdev.c,v
retrieving revision 1.31
diff -u -p -u -p -r1.31 ofdev.c
--- arch/sparc64/stand/ofwboot/ofdev.c 9 Dec 2020 18:10:19 -0000 1.31
+++ arch/sparc64/stand/ofwboot/ofdev.c 19 Nov 2021 01:07:40 -0000
@@ -666,6 +666,17 @@ devopen(struct open_file *of, const char
ofdev.handle = handle;
ofdev.type = OFDEV_DISK;
ofdev.bsize = DEV_BSIZE;
+
+ /*
+ * Older OpenBoot PROMS seem to have bugged writing code
+ * At least OpenBoot Version Equal or Older to 4.17.1
+ * How do you ask OFW this?
+ */
+ if (1) {
+ printf("devopen: Flagging %s with F_NOWRITE\n", fname);
+ of->f_flags |= F_NOWRITE;
+ }
+
if (!strcmp(buf, "block")) {
error = load_disklabel(&ofdev, &label);
if (error && error != ERDLAB)
Index: lib/libsa/fchmod.c
===================================================================
RCS file: /cvs/src/sys/lib/libsa/fchmod.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 fchmod.c
--- lib/libsa/fchmod.c 3 Aug 2019 15:22:17 -0000 1.1
+++ lib/libsa/fchmod.c 19 Nov 2021 01:07:48 -0000
@@ -53,6 +53,12 @@ fchmod(int fd, mode_t m)
errno = EOPNOTSUPP;
return (-1);
}
+ /* writing is broken or unsupported */
+ if (f->f_flags & F_NOWRITE) {
+ errno = EOPNOTSUPP;
+ printf("Awooga Don't Write\n");
+ return (-1);
+ }
errno = (f->f_ops->fchmod)(f, m);
return (0);
Index: lib/libsa/stand.h
===================================================================
RCS file: /cvs/src/sys/lib/libsa/stand.h,v
retrieving revision 1.71
diff -u -p -u -p -r1.71 stand.h
--- lib/libsa/stand.h 24 Oct 2021 17:49:19 -0000 1.71
+++ lib/libsa/stand.h 19 Nov 2021 01:07:48 -0000
@@ -111,6 +111,7 @@ extern struct open_file files[];
#define F_WRITE 0x0002 /* file opened for writing */
#define F_RAW 0x0004 /* raw device open - no file system */
#define F_NODEV 0x0008 /* network open - no device */
+#define F_NOWRITE 0x0010 /* bootblock writing is broken or unsupported */
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define islower(c) ((c) >= 'a' && (c) <= 'z')
--
Ted Bullock <[email protected]>