Coda File System

Re: Patch: FreeBSD support for Coda 5.2.20

From: Greg Troxel <>
Date: 08 Mar 2003 09:59:31 -0500
It's great to see the FreeBSD 5.0 patches!  Now I just have to be
unlame and fix the NetBSD 1.6 kernel.

  Cool, applied. I agree this one should be an autoconf test, but the idea
  behind coda.h is that is 'should' be a drop-in replacement of the
  identical header in various kernels. And those typically don't like

IMHO this is broken.  If the kernel supports coda, it should install
coda.h in /usr/include/coda/coda.h or some such, and userland code
should link against the include file provided by the kernel.  This way
the interface to the kernel is defined by the kernel, and problems are
more likely to show up at compile time than (more mysteriously) at run
time.  And, it's how the rest of unix works.

A transition strategy would be to include the included coda.h only if
autoconf failed to find <coda/coda.h> installed on the system.  Either
that or fail and make the user install the kernel header in the right
place.  This is perhaps a mild inconvenience, but should avoid more
trouble than it causes.

I diffed NetBSD-1.6.1:src/sys/coda/coda.h against recent 5.3.20, and
found a bunch of differences.  Some of them are cosmetic (copyrights,
NetBSD removal of #ifdef sun stuff, etc.), but some are significant.

There really should be an interface specification for the kernel interface someplace

        Greg Troxel <>

diff from coda cvs to NetBSD:

 struct coda_vattr {
-       long            va_type;        /* vnode type (for create) */
+       int             va_type;        /* vnode type (for create) */
        u_short         va_mode;        /* files access mode and type */
        short           va_nlink;       /* number of references to file */
        vuid_t          va_uid;         /* owner user id */

(Are these in host native C types, or are they fixed-width?  long and
int are the same on ILP32 machines like i386 and ILP64 (OSF1 Alpha?),
but not on LP64 like NetBSD/alpha.  If it's just a type, it should be
int, not long, unless int isn't big enough.)

-#define CODA_OPEN_BY_FD        3
+#define CODA_SYNC      3
+#define CODA_READDIR   17
+#define CODA_INACTIVE  21

+/* coda_inactive: NO_OUT */
+struct coda_inactive_in {
+    struct coda_in_hdr ih;
+    ViceFid VFid;

+/* coda_rdwr: */
+struct coda_rdwr_in {
+    struct coda_in_hdr ih;
+    ViceFid    VFid;
+    int        rwflag;
+    int        count;
+    int        offset;
+    int        ioflag;
+    caddr_t    data;           /* Place holder for data. */    

+struct coda_rdwr_out {
+    struct coda_out_hdr oh;
+    int        rwflag;
+    int        count;
+    caddr_t    data;   /* Place holder for data. */

in union inputArgs:

+    struct coda_inactive_in coda_inactive;
     struct coda_vget_in coda_vget;
-    struct coda_open_by_fd_in coda_open_by_fd;
+    struct coda_rdwr_in coda_rdwr;
     struct coda_open_by_path_in coda_open_by_path;
     struct coda_statfs_in coda_statfs;

and outputArgs:

+    struct coda_rdwr_out coda_rdwr;
     struct coda_replace_out coda_replace;
-    struct coda_open_by_fd_out coda_open_by_fd;
Received on 2003-03-08 10:03:06