[GFARM LOGO] documents > User's Manual > samba/hook

Access Gfarm file system via Samba -- using Gfarm syscall-hooking library

English | Japanese

1. Summary

This document describes how to configure samba to access Gfarm file system from Windows clients, by invoking samba with preloaded Gfarm system-call-hooking library.

Another solution: GfarmFS-FUSE + Samba
You can access Gfarm file system using Samba via FUSE, but we recommend using syscall-hooking library because it is easier to configure and use.

2. Prerequisites

Related Softwares

3. Configure LDAP server

3.1 Configuration for Japanese file name

See Gfarm hook + Samba in Japanese

4. Configure Samba server

4.1 changes to smb.conf

4.1.1 Add lines to [global] section

4.1.1.1 Configuration for Japanese file name
See Gfarm hook + Samba in Japanese
4.1.1.2 Disable kernel change notify (Samba 3.X)
Make Samba not call F_NOTIFY feature of fcntl(2) because Gfarm system-call-hook library does not support it.

kernel change notify = no
A Windows client may be disconnected from the Samba server host without this setting. We have found this problem at least on Samba 3.0.10 and 3.0.20. But this setting has a side effect that file status changes doesn't displayed immediately.
This problem is not avoided on Samba version 2.X, because Samba version 2.X cannot disable 'kernel change notify'.

4.1.2 Adding a section to define a file space share

Add a section to access Gfarm file system.

4.1.2.1 Parameters to access Gfarm file system

Define the following parameters in the section.

Specify as following to make files unexecutable.
create mask = 0644
In default configuration, if you create a new file on Gfarm file sysmtem from a Windows client or copy a file from a Windows client to Gfarm file system, the file will be registered as an executable program that has the same architectue as the file system node on which the file's body will be located. This is different from what you would expect.

Specify following parameters to make Samba not invoke such system calls.
oplocks = no 
level2 oplocks = no
In default configuration, if you access a file on Gfarm file system from a Windows client, Samba invokes system calls that Gfarm doesn't support hooking them.

4.1.2.2 Example

We show you an example section to add for multiple users to share the whole Gfarm file system.

[gfarm-public]
   comment = Gfarm Public Stuff
   path = /gfarm
   public = yes
   writable = yes
   printable = no
   create mask = 0644
   oplocks = no
   level2 oplocks = no

5. Start Samba

5.1 Change start script

We explain using a case on RedHat Linux here.

Add or change the following items for starting smbd. In case of RedHat Linux, starting smbd is described in the function start() in the script file '/etc/init.d/smb'.

5.1.1 Add lines to increase the number of file descriptors

Add the following lines just before invoking smbd:

	n=$(( $(gfhost -M | wc -l) + 50))
	if [ -n "$m" -a X"$m" != X"unlimited" -a "$m" -lt $n ]; then
		ulimit -n $n
	fi

5.1.2 Add environment setting to the line which invokes smbd

Add the setting of environment variables LD_PRELOAD and LD_LIBRARY_PATH to the beginning of the line which invokes smbd. Refer to the README.hook.en document for detail.

For example, in case of RedHat Linux, change the following line

	daemon smbd $SMBDOPTIONS

to

	gfarm_prefix=/usr
	globus_location=/usr/grid
	globus_flavor=gcc32
	LD_LIBRARY_PATH="$globus_location/lib" LD_PRELOAD="$globus_location/lib/libglobus_gssapi_gsi_$globus_flavor.so.0 $globus_location/lib/libssl_$globus_flavor.so.0 $gfarm_prefix/lib/libgfs_hook.so.0 /usr/lib/gfarm/libpthread-not-hidden.so /usr/lib/gfarm/libc-not-hidden.so" daemon smbd $SMBDOPTIONS

Configure the variable gfarm_prefix and globus_location to match your installation pathnames of Gfarm and Globus, and configure globus_flavor variable to match your Globus flavor name which is linked with Gfarm.

Before adding these Globus related paths, you need to install Globus shared libraries if you have linked Globus libraries to Gfarm binaries, otherwise you need not this addition. If you install Gfarm binary distribution for RedHat Linux, you need this addition because they are linked with Globus.

Adding assignment to LD_LIBRALY_PATH is necessary only if Globus is dynamically linked to Gfarm binaries. Binary distribution for RedHat Linux is statically linked with Globus so it can be omitted.

Specifying "*-not-hiddden.so" is unnecessary on OS other than Linux.

5.2 Sample of configured script to start Samba

#!/bin/sh

(*snip*)

start() {
	KIND="SMB"
	echo -n $"Starting $KIND services: "
	m=`ulimit -n`
	n=$(( $(gfhost -M | wc -l) + 50))
	if [ -n "$m" -a X"$m" != X"unlimited" -a "$m" -lt $n ]; then
		ulimit -n $n
	fi
	gfarm_prefix=/usr
	globus_location=/usr/grid
	globus_flavor=gcc32
	LD_LIBRARY_PATH="$globus_location/lib" LD_PRELOAD="$globus_location/lib/libglobus_gssapi_gsi_$globus_flavor.so.0 $globus_location/lib/libssl_$globus_flavor.so.0 $gfarm_prefix/lib/libgfs_hook.so.0 /usr/lib/gfarm/libpthread-not-hidden.so /usr/lib/gfarm/libc-not-hidden.so" daemon smbd $SMBOPTIONS
	RETVAL=$?
	echo
	KIND="NMB"
	echo -n $"Starting $KIND services: "
	daemon nmbd $NMBDOPTIONS
	RETVAL2=$?
	echo
	[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
	   RETVAL=1
	return $RETVAL
}	

(*snip*)

5.3 Starting or Restarting Samba

For example, invoke the following command on RedHat Linux.

# /etc/init.d/smb [start|restart] 

6. Access Samba server from Windows Client

Map a network drive to the Samba share. The following sample steps shows how to map

  1. Right-click on "'My Network" icon.
  2. Left-click on "Map Network Drive" menu item.
  3. Input a drive name and shared folder name on the displayed dialog.