Coda File System

Re: getcwd

From: Jan Harkes <jaharkes_at_cs.cmu.edu>
Date: Wed, 16 Jun 1999 09:54:58 -0400
| Hello!
| 
| I'm interested in using the coda Venus/kernel interface for mounting a
| user-space filesystem . Coda provides a well defined, efficient and
| relatively portable (across free *NIXes) interface for this.
| 
| The first problem I came across, is that getcwd() doesn't work under
| glibc < 2.1. This is because the d_ino returned by readdir() is that
| of the local file, while st_ino returned by stat() is the inode number
| allocated by the the kernel. 
|
| Am I doing something wrong, or this is a real problem?
| 
| Thanks,
| Miklos

Strange, it works here (glibc-2.0.7).

  What operating system and version of venus are you using?
  Are you weakly- or dis-connected from the servers?
  Does it always happen, reproducably, or only occasionally?

Ehrm, wait, I'm rereading your message, you are only using the Coda 
kernel code? Then the problem is with your userspace client.

The inode number that the kernel uses is calculated from the ViceFid
of the file, and the `formula' is defined in coda.h.

#ifdef __linux__
static __inline__ ino_t  coda_f2i(struct ViceFid *fid)
{
        if ( !fid ) return 0; 
        if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
                return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
        else    return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
}
#else
#define coda_f2i(fid)\
        ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
#endif

So when your userspace code sets up the directory data, it has to pick 
the fids for all directory entries, and can then fill in the correct
inode numbers in the directory structure.

Avoid the `weird' fids (coda_linux.c:coda_fid_is_weird), which the kernel
handles differently. Well, that's actually easy, just keep the Volume and
Vnode fields at 0 and only play around with the Uniquefier. 

Jan


ps. The difference between linux and non-linux systems, is that we
have had (only with linux) a lot of problems with inode collisions in
disconnected mode, something like the 1024th file after creating a
directory got the inode confused, which made it impossible to untar
f.i. the coda or linux sources.


pps. I've been working on some changes that remove the ViceFid out of
the kernel. It simplifies life for the kernel, and probably also for
3rd party clients that use the Coda kernel module for userfs type
implementations. The main obstacle I'm facing right now is making our
Coda client do the inode<>fid mapping reliably when the fids are 
replaced during repair and reintegration.
Received on 1999-06-16 09:56:10