Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title How to access files on QNX from Windows through Samba
Ref. No. QNX.000009292
Category(ies) Configuration
Issue We'd like to access the files on a QNX host from a Windows 95 machine, but we don't have an NFS package and was wondering about an alternative. Can we use Samba for our application?


Solution The Samba program suite will let you redirect disks and printers from a variety of clients (including LAN Manager, Windows for Workgroups 3.11, and Windows NT) to a QNX server's filespace and printers via the SMB (Session Message Block) protocol.

To use Samba, TCP/IP for QNX must be configured and running. You'll have to download the Samba archive (samba-1.9.16p9-bin.tgz) from our web site, www.qnx.com. The archive containing the source and binaries can be found in:

/usr/free/qnx4/tcpip/utils/samba-1.9.16p9-qnx.tgz

The following archive contains binaries only:

/usr/free/qnx4/tcpip/utils/samba-1.9.16p9-hin.tgz

Unzip the archive file using the following command:

gzip -d -c archiv_filename | pax -rv

This command will create a Samba directory called samba1.9.16p9 in your current directory and extract all the files in the archive. Please read the file docs/QNX4.txt before you begin; it describes how to set up the Samba files on your disk. If you download the archive containing source and binaries, typing make install in the source subdirectory should move the binary files to their proper locations. But if the directory /usr/adm doesn't exist, you'll have to create it.

The next thing you'll need to do is add the following lines to your /etc/services file:

netbios-ns 137/udp
netbios-ssn 139/tcp
netbios-ssn 139/udp
netbios-dgm 138/udp

Next, make a Samba configuration file. By default, Samba assumes that the configuration file resides in the /etc directory. If you create the configuration file elsewhere, you must specify that location on the command line when you start any of the various Samba programs. For example, the following command tells smbd (the Samba server) to look for the configuration file (smb.conf) in my home directory:

smbd -s /home/bruce/smb.conf

Here's what a sample configuration file might look like (these are only some of the available parameters-all parameters are described in docs/smb.conf.5):

[global]
x09guest account = pcguest

[tmp]
x09path = /tmp
x09public = yes
x09writable = yes
x09read only = no

Basically, these entries would create a share tmp that can be mounted by other filesystems. The guest account is used to grant public access (public = yes) so that any user can mount this share. The share is set up as readable and writable. The default user for guest account is nobody. An entry for the specified user (i.e.pcguest) must exist in the /etc/passwd file. For example, /etc/psswd might contain the following entry:

pcguest:x269:120:test_account_for_samba:/home/pcguest:/bin/date

The Samba server smbd will assume the identity of this user for connection purposes, so make sure that the path you specify can be accessed by pcguest.

After creating the configuration file, start the Samba programs as root as follows:

/bin/smbd &
/bin/nmbd &

You should now be able to mount the tmp share from a system on your subnet. For a test, try running the command /uxr/bin/smbclient -L host, where host is the hostname of your system (smbclient is provided in the Samba archive). You should get a list of the shares available on the system (otherwise, see Debugging below). Provide the share tmp is available, you can mount it on any system that supports the SMB protocol (such as QNX, Windows 95, Windows NT, etc.).

QNX 4.23A ships with an SMB client called SMBfsys. To access the remote system's /tmp directory as the dir directory via SMBfsys, start SMBfsys as root and mount the share using commands similar to the following:

SMBfsys &
mount_smb //serverhostname/tmp dir

To let remote users mount their home directories, add the following lines to the smb.conf file (you don't have to restart the smbd or nmbd programs; they'll accept the changes automatically):

[homes]
comment = Home Directories
browseable = no
read only = no
create mode = 0750

Note that the user accounts must have password. Users can mount their home directories using the following commands:

user_smb usrid
mount_smb //serverhostname/homes dir password

You can also created a share that only a specific user can mount.
Try adding the following share to smb.conf:

[usershare]
path = /home/usrid
public = no
writable = yes
read only = no
user = usrid

The commands for mounting this share are almost the same as above:

user_smb usrid
mount_smb //serverhostname/usershare dir password

Once you have these shares working, try adding a printer share. This share can be mounted on a system like a spool directory. Any files copied to this directory will be sent to the printer on the remote system using the commands specified in the share. For printer support, add lines similar to the following to smb.conf:

[aprinter]
path = /temp
printable = yes
public = yes
writable = no
create mode = 600
printer name = txt
print command = /usr/bin/lp -P%p %s

The path directory is where the file to be printed is stored after it has been sent to the server system. The value of printer name is used by print command to print to the appropriate printer. The printer's name is passed as the %p argument to lp. The name of the file to be printed is represented by the %s parameter.

To use this printer share, execute the following command on the client system:

mount_smb -p //serverhostname/aprinter dir

Afterwards, any file copied to the dir directory will be printed on the remote printer.

Debugging

The utilities for debugging a Samba server are documented in docs/DIAGNOSIS.txt. There are debugging options for the smbd and nmbd programs too. To enable debugging, start these programs with the following options:

-d number -| path/file

where number is the debug level and path/file is the location of the debug log that's created.

The debug level can be from 1 to 99. Debug level 99 will cause these utilities to log almost everything they do, but a high debug level will cost you in performance - it's best to leave debugging off during normal operation.