0

I have a file on a Samba share and there are several computers which append data to the file. I need to lock this file by each computer in order to perform append operations sequentially. How can I achieve it?
The reason is that the file turns out complete mess at that moment. I've tried to play with Samba options but I couldn't solve this issue.

testparm:

[global]
    netbios name = XXXXXXX
    server string = %h server (Samba, Ubuntu)
    map to guest = Bad User
    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* .
    unix password sync = Yes
    syslog = 0
    log file = /var/log/samba/log.%m
    max log size = 1000
    dns proxy = No
    usershare allow guests = Yes
    panic action = /usr/share/samba/panic-action %d
    idmap config * : backend = tdb

[HwInfo]
    path = /home/XXXXXXXXX/hw/IN
    write list = all
    read only = No
    create mask = 0644
    guest ok = Yes

I created the next script:

STR="\n\n\n$1\n\n"

while : ; do
  echo -e $STR >> "./temp/info.csv"
done

and ran it in the several terminal sessions on the same computer simultaneously. "./temp" is the mount point for the Samba share.

6
  • Samba usually has locking enabled by default, can you show the settings for your share? And global settings
    – Ziazis
    Aug 17, 2017 at 8:17
  • @Ziazis I added testparm output. Do you need the exact content of smb.conf or it is ok?
    – Yuri H
    Aug 17, 2017 at 8:34
  • Ok, another question are you using that share only on windows machines or are you trying to use it on linux aswell and want to have lock files on linux mixed with windows machines?
    – Ziazis
    Aug 17, 2017 at 9:02
  • @Ziazis Only Linux. Well, I'm looking at NFS now but I'd like to use Samba cause it's already installed and used on the Server.
    – Yuri H
    Aug 17, 2017 at 9:05
  • 1
    Pretty sure that is not possible, since linux doesn't care about oplocks per se. That's why you'd use a dbms if you have a program or something with multiple access' or just add to the file output with >> e.g. Of course there are also flocks on linux but samba doesn't have it build in since it is actually aimed at windows clients.
    – Ziazis
    Aug 17, 2017 at 9:33

0

You must log in to answer this question.

Browse other questions tagged .