Redesigned file system handling on the Apple2:

The general idea is to have only as much file i/o code in the resident Contiki kernel as it is absolutely necessary to load apps and provide additional file i/o functionality only to the apps needing them. This approach works out nicely because the largest app (the web browser) doesn't do file i/o at all but delegates this on demand to the wget app.

Unfortunately the paradigm of file system services doesn't help at all to implement the approach outlined above because the (presumably small) inital  file system get's at some point replaced by a fullblown one but there's no trigger to revert to the small one i.e. before loading the web browser.

Therefore I opted against file system services altogether, but used two distinct file systems:

One is custom made (only 123 bytes) and linked statically with the Contiki kernel and therefore called "kernel file system (kfs)". It provides just enough functionality to load apps/drivers etc. The module loader code is customized on the Apple2 to make use of the kfs.

The other is linked statically with the apps which require it. Instead of implementing yet another file system the posix file i/o library from the cc65 C library is used here. Because the code resides in a library this has the nice side effect being linked in on demand.

Because the exsisting apps use the "Contiki file system (cfs)" calls typically implemented by file system services a custom cfs.h file is used that maps the cfs calls via macros to the posix calls.

The obvious downside of this approach is that the code is multiplied in memory if several apps using it are running simultaniously - but after all there isn't enough memory to run more than one "big" app anyway.

A less obvious downside is the the more code from the cc65 C library we link to apps the more we run into the issue of not executing cc65 C libray constructors / destructors. Maybe the Contiki app loading infrastructure should be enhanced to do so...
diff --git a/contiki-apple2/lib/kfs.h b/contiki-apple2/lib/kfs.h
new file mode 100644
index 0000000..baab435
--- /dev/null
+++ b/contiki-apple2/lib/kfs.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: kfs.h,v 1.1 2005/04/12 21:42:40 oliverschmidt Exp $
+ */
+#ifndef __KFS_H__
+#define __KFS_H__
+
+int kfs_open(const char* name);
+int __fastcall__ kfs_read(int fd, void* buf, unsigned count);
+int __fastcall__ kfs_close(int fd);
+char* kfs_getdir(void);
+
+#endif /* __KFS_H__ */