这里发生了什么?目录名和/或文件名中的反斜杠似乎会导致各种校验和实用程序报告前面带有反斜杠的哈希值。
请注意,coreutil 的wc
行为并非如此。
行为符合预期:
#ppd# ls -1a
.
..
#ppd# mkdir a\\b
#ppd# ls -1
a\b
#ppd# for i in 1 2 3; do echo $i > a\\b/c$i; done
#ppd# ls -1 a\\b/c*
a\b/c1
a\b/c2
a\b/c3
#ppd# cat a\\b/c*
1
2
3
#ppd# wc --version
wc (GNU coreutils) 8.13
#pre# wc a\\b/c*
1 1 2 a\b/c1
1 1 2 a\b/c2
1 1 2 a\b/c3
#ppd# cd a\\b/
#ppd# md5sum --version
md5sum (GNU coreutils) 8.13
#ppd# md5sum c*
b026324c6904b2a9cb4b88d6d61c81d1 c1
26ab0db90d72e28ad0ba1e22ee510510 c2
6d7fce9fee471194aa8b5b6e47267f03 c3
现在来看看奇怪的行为:
#ppd# pwd
/home/abe/tdir/a\b
#ppd# md5sum ../a\\b/c*
\b026324c6904b2a9cb4b88d6d61c81d1 ../a\\b/c1
\26ab0db90d72e28ad0ba1e22ee510510 ../a\\b/c2
\6d7fce9fee471194aa8b5b6e47267f03 ../a\\b/c3
#ppd# cd ..
#ppd# md5sum a\\b/c*
\b026324c6904b2a9cb4b88d6d61c81d1 a\\b/c1
\26ab0db90d72e28ad0ba1e22ee510510 a\\b/c2
\6d7fce9fee471194aa8b5b6e47267f03 a\\b/c3
#ppd# sha1sum a\\b/c*
\e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e a\\b/c1
\7448d8798a4380162d4b56f9b452e2f6f9e24e7a a\\b/c2
\a3db5c13ff90a36963278c6a39e4ee3c22e2a436 a\\b/c3
#ppd# sha256sum a\\b/c*
\4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 a\\b/c1
\53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 a\\b/c2
\1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2 a\\b/c3
文件名中的反斜杠:
#ppd# echo "4" > a\\b/c\\4
#ppd# ls -1 a\\b/*
a\b/c1
a\b/c2
a\b/c3
a\b/c\4
#ppd# md5sum a\\b/*
\b026324c6904b2a9cb4b88d6d61c81d1 a\\b/c1
\26ab0db90d72e28ad0ba1e22ee510510 a\\b/c2
\6d7fce9fee471194aa8b5b6e47267f03 a\\b/c3
\48a24b70a0b376535542b996af517398 a\\b/c\\4
#ppd# cd a\\b/
#ppd# md5sum *
b026324c6904b2a9cb4b88d6d61c81d1 c1
26ab0db90d72e28ad0ba1e22ee510510 c2
6d7fce9fee471194aa8b5b6e47267f03 c3
\48a24b70a0b376535542b996af517398 c\\4
我在将 xattrs 中的哈希值存储为 时发现了上述内容ss=md5sum <filename>; setfattr -n user.cksm -v ${ss:0:32}
。以下是报告的一些字符getfattr -n user.cksm.md5
(第一行只是为了帮助计算字符数,对于 md5 哈希值来说,字符数应该为 32:
# 123456789 123456789 123456789 12
user.cksm.md5="be28d5286d9c719a904550f41593d"
user.cksm.md5="a4e9e6958c9d5762dcf090871e44bf"
user.cksm.md5="#f39b8c4dc110178505c089cba7986"
user.cksm.md5="\\ebf1b8f8054d21c78f2a699776f84a0"
user.cksm.md5="+c2769ebdd2ce3a8355395d2129051"
user.cksm.md5="/9ac5b68efea0e9f02c917503cbb3e"