Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Jan 14, 2020
0 parents commit db8e6c8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# cursedfs

Make a disk image formatted with both ext2 and FAT, at once.

```bash
~/cursedfs% wget 'https://github.com/NieDzejkob/cursedfs/releases/download/v1.0/cursed.img'
~/cursedfs% sudo mount -o loop -t ext2 cursed.img mountpoint/
~/cursedfs% ls mountpoint/
mkfs.cursed
~/cursedfs% sudo umount mountpoint/
~/cursedfs% sudo mount -o loop -t msdos cursed.img mountpoint/
~/cursedfs% ls mountpoint/
gudnuse.ogg
```

# Why?

[I got nerd-sniped](https://twitter.com/Foone/status/1217162186130198529?s=20)

# How?

It turns out this is surprisingly simple to do: just create a FAT volume with a
lot of reserved sectors and put the ext2 into the reserved sectors. This works
because the filesystems choose different places to put their superblock: FAT
uses the very first sector, while ext2 leaves the first kilobyte unused.
13 changes: 13 additions & 0 deletions mkfs.cursed
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

SIZE_EXT2=128 # sectors, max is 65535

set -euxo pipefail
EXT2_TMP="$(mktemp)"
trap "rm $EXT2_TMP" EXIT

truncate -s 4M cursed.img
truncate -s "$((512*$SIZE_EXT2))" $EXT2_TMP
mkfs.ext2 $EXT2_TMP
mkfs.fat -R $SIZE_EXT2 cursed.img
dd if=$EXT2_TMP of=cursed.img bs=512 skip=1 seek=1 conv=notrunc

0 comments on commit db8e6c8

Please sign in to comment.