2 Copyright © 2011-2014, The AROS Development Team. All rights reserved.
5 Desc: Low-level filesystem access functions, packet version
9 #include <aros/debug.h>
11 #include <proto/dos.h>
12 #include <proto/exec.h>
14 #include "dos_intern.h"
15 #include "fs_driver.h"
17 LONG
fs_LocateObject(BPTR
*ret
, struct MsgPort
*port
, BPTR parent
, CONST_STRPTR name
, LONG accessMode
, struct DosLibrary
*DOSBase
)
20 BSTR bstrname
= C2BSTR(name
);
23 return ERROR_NO_FREE_STORE
;
25 *ret
= (BPTR
)dopacket3(DOSBase
, &error
, port
, ACTION_LOCATE_OBJECT
, parent
, bstrname
, accessMode
);
28 return (*ret
) ? 0 : error
;
31 LONG
fs_Open(struct FileHandle
*handle
, struct MsgPort
*port
, BPTR lock
, LONG mode
, CONST_STRPTR name
, struct DosLibrary
*DOSBase
)
38 /* The MODE_* flags exactly match their corresponding ACTION_*
41 * MODE_READWRITE = ACTION_FINDUPDATE = 1004
42 * MODE_OLDFILE = ACTION_FINDINPUT = 1005
43 * MODE_NEWFILE = ACTION_FINDOUTPUT = 1006
45 * Even so, we don't want bad data propagating
46 * down, so check that the mode is valid.
48 if ((mode
== MODE_READWRITE
) ||
49 (mode
== MODE_OLDFILE
) ||
50 (mode
== MODE_NEWFILE
))
53 return ERROR_NOT_IMPLEMENTED
;
55 bstrname
= C2BSTR(name
);
57 return ERROR_NO_FREE_STORE
;
59 status
= dopacket3(DOSBase
, &error
, port
, action
, MKBADDR(handle
), lock
, bstrname
);
62 handle
->fh_Type
= port
;
63 return status
? 0 : error
;
66 LONG
fs_ReadLink(BPTR parent
, struct DevProc
*dvp
, CONST_STRPTR path
, STRPTR buffer
, ULONG size
, struct DosLibrary
*DOSBase
)
72 struct FileLock
*fl
= BADDR(parent
);
79 parent
= dvp
->dvp_Lock
;
82 return ReadLink(port
, parent
, path
, buffer
, size
);
85 LONG
fs_ChangeSignal(BPTR handle
, struct Process
*task
, struct DosLibrary
*DOSBase
)
89 struct FileHandle
*fh
= BADDR(handle
);
91 status
= dopacket3(DOSBase
, &error
, fh
->fh_Type
, ACTION_CHANGE_SIGNAL
, fh
->fh_Arg1
, (IPTR
)task
, (SIPTR
)NULL
);
93 return status
? 0 : error
;
96 LONG
fs_AddNotify(struct NotifyRequest
*notify
, struct DevProc
*dvp
, BPTR lock
, struct DosLibrary
*DOSBase
)
99 LONG status
= dopacket1(DOSBase
, &err
, notify
->nr_Handler
, ACTION_ADD_NOTIFY
, (SIPTR
)notify
);
101 return status
? 0 : err
;