2 * ntfs.handler - New Technology FileSystem handler
4 * Copyright © 2012 The AROS Development Team
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
12 #define AROS_ALMOST_COMPATIBLE
14 #include <exec/types.h>
16 #include <dos/notify.h>
17 #include <proto/exec.h>
20 #include "ntfs_protos.h"
24 void SendNotify(struct NotifyRequest
*nr
)
26 struct NotifyMessage
*nm
;
28 D(bug("[NTFS] notifying for '%s'\n", nr
->nr_FullName
));
30 /* signals are a doddle */
31 if (nr
->nr_Flags
& NRF_SEND_SIGNAL
) {
32 D(bug("[NTFS] sending signal %ld to task 0x%08x\n", nr
->nr_stuff
.nr_Signal
.nr_SignalNum
, nr
->nr_stuff
.nr_Signal
.nr_Task
));
34 Signal(nr
->nr_stuff
.nr_Signal
.nr_Task
, 1 << nr
->nr_stuff
.nr_Signal
.nr_SignalNum
);
39 /* if message isn't set, then they screwed up, and there's nothing to do */
40 if (!(nr
->nr_Flags
& NRF_SEND_MESSAGE
)) {
41 D(bug("[NTFS] weird, request doesn't have SIGNAL or MESSAGE bits set, doing nothing\n"));
45 /* don't send if we're supposed to wait for them to reply and there's
46 * still messages outstanding */
47 if (nr
->nr_Flags
& NRF_WAIT_REPLY
&& nr
->nr_MsgCount
> 0) {
48 D(bug("[NTFS] request has WAIT_REPLY set and there are %ld messages outstanding, doing nothing\n", nr
->nr_MsgCount
));
55 D(bug("[NTFS] request now has %ld messages outstanding\n", nr
->nr_MsgCount
));
57 /* allocate and build the message */
58 nm
= AllocVec(sizeof(struct NotifyMessage
), MEMF_PUBLIC
| MEMF_CLEAR
);
59 nm
->nm_ExecMessage
.mn_ReplyPort
= glob
->notifyport
;
60 nm
->nm_ExecMessage
.mn_Length
= sizeof(struct NotifyMessage
);
61 nm
->nm_Class
= NOTIFY_CLASS
;
62 nm
->nm_Code
= NOTIFY_CODE
;
65 D(bug("[NTFS] sending notify message to port 0x%08x\n", nr
->nr_stuff
.nr_Msg
.nr_Port
));
68 PutMsg(nr
->nr_stuff
.nr_Msg
.nr_Port
, (struct Message
*) nm
);
71 /* send a notification for the file referenced by the passed global lock */
72 void SendNotifyByLock(struct FSData
*sb
, struct GlobalLock
*gl
)
74 struct NotifyNode
*nn
;
76 D(bug("[NTFS] notifying for lock (%ld/%ld)\n", gl
->dir_cluster
, gl
->dir_entry
));
78 ForeachNode(&sb
->info
->notifies
, nn
)
83 /* send a notification for the file referenced by the passed dir entry */
84 void SendNotifyByDirEntry(struct FSData
*sb
, struct DirEntry
*de
)
86 struct NotifyNode
*nn
;
90 /* Inside the loop we may reuse the dirhandle, so here we explicitly mark it
94 D(bug("[NTFS] notifying for dir entry (%ld/%ld)\n", de
->cluster
, de
->no
));
96 ForeachNode(&sb
->info
->notifies
, nn
)
98 if (nn
->gl
->dir_cluster
== de
->cluster
&& nn
->gl
->dir_entry
== de
->no
)
103 if (InitDirHandle(sb
, &sdh
, TRUE
) != 0)
106 if (GetDirEntryByPath(&sdh
, nn
->nr
->nr_FullName
, strlen(nn
->nr
->nr_FullName
), &sde
) != 0)
109 if (sde
.cluster
== de
->cluster
&& sde
.no
== de
->no
)
112 ReleaseDirHandle(&sdh
);
116 /* handle returned notify messages */
117 void ProcessNotify(void)
119 struct NotifyMessage
*nm
;
121 while ((nm
= (struct NotifyMessage
*) GetMsg(glob
->notifyport
)) != NULL
)
123 if (nm
->nm_Class
== NOTIFY_CLASS
&& nm
->nm_Code
== NOTIFY_CODE
) {
124 nm
->nm_NReq
->nr_MsgCount
--;
125 if (nm
->nm_NReq
->nr_MsgCount
< 0)
126 nm
->nm_NReq
->nr_MsgCount
= 0;
128 D(bug("[NTFS] received notify message reply, %ld messages outstanding for this request\n", nm
->nm_NReq
->nr_MsgCount
));
134 D(bug("[NTFS] non-notify message received, dropping it\n"));