Latest Blog Posts

Introduction

WinBtrfs is a feature-complete IFSD (Installable File System Driver) for NT operating systems, written by Mark Harmstone. This driver is checked into the ReactOS source code for some time already. My main goal for this GSoC project was to implement all missing features (and fix bugs, of course) in ReactOS that prevents booting from BTRFS file system.

Links

All work is merged into gsoc2018_all branch in my ReactOS fork on GitHub. A pull-request can be found here and unified diff is here. You can check it out like an ordinary ReactOS repo and build it as. See official Building Instructions for full information.

What has been done

FreeLoader BTRFS support

Basic read-only support has been implemented in the “FreeLoader” bootloader. The implementation is able to do path traversing, can handle hard and symbolic links and reads files splitted to several extents.
Only single-disk uncompressed setup is supported right now. Other WinBtrfs features can be added once ReactOS will support them.

Code for a VBR (Volume Boot Record) has also been written from scratch in ASM to support early boot phase when CPU is in real mode. It loads main bootloader executable into memory - freeldr.sys

Installer

ReactOS first-stage installer (usetup.exe) is now able to format partitions to BTRFS file system, install proper VBR for it and of course copy all the needed ReactOS files into it :)

Driver fixes

A couple of bugs were found in WinBtrfs driver during testing. One is related to NtQueryDirectoryFile kernel function, which returned wrong information under some circumstances.
Another one is about driver behaviour upon system shutdown. The driver tried to free its structures too early and that led to occasional BSODs.
Both fixes were sent upstream (PR#102 and PR#103) and are waiting to be merged.

ReactOS fixes

Not only driver issues were found during testing of BTRFS boot. Another bug was found and fixed in FastIO code, which is not used within the FAT file system. This small fix made WinBtrfs work in a much more stable way, and other third-party drivers can benefit from it too.
There is also a memory leak which I was not able to triage before the GSoC ending. This leak prevents ReactOS self-hosting on BTRFS filesystem (because checking out the source code and building binaries requires a lot of IO). I’m going to fix it after GSoC ending.

Conclusion

All this work lead to successfully booting ReactOS from BTRFS partition! Sounds too simple :)
Thanks cernodile and Illen from the community, who made a video of the process:

What has not been done

Windows 2003 still has issues with booting from BTRFS using FreeLoader. This is the only goal which has not been reached during this GSoC. But this is not the end, I will fix it later, of course (see news from the upcoming Hackfest).

There are still issues with BTRFS on ReactOS (see memory leak above), so it is not yet as stable as the FAT filesystem.

What's next

First of all, I thank GSoC that gave me an opportunity to work with such great team. I will definitely stay with ReactOS project and will continue kernel development here.

During upcoming Hackfest, It is planned to merge all BTRFS work.
I am also going to fix as much bugs as possible and will try to make ReactOS as stable with BTRFS as it is with FAT file system :)

Freeloader is now able to read files and follow symlinks from btrfs partition. One major issue is left here - case sensitivity. BTRFS is case-sensitive file system, so paths like /ReactOS/System32, /reactos/system32, /ReactOS/system32 are different here. But in Windows world most software is written assuming that case does not matter during path lookup. This thing is solved in WinBtrfs driver, but for Freeloader it can be a bit tricky. Right now I’ve implemented a hack for this, we will handle this later.

During Freeloader development, I’ve found a bug in VirtualBox BIOS implementation. At first, my boot sector didn’t work on VirtualBox and finding out what’s wrong there was annoying.
The problem was in INT 13h AH=42h implementation: in VirtualBox it can’t read more than 8 sectors per call. Simple fix, but much time spent on debugging…

After Freeloader was done and VirtualBox bug fixed, I was able to get to first error message from btrfs-booted ReactOS :)

Now it’s time to fix errors in ReactOS itself, not in bootloader.

This message was not obvious to fix. The exception, which caused this error (STATUS_ACCESS_VIOLATION), lead me to winsxs code, which is mostly imported from Wine. But finally, I’ve found the reason - it’s a bug in WinBtrfs driver. It works wrong when using NtQueryDirectoryFile with a file mask, which starts with the "*" symbol.
Our winsxs implementation heavily relies on this function and makes queries like "*_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.*.*_*_*.manifest" to find appropriate manifest when needed, so it failed quite early because of this bug. A pull-request to the upstream repository with a bugfix is here.

This was the only bug, which prevented booting to desktop:

First version of the fix had issues - there are some graphical glitches in taskbar. Never know what troubles winsxs bugs can cause!

So, right now ReactOS is able to boot from BTRFS partition and it is in quite stable state. But there are a lot of problems left:

Pagefile cannot be created on such partition. Our paging implementation is different from Windows one and requires extra functions in FS driver to be implemented.

Errors during some write operations. For example, it is not able to install Git right now. Will need to investigate this.

Occasional BSODs during shutdown. This problem is already tracked down, seems like nobody tried to use WinBtrfs as boot driver before :)More PRs to upstream are expected next week.

I want to say huge thanks to all mentors in IRC and especially Hermès Bélusca-Maïto who helped me a lot with tracking down all these issues :)

[WIN32SS][FONT] Fix font metrics (#713)
Fix vertical alignment and Aspect penalty; improve font penalty system; fixes for Wine tests.
This is an update of #706. See CORE-11536 for more details.
The display of the following programs is fixed... More