revert between 56095 -> 55830 in arch
[AROS.git] / rom / dos / fs_driver.c
blob922744307bb31e9629da945f435daec34fc194f7
1 /*
2 Copyright © 2011-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Low-level filesystem access functions, packet version
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <dos/dos.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)
19 SIPTR error = 0;
20 BSTR bstrname = C2BSTR(name);
22 if (!bstrname)
23 return ERROR_NO_FREE_STORE;
25 *ret = (BPTR)dopacket3(DOSBase, &error, port, ACTION_LOCATE_OBJECT, parent, bstrname, accessMode);
26 FREEC2BSTR(bstrname);
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)
33 ULONG action;
34 BSTR bstrname;
35 SIPTR error = 0;
36 LONG status;
38 /* The MODE_* flags exactly match their corresponding ACTION_*
39 * flags:
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))
51 action = mode;
52 else
53 return ERROR_NOT_IMPLEMENTED;
55 bstrname = C2BSTR(name);
56 if (!bstrname)
57 return ERROR_NO_FREE_STORE;
59 status = dopacket3(DOSBase, &error, port, action, MKBADDR(handle), lock, bstrname);
60 FREEC2BSTR(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)
68 struct MsgPort *port;
70 if (parent)
72 struct FileLock *fl = BADDR(parent);
74 port = fl->fl_Task;
76 else
78 port = dvp->dvp_Port;
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)
87 SIPTR error = 0;
88 LONG status;
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)
98 SIPTR err = 0;
99 LONG status = dopacket1(DOSBase, &err, notify->nr_Handler, ACTION_ADD_NOTIFY, (SIPTR)notify);
101 return status ? 0 : err;