Guillaume Boudreau
2010-Mar-25 01:13 UTC
[Samba] Can't access opaque symlinks pointing to another Samba mount
Computer A runs my samba server. Has unix extensions = off, wide links = on (don't think this one matters with unix extensions off...) This way, if I have a symlink on my shares, clients see it as a normal file, not as a symlink. This works fine, even for symlinks to files outside the shares paths. Except when the symlink points to a file that is on a CIFS mount. So say I have computer B (running Mac OS X) that shares something using Samba. I mount such share on computer A, in /mnt/hdd-air. Then, on a share of computer A, I create a symlink to a file in /mnt/hdd-air: ln -s /mnt/hdd-air/gh/TimeMachine/file2 /mnt/hdd0/shares/TimeMachine/file2 If I mount my TimeMachine share (on computer A or any other computer), file2 is listed, but I can't access it. That is, it can't be accessed UNLESS the file was accessed successfully in the last second! Here's a test case I created on computer A: # This is my /mnt/hdd-air share; I tried various mount options, and I always have the problem. [gb at hda TimeMachine]$ grep hdd-air /etc/fstab //192.168.155.5/gb /mnt/hdd-air cifs credentials=/home/gb/.smb_credentials,uid=500,gid=100,file_mode=0666,dir_mode=0777,hard,_netdev 0 0 # Now I created 3 symlinks to various targets on my TimeMachine share. [gb at hda TimeMachine]$ ls -l lrwxrwxrwx 1 gb users 30 2010-03-24 17:04 file1 -> /mnt/hdd0/gh/TimeMachine/file1 lrwxrwxrwx 1 gb users 33 2010-03-24 17:05 file2 -> /mnt/hdd-air/gh/TimeMachine/file2 lrwxrwxrwx 1 gb users 30 2010-03-24 17:08 file3 -> /mnt/hdd1/gh/TimeMachine/file3 # We can see here that I can access all 3 files here, as expected. [gb at hda TimeMachine]$ cat file* 1 2 3 # Here's the targets of my symlinks [gb at hda TimeMachine]$ mount | grep -E "/mnt/hdd0|/mnt/hdd1|/mnt/hdd-air" /dev/sda6 on /mnt/hdd0 type ext3 (rw) /dev/sdf1 on /mnt/hdd1 type ext3 (rw) //192.168.155.5/gb on /mnt/hdd-air type cifs (rw,mand) # Now, I mounted my TimeMachine share locally to ease testing... [gb at hda TimeMachine]$ cd /mnt/samba/TimeMachine/ # file2 looks fine [gb at hda TimeMachine]$ ls -l -rw-rw---- 1 gb users 2 2010-03-24 17:05 file1 -rw-rw---- 0 gb users 2 2010-03-24 17:05 file2 -rw-rw---- 1 gb users 2 2010-03-24 17:08 file3 # But can't be accessed [gb at hda TimeMachine]$ cat file* 1 cat: file2: No such file or directory 3 # But there is no problem if the file was successfully accessed in the last second! [gb at hda TimeMachine]$ date; cat /mnt/hdd0/shares/TimeMachine/file*; date; cat /mnt/samba/TimeMachine/file*; date; cat /mnt/samba/TimeMachine/file*; sleep 1; cat /mnt/samba/TimeMachine/file* Wed Mar 24 18:24:45 EDT 2010 1 2 3 Wed Mar 24 18:24:45 EDT 2010 1 2 3 Wed Mar 24 18:24:45 EDT 2010 1 2 3 Wed Mar 24 18:24:46 EDT 2010 1 cat: /mnt/samba/TimeMachine/file2: No such file or directory 3 As you can see, file2 works fine through my share until I wait 1 second after the last successful access, at which point the file becomes unaccessible. I also tried to access /mnt/samba/TimeMachine/file2 in an infinite loop after accessing /mnt/hdd0/shares/TimeMachine/file2 once, and it works fine. file2 accessed through the share will work fine until I stop the loop, wait 1 second, and then try to access it again! I've set log level = 3 and traced what happens when I can and can't access the file. I attached both files. Any pointer as to what is happening, why, or how I could work around this issue would be welcome! Thanks, - Guillaume Boudreau