Minor fixes to comments.
[AROS.git] / rom / dos / fs_driver.c
blob0e39d29adabdd273ceebafc9150a95b7af064182
1 /*
2 Copyright © 2011, 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 propogaing
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 if (!port)
57 /* handler pointer not set, return NIL: handle */
58 SetIoErr(0);
59 handle->fh_Type = BNULL;
60 /* NIL: is not considered interactive */
61 handle->fh_Interactive = DOSFALSE;
62 return 0;
65 bstrname = C2BSTR(name);
66 if (!bstrname)
67 return ERROR_NO_FREE_STORE;
69 status = dopacket3(DOSBase, &error, port, action, MKBADDR(handle), lock, bstrname);
70 FREEC2BSTR(bstrname);
72 handle->fh_Type = port;
73 return status ? 0 : error;
76 LONG fs_ReadLink(BPTR parent, struct DevProc *dvp, CONST_STRPTR path, STRPTR buffer, ULONG size, struct DosLibrary *DOSBase)
78 struct MsgPort *port;
80 if (parent)
82 struct FileLock *fl = BADDR(parent);
84 port = fl->fl_Task;
86 else
88 port = dvp->dvp_Port;
89 parent = dvp->dvp_Lock;
92 return ReadLink(port, parent, path, buffer, size);
95 LONG fs_ChangeSignal(BPTR handle, struct Process *task, struct DosLibrary *DOSBase)
97 SIPTR error = 0;
98 LONG status;
99 struct FileHandle *fh = BADDR(handle);
101 status = dopacket3(DOSBase, &error, fh->fh_Type, ACTION_CHANGE_SIGNAL, fh->fh_Arg1, (IPTR)task, (SIPTR)NULL);
103 return status ? 0 : error;
106 LONG fs_AddNotify(struct NotifyRequest *notify, struct DevProc *dvp, BPTR lock, struct DosLibrary *DOSBase)
108 SIPTR err = 0;
109 LONG status = dopacket1(DOSBase, &err, notify->nr_Handler, ACTION_ADD_NOTIFY, (SIPTR)notify);
111 return status ? 0 : err;