mirror of
https://github.com/sheumann/NetDisk.git
synced 2024-06-09 06:29:28 +00:00
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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gsos.h>
|
#include <locator.h>
|
||||||
#include "mounturl.h"
|
#include "mounturl.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
struct MountURLRec mountURLRec;
|
if (argc < 2)
|
||||||
DAccessRecGS controlRec = {5};
|
|
||||||
|
|
||||||
if (argc < 3)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mountURLRec.byteCount = sizeof(mountURLRec);
|
struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
|
||||||
mountURLRec.url = argv[2];
|
mountURLRec.result = NETDISK_NOT_PRESENT;
|
||||||
|
mountURLRec.url = argv[1];
|
||||||
|
|
||||||
controlRec.devNum = strtoul(argv[1], NULL, 0);
|
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
||||||
controlRec.code = MountURL;
|
(Long)&mountURLRec, NULL);
|
||||||
controlRec.list = (Pointer)&mountURLRec;
|
|
||||||
controlRec.requestCount = sizeof(mountURLRec);
|
|
||||||
|
|
||||||
DControl(&controlRec);
|
|
||||||
|
|
||||||
if (mountURLRec.result != OPERATION_SUCCESSFUL) {
|
if (mountURLRec.result != OPERATION_SUCCESSFUL) {
|
||||||
fprintf(stderr, "MountURL error %u\n", mountURLRec.result);
|
fprintf(stderr, "MountURL error %u\n", mountURLRec.result);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
/* Custom DControl code and request code for MountURL operation */
|
/* Custom DControl code and request code for MountURL operation */
|
||||||
#define MountURL 0x8080
|
#define MountURL 0x8080
|
||||||
|
|
||||||
|
#define NETDISK_REQUEST_NAME "\pSTH~NetDisk~"
|
||||||
|
|
||||||
struct MountURLRec {
|
struct MountURLRec {
|
||||||
Word byteCount;
|
Word byteCount;
|
||||||
enum NetDiskError result; /* output value */
|
enum NetDiskError result; /* output value */
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
enum NetDiskError {
|
enum NetDiskError {
|
||||||
OPERATION_SUCCESSFUL = 0,
|
OPERATION_SUCCESSFUL = 0,
|
||||||
|
|
||||||
DISK_ALREADY_MOUNTED = 100,
|
NETDISK_NOT_PRESENT = 100,
|
||||||
|
DISK_ALREADY_MOUNTED,
|
||||||
|
NO_DIBS_AVAILABLE,
|
||||||
OUT_OF_MEMORY,
|
OUT_OF_MEMORY,
|
||||||
|
|
||||||
/* SetURL errors */
|
/* SetURL errors */
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "installdriver.h"
|
#include "installdriver.h"
|
||||||
#include "asmglue.h"
|
#include "asmglue.h"
|
||||||
|
#include "mounturl.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
||||||
|
@ -30,6 +31,7 @@ static struct NotificationProcRec {
|
||||||
#define NOTIFY_GSOS_SWITCH 0x04
|
#define NOTIFY_GSOS_SWITCH 0x04
|
||||||
|
|
||||||
static void notificationProc(void);
|
static void notificationProc(void);
|
||||||
|
static pascal Word mountRequestProc(Word reqCode, void *dataIn, void *dataOut);
|
||||||
|
|
||||||
#define JML 0x5C
|
#define JML 0x5C
|
||||||
|
|
||||||
|
@ -78,6 +80,9 @@ int main(void) {
|
||||||
* yet when this init loads).
|
* yet when this init loads).
|
||||||
*/
|
*/
|
||||||
SetDefaultTPT();
|
SetDefaultTPT();
|
||||||
|
|
||||||
|
/* Accept requests to mount URLs */
|
||||||
|
AcceptRequests(NETDISK_REQUEST_NAME, userid(), &mountRequestProc);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -104,3 +109,39 @@ static void notificationProc(void) {
|
||||||
}
|
}
|
||||||
#pragma databank 0
|
#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
Block a user