{"id":114,"date":"2014-10-04T01:19:02","date_gmt":"2014-10-04T01:19:02","guid":{"rendered":"http:\/\/blogs.gentoo.org\/blueness\/?p=114"},"modified":"2014-10-04T01:19:02","modified_gmt":"2014-10-04T01:19:02","slug":"lilblue-linux-release-20140925-adventures-beyond-the-land-of-posix","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/blueness\/2014\/10\/04\/lilblue-linux-release-20140925-adventures-beyond-the-land-of-posix\/","title":{"rendered":"Lilblue Linux: release 20140925.  Adventures beyond the land of POSIX."},"content":{"rendered":"<p>It has been four months since my last major build and release of <em>Lilblue Linux, <\/em>a pet project of mine [1]<em>.<\/em>\u00a0 The name is a bit pretentious, I admit, since Lilblue is not some other Linux distro.\u00a0 It is Gentoo, but Gentoo with a twist.\u00a0 It&#8217;s a fully featured amd64, hardened, XFCE4 desktop that uses uClibc instead of glibc as its standard C library.\u00a0 I use it on some of my workstations at the College and at home, like any other desktop, and I know other people that use it too, but the main reason for its existence is that I wanted to push uClibc to its limits and see where things break.\u00a0 Back in 2011, I got bored of working with the usual set of embedded packages.\u00a0 So, while my students where writing their exams in Modern OS, I entertained myself just adding more and more packages to a stage3-amd64-hardened system [2] until I had a decent desktop.\u00a0 After playing with it on and off, I finally polished it where I thought others might enjoy it too and started pushing out releases.\u00a0 Recently, I found out that the folks behind uselessd [3] used Lilblue as their testing ground. uselessd is another response to systemd [4], something like eudev [5], which I maintain, so the irony here is too much not to mention!\u00a0 But that&#8217;s another story &#8230;<\/p>\n<p>There was only one interesting issue about this release.\u00a0 Generally I try to keep all releases about the same.\u00a0 I&#8217;m not constantly updating the list of packages in @world.\u00a0 I did remove pulseaudio this time around because it never did work right and I don&#8217;t use it.\u00a0 I&#8217;ll fix it in the future, but not yet!\u00a0 Instead, I concentrated on a much more interesting problem with a new release of e2fsprogs [6].\u00a0\u00a0 The problem started when upstream&#8217;s commit 58229aaf removed a broken fallback syscall for fallocate64() on systems where the latter is unavailable [7].\u00a0 There was nothing wrong with this commit, in fact, it was the correct thing to do.\u00a0 e4defrag.c used to have the following code:<\/p>\n<pre>#ifndef HAVE_FALLOCATE64\r\n#warning Using locally defined fallocate syscall interface.\r\n\r\n#ifndef __NR_fallocate\r\n#error Your kernel headers dont define __NR_fallocate\r\n#endif\r\n\r\n\/*\r\n * fallocate64() - Manipulate file space.\r\n *\r\n * @fd: defrag target file's descriptor.\r\n * @mode: process flag.\r\n * @offset: file offset.\r\n * @len: file size.\r\n *\/\r\nstatic int fallocate64(int fd, int mode, loff_t offset, loff_t len)\r\n{\r\n    return syscall(__NR_fallocate, fd, mode, offset, len);\r\n}\r\n#endif \/* ! HAVE_FALLOCATE *\/\r\n<\/pre>\n<p>The idea was that, if a configure test for fallocate64() failed because it isn&#8217;t available in your libc, but there is a system call for it in the kernel, then e4defrag would just make the syscall via your libc&#8217;s indirect syscall() function.\u00a0 Seems simple enough, except that how system calls are dispatched is architecture and ABI dependant and the above is broken on 32-bit systems [8].\u00a0 Of course, uClibc didn&#8217;t have fallocate() so e4defrag failed to build after that commit.\u00a0 To my surprise, musl does have fallocate() so this wasn&#8217;t a problem there, even though it is a Linux specific function and not in any standard.<\/p>\n<p>My first approach was to patch e2fsprogs to use posix_fallocate() which is supposed to be equivalent to fallocate() when invoked with mode = 0.\u00a0 e4defrag calls fallocate() in mode = 0, so this seemed like a simple fix.\u00a0 However, this was not acceptable to Ts&#8217;o since he was worried that some libc might implement posix_fallocate() by brute force writing 0&#8217;s.\u00a0 That could be horribly slow for large allocations!\u00a0 This wasn&#8217;t the case for uClibc&#8217;s implementation but that didn&#8217;t seem to make much difference upstream.\u00a0 Meh.<\/p>\n<p>Rather than fight e2fsprogs, I sat down and hacked fallocate() into uClibc.\u00a0 Since both fallocate() and posix_fallocate(), and their LFS counterparts fallocate64() and posix_fallocate64(), make the same syscall, it was sufficient to isolate that in an internal function which both could make use of.\u00a0 That, plus a test suite, and Bernhard was kind enough to commit it to master [10].\u00a0 Then a couple of backports, and uClibc&#8217;s 0.9.33 branch now has the fix as well.\u00a0 Because there hasn&#8217;t been a release of\u00a0 uClibc in about two years, I&#8217;m using the 0.9.33 branch HEAD for Lilblue, so the problem there was solved &#8212; I know its a little problematic, but it was either that or try to juggle dozens of patches.<\/p>\n<p>The only thing that remains is to backport those fixes to vapier&#8217;s patchset that he maintains for the uClibc ebuilds.\u00a0 Since my uClibc stage3&#8217;s don&#8217;t use the 0.9.33 branch head, but the stable tree ebuilds which use the vanilla 0.9.33.2 release plus Mike&#8217;s patchset, upgrading e2fsprogs is blocked for those stages.<\/p>\n<p>This whole process may seem like a real pita, but this is exactly the sort of issues I like uncovering and cleaning up.\u00a0 So far, the feedback on the latest release is good.\u00a0 If you want to play with Lilblue and you don&#8217;t have a free box, fire up VirtualBox or your emulator of choice and give it a try.\u00a0 You can download it from the experimental\/amd64\/uclibc off any mirror [11].<\/p>\n<ul>\n<li>[1] <a href=\"https:\/\/wiki.gentoo.org\/wiki\/Project:Hardened_uClibc\/Lilblue\" target=\"_blank\">https:\/\/wiki.gentoo.org\/wiki\/Project:Hardened_uClibc\/Lilblue<\/a><\/li>\n<li>[2] <a href=\"http:\/\/distfiles.gentoo.org\/releases\/amd64\/autobuilds\/current-stage3-amd64-uclibc-hardened\/\" target=\"_blank\">http:\/\/distfiles.gentoo.org\/releases\/amd64\/autobuilds\/current-stage3-amd64-uclibc-hardened\/<\/a><\/li>\n<li>[3] <a href=\"http:\/\/uselessd.darknedgy.net\/\" target=\"_blank\">http:\/\/uselessd.darknedgy.net\/<\/a><\/li>\n<li>[4] <a href=\"http:\/\/www.freedesktop.org\/wiki\/Software\/systemd\/\" target=\"_blank\">http:\/\/www.freedesktop.org\/wiki\/Software\/systemd\/<\/a><\/li>\n<li>[5] <a href=\"https:\/\/github.com\/gentoo\/eudev\" target=\"_blank\">https:\/\/github.com\/gentoo\/eudev<\/a><\/li>\n<li>[6] My adventures beyond the land of POSIX are chronicled in <a href=\"https:\/\/bugs.gentoo.org\/show_bug.cgi?id=516988\" target=\"_blank\">https:\/\/bugs.gentoo.org\/show_bug.cgi?id=516988<\/a><\/li>\n<li>[7] <a href=\"http:\/\/git.kernel.org\/cgit\/fs\/ext2\/e2fsprogs.git\/commit\/?id=58229aaf85d435469e901c974f31ead6d9124166\" target=\"_blank\">http:\/\/git.kernel.org\/cgit\/fs\/ext2\/e2fsprogs.git\/commit\/?id=58229aaf85d435469e901c974f31ead6d9124166<\/a><\/li>\n<li>[8] You can read about the arch\/ABI dependancies in `man 2 syscall`<\/li>\n<li>[9] See `man 2 fallocate` and `man 3 posix_fallocate`.<\/li>\n<li>[10] <a href=\"http:\/\/git.uclibc.org\/uClibc\/commit\/?id=33a12b5540b8abbc4ee0ecb3a51912b3c7868517\" target=\"_blank\">http:\/\/git.uclibc.org\/uClibc\/commit\/?id=33a12b5540b8abbc4ee0ecb3a51912b3c7868517<\/a><\/li>\n<li>[11] <a href=\"http:\/\/distfiles.gentoo.org\/experimental\/amd64\/uclibc\/\" target=\"_blank\">http:\/\/distfiles.gentoo.org\/experimental\/amd64\/uclibc\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>It has been four months since my last major build and release of Lilblue Linux, a pet project of mine [1].\u00a0 The name is a bit pretentious, I admit, since Lilblue is not some other Linux distro.\u00a0 It is Gentoo, but Gentoo with a twist.\u00a0 It&#8217;s a fully featured amd64, hardened, XFCE4 desktop that uses &hellip; <a href=\"https:\/\/blogs.gentoo.org\/blueness\/2014\/10\/04\/lilblue-linux-release-20140925-adventures-beyond-the-land-of-posix\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Lilblue Linux: release 20140925.  Adventures beyond the land of POSIX.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":141,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1,3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/posts\/114"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/users\/141"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":14,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/posts\/114\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/blueness\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}