Created
February 5, 2026 22:02
-
-
Save enorrmann/df2c894a599c9560b217ea0eb70b2a71 to your computer and use it in GitHub Desktop.
symlink like for fat using fatcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # fat-ln-s.sh | |
| # Usage: fat-ln-s.sh <device> <target> <link_name> | |
| # Example: fat-ln-s.sh /dev/sda1 /DIR_B /DIR_A | |
| set -e | |
| DEV="$1" | |
| TARGET="$2" | |
| LINK="$3" | |
| if [ $# -ne 3 ]; then | |
| echo "Usage: $0 <device> <target> <link_name>" | |
| exit 1 | |
| fi | |
| # Check device | |
| if [ ! -b "$DEV" ]; then | |
| echo "Error: $DEV is not a block device" | |
| exit 1 | |
| fi | |
| # Extract cluster of TARGET | |
| TARGET_CLUSTER=$(fatcat "$DEV" -e "$TARGET" \ | |
| | awk '/First cluster:/ {print $3}') | |
| if [ -z "$TARGET_CLUSTER" ]; then | |
| echo "Error: could not read cluster of $TARGET" | |
| exit 1 | |
| fi | |
| echo "Target cluster: $TARGET_CLUSTER" | |
| # Repoint LINK to TARGET cluster | |
| fatcat "$DEV" -e "$LINK" -c "$TARGET_CLUSTER" | |
| echo "Linked $LINK -> $TARGET (cluster $TARGET_CLUSTER)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment