The future is here or encoded right in the browser

I’ll tell you about the curious situation that happened to me, and how to become a contributor to a famous project.



Not so long ago I was busy with one idea: booting Linux directly from UEFI ...

The idea is not new and there are a number of manuals on this topic. One of them can be seen here.



Actually, my long-standing attempts to resolve this issue resulted in a well-formed solution . The solution is quite working and I use it on parts of my home machines. This solution is described in more detail here .



The essence of UEFI-Boot is that the ESP (EFI System Partition) partition is combined with the / boot directory. Those. all kernels, and boot images (initrd) are located on the same section from which UEFI can run executable files and, in particular, run system boot loaders. But the Linux kernel itself is already built in many distributions with the UEFISTUB option, which allows the kernel to be launched from UEFI.



This solution has one unpleasant moment - the ESP partition is formatted in FAT32, on which it is impossible to create hard links (which the system creates regularly when updating initrd). And there is nothing particularly criminal in this, but to see system warnings when updating kernel components is not very pleasant ...



There is another way.



The UEFI boot manager (the one where you need to register the OS loader) can load drivers besides Linux loaders / kernels. So you can load the driver of that file system where you have / boot and load the kernel directly from there using the UEFI tools. The driver, of course, needs to be put in the ESP section. This is what GRUB loaders do. But the highlight is that all the frequently used GRUB functions are already in UEFI. More precisely in his download manager. And to be even more boring, the UEFI boot manager has even more options in some areas.



It seems to be a beautiful solution, but there is one “BUT" (or rather it was, but more on that later). The fact is that the UEFI driver system is pretty straightforward. There is no such thing as mounting a file system or associating a driver with a specific device. There is a system call with the conventional name Map (English) that takes each driver in turn and tries to connect it with all the devices that fit the worst. And if the device was able to pick up the driver, then mapping is created - a binding record. This is exactly how the newly loaded driver should be initialized in the general heap with all the others. And all that’s needed is to put one bit (LOAD_OPTION_FORCE_RECONNECT) in 1 in the boot record of the driver and UEFI will do this same global remap after loading it.



But this is not so easy to do. The standard efibootmgr utility (by means of which the UEFI unload manager is configured) does not know how (or rather did not know how) to set this bit. I had to put it with my hands through a rather complicated and dangerous procedure.



And once again, having tried to do this with my hands, I could not stand it and wrote an issue on GitHub asking developers to add this feature.



Several days passed, but no one paid attention to my request. And out of curiosity I looked at the source ... forked, and figured out "on my knees" how to add this feature ... "On my knees" because I didn’t set anything like that and edited the source directly in the browser.



C (programming language) I know very superficially, but about the solution I threw (mostly copy-paste) ... well, then I thought - but at least I probably have a lot of errors there (my previous attempts to edit someone else's C-code were collected from the 10th) I will issue a Pull Request. Well designed .



And there TraviCI was screwed to check pull requests. And he carefully gave me all my mistakes. Well, if mistakes are known - whatever would be corrected: again right in the browser, and from the fourth attempt the code was collected (an achievement for me).



And so, without crawling out of the browser, I designed a very real Pull Request into a utility that is used in almost all modern Linux distributions.



I was most surprised by the fact that I, without really knowing the language, and not setting up anything myself (there, by the dependencies, I need a small bundle of libraries for assembly), and even without even starting the compiler, I just “popped up” a working and useful feature in the browser .



However, my request has been hanging without reaction since March 19, 2019, and I have already begun to forget about it.



But yesterday, this request was added to master.






So what is my story about. And it is about the fact that, within the framework of modern technologies, it turned out that real code can already be written in a browser without having to deploy any development tools and dependencies locally.



Moreover, I must admit, this is my second pull request to well-known (at least in narrow circles) utilities. Last time, my request to correct the display of some fields in the SyncThing web interface resulted in my literally one-line edit in an environment that I do not know at all.



All Articles