Coda File System

[Darwincoda] Partial success with Mac OS X coda client

From: Stephen J. Turnbull <stephen_at_xemacs.org>
Date: Thu, 12 Aug 2004 15:05:04 +0900
Before I write anything else, all the real code here is due to
Christer Bernérus and Pekka Nikander, but I thought I'd try to pull
together the current state, as well as report some remaining problems.

>>>>> "sjt" == Stephen J Turnbull <stephen_at_xemacs.org> writes:

>>>>> "Jan" == Jan Harkes <jaharkes_at_cs.cmu.edu> writes:

    Jan> I guess you mean that the following two tests don't trigger
    Jan> linking against libresolv

    Jan>     AC_SEARCH_LIBS(gethostbyname, resolv)
    Jan>     AC_SEARCH_LIBS(res_search, resolv)

    sjt> Yes.

This is still true, as you'll see in the attached patch I'm still
hacking it in by hand.  I think I know how to do this, but I won't be
able to get to it before Sept 1 because of international travel.

With Christer's kernel module (with and without Pekka's patch to make
the Finder work) I have successfully listed directories, read files,
logged in, and created files in the root volumes of two servers, my
own and testserver.coda.cs.cmu.edu.  With Pekka's patch, the Finder
finds /coda and /coda/tleepslib.sk.tsukuba.ac.jp (my server), but it
can't list my root volume claiming it's not registered or something
like that (it's in Japanese).  It also shows up as a network volume
(in a frame of the finder with the hard drive local volume, and some
Apple-specific network volumes).  The testserver.coda.cs.cmu.edu realm
doesn't show up in either place, even if I ls or cd to it.

I don't know if there's more than a root volume on testserver, but in
my own realm I was unable to get a listing for directories contained
in any volume but the root.  An attempt to do cfs lv would give a no
such file or directory error, while ls -l shows not directories but
the magic symlink from a Coda mount point to the volume (eg, ls -l
/coda/tleepslib.sk.tsukuba.ac.jp/Software/XEmacs would produce
information of the form

total 2541
-rw-r--r--   1 codakami nogroup  147169 Jan  9  2003 #21.5-20030103.diff#
lrw-r--r--  15 codakami nogroup       9 Nov 10  2001 21.1 -> #xe:21-1
lrw-r--r--  15 codakami nogroup       9 Nov 10  2001 21.4 -> #xe:21-4
lrw-r--r--  15 codakami nogroup       9 Feb  5  2002 21.5 -> #xe:21-5
-rw-r--r--   1 codakami nogroup  147351 Jan  3  2003 21.5-20030103.diff~
drwxr-xr-x   3 codakami nogroup    2048 Aug 29  2003 CVSROOT
drwxr-xr-x   3 codakami nogroup    2048 Feb 22  2002 InfoDock

etc.  As you can see the regular files and regular directories are
fine.  The suspiciously ancient dates on the symlinks are consistent
with creation of the mountpoints on those dates, I guess.

I'm currently having problems with authentication, it's not finding
the authserver for my realm although I have an authservers line in
venus.conf, nor the testserver realm.  But in an earlier build, before
I upgraded Mac OS X from 10.3.4 to 10.3.5, both worked without a -host
spec.  clog -host tleepslib... codakami_at_tleepslib... still works, but
not clog -host testserver... guest_at_testserver... (I guess testserver's
authserver is not testserver?)  I suspect that somehow the necessary
ioctls or something are not properly getting #included or #ifdef'd in
the clog code in the current build, since it did work before, but I'd
appreciate any advice on where to look.

Here's the patch against Coda proper I'm running with.  (The kernel
module is available from Christer's project on cvs.opendarwin.org, and
is Christer's code plus a patch posted by Pekka.)

The changes to the Makefile.in's reflect the problem with libresolv.

Either in a recent change to Coda, or when I updated to Mac OS X
10.3.5 recently some ioctl macros got lost.  AFAICT from code in other
places, "defined(__APPLE__) && defined(__MACH__)" is the accepted way
to spell "Darwin" in #if's.  I've just set things up to pull in that
code on Darwin as well as for DJGPP.  This required some
rearrangement to avoid redefining other macros that Darwin does
provide in kerndep/pioctl.h.

A bit of poking around in the system headers leads me to believe that
the NetBSD way of getting a process's name should work on Darwin, thus
the comment in util/proc.cc.

I don't know about Coda's style in these matters; the hack to #define
__BSD44__ in venus/worker.h is safe, I think, but of course it risks
getting forgotten and never fixed properly.  I'll think about
autoconfiscating this, too.

The autobogotify cache really needs to be trashed in make distclean,
for sure, and maybe in make clean, as well (the latter is my
preference, but of course it does slow down the compile/test cycle).
So I propose adding that in configs/Makerules.

Thanks to Christer and Pekka for all the hard work on the Darwin
kernel extension, and to the Coda team at large!


Index: coda-src/auth2/Makefile.in
===================================================================
RCS file: /coda-src/coda/coda-src/auth2/Makefile.in,v
retrieving revision 4.44
diff -u -u -r4.44 Makefile.in
--- coda-src/auth2/Makefile.in	5 May 2004 20:17:26 -0000	4.44
+++ coda-src/auth2/Makefile.in	12 Aug 2004 03:48:41 -0000
@@ -65,7 +65,7 @@
 RP2HEADERS  = auth2.h
 
 DEPLIBS = $(LIBUTIL) $(LIBKERNDEP) $(LIBBASE)
-LIBS := $(LIBRPC2) $(LIBLWP) $(LIBCRYPTO) $(LIBS)
+LIBS := $(LIBRPC2) $(LIBLWP) $(LIBCRYPTO) $(LIBS) -lresolv
 
 LIBRARIES   = libauth2.a libauser.a
 HEADERS     = avenus.h avice.h
Index: coda-src/kerndep/pioctl.h
===================================================================
RCS file: /coda-src/coda/coda-src/kerndep/pioctl.h,v
retrieving revision 4.10
diff -u -u -r4.10 pioctl.h
--- coda-src/kerndep/pioctl.h	23 May 2003 18:26:31 -0000	4.10
+++ coda-src/kerndep/pioctl.h	12 Aug 2004 03:48:41 -0000
@@ -42,7 +42,12 @@
 int pioctl(const char *path, unsigned long com, struct
 	   ViceIoctl *vidata, int follow);
 
-#if defined(DJGPP)
+
+#if defined(DJGPP) || (defined(__APPLE__) && defined(__MACH__))
+/*
+ * Windows+GCC or Darwin
+ * These are absent from Darwin's <sys/ioccom.h>.
+ */
 #define _IOC_NRBITS	8
 #define _IOC_TYPEBITS	8
 #define _IOC_SIZEBITS	14
@@ -58,6 +63,14 @@
 #define _IOC_SIZESHIFT	(_IOC_TYPESHIFT+_IOC_TYPEBITS)
 #define _IOC_DIRSHIFT	(_IOC_SIZESHIFT+_IOC_SIZEBITS)
 
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr)		(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr)		(((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr)		(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr)		(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+#endif /* Windows+GCC or Darwin */
+
+#if defined(DJGPP) /* Windows+GCC */
 /*
  * Direction bits.
  */
@@ -77,12 +90,6 @@
 #define _IOW(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),sizeof(size))
 #define _IOWR(type,nr,size)	_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
 
-/* used to decode ioctl numbers.. */
-#define _IOC_DIR(nr)		(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
-#define _IOC_TYPE(nr)		(((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
-#define _IOC_NR(nr)		(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
-#define _IOC_SIZE(nr)		(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
-
 /* ...and for the drivers/sound files... */
 
 #define IOC_IN		(_IOC_WRITE << _IOC_DIRSHIFT)
@@ -90,7 +97,7 @@
 #define IOC_INOUT	((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
 #define IOCSIZE_MASK	(_IOC_SIZEMASK << _IOC_SIZESHIFT)
 #define IOCSIZE_SHIFT	(_IOC_SIZESHIFT)
-#endif
+#endif /* Windows+GCC */
 
 #if defined(__CYGWIN32__)
 /* Get the _IO... definitions for CYGWIN. */
Index: coda-src/util/proc.cc
===================================================================
RCS file: /coda-src/coda/coda-src/util/proc.cc,v
retrieving revision 4.9
diff -u -u -r4.9 proc.cc
--- coda-src/util/proc.cc	23 May 2003 18:26:59 -0000	4.9
+++ coda-src/util/proc.cc	12 Aug 2004 03:48:41 -0000
@@ -79,6 +79,10 @@
 #ifdef __BSD44__  
 
 // This is the NetBSD way to do this.
+// It should also work on Darwin, but may need some massaging to get at
+// "internal" and/or "unstable" Apple APIs.  It's not clear how to catch
+// Darwin; neither __BSD44__ nor __FreeBSD__ is #defined that I can find,
+// but BSD4_4 is #defined.  Is this function used?
 char* getcommandname(int pid) {
 #ifndef	__FreeBSD__
     kvm_t *KVM;
Index: coda-src/venus/Makefile.in
===================================================================
RCS file: /coda-src/coda/coda-src/venus/Makefile.in,v
retrieving revision 4.49
diff -u -u -r4.49 Makefile.in
--- coda-src/venus/Makefile.in	5 May 2004 20:17:27 -0000	4.49
+++ coda-src/venus/Makefile.in	12 Aug 2004 03:48:41 -0000
@@ -37,7 +37,7 @@
 	   $(LIBDIRLIB) $(LIBUTIL) $(LIBRWCDB) $(LIBBASE) $(LIBRELAY)
 LIBS := $(DEPLIBS) $(LIBRDSLWP) $(LIBSEG) $(LIBRVMLWP) $(LIBRPC2) $(LIBSE) \
 	$(LIBFAIL) $(LIBLWP) $(LIBSYS) $(LIBKVM) $(LIBDB) $(LIBCRYPTO) \
-	$(LIBMATH) $(LIBS)
+	$(LIBMATH) $(LIBS) -lresolv
 
 VOBJS = adv_monitor.o adv_daemon.o binding.o comm.o comm_daemon.o daemon.o fso0.o fso1.o fso_cachefile.o fso_cfscalls0.o fso_cfscalls1.o fso_cfscalls2.o fso_daemon.o fso_dir.o hdb.o hdb_daemon.o local_cml.o local_daemon.o local_fso.o local_subtree.o local_repair.o local_vol.o mariner.o mgrp.o venus.o venuscb.o venusrecov.o venusutil.o venusvol.o venuswb.o vol_daemon.o vol_cml.o vol_permits.o vol_reintegrate.o vol_repair.o vol_resolve.o vol_vcb.o vol_COP2.o vproc.o vproc_pathname.o vproc_pioctl.o vproc_vfscalls.o vsg.o worker.o sighand.o spool.o tallyent.o user.o nt_util.o realmdb.o realm.o
 
Index: coda-src/venus/worker.h
===================================================================
RCS file: /coda-src/coda/coda-src/venus/worker.h,v
retrieving revision 4.13
diff -u -u -r4.13 worker.h
--- coda-src/venus/worker.h	23 May 2003 18:27:21 -0000	4.13
+++ coda-src/venus/worker.h	12 Aug 2004 03:48:42 -0000
@@ -42,6 +42,11 @@
 }
 #endif
 
+/* #### Nasty hack, but what's the right thing to do here? */
+#if defined(__APPLE__) && defined(__MACH__)
+#define __BSD44__
+#endif
+
 /* interfaces */
 #include <vice.h>
 
Index: configs/Makerules
===================================================================
RCS file: /coda-src/coda/configs/Makerules,v
retrieving revision 4.51
diff -u -u -r4.51 Makerules
--- configs/Makerules	5 May 2004 20:17:27 -0000	4.51
+++ configs/Makerules	12 Aug 2004 03:48:42 -0000
@@ -246,7 +246,7 @@
 xtraclean:
 
 distclean: clean
-	-$(RM) -r include
+	-$(RM) -r include autom4te.cache
 	-$(RM) config.cache config.log config.status
 	-$(RM) Makeconf.setup `find . -name "Makefile" | grep -v linux`
 	-$(RM) config.h coda_config.h


-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.
_______________________________________________
Darwincoda mailing list
Darwincoda_at_opendarwin.org
http://www.opendarwin.org/mailman/listinfo/DarwinCoda
Received on 2004-08-16 23:02:10