21,10 → 21,10 |
; Media flags. Represent bits in DISKMEDIAINFO.Flags. |
DISK_MEDIA_READONLY = 1 |
|
; If too many partitions are detected,there is probably an error on the disk. |
; If we see too many partitions, probably there is some error on the disk. |
; 256 partitions should be enough for any reasonable use. |
; Also, the same number is limiting the number of MBRs to process; if |
; too many MBRs are visible,there probably is a loop in the MBR structure. |
; Also, the same number is limiting the number of MBRs to process; if we see |
; too many MBRs, probably there is a loop in the MBR structure. |
MAX_NUM_PARTITIONS = 256 |
|
; ============================================================================= |
85,9 → 85,9 |
; Return value: 0 = disable cache, otherwise = used cache size in bytes. |
ends |
|
; This structure holds information on a medium. |
; Objects with this structure are allocated by the kernel as a part of the DISK |
; structure and are filled by a driver in the 'querymedia' callback. |
; This structure holds an information about a media. |
; Objects with this structure are allocated by the kernel as a part of DISK |
; structure and filled by a driver in the 'querymedia' callback. |
struct DISKMEDIAINFO |
.Flags dd ? |
; Combination of DISK_MEDIA_* bits. |
97,8 → 97,8 |
; Size of the media in sectors. |
ends |
|
; This structure represents the disk cache. To follow the old implementation, |
; there are two distinct caches for a disk, one for "system" data,and the other |
; This structure represents disk cache. To follow the old implementation, |
; there are two distinct caches for a disk, one for "system" data, other |
; for "application" data. |
struct DISKCACHE |
.Lock MUTEX |
160,9 → 160,9 |
; Another reference is taken during any filesystem operation for this media. |
; The callback 'closemedia' is called when the reference count decrements to |
; zero: this usually occurs in 'disk_media_changed', but can be delayed to the |
; end of the last filesystem operation, if one is active. |
; end of last filesystem operation, if one is active. |
.MediaInfo DISKMEDIAINFO |
; This field keeps information on the current media. |
; This field keeps an information about the current media. |
.NumPartitions dd ? |
; Number of partitions on this media. |
.Partitions dd ? |
227,9 → 227,9 |
uglobal |
; This mutex guards all operations with the global list of DISK structures. |
disk_list_mutex MUTEX |
; * There are two dependent objects, a disk and a media. In the simplest case, |
; * There are two dependent objects, a disk and a media. In the simplest case |
; disk and media are both non-removable. However, in the general case both |
; can be removed at any time, simultaneously or only media,and this makes things |
; can be removed at any time, simultaneously or only media, this makes things |
; complicated. |
; * For efficiency, both disk and media objects are located in the one |
; structure named DISK. However, logically they are different. |
341,7 → 341,7 |
; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0. |
test eax, eax |
jz .nothing |
; 2. Copy the disk name to the DISK structure. |
; 2. Copy disk name to the DISK structure. |
; 2a. Get length of the name, including the terminating zero. |
mov ebx, [esp+8+8] ; ebx = pointer to name |
push eax ; save allocated pointer to DISK |
627,7 → 627,7 |
mov eax, [esp+4] |
ret 4 |
|
; This is an internal function called from 'disk_media_changed' when a new media |
; This is an internal function called from 'disk_media_changed' when new media |
; is detected. It creates the list of partitions for the media. |
; If media is not partitioned, then the list consists of one partition which |
; covers all the media. |
688,10 → 688,10 |
; execute step 9 and possibly step 10. |
test ebp, ebp |
jnz .mbr |
; The partition table can be present or not present. In the first case, we just |
; read the MBR. In the second case, we just read the bootsector for a |
; Partition table can be present or not present. In the first case, we just |
; read the MBR. In the second case, we just read the bootsector for some |
; filesystem. |
; The following algorithm is used to distinguish between these cases. |
; We use the following algorithm to distinguish between these cases. |
; A. If at least one entry of the partition table is invalid, this is |
; a bootsector. See the description of 'is_partition_table_entry' for |
; definition of validity. |
698,7 → 698,7 |
; B. If all entries are empty (filesystem type field is zero) and the first |
; byte is jmp opcode (0EBh or 0E9h), this is a bootsector which happens to |
; have zeros in the place of partition table. |
; C. Otherwise, this is an MBR. |
; C. Otherwise, this is a MBR. |
; 9. Test for MBR vs bootsector. |
; 9a. Check entries. If any is invalid, go to 10 (rule A). |
call is_partition_table_entry |
724,7 → 724,7 |
cmp byte [ebx], 0E9h |
jnz .mbr |
.notmbr: |
; 10. This is not an MBR. The media is not partitioned. Create one partition |
; 10. This is not MBR. The media is not partitioned. Create one partition |
; which covers all the media and abort the loop. |
stdcall disk_add_partition, 0, 0, \ |
dword [esi+DISK.MediaInfo.Capacity], dword [esi+DISK.MediaInfo.Capacity+4] |