Hello and welcome to my little nock of the internet. Here I have my blog which mainly contain posts about tech, the outdoors, cooking, and some times mead brewing.
A bit of background information before you step into my world of crazy. I am Lars, a.k.a. looopTools, a Software Engineer living in Northern Jutland, Denmark. I have 10+ years of experience from industry mainly through student positions, but also as self-employed consultant, or full-time employee. I mainly work in low-level user space, high-level kernel space, and storage systems in general. Besides research and software development, I also love the outdoors and try to go out as often as possible (not enough at the moment) and I am an aspiring author currently working on a few different novels. I also dabble in being a more advance home cook and baker, which you may see some posts about. Finally I like the ancient art of brewing mead, a.k.a. honey wine, and experiment with different flavour combinations and ageing times.
[Book review] Cult of the Dead Cow
From the first time I head about Cult of the Dead Cow (cDc), I was fascinated beyond my wildest dreams. Not only where they hackers, but they had ethics, a moral compass, and an overall coolness about them. However, I did not know where they came from, how the group worked not exactly what the purpose of their, at times, chaotic .txt files was. But even from the young age of 10 when I read their first .txt file I was hooked and I always wanted to learn more about this Hacktivist group.
A couple of years ago (late 2019) I stumbled upon the book Cult of the Dead Cow by Joseph Menn (fair warning Amazon Link /not affiliated/), in a brick and mortar book store in Aalborg, Denmark of all places and I got very sparkly eyes! I had wanted this book since I heard about the first time right after it was published back in June 2019. I could not believe I had it my hands! I bought it immediately as it was the only copy in the book store.
Here five years later almost I finally had the time and mental capacity to read it, and boy I was not disappointed.
The book is an honest treasure trow of information about the formation of the cDC from a humble Bulletin board in Texas, its turn to one of the most respected hacker groups in the world, and onwards to its legacy. Including the reasons for creating tools such as Back Orifice. Created with the intention of forcing big corporations to take security serious.
But Mr. Menn does not just focus on the positive it also includes the dark stuff like why Jake Laird excluded from the cult, and the impact of WikiLeaks and how the cDC saw WikiLeaks. LulzSec is also discussed and how elements inspired by the cDc may have gone their own ways away from values of the cDc.
The last member of the cDc covered in the book is Psychedelic Warlord a.k.a Beto O’Rourke. It describes how he used the style of thinking he learned from the early counter culture and cDc to campaign.
But even with all that the most important lessons from the book. Is the following
- With a few dedicated people you can do a lot
- Have principals and morals and stick to them
The Cult of the Dead Cow may have faded into a more obscure place but it and its members have left a lasting legacy on the world. Inspired many and let some of us towards better ideals. I am very thankful that I got to read this book.
Honestly my only regret about the book is that I did not buy it in hard cover!!!
./looopTools
[C/C++] Do you need a file system to write to a disk?
Before I did my PhD my interaction with data storage on disk had mainly been in the classic way. With the classic way I mean having a storage medium (SSD, HDD, USB, etc.) formatted and with a file system (HFS, EXT4, APFS, NTFS, XFS, etc.). During my PhD I started to ask the question: Do I actually need the file system?
The reason for this question was that I on Ubuntu was running in to a strange limitation. I was literally hitting an upper bound for how many files there could be in a single directory. I hit this by exceeding the number of open file descriptors allowed by Ubuntu, which was lower at the time than for instance Fedoras limit. Note, it is really confusing when code works on one Linux distribution and not the other and the error you get is related to the limits imposed for file descriptors. ANYWAYS! I had to solve this and the first solution (and worst) I came up was simply to implement a folder structure which essentially mapped a Try tree to disk. Not my smartest idea, but hey we got a FUSE based file system to work. However, after a while I started to consider if could avoid my problems by avoiding the file system all together.
The answer to this is yes, yes you can and it is surprisingly easy.
All you need is!
Is a raw block device.
What is this then?
Basically a raw block device is any device that does not have a file system to manage the data on it.
To keep it simple it is disk partitions that has not been formatted with a file system, an entire disk or in the *NIX Virtual device such as /dev/null.
You will need knowledge of pwrite and pread (or read/write or fread/fwrite), I will get into why I prefer the p versions later.
These two functions can be untilised by including the unistd.h header.
Oh and you need a file descriptor to the device.
Let us start by looking at pread and pwrite (see code below).
Both take the same parameters as an input, a file descriptor fd, a data buffer buf which in the case of pwrite is const to indicate it is not changed, a byte counter count indicating how many bytes should be read/written, and an offset from/to where data should be read/written.
A note, the file descriptor must be capable of seeking.
The return value is the number of bytes read/written can be compared to count
For pwrite 0 indicates nothing was written or end of file (EOF) in the case of pread.
If -1 is returned and error has occurred and we can use errno to check what error it is.
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
From this we can create a fairly simple example. /WARNING/: DO NOT RUN THIS EXAMPLE UNLESS YOU ADAPT IT TO A DEVICE WHERE YOU DO NOT MIND LOSING THE DATA!
#include <fcntl.h> // Opening files and related flags
#include <unistd.h> // pread and pwrite
#include <string.h> // strcmp
#include <stdio.h> // prints
int main(void)
{
const char *device = "/dev/sda";
const char *data = "Hello world!";
const size_t data_length = 12;
const off_t offset = 0;
int fd = open(device, O_RDWR); // Opens file descriptor in READ/WRITE mode
if (fd == -1) {
perror("Error opening Device");
return 1;
}
ssize_t bytes_written = pwrite(fd, data, data_length, offset);
if (bytes_written == -1) {
perror("Error writing data");
}
else {
char data_out[data_length];
bytes_written = pread(fd, data_out, data_length, offset);
if (bytes_written == -1) {
perror("Error Reading Data");
} else {
const int result_of_compare = strcmp(data, data_out);
printf("It is the same data: %s", result_of_compare == 0 ? "True" : "False");
}
}
close(fd);
return 0;
}
Based on this example you should be able to see a few issues when reading and writing without a file system.
First, where is the data or where should I put it?
Let us say I run this code again, but with the data being I love hamburgers and data_length being 17.
Then we will write over the Hello World on disk.
But how do we know it is there?
Well, we do not and we never will, unless we keep a record of it.
Secondly, how do we know how much data to read?
Let us say that the our write and read happens at two different points in time, how do we know how much data to read?
Well, we do not and we never will, unless we keep a record of it.
So we need to keep a record of both, which essentially is the beginning of a file system…
But still we can read and write without a file system.
Now why do I prefer pread and pwrite over read/write and fread/fwrite.
Well frankly, I just prefer the way I can provide an offset and then “magic” happens behind the seen doing the seek operations for me.
But I know purist who prefer read and write for the opposite reason and that is fair enough.
Anyways now you can write to disk like a pro.
For the love of all gods and demons be careful.
./Lars
Apps for macOS I cannot live without?
A while back I made these two blog posts “Why I prefer physcial notebooks over software-based” and “Writing my notes by hand”. This resulted in me getting a few emails about note Apps I should try for both mac and Linux which totally would get me to drop the physical notebook. Well it has not, I tried Notion for Notes & Docs but it simply is not me. Honestly, I still prefer Emacs with org-mode if I have to take notes on a computer. Now, I actually also got some questions about what applications do I use and mainly I was asked for macOS. So I this bog post I will cover which Apps I cannot live without on macOS and later I will make a similar post for Linux. So let us get started!
Emacs
Emacs is my drug of choice and by the application I use the most. Not just on macOS but also on Linux. Although it is an old text editor, it can be modernised quite a lot through modifications and plugins. I use it for writing blog post for this blog, writing my books, coding, note taking using org-mode and more. It is my multi-tool and I love it.
I will ammend here that the learning curve is quite steep and I might not recommend vanilla Emacs to most people. There are alternatives such as doomeacs which suites modern people a lot more. Although I have not made that leap yet myself… I have actually considered setting up a virtual machine and testing how much I like it.
Apple Pages
For the rare occasion where I need something written which I need in .docx format I do not use Microsoft Word, I use Apple Pages. But why do I use Pages over let us say OpenOffice, LibreOffice, or ONLYOFFICE. Well first of all! I honestly dislike Microsoft Words user interface. I find it very confusing and very unintuitive, which from the get go removes ONLYOFFICE. Then there is {Open,Libre}Office and while LibreOffice is my go to on Linux, I find it really unstable on macOS doing some very weird things from time to time. But, that is not the only reasons I use Pages. I also use Pages because:
- The UI is simply
- It does what I need
- It is stable
- I have iCloud sync between my personal devices (even my Linux machine(s))
- The online editor when I need it is reasonably good, and miles a head of Google Docs and Office 365.
It is a solid what you see is what you get editor and it never surprises me which I really, really like. Here I particular scowl at Microsoft Word and OpenOffice.
Apple Music
I do not understand the hatred people have towards this application. Did I prefer it when it was called iTunes and the layout was less website like… YES! But do I hate it? No! Apple Music lets me listen to my music and that is really all I want from it. I only really use the Apple curated play lists I do not use custom play lists so much… Yet.
Additionally, I love the automatic synchronisation between my phone, tablet, and computers. Side note here! For the blog post on Linux applications I will talk about Cider which I use to listen to Apple Music on Linux.
Things
I am a todo alcoholic and I have been a heavy user of Apple Reminders and I love it. However, I need a more sophisticated app with some feature in terms of note taking for a todo in the todo app. Enter Things. I had been eyeing this app for quite a while and people promised it would beat Apple Reminders by miles and quite honestly it does. The organisation of projects and areas are unparalleled compared to any app I have tried both on Linux and Mac. I was lucky to get it for iPad, macOS, and iPhone last year at black Friday and I have not regretted buying the App.
So that is the apps I cannot live with out.
./Lars
Difference of opinion is okay!
I have thought long about whether or not I should publish this particular piece of writing. Mainly because I cannot foresee the consequence. Which ironically is one of the reasons I wanted to write it in the first place. So let us see what happens.
Also this is a work in progress I will probably reiterate this post many, many times as I give it more thought.
I was born in 1989 which means I got to grow up in the nineties and beginning of the new millennium. It means that by the time I turned twenty, I had experienced the mobile phone and internet become mainstream. I watch opinion providers going from being experts on TV, on the radio, or in papers, to be whomever wanted to shouter their opinion out on the internet. I saw this rice of the comment section on news articles, the hatred it sparked, the rudeness, the unkindness, in particular to people of a different opinion. I witnessed the rise of the opinion influence, with this I mean those influence whom provide opinion on any topic be it political or not. And honestly it frightens me what I have witnessed and what it has become. It frightens me because the nuance of debate has been lost. I has become us versus them and they need to disappear
Enter almost any subreddit (for the uninitialised subforum) on Reddit and you will at minimum see one active “debate”. Where people are throwing slurs at one another because mentality “your dumb arse is wrong and I am write” is strong. Go to Facebook and read the comment track for a news article and see the anger and hate, even if people did not read the article. It is insane. But what is even worse, no one really debate. People stand first on their own opinion with no desire to even try and understand the other side. From arguing about if pineapple on Pizza is sacrilegious, to which band it better, to which political direction is better. No one wants to give up on their opinion and their, in lack of better words, right to be right.
We have become unable to see the side of an opponent. To see that their may be some truth in what the opponent say. It is a lost skill. I have heard and read in many places that this in part can be blamed on information warfare from Russia, China, and other adversaries of the west. But can it really? I have not actually seen a fully convincing argument for it being the sole reason. Others argue that it is the media, their click bait, the dividing stories. But is it? I would argue, no. The reason is that whilst the news do bring these stories that polarise, they do so because it is the once we read and interact with. With todays need for likes, clicks, and interactions, who can blame them? Would you pay for a media that do not do this? I know I want to but right now I do not. For instance I know Zetland exists, an amazing danish news outlet. But do I subscribe… No. Instead I subscribe to a none local news outlet, the New York Times and mainly due to their book and tech sections, not the news. But I should reconsider.
Therefore we should relearn that difference of opinion is okay. We should relearn to accept the opinions of others. We should relearn to evaluate our own opinions. It is a must.
./Lars
QueryC++ 4.0.0
FINALLY!!! We are releasing QueryC++ 4.0.0 and I could not be happier and you can get it here: codeberg.org/ObsidianWolfLabs/querycpp/releases/tag/4.0.0. It has been a much slower process than I hoped and we are already working on release 4.1.0.
Sadly, the documentation is not quite ready yet for the new version, but it will be available here: querycpp-doc.obsidian-wolf-labs.com ASAP.
What have we done? A lot!
- We fully changed the library to use all lowercase function naming, As a request from users and this is the main reason that it is a major release… you know breaking changes.
- We add more functions for SQL commands. Amongst others you can now do joins.
- We add integration test with SQLite which also serves as our example for SQLite.
- We started working on our mdbook based documentation, which we will also release soon.
- We improved the PostgreSQL integration test and again it serves as our example for PostgresSQL.
- We expanded our unit tests.
Over all we are really proud of this release. This will be the last release announcement on this blog for QueryC++. The next one will be at blog.obsidian-wolf-labs.com when we get around to set up our blog there.
./Lars