HNHacker News
TopNewBestAskShowJobs

amenonsen

105 karma · joined October 27, 2010

https://toroid.org
submissionscomments
amenonsen··on Upgrading a motherboard’s BIOS/UEFI (the hard way)
Yes, isn't it great? As someone who knew that it's possible to reflash BIOS chips, but had no idea what equipment or process it would take to actually do so, I really appreciated the detailed explanation of the steps involved and (more so) the various potential problems that the author thought about and addressed along the way.
amenonsen··on Why Uber Engineering Switched from Postgres to MySQL (2016)
It doesn't make sense to you because everything in the comment you're replying to is wrong.

Neither log shipping (copying WAL files one by one) nor streaming replication (sending a stream of WAL) works by sending queries. WAL segments are 16MB by default, and the default archive_timeout is 0, not 1 minute (and the archive timeout is not applicable to streaming replication anyway). There is also nothing "adaptive" about the replication—when there is no traffic, there will be ~no changes, and when there are changes, they will be sent to the replica.

I don't understand what the comment is suggesting used to happen in periods of no activity that made replication unusable, but it is also probably incorrect, and has nothing to do with the write amplification problem.

amenonsen··on Why Uber Engineering Switched from Postgres to MySQL (2016)
> In more recent versions there's "logical replication", which sort of "sends the queries"

What it sends is not the queries, but a logical description of the changes to each row that were made by running the query. So an UPDATE that changes N rows would generate N changes to be applied to the corresponding rows (usually identified by primary key) on the logical replica, not a single update that had to be "re-executed".

amenonsen··on How are Unix pipes implemented?
FYI: I'm the author of the linked article, and I added a link to the image after it was posted here.
amenonsen··on How are Unix pipes implemented?
> Can you elaborate on how to identify the filename for a pipe in procfs or sysfs in a simple "echo hello | wc -c" example?

You can see it under /proc/$pid/fd. For example, if you run "sleep 600|wc -c" (just to give yourself some time to poke around), you can see:

    $ ls -l /proc/2760791/fd 
    total 0
    lrwx------ 1 ams ams 64 Mar 28 13:35 0 -> /dev/pts/10
    l-wx------ 1 ams ams 64 Mar 28 13:35 1 -> pipe:[54074122]
    lrwx------ 1 ams ams 64 Mar 28 13:35 2 -> /dev/pts/10
    
    $ ls -l /proc/2760792/fd
    total 0
    lr-x------ 1 ams ams 64 Mar 28 13:35 0 -> pipe:[54074122]
    lrwx------ 1 ams ams 64 Mar 28 13:35 1 -> /dev/pts/10
    lrwx------ 1 ams ams 64 Mar 28 13:35 2 -> /dev/pts/10
Here 2760791 is the pid of the "sleep 600", and 2760792 is the pid of "wc". You can see they're both connected to "pipe:[54074122]".

54074122 is the (virtual, i.e., not disk-based) inode of the pipe. You can get substantially the same information from lsof:

    $ lsof -E -u ams|egrep 'sleep|wc'|grep pipe
    sleep     2760791  ams    1w     FIFO               0,13        0t0   54074122 pipe 2760792,wc,0r
    wc        2760792  ams    0r     FIFO               0,13        0t0   54074122 pipe 2760791,sleep,1w
But the name "pipe:[54074122]" is actually the "filename" of the pipe, and it comes from here in fs/pipe.c:

    static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen)
    {
            return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]",
                                    d_inode(dentry)->i_ino);
    }
(There's an interesting note in Documentation/filesystems/vfs.txt about how pseudo-filesystems like pipefs can generate these names only when someone asks for them, since they're not used for anything otherwise. The only way I know of to ask for the name in this case is to call readlink() on the pipe fd under /proc/$pid/fd, as ls does.)
amenonsen··on How are Unix pipes implemented?
Sorry, I was wrong about the BSDs. FreeBSD's pipe.2 manpage clearly says that pipes are still bidirectional. https://www.freebsd.org/cgi/man.cgi?query=pipe&sektion=2

That said, it is not based on socketpair any more. sys/kern/sys_pipe.c says:

    /*
     * This file contains a high-performance replacement for the socket-based
     * pipes scheme originally used in FreeBSD/4.4Lite.  It does not support
     * all features of sockets, but does do everything that pipes normally
     * do.
     */
amenonsen··on How are Unix pipes implemented?
The slides are from 2011, not the code. Linux had pipes even in the v0.01 release from 1991, as the original article here mentions.
amenonsen··on How are Unix pipes implemented?
> So do modern Linux pipes work bi-directionally?

