Implement request procedure for mounting a disk by URL.
This commit is contained in:
parent
8b09d6bb7d
commit
4dbfd93179
20
mounturl.c
20
mounturl.c
|
@ -1,25 +1,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <gsos.h>
|
||||
#include <locator.h>
|
||||
#include "mounturl.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct MountURLRec mountURLRec;
|
||||
DAccessRecGS controlRec = {5};
|
||||
|
||||
if (argc < 3)
|
||||
if (argc < 2)
|
||||
return;
|
||||
|
||||
mountURLRec.byteCount = sizeof(mountURLRec);
|
||||
mountURLRec.url = argv[2];
|
||||
struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
|
||||
mountURLRec.result = NETDISK_NOT_PRESENT;
|
||||
mountURLRec.url = argv[1];
|
||||
|
||||
controlRec.devNum = strtoul(argv[1], NULL, 0);
|
||||
controlRec.code = MountURL;
|
||||
controlRec.list = (Pointer)&mountURLRec;
|
||||
controlRec.requestCount = sizeof(mountURLRec);
|
||||
|
||||
DControl(&controlRec);
|
||||
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
||||
(Long)&mountURLRec, NULL);
|
||||
|
||||
if (mountURLRec.result != OPERATION_SUCCESSFUL) {
|
||||
fprintf(stderr, "MountURL error %u\n", mountURLRec.result);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
/* Custom DControl code and request code for MountURL operation */
|
||||
#define MountURL 0x8080
|
||||
|
||||
#define NETDISK_REQUEST_NAME "\pSTH~NetDisk~"
|
||||
|
||||
struct MountURLRec {
|
||||
Word byteCount;
|
||||
enum NetDiskError result; /* output value */
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
enum NetDiskError {
|
||||
OPERATION_SUCCESSFUL = 0,
|
||||
|
||||
DISK_ALREADY_MOUNTED = 100,
|
||||
NETDISK_NOT_PRESENT = 100,
|
||||
DISK_ALREADY_MOUNTED,
|
||||
NO_DIBS_AVAILABLE,
|
||||
OUT_OF_MEMORY,
|
||||
|
||||
/* SetURL errors */
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "driver.h"
|
||||
#include "installdriver.h"
|
||||
#include "asmglue.h"
|
||||
#include "mounturl.h"
|
||||
#include "version.h"
|
||||
|
||||
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
||||
|
@ -30,6 +31,7 @@ static struct NotificationProcRec {
|
|||
#define NOTIFY_GSOS_SWITCH 0x04
|
||||
|
||||
static void notificationProc(void);
|
||||
static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut);
|
||||
|
||||
#define JML 0x5C
|
||||
|
||||
|
@ -78,6 +80,9 @@ int main(void) {
|
|||
* yet when this init loads).
|
||||
*/
|
||||
SetDefaultTPT();
|
||||
|
||||
/* Accept requests to mount URLs */
|
||||
AcceptRequests(NETDISK_REQUEST_NAME, userid(), &mountRequestProc);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -104,3 +109,39 @@ static void notificationProc(void) {
|
|||
}
|
||||
#pragma databank 0
|
||||
|
||||
static void doMountURL(struct MountURLRec *mountURLRec) {
|
||||
DAccessRecGS controlRec = {5};
|
||||
controlRec.code = MountURL;
|
||||
controlRec.list = (pointer)mountURLRec;
|
||||
controlRec.requestCount = mountURLRec->byteCount;
|
||||
|
||||
for (unsigned i = 0; i < NDIBS; i++) {
|
||||
Word devNum = dibs[i].DIBDevNum;
|
||||
if (devNum == 0)
|
||||
continue;
|
||||
|
||||
controlRec.devNum = devNum;
|
||||
DControl(&controlRec);
|
||||
|
||||
if (mountURLRec->result != DISK_ALREADY_MOUNTED)
|
||||
return;
|
||||
}
|
||||
|
||||
mountURLRec->result = NO_DIBS_AVAILABLE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Request procedure called to mount a disk image by URL.
|
||||
*/
|
||||
#pragma databank 1
|
||||
#pragma toolparms 1
|
||||
static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut) {
|
||||
if (reqCode == MountURL) {
|
||||
doMountURL((struct MountURLRec *) dataIn);
|
||||
return 0x8000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma toolparms 0
|
||||
#pragma databank 0
|
||||
|
|
Loading…
Reference in New Issue