This is a LUFS filesystem module allowing to access the filesystem of
a Windows CE device (HP (Compaq) Ipaq, HP Jornada, etc...)

Because of limitations of the current version of librapi not all
filesystem operations are supported.  Specifically, file read and
write are performed only at file open and file close.  Opening files
in read-write mode is not supported.

This code uses librapi library from the SynCE project.  For
convenience asyncd source code from that project is also included in
this distribution.

	http://synce.sourceforge.org

SOURCES OF ADDITIONAL INFORMATION

	http://synce.sourceforge.org
	http://www.handhelds.org

REQUIREMENS

A Windows CE device :)

INSTALLATION

To use the CEFS module you should be able to connect your Windows CE
device to the Linux box using serial cable, USB, or IRDA.

Here I give some explanations of how to setup the connection between
the Linux box and PDA.  It is described in many places, so you may
find it interesting to compare the description here with bits of
information you can read on http://synce.sourceforge.org
http://www.handhelds.org and in Documentation/usb/usb-serial.txt in
the kernel source.


I. Asyncd setup

In any case you should setup asyncd -- a daemon to keep the connection
up.  Notice, that if you protected you Windows CE device with a
password (which is generally quite a good idea), you should change it
from the default value "1234" in asyncd.c recompile and reinstall
asyncd.  Long passwords are not supported now.

1) add the following line to /etc/services :

dccm          5679/tcp                        # ActiveSync KeepAlive

2) configure your Inetd super-daemon (either inetd, or xinetd), so that client/asyncd is
 fired whenever someone initiates a TCP connect on port 5679 on your
 computer (insert the prefix you used in ./configure instead of the default /usr/local):

* inetd : add the following line to /etc/inetd.conf
-------------------------------------------------------------
asyncd      stream  tcp     nowait  lufs    /usr/local/bin/asyncd asyncd
-------------------------------------------------------------

* xinetd : add the following file (asyncd) to /etc/xinetd.d :
-------------------------------------------------------------
# default: on
service asyncd
{
    flags           = REUSE NOLIBWRAP
    socket_type     = stream
    wait            = no
    user            = lufs
    server          = /usr/local/bin/asyncd
    log_on_failure  += USERID
    only_from       = 127.0.0.1 192.168.131.0/24
    disable         = no
}
-------------------------------------------------------------

