Commit d5cc2c40 authored by Robert Sprowson's avatar Robert Sprowson

Correction to Boot$ReadOnly evaluation logic

BootVars was not accounting for a locked drive (with FSLock) when working out whether to set Boot$ReadOnly.
This meant that a locked drive would unhelpfully create a small RAM disc with a default setup in it rather than running the normal boot sequence (albeit locked against changes to everything except $.Public and !Scrap).
Tested on RISC OS 4.02.

Version 1.21. Tagged as 'Boot-1_21'
parent 7c1754c9
......@@ -42,6 +42,7 @@
#include "Global/OsBytes.h"
#include "Global/FSNumbers.h"
#include "Interface/Econet.h"
#include "Interface/HighFSI.h"
#include "sys/types.h"
#include "sys/dcistructs.h"
......@@ -268,26 +269,47 @@ static bool fs_is_readonly(char *unique)
{
char buffer[256];
int type, load_addr, exec_addr, size, attr;
int state, whichfs;
_kernel_oserror *err;
sprintf(buffer, "<Boot$Dir>.MchConfig.%s", unique);
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5), 17, buffer, &type, &load_addr, &exec_addr, &size, &attr);
if (err || type == 0) {
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5),
OSFile_ReadNoPath, buffer,
&type, &load_addr, &exec_addr, &size, &attr);
if ((err != NULL) || (type == object_nothing)) {
sprintf(buffer, "<Boot$Dir>.RO<Boot$OSVersion>Hook");
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5), 17, buffer, &type, &load_addr, &exec_addr, &size, &attr);
if (err || type == 0) {
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5),
OSFile_ReadNoPath, buffer,
&type, &load_addr, &exec_addr, &size, &attr);
if ((err != NULL) || (type == object_nothing)) {
sprintf(buffer, "<Boot$Dir>.Choices");
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5), 17, buffer, &type, &load_addr, &exec_addr, &size, &attr);
if (err || type == 0)
err = _swix(OS_File, _INR(0,1) | _OUT(0) | _OUTR(2,5),
OSFile_ReadNoPath, buffer,
&type, &load_addr, &exec_addr, &size, &attr);
if ((err != NULL) || (type == object_nothing))
{
/* None of the tree for network/local !Boot seems to be there */
return true;
}
}
}
err = _swix(OS_File, _INR(0,3) | _IN(5), 1, buffer, load_addr, exec_addr, attr);
/* Need to distinguish a) FS is readonly (like ROMFS or ResourceFS)
* b) Media is write protected (a disc with a write protect tab)
* c) FS is locked (via FSLock)
*/
err = _swix(FSLock_Status, _IN(0) | _OUTR(0,1), 0, &state, &whichfs);
if (err == NULL) {
if ((bootvars_read_configured_fs() == whichfs) && (state != 0)) {
/* Case (c) isn't readonly as FSLock whitelists !Scrap and Public */
return false;
}
}
/* Try refreshing the catalogue entry, this catches (a) and (b) in one test */
err = _swix(OS_File, _INR(0,3) | _IN(5),
OSFile_WriteInfo, buffer, load_addr, exec_addr, attr);
return err ? true : false;
return (err != NULL) ? true : false;
}
static void bootvars_readonly_unique(bool readonly)
......
/* (1.20)
/* (1.21)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.20
#define Module_MajorVersion_CMHG 1.21
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Apr 2014
#define Module_Date_CMHG 26 Sep 2014
#define Module_MajorVersion "1.20"
#define Module_Version 120
#define Module_MajorVersion "1.21"
#define Module_Version 121
#define Module_MinorVersion ""
#define Module_Date "18 Apr 2014"
#define Module_Date "26 Sep 2014"
#define Module_ApplicationDate "18-Apr-14"
#define Module_ApplicationDate "26-Sep-14"
#define Module_ComponentName "Boot"
#define Module_ComponentPath "castle/RiscOS/Sources/SystemRes/Boot"
#define Module_FullVersion "1.20"
#define Module_HelpVersion "1.20 (18 Apr 2014)"
#define Module_LibraryVersionInfo "1:20"
#define Module_FullVersion "1.21"
#define Module_HelpVersion "1.21 (26 Sep 2014)"
#define Module_LibraryVersionInfo "1:21"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment