Hi! On a Debian GNU/Linux 5.0.2 (lenny) I have Samba 3.4.2-1 installed (see more details at the end). I mount a Samba shared directory on the same system using: # mount.cifs //debian-host/backup$ /media/samba_share -o username=samba_user,password=mypassword,iocharset=utf8 Now, I notice a problem writing to files on the mounted CIFS. Here is a simple test script that illustrates the problem: # cat test.sh #!/bin/bash n=$1 outFile=$2 rm $outFile for (( i = 0; i < $n; i++ )); do echo "i = $i" echo "$i $HOSTNAME" >> $outFile echo "$outFile contains:" cat $outFile done ------------------------------------------------------------ Here is the expected output of the script when it writes to a file on the local ext3 file system: # ./test.sh 4 test.txt i = 0 test.txt contains: 0 debian-host ---------- i = 1 test.txt contains: 0 debian-host 1 debian-host ---------- i = 2 test.txt contains: 0 debian-host 1 debian-host 2 debian-host ---------- i = 3 test.txt contains: 0 debian-host 1 debian-host 2 debian-host 3 debian-host ---------- ------------------------------------------------------------ But, when the script writes to a file on the mounted CIFS, I get an unexpected result: # ./test.sh 4 /media/samba_share/test.txt i = 0 /media/samba_share/test.txt contains: 0 debian-host ---------- i = 1 /media/samba_share/test.txt contains: 0 debian-host 0 debian-host 1 debian-host ---------- i = 2 /media/samba_share/test.txt contains: 0 debian-host 0 debian-host 1 debian-host 0 debian-host 0 debian-host 1 debian-host 2 debian-host ---------- i = 3 /media/samba_share/test.txt contains: 0 debian-host 0 debian-host 1 debian-host 0 debian-host 0 debian-host 1 debian-host 2 debian-host 0 debian-host 0 debian-host 1 debian-host 0 debian-host 0 debian-host 1 debian-host 2 debian-host 3 debian-host ---------- ------------------------------------------------------------ If you get such a result, try a greater number for the loop in the test script. I don't see any errors either in the Samba log files or in the syslog. If I mount a remote CIFS share that exists on a MS Windows XP Pro. SP3, the test script gives the expected result. Also, if I run the test script on a MS Windows XP Pro. SP3 so that it writes to my Samba share, I also get the expected result. For this test I use the following Tcl script: # cat test.tcl #!/usr/bin/tclsh set n [lindex $argv 0] set outFile [lindex $argv 1] file delete $outFile set hostname [info hostname] for {set i 0} {$i < $n} {incr i} { puts "i = $i" set ch [open $outFile a] puts $ch "$i $hostname" close $ch set ch [open $outFile r] puts "$outFile contains:" while {[gets $ch line] >= 0} { puts $line } close $ch puts "----------" } ------------------------------------------------------------ So, I'd say that the problem only exists when a linux system running Samba server mounts its own Samba share. # uname -a Linux debian-host 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64 GNU/Linux # dpkg --list samba smbfs ii samba 2:3.4.2-1~bpo5 SMB/CIFS file, print, and login server for U ii smbfs 2:3.4.2-1~bpo5 Samba file system utilities # df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/hda1 ext3 18398028 1285164 16178288 8% / tmpfs tmpfs 497752 0 497752 0% /lib/init/rw udev tmpfs 10240 676 9564 7% /dev tmpfs tmpfs 497752 0 497752 0% /dev/shm /dev/md0 ext3 480616600 299483796 176250012 63% /samba_data # testparm Load smb config files from /etc/samba/smb.conf Processing section "[backup$]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions [global] server string = %h Samba server obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . username map = /etc/samba/smbusers unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 10000 socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 dns proxy = No panic action = /usr/share/samba/panic-action %d [backup$] comment = No comment path = /samba_data/backup read only = No create mask = 0770 security mask = 0770 directory mask = 0770 directory security mask = 0770 ------------------------------------------------------------ # ifconfig eth0 Link encap:Ethernet HWaddr 00:22:b0:de:eb:06 inet addr:192.168.33.151 Bcast:192.168.33.151 Mask:255.255.255.0 inet6 addr: fe80::222:b0ff:fede:eb06/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:517386 errors:0 dropped:0 overruns:0 frame:0 TX packets:277734 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:719154219 (685.8 MiB) TX bytes:26902845 (25.6 MiB) Interrupt:20 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4598 errors:0 dropped:0 overruns:0 frame:0 TX packets:4598 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3950022 (3.7 MiB) TX bytes:3950022 (3.7 MiB) ------------------------------------------------------------ -- rpr.
I have tested this also on Ubuntu Desktop 8.04 and found no problems. # uname -a Linux ubuntu-01 2.6.24-25-generic #1 SMP Tue Oct 20 07:31:10 UTC 2009 i686 GNU/Linux # dpkg --list samba smbfs ii samba 3.0.28a-1ubuntu4.9 a LanManager-like file and printer server for Unix ii smbfs 3.0.28a-1ubuntu4.9 mount and umount commands for the smbfs (for kerne -- rpr.
I don't see this problem any more with Samba 3.4.8 (on a Debian GNU/Linux 5.0.5 with Linux 2.6.32-bpo.5-amd64).