- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / test / getdeviceproc.c
blob03df042afc5f584e85096ea1aa8fe1fd2b325d88
1 #include <exec/types.h>
2 #include <dos/dos.h>
3 #include <dos/dosextens.h>
4 #include <dos/filesystem.h>
5 #include <proto/exec.h>
6 #include <proto/dos.h>
7 #include <stdio.h>
9 int main(int argc, char **argv) {
10 #ifdef AROS_DOS_PACKETS
11 return 0;
12 #else
13 struct DevProc *dvp;
14 struct IOFileSys iofs;
15 struct FileHandle *fh;
16 UBYTE buf[256];
18 if (argc != 2) {
19 printf("usage: %s path\n", argv[0]);
20 return 1;
23 iofs.IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
24 iofs.IOFS.io_Message.mn_ReplyPort = &(((struct Process *) FindTask(NULL))->pr_MsgPort);
25 iofs.IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
26 iofs.IOFS.io_Flags = 0;
28 iofs.io_Union.io_OPEN.io_Filename = "";
29 iofs.io_Union.io_OPEN.io_FileMode = FMF_READ;
31 dvp = NULL;
32 while ((dvp = GetDeviceProc(argv[1], dvp)) != NULL) {
33 iofs.IOFS.io_Command = FSA_OPEN;
34 iofs.IOFS.io_Device = (struct Device *) dvp->dvp_Port;
36 if (dvp->dvp_Lock != NULL)
37 iofs.IOFS.io_Unit = ((struct FileHandle *) BADDR(dvp->dvp_Lock))->fh_Unit;
38 else
39 iofs.IOFS.io_Unit = dvp->dvp_DevNode->dol_Ext.dol_AROS.dol_Unit;
41 DoIO(&iofs.IOFS);
43 if (iofs.io_DosError == 0) {
44 fh = AllocDosObject(DOS_FILEHANDLE, NULL);
45 fh->fh_Device = iofs.IOFS.io_Device;
46 fh->fh_Unit = iofs.IOFS.io_Unit;
48 if (NameFromLock(MKBADDR(fh), buf, sizeof(buf)) == DOSFALSE) {
49 Fault(IoErr(), NULL, buf, sizeof(buf));
50 printf("found file, but couldn't get lock name: %s\n", buf);
52 else
53 printf("found in: %s\n", buf);
55 Close(MKBADDR(fh));
58 else if (iofs.io_DosError != ERROR_OBJECT_NOT_FOUND) {
59 Fault(IoErr(), NULL, buf, sizeof(buf));
60 printf("error expanding name: %s\n", buf);
61 FreeDeviceProc(dvp);
62 return 1;
66 FreeDeviceProc(dvp);
68 return 0;
69 #endif