No, they do not (nor on the modern BSD kernels, as far as I can tell). The Linux pipe(7) manpage says (under "Portability notes"):

    «On some systems (but not Linux), pipes are bidirectional:
    data can be transmitted in both directions between the
    pipe ends. POSIX.1 requires only unidirectional pipes.
    Portable applications should avoid reliance on
    bidirectional pipe semantics.»
I believe the systems that supported bidirectional pipes were SysV kernels that implemented pipes using STREAMS and 4(?)BSD kernels that implemented it using socketpair.
amenonsen··on How are Unix pipes implemented?
Yes, xv6 is great. The original post here already has a brief section on the code from xv6/pipe.c, which made for pleasant reading after I had just finished working my way through the 6E code.

I also looked at the pipe implementation in Minix, which is a (non-trivial) variant of John S. Dyson's implementation that the BSDs share. It is implemented as a server (in the microkernel sense), so there's quite some added complexity there in handling "vmount"s and locking, but there are still some familiar elements of the code too, such as the "put it all together with flags" code in create_pipe().

https://github.com/Stichting-MINIX-Research-Foundation/minix...

For something even further along these lines, there's also the pipe implementation from Plan9, which at first glance felt so unfamiliar that I wasn't sure I was looking in the right place:

https://9p.io/sources/plan9/sys/src/9/port/devpipe.c

amenonsen··on How are Unix pipes implemented?
That commit is a fascinating illustration of how pipes allow a model of inter-process interaction that goes beyond what you can do with temporary files, as well as how much further things have evolved from the days of the "very conservative locking" in readp/writep from the 6E Unix kernel.
amenonsen··on How are Unix pipes implemented?
Thanks for the link. That article seems to have a completely different focus (API rather than internals), but it's very nicely done.
amenonsen··on How are Unix pipes implemented?
Thank you very much for digging this up, and to all the other commenters here for the useful references.
amenonsen··on How are Unix pipes implemented?
> Manual formatters still send, even today, TTY Model 37 style input from 1969 to the manual pager

Thanks, you are perfectly right. What I found charming was that the 3E pipe.2 manual page contains «word^H^H^H^H____» written out by hand in the roff _source_. The 4E one switched to using ".it word" instead.

https://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man2/pi...

Another charming little quirk: the 6E kernel's falloc() does «printf("no files\n")» if it fails to find a free file structure.

amenonsen··on What is fsck up to now?
https://groups.google.com/forum/#!msg/alt.sysadmin.recovery/...
amenonsen··on What is fsck up to now?
> Thanks for the awesome write-up.

Glad you enjoyed it. :-)

> I have considered doing something totally ridiculous like setting up a Raspberry Pi with a camera and machine vision software to watch the LED displays on these devices to glean status information. Silly, but...

Ha! I actually have a PoE camera pointed at the display of my UPS. Here's what it looks like right now: https://toroid.org/misc/ups-display.jpg

Notice that horizontal blank row of dead pixels halfway down the right side of the display? The one that makes "54.6" look like "51.6"? That gap defeated my naïve five-minute attempt to use image recognition to extract the battery voltage.

amenonsen··on What is fsck up to now?
(I'm this person.) It so happens that the solar inverter I'm using right now doesn't provide a data connection that I could use to shut down the computers cleanly.

But I should also clarify that my long-running fsck isn't always the result of an unclean shutdown. There's something about my combination of iSCSI+crypttab+NFS that causes fsck to be run too often—even if I shut down the machine cleanly while the NAS is running, it usually decides to fsck when it comes back up.

Something to investigate next winter, perhaps.

amenonsen··on LibreOffice 6.1 released
I find it a bit strange that I have to download the LibreOffice "built-in" help package separately.
amenonsen··on A girl was found living among monkeys in an Indian forest
> If so, then maybe writing "Malayam" instead of "Malayalam" isn't too far wrong.

No, it's very far wrong. (I'm a Malayali.)

