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 #include <exec/types.h>
13 #include <exec/execbase.h>
14 #include <dos/dosextens.h>
15 #include <dos/filehandler.h>
16 #include <devices/input.h>
17 #include <devices/inputevent.h>
18 #include <intuition/intuition.h>
19 #include <intuition/intuitionbase.h>
21 #include <proto/intuition.h>
22 #include <proto/exec.h>
23 #include <proto/alib.h>
33 void SendEvent(LONG event
) {
34 struct IOStdReq
*InputRequest
;
35 struct MsgPort
*InputPort
;
36 struct InputEvent
*ie
;
38 if ((InputPort
= (struct MsgPort
*)CreateMsgPort())) {
40 if ((InputRequest
= (struct IOStdReq
*)CreateIORequest(InputPort
, sizeof(struct IOStdReq
)))) {
42 if (!OpenDevice("input.device", 0, (struct IORequest
*)InputRequest
, 0)) {
44 if ((ie
= AllocVec(sizeof(struct InputEvent
), MEMF_PUBLIC
| MEMF_CLEAR
))) {
46 InputRequest
->io_Command
= IND_WRITEEVENT
;
47 InputRequest
->io_Data
= ie
;
48 InputRequest
->io_Length
= sizeof(struct InputEvent
);
50 DoIO((struct IORequest
*)InputRequest
);
54 CloseDevice((struct IORequest
*)InputRequest
);
56 DeleteIORequest((struct IORequest
*)InputRequest
);
58 DeleteMsgPort (InputPort
);
62 /*-------------------------------------------------------------------------*/
64 int ilog2(ULONG data
) {
66 ULONG bitmask
= 1 << bitoffset
;
69 if ((data
& bitmask
) != 0)
74 } while (bitmask
!= 0);
79 /*-----------------------------------------------------------------------*/
81 void ErrorMessage(CONST_STRPTR fmt
, ...)
83 struct IntuitionBase
*IntuitionBase
;
85 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 36);
87 struct EasyStruct es
= {
88 sizeof (struct EasyStruct
),
90 "NTFS filesystem critical error",
95 es
.es_TextFormat
= fmt
;
96 AROS_SLOWSTACKFORMAT_PRE(fmt
);
97 EasyRequestArgs(NULL
, &es
, NULL
, AROS_SLOWSTACKFORMAT_ARG(fmt
));
98 AROS_SLOWSTACKFORMAT_POST(fmt
);
99 CloseLibrary((struct Library
*)IntuitionBase
);
103 void NTFS2DateStamp(UQUAD
*NTFSTime
, struct DateStamp
*DS
)
109 // nttimeoffset = (377 * 365 + 91) * 24 * 3600 * 10000000;
110 nttimeoffset
= 0x02C51CD000ULL
* 10000000;
112 adjustedtime
= *NTFSTime
- nttimeoffset
;
114 D(bug("[NTFS]: %s: adjusted = %d, offset = %d\n", __PRETTY_FUNCTION__
, adjustedtime
, nttimeoffset
));
116 tval
.tv_secs
= adjustedtime
/ 10000000;
117 tval
.tv_micro
= (adjustedtime
/ 10) % 1000000;
119 /* calculate days since 1978-01-01 (DOS epoch) */
120 DS
->ds_Days
= tval
.tv_secs
/ (60 * 60 * 24);
122 /* minutes since midnight */
123 DS
->ds_Minute
= tval
.tv_secs
/ 60 % (24 * 60);
125 /* 1/50 sec ticks since last minute */
126 DS
->ds_Tick
= 50 * (tval
.tv_secs
% 60) + (tval
.tv_micro
/ 20000);
129 APTR
_AllocVecPooled(APTR mem_pool
, ULONG size
)
131 APTR newvec
= AllocVecPooled(mem_pool
, size
);
132 D(bug("**** [pool:0x%p] Allocated %d bytes @ 0x%p\n", mem_pool
, size
, newvec
));
136 void _FreeVecPooled(APTR mem_pool
, APTR vecaddr
)
138 D(bug("**** [pool:0x%p] Freeing 0x%p\n", mem_pool
, vecaddr
));
139 FreeVecPooled(mem_pool
, vecaddr
);