在 Debain Jessie 8.2 中,如果 samaba 挂载上没有匹配项,则使用通配符/glob(至少*
和?
)bash
会导致出现错误。在其他文件系统上,会出现预期的错误。input/output error
cifs
No such file
相同的 samaba 挂载点位于 archlinux 机器上,没有 io 错误。Archlinux 机器mount.cifs
可以理解mapposix
。我怀疑mount.cifs
jessie 上的“不允许/理解”mapposix
与此有关。
有没有什么办法可以解决 io 错误*
?
## works as expected on cifs mount from centos server
ls /data/Luna1/*adfadf*
# ls: cannot access /data/Luna1/*adfadf*: No such file or director
### unexpected io failure on osx mounted on debian
mkdir /Volumes/Phillips/testdir
## no files match in empty directory: io error
ls /Volumes/Phillips/testdir/*
# ls: reading directory /Volumes/Phillips/testdir/*: Input/output error
## glob matches, ls results
touch /Volumes/Phillips/testdir/file
ls /Volumes/Phillips/testdir/*
# /Volumes/Phillips/testdir/file
## glob matches, ls results
ls /Volumes/Phillips/testdir/*il*
# /Volumes/Phillips/testdir/file
## no files match: io error
ls /Volumes/Phillips/testdir/*foobar*
# ls: reading directory /Volumes/Phillips/testdir/*foobar*: Input/output error
# fails as expected
ls /*filedoesnotexist*
# ls: cannot access /*filedoesnotexist*: No such file or directory
## zsh handles this correctly
zsh -c "ls /Volumes/Phillips/*dne*"
# zsh:1: no matches found: /Volumes/Phillips/*dne*
系统信息:
cat /etc/debian_version
8.2
dpkg -l cifs-utils
ii cifs-utils 2:6.4-1 amd64 Common Internet File
mount |grep cifs
//gromit/Luna1/ on /data/Luna1 type cifs (rw,relatime,vers=1.0,cache=strict,username=foranw,domain=GROMIT,uid=1000,forceuid,gid=1000,forcegid,addr=10.145.64.52,unix,posixpaths,serverino,nobrl,acl,rsize=61440,wsize=65536,actimeo=1)
//skynet/Phillips/ on /Volumes/Phillips type cifs (rw,nosuid,nodev,noexec,relatime,vers=1.0,cache=strict,username=lncd,domain=SKYNET,uid=1000,forceuid,gid=1000,forcegid,addr=10.145.64.109,file_mode=0755,dir_mode=0755,nounix,nobrl,rsize=61440,wsize=65536,actimeo=1)
答案1
我当前的解决方法是触摸与 glob 匹配的文件以避免错误
bet
这对于使用不匹配任何内容的 glob 调用 FSL 的where尤其有效rm
。有趣的是,它会抛出“目录存在”(当不存在时)而不是 IO 错误。
bet 002_mprage_hpf 002_mprage_hpf_brain -m -f 0.1
# /bin/rm: cannot remove '002_mprage_hpf_brain_tmp*': Is a directory.
[ $? -ne 0 ] && echo failed
# failed
对比
touch 002_mprage_hpf_brain_tmp_hackyhackhack
bet 002_mprage_hpf 002_mprage_hpf_brain -m -f 0.1
[ $? -ne 0 ] && echo failed
# $? == 0