amenonsen··on On the Impending Crypto Monoculture (2016)
Why Blake rather than Keccak? (Maybe I missed some reason why it's a good idea to avoid the latter.)
amenonsen··on Barman 2.0 Released
The big conceptual difference is that with WAL-E, all your backup code and configuration is on your Postgres server, whereas with Barman, it's all (or almost all) on your backup server. WAL-E stores backups in S3 (or S3-alikes), whereas Barman is built around the idea of having a backup server (it can store backups in S3 too, but it's not central to its operation as it is with WAL-E).
amenonsen··on Barman 2.0 Released
Recent versions of Barman allow you to do WAL archiving without using an rsync/ssh-based archive_command. Instead, the backup server uses streaming replication via the standard pg_receivexlog command to build up a WAL archive. The big new feature in Barman 2.0 is that it can take base backups using pg_basebackup, rather than rsync. This means that it can be used without SSH access between servers (only replication connections to Postgres on port 5432).
amenonsen··on Datapath.io: Provider-Independent Elastic IP Addresses
When I first saw the page (opened along with a bunch of other tabs from HN links), with its "Timeout error!" balloon and "Service disruption" headline, I thought it was a fancy error page and hit reload. Oops.
amenonsen··on Be your own VPN provider with OpenBSD
I am often dependent on a high-latency GPRS link, and the overhead of establishing a tunnel using OpenVPN or SSH (e.g. sshuttle) is prohibitive. OpenVPN is very likely to timeout before it can negotiate a TLS session. This is one of the major reasons why I wrote my own VPN software[1] using NaCl. Deterministic public-key encryption means that there is no negotiation required at startup. The tunnel is therefore ready to use as soon as the program is started. To me, that's the difference between a usable connection and nothing at all.

[1] https://github.com/amenonsen/tappet

amenonsen··on Some gripes about nacl
As someone who didn't really know what they were doing, I used NaCl recently to write a program to tunnel packets over UDP.

I started by reading the NaCl source and all the introductory material available—the web site, the two NaCl papers ("Cryptography in NaCl", "The security impact of a new cryptography library"), and quickly reviewed a couple of other papers (e.g. to understand deterministic encryption and D-H key exchange). I think the biggest problem I had was to understand nonce generation and handling properly. The "Cryptography …" paper does contain some advice that I ultimately implemented. But I had to think very hard about what it said before I was confident that I was doing what it said. For example, it says:

«…the nonce can be chosen as a simple counter: 0 for Alice’s first packet, 1 for Bob’s first packet, 2 for Alice’s second packet, 3 for Bob’s second packet, 4 for Alice’s third packet, 5 for Bob’s third packet, etc. Choosing the nonce as a counter followed by (e.g.) 32 random bits helps protect some protocols against denial-of-service attacks. In many applications it is better to increase the counter to, e.g., the number of nanoseconds that have passed since a standard epoch in the local clock, so that the current value of the counter does not leak the traffic rate.»

I managed to figure it out, but I would certainly have welcomed a more detailed explanation, and would have been very happy to have help from the code to do the right thing.

In contrast, the cryptography functions were easy enough to figure out and use (with the C API). The only mistake I kept making was specifying the secret key first and the public key second in all my function calls. Once I got used to doing it the other way around, it was fine. Zero-padding the messages was slightly ugly, but I didn't develop any especially strong feelings about it. (Aside: I actually ended up using TweetNaCl, but of course all the documentation is the same.)

I'm very pleased with the resulting code, anyway.

P.S. I looked at libsodium, but greatly preferred the unadorned library.

amenonsen··on Kathy Sierra: Your app makes me fat
I remember the harrassment incidents, but I had never read anything she had written before. Thanks for the link.

As a former dog owner, I found the dog example in this article especially evocative, because I've seen what an effort it can be for dogs to sit still when they're told.

(Minor aside: the extraordinary overuse of emphasis made this article much harder to read.)

amenonsen··on Vivid Schemer: An Interactive Version of the Little Schemer
If I had been asked this question earlier, I might have said "It could be useful". Having tried this page, though, I agree with you. It was painful and distracting to step through the first example, and I can't imagine doing it for non-trivial pieces of code. At least for me, it would devolve into clicking "Next" blindly until the end.
amenonsen··on Youth expelled from Montreal college after finding security flaw
What did you think of the course textbook ("Exploiting Software", Hoglund & McGraw)? Is there a more modern alternative that you (or anyone) can recommend?
amenonsen··on Photographers face copyright threat after shock ruling
«Well, we may discuss about the "closely as possible without infringing".»

Did you read the judgement yet? There's no point discussing anything without knowing the facts of the case.

«Seems quite obvious that if find yourself in that photo spot, and a red bus passes by, you immediately think to make it pop out with such a post processing trick.»

If that's all it had been, the judgement makes it clear that the result would not have been infringing.

amenonsen··on Photographers face copyright threat after shock ruling
I read the judgement (http://www.bailii.org/ew/cases/EWPCC/2012/1.html, linked to from the page originally posted), and I think it is a clearly-written, well-thought-out ruling in a subtle case.

The finding hinges on the fact that the infringing photograph was not an independent work, but was created based on knowledge of the claimant's original photograph, without drawing inspiration from (or knowing about) other similar works, a series of which are analysed. In no way does it mean that any photograph of a red bus in London would infringe on the claimant's copyright; in fact, this is specifically denied, and various ways in which the defendant could have created a non-infringing photograph are discussed.

I find it's often instructive to read actual judgements rather than what is reported about them in the press.