(xinetd : replace the line 'only_from' with your local network mask (the one where your
CE device will be calling from, or disable it completly)


II. Physical link setup

II.A Serial link setup.

Here you have a lot of variants.  The simplest is:

Variant 1.

Create the following file (cedevice) in /etc/ppp/peers :
-------------------------------------------------------------
/dev/ttyS1 115200 modem
connect '/usr/sbin/chat -v CLIENT "CLIENT\c" "" "SERVER\c"'
noauth
local
192.168.131.102:192.168.131.201
ms-dns 192.168.131.102
lcp-echo-failure 2
lcp-echo-interval 2
linkname cedevice
-------------------------------------------------------------

To start the communications you'll have to run (as root):

$ pppd call cedevice

This should start your Windows CE device, and start a PPP link.
Check that your PPP configuration shows the link, and check that 'asyncd' has
created a file '/tmp/cedevice' which contains the informations on your device (
IP address, brand, etc...)


Variant 2.

As an alternative method you can use mgetty to automatically start the
link on connection of your PDA to the computer.  It is a very simple
setup, assuming that you don't have dialin connections.

Add the following lines to /etc/mgetty+sendfax/mgetty.config:
------------------------------------------------------------------------
# WinCE connection: port ttyS1
  speed 115200
  direct y
  toggle-dtr n
  issue-file /etc/ppp/wince.issue
------------------------------------------------------------------------
Add this to /etc/mgetty+sendfax/login.config:
------------------------------------------------------------------------
# This is for WinCE
/AutoPPP/ -    a_ppp   /usr/sbin/pppd file /etc/ppp/wince
------------------------------------------------------------------------
Create the file /etc/ppp/wince.issue:
------------------------------------------------------------------------
CLIENTSERVER
CLIENTSERVER
CLIENTSERVER
------------------------------------------------------------------------
and the file /etc/ppp/wince:
------------------------------------------------------------------------
modem
noauth
local
192.168.131.102:192.168.131.201
ms-dns 192.168.131.102
lcp-echo-failure 2
lcp-echo-interval 2
linkname cedevice
------------------------------------------------------------------------


II.B. USB Setup.

If you have an old kernel, you can try to use ipaqd from SynCE
project.  Here I'll describe usage if ipaq module present in kernel
(starting at least from 2.4.18 ar maybe earlier).  Generally, you
should first look at the file Documentation/usb/usb-serial.txt in your
kernel source.  BUT: Don't believe the words written there abut uhci.o
and usb-uhci.o modules.  In my case it works _only_ with usb-uhci and
does not work at all with uhci.  Maybe in some cases opposite is
better, I don't know.

Also you shold make a special version of chat.  To get it, recompile
the ppp distribution after applying the patch ppp-chat.patch in the
'other' directory.  This will make the chat program which does not
make intercharacter delay.  For some reason In my case it is crucially
needed to make things work.  Maybe it is not always the case, so you
may try first without this, and do this only if your PDA freezes
during establishing connection with the computer.  Another patch that
was needed in my case is ppp-pppd.patch, which _adds_ some delay
between ppp control packets.  It is really a patch that I don't
understand, but it helped in my case.

You should install hotplug, to use USB.  Here I give an example setup.
Create the file /etc/hotplug/usb/ipaq:
------------------------------------------------------------------------
#!/bin/bash echo $REMOVER created >>/tmp/ipaqlog cat >$REMOVER
<<-'EOF'
	#!/bin/sh
	if [ -f /var/lock/LCK..ttyUSB0 ]
	then
	    kill -9 `cat /var/lock/LCK..ttyUSB0`
	fi
EOF
chmod a+x $REMOVER
MYIP=192.168.131.102
REMOTEIP=192.168.131.201
MYDNS=192.168.131.102

if [ -f /var/lock/LCK..ttyUSB0 ]
then
    kill -9 `cat /var/lock/LCK..ttyUSB0`
fi
/usr/sbin/pppd.ipaq /dev/ttyUSB0 \
        connect "/usr/sbin/chat.nopause -v TIMEOUT 60 CLIENT 'CLIENTSERVER\c'" \
        nocrtscts local passive $MYIP:$REMOTEIP ms-dns $MYDNS noauth
-----------------------------------------------------------------------
And apply the following patch to /etc/hotplug/usb.agent
------------------------------------------------------------------------
--- /home/fedor/usb.agent	Mon Sep 23 00:28:48 2002
+++ /etc/hotplug/usb.agent	Thu Apr 11 10:38:36 2002
@@ -298,6 +298,15 @@
 	rm -f "$REMOVER"
     fi
 
+    if [ "$PRODUCT" = "49f/3/0" ]; then   # Compaq Ipaq 3760
+        /etc/hotplug/usb/ipaq
+        exit 0
+    fi
+    if [ "$PRODUCT" = "3f0/1116/0" ]; then # HP Jornada 568
+        /etc/hotplug/usb/ipaq
+        exit 0
+    fi
+
     # on 2.4 systems, modutils 2.4.2+ maintains MAP_CURRENT
     # ... otherwise we can't rely on it (sigh)
     case "$KERNEL" in
________________________________________________________________________


II.C IRDA Setup

To be written.  But it works, it was checked.  Ask, if you are interested.


III lufs setup

Nothing additional to general lufs setup!


USAGE

Simply mount the filesystem after connecting your PDA with a command
like

	mount -t lufs -o fs=cefs none /mnt/lufs

No additional options, instead of general LuFS options uid, gid, fmask
and dmask are present.

And umount it before disconnecting.  It may be a good idea to setup
automounter to do this.


Fedor Bezrukov
<fedor@ms2.inr.ac.ru>
