Rev 6428 | Rev 6468 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6428 | Rev 6462 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line -... | Line 8... | ||
- | 8 | $Revision: 6462 $ |
|
- | 9 | ||
- | 10 | ; NTFS external functions |
|
8 | $Revision: 6428 $ |
11 | ; in: |
- | 12 | ; ebx -> parameter structure of sysfunc 70 |
|
- | 13 | ; ebp -> NTFS structure |
|
- | 14 | ; [esi]+[[esp+4]] = name |
|
- | 15 | ; out: |
|
- | 16 | ; eax, ebx = return values for sysfunc 70 |
|
- | 17 | iglobal |
|
- | 18 | align 4 |
|
- | 19 | ntfs_user_functions: |
|
- | 20 | dd ntfs_free |
|
- | 21 | dd (ntfs_user_functions_end - ntfs_user_functions - 4) / 4 |
|
- | 22 | dd ntfs_ReadFile |
|
- | 23 | dd ntfs_ReadFolder |
|
- | 24 | dd ntfs_CreateFile |
|
- | 25 | dd ntfs_WriteFile |
|
- | 26 | dd ntfs_SetFileEnd |
|
- | 27 | dd ntfs_GetFileInfo |
|
- | 28 | dd ntfs_SetFileInfo |
|
- | 29 | dd 0 |
|
- | 30 | dd ntfs_Delete |
|
- | 31 | dd ntfs_CreateFolder |
|
Line 9... | Line 32... | ||
9 | 32 | ntfs_user_functions_end: |
|
10 | ; NTFS driver |
33 | endg |
11 | 34 | ||
12 | ; Basic concepts: |
35 | ; Basic concepts: |
Line 93... | Line 116... | ||
93 | fileNameLength = 50h |
116 | fileNameLength = 50h |
94 | namespace = 51h |
117 | namespace = 51h |
95 | fileName = 52h |
118 | fileName = 52h |
Line 96... | Line 119... | ||
96 | 119 | ||
97 | struct NTFS PARTITION |
120 | struct NTFS PARTITION |
98 | Lock MUTEX ? ; Currently operations with one partition |
121 | Lock MUTEX ; Currently operations with one partition |
99 | ; can not be executed in parallel since the legacy code is not ready. |
122 | ; can not be executed in parallel since the legacy code is not ready. |
100 | sectors_per_cluster dd ? |
123 | sectors_per_cluster dd ? |
101 | mft_cluster dd ? ; location |
124 | mft_cluster dd ? ; location |
102 | mftmirr_cluster dd ? ; location |
125 | mftmirr_cluster dd ? ; location |
Line 149... | Line 172... | ||
149 | attrlist_buf rb 1024 |
172 | attrlist_buf rb 1024 |
150 | attrlist_mft_buf rb 1024 |
173 | attrlist_mft_buf rb 1024 |
151 | bitmap_buf rb 1024 |
174 | bitmap_buf rb 1024 |
152 | ends |
175 | ends |
Line 153... | Line -... | ||
153 | - | ||
154 | ; NTFS external functions |
- | |
155 | ; in: |
- | |
156 | ; ebx -> parameter structure of sysfunc 70 |
- | |
157 | ; ebp -> NTFS structure |
- | |
158 | ; [esi]+[esp+4] = name |
- | |
159 | ; out: |
- | |
160 | ; eax, ebx = return values for sysfunc 70 |
- | |
161 | iglobal |
- | |
162 | align 4 |
- | |
163 | ntfs_user_functions: |
- | |
164 | dd ntfs_free |
- | |
165 | dd (ntfs_user_functions_end - ntfs_user_functions - 4) / 4 |
- | |
166 | dd ntfs_ReadFile |
- | |
167 | dd ntfs_ReadFolder |
- | |
168 | dd ntfs_CreateFile |
- | |
169 | dd ntfs_WriteFile |
- | |
170 | dd ntfs_SetFileEnd |
- | |
171 | dd ntfs_GetFileInfo |
- | |
172 | dd ntfs_SetFileInfo |
- | |
173 | dd 0 |
- | |
174 | dd ntfs_Delete |
- | |
175 | dd ntfs_CreateFolder |
- | |
176 | ntfs_user_functions_end: |
- | |
177 | endg |
- | |
178 | 176 | ||
179 | ntfs_test_bootsec: |
177 | ntfs_test_bootsec: |
180 | ; in: ebx -> buffer, edx = size of partition |
178 | ; in: ebx -> buffer, edx = size of partition |
181 | ; out: CF=1 -> invalid |
179 | ; out: CF=1 -> invalid |
182 | ; 1. Name=='NTFS ' |
180 | ; 1. Name=='NTFS ' |
Line 256... | Line 254... | ||
256 | ret |
254 | ret |
257 | .no: ; No, this bootsector isn't NTFS |
255 | .no: ; No, this bootsector isn't NTFS |
258 | stc |
256 | stc |
259 | ret |
257 | ret |
Line -... | Line 258... | ||
- | 258 | ||
260 | 259 | ; Mount if it's a valid NTFS partition. |
|
- | 260 | ntfs_create_partition: |
|
- | 261 | ; in: |
|
- | 262 | ; ebp -> PARTITION structure |
|
- | 263 | ; ebx -> boot sector |
|
- | 264 | ; ebx+512 -> buffer |
|
- | 265 | ; out: |
|
261 | ntfs_create_partition: |
266 | ; eax -> NTFS structure, 0 = not NTFS |
262 | cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
267 | cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
263 | jnz .nope |
268 | jnz .nope |
264 | mov edx, dword [ebp+PARTITION.Length] |
269 | mov edx, dword [ebp+PARTITION.Length] |
265 | cmp dword [esp+4], 0 |
270 | cmp dword [esp+4], 0 |
Line 1682... | Line 1687... | ||
1682 | mov eax, [edx+4] |
1687 | mov eax, [edx+4] |
1683 | mov [edi+4], eax |
1688 | mov [edi+4], eax |
1684 | mov eax, 0x10 |
1689 | mov eax, 0x10 |
1685 | stosd |
1690 | stosd |
1686 | scasd |
1691 | scasd |
1687 | push edx |
1692 | push ebx ecx edx |
1688 | mov eax, dword [ebp+NTFS.bitmap_buf] |
1693 | mov eax, dword [ebp+NTFS.bitmap_buf] |
1689 | mov edx, dword [ebp+NTFS.bitmap_buf+4] |
1694 | mov edx, dword [ebp+NTFS.bitmap_buf+4] |
1690 | call ntfs_datetime_to_bdfe |
1695 | call ntfs_datetime_to_bdfe |
1691 | mov eax, dword [ebp+NTFS.bitmap_buf+0x18] |
1696 | mov eax, dword [ebp+NTFS.bitmap_buf+0x18] |
1692 | mov edx, dword [ebp+NTFS.bitmap_buf+0x1C] |
1697 | mov edx, dword [ebp+NTFS.bitmap_buf+0x1C] |
1693 | call ntfs_datetime_to_bdfe |
1698 | call ntfs_datetime_to_bdfe |
1694 | mov eax, dword [ebp+NTFS.bitmap_buf+8] |
1699 | mov eax, dword [ebp+NTFS.bitmap_buf+8] |
1695 | mov edx, dword [ebp+NTFS.bitmap_buf+0xC] |
1700 | mov edx, dword [ebp+NTFS.bitmap_buf+0xC] |
1696 | call ntfs_datetime_to_bdfe |
1701 | call ntfs_datetime_to_bdfe |
1697 | pop edx |
1702 | pop edx ecx ebx |
1698 | xor eax, eax |
1703 | xor eax, eax |
1699 | stosd |
1704 | stosd |
1700 | stosd |
1705 | stosd |
1701 | mov al, '.' |
1706 | mov al, '.' |
1702 | push edi ecx |
1707 | push edi ecx |
Line 1776... | Line 1781... | ||
1776 | and eax, not 0x10000000 |
1781 | and eax, not 0x10000000 |
1777 | or al, 0x10 |
1782 | or al, 0x10 |
1778 | @@: |
1783 | @@: |
1779 | stosd |
1784 | stosd |
1780 | scasd |
1785 | scasd |
1781 | push edx |
1786 | push ebx ecx edx |
1782 | mov eax, [esi+fileCreated] |
1787 | mov eax, [esi+fileCreated] |
1783 | mov edx, [esi+fileCreated+4] |
1788 | mov edx, [esi+fileCreated+4] |
1784 | call ntfs_datetime_to_bdfe |
1789 | call ntfs_datetime_to_bdfe |
1785 | mov eax, [esi+fileAccessed] |
1790 | mov eax, [esi+fileAccessed] |
1786 | mov edx, [esi+fileAccessed+4] |
1791 | mov edx, [esi+fileAccessed+4] |
1787 | call ntfs_datetime_to_bdfe |
1792 | call ntfs_datetime_to_bdfe |
1788 | mov eax, [esi+fileModified] |
1793 | mov eax, [esi+fileModified] |
1789 | mov edx, [esi+fileModified+4] |
1794 | mov edx, [esi+fileModified+4] |
1790 | call ntfs_datetime_to_bdfe |
1795 | call ntfs_datetime_to_bdfe |
1791 | pop edx |
1796 | pop edx ecx ebx |
1792 | mov eax, [esi+fileRealSize] |
1797 | mov eax, [esi+fileRealSize] |
1793 | stosd |
1798 | stosd |
1794 | mov eax, [esi+fileRealSize+4] |
1799 | mov eax, [esi+fileRealSize+4] |
1795 | stosd |
1800 | stosd |
1796 | ret |
1801 | ret |
Line 1797... | Line -... | ||
1797 | - | ||
1798 | iglobal |
- | |
1799 | months db 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
- | |
1800 | months2 db 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
- | |
1801 | endg |
- | |
1802 | 1802 | ||
1803 | ntfs_datetime_to_bdfe: |
1803 | ntfs_datetime_to_bdfe: |
1804 | ; edx:eax = number of 100-nanosecond intervals since January 1, 1601, in UTC |
1804 | ; in: edx:eax = seconds since 01.01.1601 x10000000 |
1805 | push ebx ecx |
1805 | ; edi -> data block |
1806 | mov ebx, eax |
1806 | ; out: edi = edi+8 |
1807 | mov eax, edx |
1807 | sub eax, 3365781504 |
1808 | xor edx, edx |
1808 | sbb edx, 29389701 |
1809 | mov ecx, 10000000 |
- | |
1810 | div ecx |
- | |
1811 | xchg eax, ebx |
- | |
1812 | div ecx |
- | |
1813 | .forEXT: |
- | |
1814 | xchg eax, ebx |
1809 | mov ecx, 10000000 |
1815 | xor edx, edx |
- | |
1816 | mov ecx, 60 |
- | |
1817 | div ecx |
- | |
1818 | xchg eax, ebx |
1810 | cmp edx, ecx |
1819 | div ecx |
- | |
1820 | mov [edi], dl |
- | |
1821 | mov edx, ebx |
- | |
1822 | ; edx:eax = number of minutes |
- | |
1823 | div ecx |
- | |
1824 | mov [edi+1], dl |
- | |
1825 | ; eax = number of hours |
- | |
1826 | xor edx, edx |
- | |
1827 | mov cl, 24 |
- | |
1828 | div ecx |
- | |
1829 | mov [edi+2], dx |
- | |
1830 | ; eax = number of days since January 1, 1601 |
1811 | jc @f |
1831 | xor edx, edx |
- | |
1832 | mov cx, 365 |
- | |
1833 | div ecx |
- | |
1834 | mov ebx, eax |
- | |
1835 | add ebx, 1601 |
- | |
1836 | shr eax, 2 |
- | |
1837 | sub edx, eax |
- | |
1838 | mov cl, 25 |
- | |
1839 | div cl |
- | |
1840 | xor ah, ah |
- | |
1841 | add edx, eax |
- | |
1842 | shr eax, 2 |
- | |
1843 | sub edx, eax |
- | |
1844 | jns @f |
- | |
1845 | dec ebx |
- | |
1846 | add edx, 365 |
- | |
1847 | test bl, 3 |
- | |
1848 | jnz @f |
- | |
1849 | inc edx |
1812 | xor edx, edx |
1850 | @@: |
- | |
1851 | xor eax, eax |
- | |
1852 | mov ecx, months-1 |
- | |
1853 | test bl, 3 |
- | |
1854 | jnz @f |
- | |
1855 | add ecx, 12 |
- | |
1856 | @@: |
1813 | @@: |
1857 | inc ecx |
- | |
1858 | inc eax |
- | |
1859 | sub dl, [ecx] |
- | |
1860 | jnc @b |
- | |
1861 | dec dh |
- | |
1862 | jns @b |
- | |
1863 | add dl, [ecx] |
- | |
1864 | inc edx |
- | |
1865 | mov [edi+4], dl |
- | |
1866 | mov [edi+5], al |
- | |
1867 | mov [edi+6], bx |
- | |
1868 | add edi, 8 |
- | |
1869 | pop ecx ebx |
- | |
1870 | ret |
- | |
1871 | - | ||
1872 | .sec: |
- | |
1873 | push ebx ecx |
- | |
1874 | mov ebx, edx |
1814 | div ecx |
Line 1875... | Line 1815... | ||
1875 | jmp .forEXT |
1815 | jmp fsTime2bdfe |
1876 | 1816 | ||
1877 | ;---------------------------------------------------------------- |
1817 | ;---------------------------------------------------------------- |
1878 | ntfs_GetFileInfo: |
1818 | ntfs_GetFileInfo: |
Line 4177... | Line 4117... | ||
4177 | mov edx, [ebp+NTFS.nodeLastRead] |
4117 | mov edx, [ebp+NTFS.nodeLastRead] |
4178 | call writeRecord ; directory |
4118 | call writeRecord ; directory |
4179 | call ntfsSpaceClean |
4119 | call ntfsSpaceClean |
4180 | jmp ntfsDone |
4120 | jmp ntfsDone |
Line 4181... | Line -... | ||
4181 | - | ||
4182 | ntfsReadCMOS: |
- | |
4183 | out 70h, al |
- | |
4184 | in al, 71h |
- | |
4185 | xor ah, ah |
- | |
4186 | shl ax, 4 |
- | |
4187 | shr al, 4 |
- | |
4188 | aad |
- | |
4189 | ret |
- | |
4190 | 4121 | ||
4191 | ntfsGetTime: |
- | |
4192 | mov al, 7 |
4122 | ntfsGetTime: |
4193 | call ntfsReadCMOS |
- | |
4194 | ror eax, 8 |
- | |
4195 | mov al, 8 |
- | |
4196 | call ntfsReadCMOS |
- | |
4197 | ror eax, 8 |
- | |
4198 | mov al, 9 |
- | |
4199 | call ntfsReadCMOS |
- | |
4200 | add eax, 2000 |
- | |
4201 | ror eax, 16 |
4123 | call fsGetTime |
4202 | push eax |
- | |
4203 | xor eax, eax |
- | |
4204 | call ntfsReadCMOS |
- | |
4205 | ror eax, 8 |
- | |
4206 | mov al, 2 |
- | |
4207 | call ntfsReadCMOS |
- | |
4208 | ror eax, 8 |
- | |
4209 | mov al, 4 |
- | |
4210 | call ntfsReadCMOS |
- | |
4211 | ror eax, 16 |
- | |
4212 | push eax |
- | |
4213 | mov esi, esp |
- | |
- | 4124 | jmp @f |
|
4214 | add esp, 8 |
4125 | |
4215 | ntfsCalculateTime: |
4126 | ntfsCalculateTime: |
4216 | ; in: esi -> data block |
4127 | ; in: esi -> data block |
4217 | ; out: edx:eax = time |
- | |
4218 | movzx eax, word [esi+6] |
- | |
4219 | sub eax, 2001 |
- | |
4220 | jnc @f |
- | |
4221 | xor eax, eax |
- | |
4222 | @@: |
- | |
4223 | mov edx, months |
- | |
4224 | mov ebx, eax |
- | |
4225 | inc eax |
- | |
4226 | test eax, 3 |
- | |
4227 | jnz @f |
- | |
4228 | add edx, 12 |
- | |
4229 | @@: |
- | |
4230 | movzx eax, byte [esi+5] |
- | |
4231 | dec eax |
- | |
4232 | xor ecx, ecx |
- | |
4233 | @@: |
- | |
4234 | dec eax |
- | |
4235 | js @f |
4128 | ; out: edx:eax = seconds since 01.01.1601 x10000000 |
4236 | add cl, [edx+eax] |
- | |
4237 | adc ch, 0 |
- | |
4238 | jmp @b |
4129 | call fsCalculateTime |
4239 | @@: |
- | |
4240 | mov eax, ebx |
4130 | @@: |
4241 | mov edx, 365 |
- | |
4242 | mul edx |
- | |
4243 | shr ebx, 2 |
- | |
4244 | add eax, ebx |
- | |
4245 | add eax, ecx |
- | |
4246 | mov bl, [esi+4] |
- | |
4247 | add eax, ebx |
- | |
4248 | add eax, 400*365+100-4 |
- | |
4249 | mov dl, 24 |
4131 | mov edx, 10000000 |
4250 | mul edx |
- | |
4251 | mov bl, [esi+2] |
4132 | mul edx |
4252 | add eax, ebx |
- | |
4253 | mov ecx, 60 |
- | |
4254 | mul ecx |
- | |
4255 | mov bl, [esi+1] |
- | |
4256 | add eax, ebx |
- | |
4257 | mul ecx |
- | |
4258 | mov bl, [esi] |
- | |
4259 | add ebx, eax |
- | |
4260 | mov eax, edx |
- | |
4261 | mov ecx, 10000000 |
- | |
4262 | mul ecx |
- | |
4263 | xchg eax, ebx |
- | |
4264 | mul ecx |
4133 | add eax, 3365781504 |
4265 | add edx, ebx |
4134 | adc edx, 29389701 |
Line 4266... | Line 4135... | ||
4266 | ret |
4135 | ret |
4267 | 4136 | ||
4268 | ;---------------------------------------------------------------- |
4137 | ;---------------------------------------------------------------- |