fhget and ftpfs

Csaba Henk csaba-ml at creo.hu
Sat Jul 9 04:01:49 CEST 2005


Hi!

There is an ftpfs based on nnpfs,

http://www.adaptive-enterprises.com.au/~d/software/ftpfs/

It's pretty nifty code, but somewhat dated. I tried to get it working;
for the curious, a patch can be got from 

http://www.creo.hu/~csaba/ftpfs-050709.tar.gz

For most of the stuff, I didn't have to change much, just replace "xfs"
with "nnpfs", and rename a few constants.

But there are two functions which behave nastily: nnpfs_fhget and
nnpfs_fhopen in nnpfs.c (after renaming functions and files). Eg.,
nnpfs_fhget looked like this:


int
nnpfs_fhget(name, followsymlinks, cache_handle)
        const char *name;
        int followsymlinks;
        struct nnpfs_cache_handle *cache_handle;
{
        int error;
        struct ViceIoctl vi;

        vi.in_size = 0;
        vi.in = NULL;
        vi.out_size = sizeof *cache_handle;
        vi.out = (caddr_t)cache_handle;

        error = syscall(SYS_nnpfspioctl,
                AFSCALL_PIOCTL,         /* operation */
                name,                   /* a_pathP */
                VIOC_FHGET,             /* a_opcode */
                &vi,                    /* a_paramsP */
                followsymlinks          /* a_followSymlinks */
        );

        return error;

}


As I could find neither of the SYS_nnpfspioctl, nor SYS_xfspioctl
syscalls, I looked around for an alternative, and I tried to use the
kerberos-based version of this from arlad/fcache.c (in the arla source
tree). I put toghether this:


int
nnpfs_fhget(name, followsymlinks, cache_handle)
        const char *name;
        int followsymlinks;
        struct nnpfs_cache_handle *cache_handle;
{
        struct arlaViceIoctl vice_ioctl;
        int ret;

        if (!fhopen_working)
            return 0;

        vice_ioctl.in      = NULL;
        vice_ioctl.in_size = 0;
/*      vice_ioctl.out      = (caddr_t)&cache_handle->nnpfs_handle;
        vice_ioctl.out_size = sizeof(cache_handle->nnpfs_handle);    */
        vice_ioctl.out      = (caddr_t)&cache_handle;
        vice_ioctl.out_size = sizeof(cache_handle);

        ret = k_pioctl (name, ARLA_VIOC_FHGET, (void *)&vice_ioctl, 0);
/*        if (ret == 0)
            cache_handle->valid = 1; */

        return ret;

}


This function may get many things wrong (struct member inconsistency?),
but at least, it compiles. I've also seen that in the beginning I'll
need a k_hasafs() call, so I insterted that into the code, too. Now it
compiled. 

But when I tried to mount with this as a daemon, the mount command hung.

Here's the ktrace output:

 90420 ftpfs    CALL  write(0x2,0x8051f5a,0xf)
 90420 ftpfs    GIO   fd 2 wrote 15 bytes
       "k_hasafs comes
       "
 90420 ftpfs    RET   write 15/0xf
 90420 ftpfs    CALL  sigaction(0xc,0xbfbee600,0)
 90420 ftpfs    RET   sigaction 0
 90420 ftpfs    CALL  sigprocmask(0x1,0,0x2808ecdc)
 90420 ftpfs    RET   sigprocmask 0
 90420 ftpfs    CALL  sigprocmask(0x3,0,0x805e11c)
 90420 ftpfs    RET   sigprocmask 0
 90420 ftpfs    CALL  #339(0x14,0,0x800c5603,0xbfbee680,0)
 90420 ftpfs    RET   #339 -1 errno 4 Interrupted system call
 90420 ftpfs    PSIG  SIGINT SIG_DFL

That is, syscall #339 was the one with no retrurn.

Any alternative solution for the fhget/fhopen stuff, or idea about
getting the kerberos thing right?

I'm on FreeBSD-5.4, with arla-0.40 and heimdal-0.6.3_2.

TIA for any idea.

Csaba





More information about the Arla-drinkers mailing list