1
1
mirror of https://github.com/mgree/ffs.git synced 2024-07-14 14:50:23 +03:00
ffs/tests/removexattr.sh
Michael Greenberg fad45bed4b
Manage metadata using extended attributes (#30)
Extended attributes in `user.type` track the type of files and directories. Users can update these to alter the metadata.

Loading files records types; serialization tries to use them (but will default to strings or bytes if it can't interpret the file appropriately).

In particular, it's now possible to convert between both kinds of directories (list and named).

This isn't a long term solution, because extended attributes have no real affordances---it's not obvious that they even exist, and even once you see `user.type`, it's obvious what it means or what values it has. #2 has other ideas about ways to represent and manipulate metadata.

All of this comes with a few new flags and some brittle file ignoring behavior (macOS will generate `._*` files to hold extended attributes on filesystems that don't support them). The man page is updated with detail on the data model, and now the manpage is part of the website proper.
2021-07-01 18:52:53 -07:00

47 lines
826 B
Bash
Executable File

#!/bin/sh
fail() {
echo FAILED: $1
if [ "$MNT" ]
then
cd
umount "$MNT"
rmdir "$MNT"
fi
exit 1
}
if [ "$RUNNER_OS" = "Linux" ] || [ "$(uname)" = "Linux" ]; then
which setfattr || fail setfattr
rmattr() {
attr=$1
shift
setfattr -x "$attr" "$@"
}
elif [ "$RUNNER_OS" = "macOS" ] || [ "$(uname)" = "Darwin" ]; then
rmattr() {
attr=$1
shift
xattr -d "$attr" "$@"
}
else
fail os
fi
MNT=$(mktemp -d)
ffs -m "$MNT" ../json/object.json &
PID=$!
sleep 2
rmattr user.type $MNT && fail "root user.type"
rmattr user.fake $MNT && fail "root user.fake"
rmattr user.type "$MNT/name" && fail "root user.type"
umount "$MNT" || fail unmount
sleep 1
kill -0 $PID >/dev/null 2>&1 && fail process
rmdir "$MNT" || fail mount