grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / dos / endnotify.c
blob8aed35441934f4d1f8f5068ffb3ec52c13342edd
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <exec/lists.h>
11 #include <proto/exec.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
19 #include <dos/notify.h>
20 #include <proto/dos.h>
22 #include <string.h>
24 AROS_LH1(void, EndNotify,
26 /* SYNOPSIS */
27 AROS_LHA(struct NotifyRequest *, notify, D1),
29 /* LOCATION */
30 struct DosLibrary *, DOSBase, 149, Dos)
32 /* FUNCTION
33 End a notification (quit notifying for a request previously sent with
34 StartNotify()).
36 INPUTS
37 notify - NotifyRequest used with StartNotify()
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 StartNotify()
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
57 * Packet handlers love to replace nr_Handler of active requests with a pointer
58 * to own real message port. It's not possible to prevent this by (simple) external
59 * means.
60 * This is why we use packet I/O here on all architectures. If nr_Handler points
61 * to packet message port, the packet will be sent directly, bypassing IOFS layer.
62 * This is 100% safe because we don't pass any locks and/or filehandles here.
63 * If nr_Handler still points to IOFS device, packet I/O emulator will take care about
64 * this.
66 dopacket1(DOSBase, NULL, notify->nr_Handler, ACTION_REMOVE_NOTIFY, (SIPTR)notify);
68 /* free fullname if it was built in StartNotify() */
69 if (notify->nr_FullName != notify->nr_Name)
70 FreeVec(notify->nr_FullName);
72 /* if the filesystem has outstanding messages, they need to be replied */
73 if ((notify->nr_Flags & NRF_SEND_MESSAGE) &&
74 ((notify->nr_Flags & NRF_WAIT_REPLY) || notify->nr_MsgCount > 0))
76 struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port;
77 struct NotifyMessage *nm, *tmp;
79 notify->nr_Flags &= ~NRF_MAGIC;
81 /* protect access to the message list */
82 Disable();
84 /* loop over the messages */
85 ForeachNodeSafe(&port->mp_MsgList, nm, tmp) {
86 /* if its one of our notify messages */
87 if (nm->nm_Class == NOTIFY_CLASS &&
88 nm->nm_Code == NOTIFY_CODE &&
89 nm->nm_NReq == notify) {
91 /* remove and reply */
92 Remove((struct Node *) nm);
93 ReplyMsg((struct Message *) nm);
95 /* decrement the count. bail early if we've done them all */
96 notify->nr_MsgCount--;
97 if (notify->nr_MsgCount == 0)
98 break;
102 /* unlock the list */
103 Enable();
106 AROS_LIBFUNC_EXIT
107 } /* EndNotify */