Rev 131 | Rev 171 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 131 | Rev 133 | ||
---|---|---|---|
Line 1872... | Line 1872... | ||
1872 | @@: |
1872 | @@: |
1873 | mov ebx, [ebx] |
1873 | mov ebx, [ebx] |
1874 | .l1: |
1874 | .l1: |
1875 | ; now edi points to direntry, ebx=start byte to write, |
1875 | ; now edi points to direntry, ebx=start byte to write, |
1876 | ; ecx=number of bytes to write, edx=data pointer |
1876 | ; ecx=number of bytes to write, edx=data pointer |
1877 | call get_time_for_file |
- | |
1878 | mov [edi+22], ax ; last write time |
- | |
1879 | call get_date_for_file |
1877 | call fat_update_datetime |
1880 | mov [edi+24], ax ; last write date |
- | |
1881 | mov [edi+18], ax ; last access date |
- | |
Line 1882... | Line 1878... | ||
1882 | 1878 | ||
1883 | ; extend file if needed |
1879 | ; extend file if needed |
1884 | add ecx, ebx |
1880 | add ecx, ebx |
1885 | jc .eof ; FAT does not support files larger than 4GB |
1881 | jc .eof ; FAT does not support files larger than 4GB |
Line 1946... | Line 1942... | ||
1946 | xor eax, eax |
1942 | xor eax, eax |
1947 | jmp ramdisk_extend_file.start_extend |
1943 | jmp ramdisk_extend_file.start_extend |
Line 1948... | Line 1944... | ||
1948 | 1944 | ||
1949 | ; extends file on ramdisk to given size, new data area is filled by 0 |
1945 | ; extends file on ramdisk to given size, new data area is filled by 0 |
1950 | ; in: edi->direntry, ecx=new size |
1946 | ; in: edi->direntry, ecx=new size |
1951 | ; out: CF=0 => OK, eax destroyed |
1947 | ; out: CF=0 => OK, eax=0 |
1952 | ; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL) |
1948 | ; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL) |
1953 | ramdisk_extend_file: |
1949 | ramdisk_extend_file: |
1954 | push ecx |
1950 | push ecx |
1955 | ; find the last cluster of file |
1951 | ; find the last cluster of file |
Line 2034... | Line 2030... | ||
2034 | add dword [edi+28], 0x200 |
2030 | add dword [edi+28], 0x200 |
2035 | jmp .extend_loop |
2031 | jmp .extend_loop |
2036 | .extend_done: |
2032 | .extend_done: |
2037 | mov [edi+28], ecx |
2033 | mov [edi+28], ecx |
2038 | pop esi edx |
2034 | pop esi edx |
2039 | clc |
2035 | xor eax, eax ; CF=0 |
2040 | ret |
2036 | ret |
2041 | .disk_full: |
2037 | .disk_full: |
2042 | pop edi ecx |
2038 | pop edi ecx |
2043 | pop esi edx |
2039 | pop esi edx |
2044 | stc |
2040 | stc |
2045 | push ERROR_DISK_FULL |
2041 | push ERROR_DISK_FULL |
2046 | pop eax |
2042 | pop eax |
2047 | ret |
2043 | ret |
Line -... | Line 2044... | ||
- | 2044 | ||
- | 2045 | fat_update_datetime: |
|
- | 2046 | call get_time_for_file |
|
- | 2047 | mov [edi+22], ax ; last write time |
|
- | 2048 | call get_date_for_file |
|
- | 2049 | mov [edi+24], ax ; last write date |
|
- | 2050 | mov [edi+18], ax ; last access date |
|
- | 2051 | ret |
|
- | 2052 | ||
- | 2053 | ;---------------------------------------------------------------- |
|
- | 2054 | ; |
|
- | 2055 | ; fs_RamdiskSetFileEnd - set end of file on ramdisk |
|
- | 2056 | ; |
|
- | 2057 | ; esi points to filename |
|
- | 2058 | ; ebx points to 64-bit number = new file size |
|
- | 2059 | ; ecx ignored (reserved) |
|
- | 2060 | ; edx ignored (reserved) |
|
- | 2061 | ; |
|
- | 2062 | ; ret eax = 0 ok or other = errormsg |
|
- | 2063 | ; |
|
- | 2064 | ;-------------------------------------------------------------- |
|
- | 2065 | fs_RamdiskSetFileEnd: |
|
- | 2066 | cmp byte [esi], 0 |
|
- | 2067 | jnz @f |
|
- | 2068 | .access_denied: |
|
- | 2069 | push ERROR_ACCESS_DENIED |
|
- | 2070 | jmp .ret |
|
- | 2071 | @@: |
|
- | 2072 | push edi |
|
- | 2073 | call rd_find_lfn |
|
- | 2074 | jnc @f |
|
- | 2075 | pop edi |
|
- | 2076 | push ERROR_FILE_NOT_FOUND |
|
- | 2077 | .ret: |
|
- | 2078 | pop eax |
|
- | 2079 | ret |
|
- | 2080 | @@: |
|
- | 2081 | ; must not be directory |
|
- | 2082 | test byte [edi+11], 10h |
|
- | 2083 | jz @f |
|
- | 2084 | pop edi |
|
- | 2085 | jmp .access_denied |
|
- | 2086 | @@: |
|
- | 2087 | ; file size must not exceed 4Gb |
|
- | 2088 | cmp dword [ebx+4], 0 |
|
- | 2089 | jz @f |
|
- | 2090 | pop edi |
|
- | 2091 | push ERROR_END_OF_FILE |
|
- | 2092 | jmp .ret |
|
- | 2093 | @@: |
|
- | 2094 | ; set file modification date/time to current |
|
- | 2095 | call fat_update_datetime |
|
- | 2096 | mov eax, [ebx] |
|
- | 2097 | cmp eax, [edi+28] |
|
- | 2098 | jb .truncate |
|
- | 2099 | ja .expand |
|
- | 2100 | pop edi |
|
- | 2101 | xor eax, eax |
|
- | 2102 | ret |
|
- | 2103 | .expand: |
|
- | 2104 | push ecx |
|
- | 2105 | mov ecx, eax |
|
- | 2106 | call ramdisk_extend_file |
|
- | 2107 | pop ecx |
|
- | 2108 | pop edi |
|
- | 2109 | ret |
|
- | 2110 | .truncate: |
|
- | 2111 | mov [edi+28], eax |
|
- | 2112 | push ecx |
|
- | 2113 | movzx ecx, word [edi+26] |
|
- | 2114 | test eax, eax |
|
- | 2115 | jz .zero_size |
|
- | 2116 | ; find new last sector |
|
- | 2117 | @@: |
|
- | 2118 | sub eax, 0x200 |
|
- | 2119 | jbe @f |
|
- | 2120 | movzx ecx, word [0x280000+ecx*2] |
|
- | 2121 | jmp @b |
|
- | 2122 | @@: |
|
- | 2123 | ; zero data at the end of last sector |
|
- | 2124 | push ecx |
|
- | 2125 | mov edi, ecx |
|
- | 2126 | shl edi, 9 |
|
- | 2127 | lea edi, [edi+0x100000+31*512+eax+0x200] |
|
- | 2128 | mov ecx, eax |
|
- | 2129 | neg ecx |
|
- | 2130 | xor eax, eax |
|
- | 2131 | rep stosb |
|
- | 2132 | pop ecx |
|
- | 2133 | ; terminate FAT chain |
|
- | 2134 | lea ecx, [0x280000+ecx+ecx] |
|
- | 2135 | push dword [ecx] |
|
- | 2136 | mov word [ecx], 0xFFF |
|
- | 2137 | pop ecx |
|
- | 2138 | and ecx, 0xFFF |
|
- | 2139 | jmp .delete |
|
- | 2140 | .zero_size: |
|
- | 2141 | and word [edi+26], 0 |
|
- | 2142 | .delete: |
|
- | 2143 | ; delete FAT chain starting with ecx |
|
- | 2144 | ; mark all clusters as free |
|
- | 2145 | cmp ecx, 0xFF8 |
|
- | 2146 | jae .deleted |
|
- | 2147 | lea ecx, [0x280000+ecx+ecx] |
|
- | 2148 | push dword [ecx] |
|
- | 2149 | and word [ecx], 0 |
|
- | 2150 | pop ecx |
|
- | 2151 | and ecx, 0xFFF |
|
- | 2152 | jmp .delete |
|
- | 2153 | .deleted: |
|
- | 2154 | pop ecx |
|
- | 2155 | pop edi |
|
- | 2156 | xor eax, eax |
|
- | 2157 | ret |
|
2048 | 2158 | ||
2049 | fs_RamdiskGetFileInfo: |
2159 | fs_RamdiskGetFileInfo: |
2050 | cmp byte [esi], 0 |
2160 | cmp byte [esi], 0 |
2051 | jnz @f |
2161 | jnz @f |
2052 | mov eax, 2 ; unsupported |
2162 | mov eax, 2 ; unsupported |