Eject all our disks when the network goes down.

This commit is contained in:
Stephen Heumann 2018-08-15 19:46:23 -05:00
parent 525dbbb1c5
commit 64ad28a740

View File

@ -13,6 +13,8 @@
#include "mounturl.h" #include "mounturl.h"
#include "version.h" #include "version.h"
#define TCPIP_REQUEST_NAME "\pTCP/IP~STH~NetDisk~"
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION; const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
Word *unloadFlagPtr; Word *unloadFlagPtr;
@ -32,6 +34,9 @@ static struct NotificationProcRec {
static void notificationProc(void); static void notificationProc(void);
static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut); static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut);
static pascal Word tcpipRequestProc(Word reqCode, void *dataIn, void *dataOut);
static void ejectAll(void);
#define JML 0x5C #define JML 0x5C
@ -84,6 +89,9 @@ int main(void) {
/* Accept requests to mount URLs */ /* Accept requests to mount URLs */
AcceptRequests(NETDISK_REQUEST_NAME, userid(), &mountRequestProc); AcceptRequests(NETDISK_REQUEST_NAME, userid(), &mountRequestProc);
/* Accept requests (notifications) from Marinetti */
AcceptRequests(TCPIP_REQUEST_NAME, userid(), &tcpipRequestProc);
return; return;
error: error:
@ -145,3 +153,38 @@ static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut) {
} }
#pragma toolparms 0 #pragma toolparms 0
#pragma databank 0 #pragma databank 0
/*
* Procedure to "eject" all our disks (called when network goes down).
*/
static void ejectAll(void) {
DAccessRecGS controlRec = {5};
controlRec.code = eject;
controlRec.list = NULL;
controlRec.requestCount = 0;
for (unsigned i = 0; i < NDIBS; i++) {
controlRec.devNum = dibs[i].DIBDevNum;
if (controlRec.devNum == 0)
continue;
DControl(&controlRec);
}
}
/*
* Request procedure called by Marinetti with its notifications.
* If the network has gone down, we unmount all the disks.
*/
#pragma databank 1
#pragma toolparms 1
static pascal Word tcpipRequestProc(Word reqCode, void *dataIn, void *dataOut) {
if (reqCode == TCPIPSaysNetworkDown) {
ejectAll();
}
return 0;
}
#pragma toolparms 0
#pragma databank 0