-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save original names that don't work as filenames (e.g., `.` and `..`). We restore these names as appropriate---if a file is `rename`d with the _same_ name, we leave it alone. But renames to fresh names destroy original names. Resolves #29. There is no way to create a file with such a name: the metadata is purely copied. There's a TODO note in the code to allow users to inspect and edit this metadata, but it's not worth exposing until somebody asks for it. (I mean, really, please don't use `.` or `:/` as a property name.)
- Loading branch information
Showing
5 changed files
with
182 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/sh | ||
|
||
fail() { | ||
echo FAILED: $1 | ||
if [ "$MNT" ] | ||
then | ||
cd | ||
umount "$MNT" | ||
rmdir "$MNT" | ||
rm "$OUT" "$EXP" | ||
fi | ||
exit 1 | ||
} | ||
|
||
MNT=$(mktemp -d) | ||
OUT=$(mktemp) | ||
EXP=$(mktemp) | ||
|
||
printf '{"he":{"dot":"shlishi"},"imnewhere":"derp","it":{".":"primo","..":"secondo"}}' >"$EXP" | ||
|
||
ffs -m "$MNT" -o "$OUT" --target json ../json/obj_rename.json & | ||
PID=$! | ||
sleep 2 | ||
case $(ls "$MNT") in | ||
(dot*dot_*dotdot*dotdot_) ;; | ||
(*) fail ls;; | ||
esac | ||
[ "$(cat $MNT/dot)" = "first" ] || fail dot | ||
[ "$(cat $MNT/dotdot)" = "second" ] || fail dotdot | ||
[ "$(cat $MNT/dot_)" = "third" ] || fail dot_ | ||
[ "$(cat $MNT/dotdot_)" = "fourth" ] || fail dotdot_ | ||
|
||
echo primo >"$MNT"/dot | ||
echo secondo >"$MNT"/dotdot | ||
echo shlishi >"$MNT"/dot_ | ||
echo derp >"$MNT"/dotdot_ | ||
|
||
mkdir "$MNT"/it | ||
mkdir "$MNT"/he | ||
|
||
mv "$MNT"/dot "$MNT"/it | ||
mv "$MNT"/dotdot "$MNT"/it | ||
|
||
mv "$MNT"/dot_ "$MNT"/he | ||
|
||
mv "$MNT"/dotdot_ "$MNT"/imnewhere | ||
|
||
umount "$MNT" || fail unmount | ||
sleep 1 | ||
kill -0 $PID >/dev/null 2>&1 && fail process | ||
|
||
diff "$OUT" "$EXP" || fail diff | ||
|
||
rmdir "$MNT" || fail mount | ||
rm "$OUT" "$EXP" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
fail() { | ||
echo FAILED: $1 | ||
if [ "$MNT" ] | ||
then | ||
cd | ||
umount "$MNT" | ||
rmdir "$MNT" | ||
rm "$OUT" "$EXP" | ||
fi | ||
exit 1 | ||
} | ||
|
||
MNT=$(mktemp -d) | ||
OUT=$(mktemp) | ||
EXP=$(mktemp) | ||
|
||
printf '{".":"primo","..":"secondo","dot":"terzo","dotdot":"quarto"}' >"$EXP" | ||
|
||
ffs -m "$MNT" -o "$OUT" --target json ../json/obj_rename.json & | ||
PID=$! | ||
sleep 2 | ||
case $(ls "$MNT") in | ||
(dot*dot_*dotdot*dotdot_) ;; | ||
(*) fail ls;; | ||
esac | ||
[ "$(cat $MNT/dot)" = "first" ] || fail dot | ||
[ "$(cat $MNT/dotdot)" = "second" ] || fail dotdot | ||
[ "$(cat $MNT/dot_)" = "third" ] || fail dot_ | ||
[ "$(cat $MNT/dotdot_)" = "fourth" ] || fail dotdot_ | ||
|
||
echo primo >"$MNT"/dot | ||
echo secondo >"$MNT"/dotdot | ||
echo terzo >"$MNT"/dot_ | ||
echo quarto >"$MNT"/dotdot_ | ||
|
||
umount "$MNT" || fail unmount | ||
sleep 1 | ||
kill -0 $PID >/dev/null 2>&1 && fail process | ||
|
||
diff "$OUT" "$EXP" || fail diff | ||
|
||
rmdir "$MNT" || fail mount | ||
rm "$OUT" "$EXP" |