Add support for ejecting NetDisk volumes.

This commit is contained in:
Stephen Heumann 2018-08-10 22:40:07 -05:00
parent 2670da4f59
commit ccc9594412
4 changed files with 29 additions and 4 deletions

View File

@ -7,7 +7,7 @@ HTTPTEST_PROG = httptest
MOUNTURL_OBJS = mounturl.a
MOUNTURL_PROG = mounturl
NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a driver.a installdriver.a asmglue.a driverwrapper.a
NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a driver.a installdriver.a asmglue.a driverwrapper.a session.a
# NETDISKINIT_RSRC =
NETDISKINIT_PROG = NetDiskInit

View File

@ -7,6 +7,7 @@
#include "seturl.h"
#include "http.h"
#include "readtcp.h"
#include "tcpconnection.h"
#include "asmglue.h"
#include "version.h"
@ -215,11 +216,11 @@ static Word DoMountURL(struct GSOSDP *dp) {
dp->transferCount = 0;
return drvrNoResrc;
}
dp->dibPointer->extendedDIBPtr = sess;
enum SetURLResult setResult = SetURL(sess, (char*)dp->controlListPtr, TRUE, FALSE);
if (setResult != SETURL_SUCCESSFUL) {
// TODO arrange for more detailed error reporting
EndNetDiskSession(sess);
dp->transferCount = 0;
return drvrIOError;
}
@ -227,6 +228,7 @@ static Word DoMountURL(struct GSOSDP *dp) {
enum RequestResult requestResult = DoHTTPRequest(sess, 0, sizeof(sess->fileHeader) - 1);
if (requestResult != REQUEST_SUCCESSFUL) {
// TODO arrange for more detailed error reporting
EndNetDiskSession(sess);
dp->transferCount = 0;
return drvrIOError;
}
@ -239,9 +241,12 @@ static Word DoMountURL(struct GSOSDP *dp) {
Word checkResult = CheckTwoImg(sess);
if (checkResult != 0) {
EndNetDiskSession(sess);
// TODO error
}
dp->dibPointer->extendedDIBPtr = sess;
//TODO report disk switch
return 0;
@ -299,11 +304,16 @@ static Word DoStatus(struct GSOSDP *dp) {
}
static Word DoEject(struct GSOSDP *dp) {
//TODO
EndNetDiskSession(dp->dibPointer->extendedDIBPtr);
dp->dibPointer->extendedDIBPtr = NULL;
dp->transferCount = 0;
return 0;
}
static Word DoShutdown(struct GSOSDP *dp) {
//TODO
EndNetDiskSession(dp->dibPointer->extendedDIBPtr);
dp->dibPointer->extendedDIBPtr = NULL;
//TODO should return error unless all of our other DIBs are already shut down?
return 0;
}

12
session.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdlib.h>
#include "session.h"
#include "tcpconnection.h"
/* End a session and free associated data. */
void EndNetDiskSession(Session *sess) {
if (sess != NULL) {
EndTCPConnection(sess);
free(sess->httpRequest);
free(sess);
}
}

View File

@ -70,4 +70,7 @@ typedef struct Session {
} fileHeader;
} Session;
void EndNetDiskSession(Session *sess);
#endif