View on GitHub

Quorten Blog 1

First blog for all Quorten's blog-like writings

Ansible in place of Docker Compose

2018-06-19

Categories: docker   ansible  
Tags: docker   ansible  

Important! Very interesting article here. Docker Compose or Ansible? So, the recommendation here is to use Ansible as it is more general and powerful than Docker Compose.

20180619/https://www.ansible.com/blog/how-i-switched-from-docker-compose-to-pure-ansible

So, you were wondering if you can see shoe prints on hard, dry pavement on a sunny day? Indeed, you can. The trick is to look for dust or grease that is stirred up into the shoe shape. Use fingerprint duster and/or special lights (ultraviolet, or simply bright LED) at an angle.

20180619/DuckDuckGo infrared light see shoe prints left on the ground

Ah, lots of great tips on SLR photography here. This is old enough such that film is recommended over digital cameras due to the higher resolution of film.

20180619/http://www.forensicscienceresources.com/Shoes.htm
20180619/DuckDuckGo photograph shoeprints on pavement dry sunny day
20180619/DuckDuckGo shoeprint dust with fingerprint powder
20180619/https://en.wikipedia.org/wiki/Fingerprint_powder
20180619/DuckDuckGo shoe print powder
20180619/https://en.wikipedia.org/wiki/Forensic_footwear_evidence
20180619/https://en.wikipedia.org/wiki/File:Footwear_impression_detection_light.jpg

U.S. National Debt

2018-06-18

Categories: misc  
Tags: misc  

US National Debt? If you were to factor it into your own personal finance decisions, what would that look like? Interesting live debt clock here.

20180618/DuckDuckGo america national debt free by 2013
20180618/http://www.usdebtclock.org
20180618/http://www.usdebtclock.org/about.html

So, now I’ve got into the lowdown of cross-compiling for MIPS… somewhat. I already had a MIPS cross-compile toolchain packaged in advance for my newer LibreCMC router, so I just used that to compile a simple “Hello World!” program, copy it to the router, and run it. Works alright. Then I went to the older router, figured out how to copy it over, which was harder because I needed to use Busybox ftp/tftp (I used tftp), and ran that… and it didn’t work. It tried to assume it was a shell script. Sure, first thing to check is if the object file formats are even compatible, so I copied a binary from the router back using tftp, and sure enough, the object code format was different. The difference between elf32-tradbigmips (new) and elf32-tradlittlemips (old). So, then I checked the pre-compiled object code files for the libraries… sure enough, they’re all elf32-tradbigmips. So I have to back-trace and make sure to compile those correctly before trying to run on the old router. Yeah, this is why having the ultra-minimalistic libc is really handy: it makes recompiling a breeze, especially when you’re trying to test some very simple cross-compiled software.

Read on →

So, you’re wondering, it can’t be that hard to write Linux syscalls for ARM and MIPS Linux from scratch, can it? For sure, it is easy, once you find out what you need to know. So here it is. We’ll start with MIPS first because it became popular first for embedded systems, relatively speaking. That being said, make sure you look at newer source code sources if you are looking for examples that work on your modern ARM Linux systems such as Raspberry Pi.

A MIPS syscall in assembler is as follows.

Reference source:
eglibc-2.11.1/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S

syscall:
        /* The mips move instruction is destination, source.  */
        move v0, a0                /* Syscall number -> v0 */
        move a0, a1                /* shift arg1 - arg7.  */
        move a1, a2
        move a2, a3
        move a3, a4
        move a4, a5
        move a5, a6
        move a6, a7
        .set noreorder             /* ??? Sometimes necessary.  */
        syscall                    /* Do the system call.  */
        .set reorder
        bne a3, zero, error
        ret
error:
        /* call __syscall_error */

Subroutine calls pass in arguments in order from register a0 to a7.

Read on →

Important! So, that one thing you’ve said earlier? You need hardware subroutine support to properly support C calling conventions? Well, after careful thought taking into consideration historic programming tricks, that’s not true.

Okay, so here’s how it works. We know the historic idea for rewriting subroutine return addresses does not work correctly with recursion or multithreading, for that matter. So we need a stack in order to do proper modern subroutines. However, using the historic programming, trick, we can in fact clear a subroutine return address from the stack in the callee. Here’s how.

  1. First of all, you need self-modifying code to rewrite addresses on jump instructions.

  2. To mitigate the issues of code being executed from ROM, initialize a thread local “thunk” routine in writable memory (RAM). This routine is effectively your substitute for a hardware subroutine return instruction. The routine in writable memory (RAM) performs the following operations:

    1. Pop the first byte off the stack.
    2. Write it to the first byte of the jump instruction’s address.
    3. Pop the second byte off of the stack.
    4. Write it to the second byte fo the jump instruction’s address.
    5. Execute the jump instruction.

Read on →

So, I’ve thought I’d implement a brk() system call really quickly in my tiny libc library, but I’ve run into complications. Why? Short answer: I read the documentation wrong. sbrk() returns the old address, not the new one!

But anyways, I’ve learned some other interesting things along the way. For odd reasons that be, I was testing on Ubuntu 10.04 LTS, which has this weird bug that under certain conditions like programs being spawned from make, memory maps are setup such that brk() is stuck between two other allocations and can't move. Thus, only mmap() can be used on this particular Linux configuration to get more memory. That's dumb. mmap()` is too complicated to be recommendable for use in very small, simple, statically-linked Linux programs.

Luckily, however, I was able to get sbrk() working even on this system.

Now it turns out there’s an easy way to check a process’s memory maps on Linux:

cat /proc/$PID/maps

Read on →

Public domain is the goal, but lawyers seem, and everyone else thinks that actual license texts have some magic words quality to it. Also, there are some people who wouldn’t otherwise use a project if it was public domain rather than permissively licensed. So fine. “Dual licensed.” Your choice, either the public domain version or the MIT licensed version.

So, you’re wondering. Does GCC have a method to inline only particular function calls? No it doesn’t. Therefore, you’re left with the old macro trick if you want to do this.

20180615/DuckDuckGo gcc force inline specific calls
20180615/https://stackoverflow.com/questions/14571593/how-can-i-inline-a-particular-function-call#14571655