Skip The Embedded Filesystem With The TAR-like UTFS Format

If you need to store some data on a resource-constrained embedded platform, the prospect of dragging in a dependency for something like FAT filesystem access to flash or other storage medium can seem rather daunting. Not only is your binary size now significantly larger, the overhead of these filesystems is also not insignificant as they were not really designed for this type of environment. Here [Drew Gaylo]’s UTFS format is an interesting alternative to just writing raw binary data to said storage medium.

As explained in the accompanying introduction article, the basic idea is similar in scope but very much slimmed down compared to the venerable Tape ARchive (TAR) format, hence the Micro (µ) Tar File System name. The provided UTFS implementation is quite small, spanning two source files in C99 with zero heap usage. Targeting a custom store medium requires implementing one read and one write function to match the underlying platform.

A couple of examples are also provided, covering using the built-in Flash of a SAMD20 MCU and the EEPROM of an ATmega328. Compared to raw binary data that’d have to be fully rewritten, UTFS allows for sections of the storage to be accessed as files and thus updated in-place.

Linux Fu: Shell Script File Embedding

You need to package up a bunch of files, send them somewhere, and do something with them at the destination. It isn’t an uncommon scenario. The obvious answer is to create an archive — a zip or tar file, maybe — and include a shell script that you have to tell the user to run after unpacking.

That may be obvious, but it assumes a lot on the part of the remote user. They need to know how to unpack the file and they also need to know to run your magic script of commands after the unpack. However, you can easily create a shell script that contains a file — even an archive of many files — and then retrieve the file and act on it at run time. This is much simpler from the remote user’s point of view. You get one file, you execute it, and you are done.

In theory, this isn’t that hard to do, but there are a lot of details. Shell scripts are not compiled — at least, not typically — so the shell only reads what it needs to do the work. That means if your script is careful to exit, you can add as much “garbage” to the end of it as you like. The shell will never look at it, so it’s possible to store the payload there.

Continue reading “Linux Fu: Shell Script File Embedding”