1 #include <exec/types.h>
3 #include <dos/dosextens.h>
4 #include <dos/filesystem.h>
5 #include <proto/exec.h>
9 int main(int argc
, char **argv
) {
11 struct IOFileSys iofs
;
12 struct FileHandle
*fh
;
16 printf("usage: %s path\n", argv
[0]);
20 iofs
.IOFS
.io_Message
.mn_Node
.ln_Type
= NT_REPLYMSG
;
21 iofs
.IOFS
.io_Message
.mn_ReplyPort
= &(((struct Process
*) FindTask(NULL
))->pr_MsgPort
);
22 iofs
.IOFS
.io_Message
.mn_Length
= sizeof(struct IOFileSys
);
23 iofs
.IOFS
.io_Flags
= 0;
25 iofs
.io_Union
.io_OPEN
.io_Filename
= "";
26 iofs
.io_Union
.io_OPEN
.io_FileMode
= FMF_READ
;
29 while ((dvp
= GetDeviceProc(argv
[1], dvp
)) != NULL
) {
30 iofs
.IOFS
.io_Command
= FSA_OPEN
;
31 iofs
.IOFS
.io_Device
= (struct Device
*) dvp
->dvp_Port
;
33 if (dvp
->dvp_Lock
!= NULL
)
34 iofs
.IOFS
.io_Unit
= ((struct FileHandle
*) BADDR(dvp
->dvp_Lock
))->fh_Unit
;
36 iofs
.IOFS
.io_Unit
= dvp
->dvp_DevNode
->dol_Ext
.dol_AROS
.dol_Unit
;
40 if (iofs
.io_DosError
== 0) {
41 fh
= AllocDosObject(DOS_FILEHANDLE
, NULL
);
42 fh
->fh_Device
= iofs
.IOFS
.io_Device
;
43 fh
->fh_Unit
= iofs
.IOFS
.io_Unit
;
45 if (NameFromLock(MKBADDR(fh
), buf
, sizeof(buf
)) == DOSFALSE
) {
46 Fault(IoErr(), NULL
, buf
, sizeof(buf
));
47 printf("found file, but couldn't get lock name: %s\n", buf
);
50 printf("found in: %s\n", buf
);
55 else if (iofs
.io_DosError
!= ERROR_OBJECT_NOT_FOUND
) {
56 Fault(IoErr(), NULL
, buf
, sizeof(buf
));
57 printf("error expanding name: %s\n", buf
);