ext2

Drive subsystem, filesystem drivers
  • There are some issues with the code.
    Serious issues:
    1. Unaligned writes to a file are handled incorrectly: e.g. try to write 2222h bytes starting with offset 1111h.
    2. File creations based on a current directory are handled incorrectly: e.g. try to set current directory with 30.1 to "/hd0/1/somedirectory" - assuming that /hd0/1 has ext2 and somedirectory exists - and create a file "somefile", it should go to "/hd0/1/somedirectory/somefile".
    Less serious issues:
    3. File creation and writes returns ebx=0 instead of number of bytes written.
    Issues that are related to read support and probably existed before KSoC:
    4. Directory reads ignore unicode flag, they always return one-byte strings and 304-byte records.
    5. Simulated read errors are handled, but with strange error codes: instead of expected error code "device error", the resulting code can be "file not found" or "filesystem corrupted"; when a read error occurs while reading a file, number of bytes read is returned as 0xFFFFFFFF instead of correct value.
    Code notes:
    6. Error handling in ext2_create_partition corrupts the stack.
    7. There are many "div" operations when the divisor is a power of 2. It is much more efficient to use shifts, "shrd+shr" for quotient, "and" for remainder. This can slightly enlarge code size, but internal frequently-called operations in a filesystem are a place when one needs to optimize for speed, not size.
    8. Generally it is a bad idea to interleave data with code, by several reasons: first-level caches for data and code are usually separate, so mixing data and code pollutes both caches; a processor can consider writes to same cache line with code as self-modifying code with fatal effects for performance; packer usually behaves better when similar-structured things are located together. We have macro iglobal/uglobal to move data to the common place while still declaring them near the code.
    9. Global variables [current_bdfe_time], [current_bdfe_date] are written to without proper synchronization, it may result in strange effects if several operations with different ext2 partitions are performed concurrently. It is better to keep them as a stack variable.
    Сделаем мир лучше!
  • Two more issues that were present in read-only support before KSoC, just for completeness:
    10. If several memory allocations are always allocated and freed together, it is better to allocate them in one chunk:

    Code: Select all

    stdcall kernel_alloc, 0x1000
    mov [mem1], eax
    stdcall kernel_alloc, 0x1000
    mov [mem2], eax
    ...
    stdcall kernel_free, [mem1]
    stdcall kernel_free, [mem2]
    
    is worse than

    Code: Select all

    stdcall kernel_alloc, 0x2000
    mov [mem1], eax
    add eax, 0x1000
    mov [mem2], eax
    ...
    stdcall kernel_free, [mem1]
    
    This is true for all memory managers, not only kernel_alloc/kernel_free: a memory manager must assume that any allocated chunk can be freed independently and thus creates some non-zero overhead per every allocated chunk.
    11. A (modern) processor has some buffer for call/ret pairs, so that when it sees "ret", it can start to prefetch and speculatively execute instructions after the corresponding "call" even before "ret" finishes executing, checking the stack, fetching the real address from the stack and so on. ext2_ReadFolder breaks this buffer by "ret"ing to non-caller. This still works because the processor eventually sees that "ret" address is not the same as assumed and just drops prefetched results, but at the cost of performance.
    Сделаем мир лучше!
  • Found a typo in the code, 'paramteres' instead of 'parameters' (multiple times).
    "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." Albert Einstein
  • Hi,

    I see 3 bugs related to my code were found. I'll be delighted to fix those, but...

    yogev_ezra, on October 21st, PM'ed me:
    yogev_ezra wrote:1) You commit your code to SVN when you see fit. It can contain bugs.
    2) I provide an acknowledgement certificate on the payment within 24 hours from your commit.
    3) You publish a final report on the forum explaining your commit and remaining bugs you know of within 24 hours from receiving acknowledgement certificate.
    4) You try to fix the remaining bugs you know of in your spare time. Not required but encouraged.
    I consented, and even gave yogev_ezra as much lee-time he wanted, even more than 24 hours if it comes to that.

    On October 21st itself, I wrote the code, and trusting yogev_ezra would handle the acknowledgement certificate, even wrote the report.

    It's been about 90 days. I am yet to receive the acknowledgement certificate. I need it for legal issues (such as to prove it's earned by me -- tax issues and all being such), and for my own uses (college applications, etc).

    I'm very bad at coercing people, yet... I hope yogev_ezra takes out just a couple of hours of his day and mails the certificate to me. Once he's done so, I'll start working on fixing those bugs.

    Note that I have, on word from yogev_ezra, no real need to fix the bugs. I'm still willing to. yogev_ezra has, on his own word, an obligation to mail me the certificate. It's been 90 days!

    Peaceful regards,
    Shikhin
  • Hi,

    yogev_ezra demands I have some simple test cases, so:

    I have attached a sample ext2 vdi image, for virtualbox. You can use this along with VirtualBox or QEMU, as an harddisk. For starters, you can copy any file to and fro any FAT* and ext2 partition, and it should work. File creation, and deletion should work. You can also edit any file in the editor.

    I know this sounds a bit too short-ish as test cases. However, I can't think of any way to make them more complex, and trying to superfluously do so would only be an insult to everyone's intelligence. I think I'll take the time to detail the bugs concerned with me: there's the issue that unaligned writes don't work too properly. This shouldn't cause problems with copy/pasting, neither with the standard editor (since that writes in full batches, AFAIK). It still is a bug, and I'm working on fixing it. The other issue is that relative writes don't work too properly; that should be easy to fix.

    Nonetheless, I don't think test cases can get any more complicated than this, and if I still fail at it, I guess it can be counted as an integral fault of mine. :)

    Regards,
    Shikhin
  • От http://vk.com/id13751256

    5.6: МЕГАПОДСТАВА!!!
    В любом файловом менеджере, при копировании из одного (NTFS) в другой (Ext2) раздел файла (рисунка 20+ кб) и его последующем удалении (кнопка Del) - удаляется совсем другой файл!
    Курсор (подсветка) стоит на желаемом файле, при подтверждении выводится имя желаемого файла, но после удаления исчезает совершенно другой файл.
    Объём файла, требуемого для удаления при этом показывается, как 0.

    ...У меня так удалились два загрузочных образа линукса с /boot :-)

    При повторном копировании в каталоге показывает 2 файла с одинаковым именем, один с объёмом реальным, другой с нулевым.
    При следующих просмотрах содержимого раздела Ext2, показывает имена этих файлов с нулевым объёмом (одинаковые!).
    При дальнейшей попытке удалить из среды Linux - выдаёт ошибку файловой системы.
    При последуещей загрузке KolibriOS - этого раздела уже не было видно (как ранее - разделов BTRFS).
    Из хаоса в космос
  • А какое текущее состояние в целом? Ext2/3/4, чтение/запись? Кто-то пользовался?
  • Я скопировал на ext2 раздел папки 3d, demos, develop. Потом начал их удалять оттуда.
    Что-то случилось с текстом. Буквы стали немного обрезаны сверху.
    Spoiler:
    0.PNG
    0.PNG (32.6 KiB)
    Viewed 12447 times
  • Ну к файловой системе это точно не относится.
  • Как раз наоборот, точно относится.
    Ведь такое не происходит на FAT32 разделе.
  • А с другой стороны, запись по неправильному адресу может объяснить любые баги.

    revision #6778

    В общем, ext2 уже можно тестировать.
  • Вот такая может возникнуть проблема из-за CaseSensitive.
    После копирования папки "File managers" на ext2 раздел KFM не захотел работать
    Spoiler:
    0.PNG
    0.PNG (37.05 KiB)
    Viewed 12381 times
  • Тема не верная. Надо фиксить KFM.
    Из хаоса в космос
  • Вообще-то вон там http://websvn.kolibrios.org/listing.php ... d4b6f55881 как раз "icons.bmp"
    А вот в "ICONS.BMP" оно превращается уже вон там http://websvn.kolibrios.org/filedetails ... 76#line-26
  • Who is online

    Users browsing this forum: No registered users and 0 guests