[haiku-commits] haiku: hrev52213 - in src/tests/add-ons/kernel/file_systems: fs_shell dos/r5 udf/r5

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 12 Aug 2018 23:50:18 -0400 (EDT)

hrev52213 adds 7 changesets to branch 'master'
old head: af8f2a39a0b49397b951192f8615f8ab95c356ef
new head: 0f36120d8dc438596a6040c8a1b636116fcfff67
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=0f36120d8dc4+%5Eaf8f2a39a0b4

----------------------------------------------------------------------------

e24a254f5504: tests/dosfs: Remove the "R5" version.
  
  Untouched since 2006.

87b501a11959: tests/udf: Remove the "R5" version.
  
  Largely untouched since 2006.

38fa917c592b: iso9660_shell: Use the fs_shell from src/tools; fix the build.

52de96da0426: udf_shell: Rework to use the fs_shell in tools/.
  
  The build appears to have been broken for quite a long time, but this
  gets it slightly closer at least.

e3db3bf84ea4: btrfs_shell: Move from src/tools to src/tests/...
  
  src/tools is for tools used in the build or other miscellaneous utilites
  that go along with Haiku itself. btrfs is, at least for now, just another
  filesystem addon, so its shell should live here with all the others.
  No functional change intended.

38c59f297107: tests/device_manager: Remove dependence on fs_shell.
  
  Doesn't build currently due to KPath API changes, but this seems unneeded
  at least.

0f36120d8dc4: "R5" fs_shell: Remove (mostly.)
  
  Two files remain: "argv.c" and "argv.h", as these are still used by some
  other, non-FS-related tests.
  
  This was one of the last significant chunks of "no commercial use" code
  in the tree, as it originally came from the "Filesystem Construction Kit,"
  the sample code distributed with "Practical Filesystem Design with the Be FS",
  and contained a sigifincant amount of BeOS kernel filesystem code in it
  (the original README, not preserved here, noted that "the cache code is
  the real Release 4 BeOS disk cache code".)
  
  It has long been replaced by Ingo's from-scratch, MIT-licensed fs_shell
  that lives in src/tools/fs_shell. Perhaps a note should be made somewhere
  of this code's prior existence, but I don't think we will have much use for
  it again, so confined to the dustbin of Git history it shall be.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

129 files changed, 95 insertions(+), 32961 deletions(-)
.../file_systems/iso9660/kernel_interface.cpp    |   10 +-
src/tests/add-ons/kernel/file_systems/Jamfile    |    2 +-
.../add-ons/kernel/file_systems/btrfs/Jamfile    |    3 +
.../file_systems/btrfs}/btrfs_shell/Jamfile      |    3 +-
.../btrfs}/btrfs_shell/additional_commands.cpp   |    0
.../btrfs}/btrfs_shell/command_cat.cpp           |    0
.../btrfs}/btrfs_shell/command_cat.h             |    0
.../add-ons/kernel/file_systems/dos/r5/Jamfile   |   16 -
.../add-ons/kernel/file_systems/dos/r5/LICENSE   |   31 -
.../add-ons/kernel/file_systems/dos/r5/attr.c    |  265 --
.../add-ons/kernel/file_systems/dos/r5/attr.h    |   22 -
.../add-ons/kernel/file_systems/dos/r5/cache.h   |  108 -
.../add-ons/kernel/file_systems/dos/r5/dir.c     | 1236 ------
.../add-ons/kernel/file_systems/dos/r5/dir.h     |   36 -
.../add-ons/kernel/file_systems/dos/r5/dlist.c   |  162 -
.../add-ons/kernel/file_systems/dos/r5/dlist.h   |   16 -
.../add-ons/kernel/file_systems/dos/r5/dosfs.c   | 1080 ------
.../add-ons/kernel/file_systems/dos/r5/dosfs.h   |  211 -
.../kernel/file_systems/dos/r5/encodings.cpp     | 1600 --------
.../kernel/file_systems/dos/r5/encodings.h       |   31 -
.../add-ons/kernel/file_systems/dos/r5/fat.c     |  644 ----
.../add-ons/kernel/file_systems/dos/r5/fat.h     |   31 -
.../add-ons/kernel/file_systems/dos/r5/file.c    | 1406 -------
.../add-ons/kernel/file_systems/dos/r5/file.h    |   30 -
.../add-ons/kernel/file_systems/dos/r5/fsproto.h |  245 --
.../add-ons/kernel/file_systems/dos/r5/iter.c    |  310 --
.../add-ons/kernel/file_systems/dos/r5/iter.h    |   47 -
.../add-ons/kernel/file_systems/dos/r5/kalloc.h  |   23 -
.../add-ons/kernel/file_systems/dos/r5/lock.h    |   46 -
.../kernel/file_systems/dos/r5/mime_table.c      |  105 -
.../kernel/file_systems/dos/r5/mime_table.h      |   16 -
.../kernel/file_systems/dos/r5/rtc_info.h        |   23 -
.../kernel/file_systems/dos/r5/settings/dos      |   17 -
.../add-ons/kernel/file_systems/dos/r5/util.c    |  149 -
.../add-ons/kernel/file_systems/dos/r5/util.h    |   43 -
.../add-ons/kernel/file_systems/dos/r5/vcache.c  |  443 ---
.../add-ons/kernel/file_systems/dos/r5/vcache.h  |   30 -
.../add-ons/kernel/file_systems/dos/r5/version.c |    6 -
.../kernel/file_systems/fs_shell/FSShellRules    |   19 -
.../add-ons/kernel/file_systems/fs_shell/Jamfile |   68 -
.../file_systems/fs_shell/additional_commands.h  |   26 -
.../add-ons/kernel/file_systems/fs_shell/cache.c | 2433 ------------
.../add-ons/kernel/file_systems/fs_shell/cache.h |   99 -
.../kernel/file_systems/fs_shell/compat.h        |  293 --
.../kernel/file_systems/fs_shell/errors.cpp      |  175 -
.../kernel/file_systems/fs_shell/errors.h        |  197 -
.../file_systems/fs_shell/external_commands.h    |   20 -
.../fs_shell/external_commands_beos.cpp          |  104 -
.../fs_shell/external_commands_unix.cpp          |  176 -
.../file_systems/fs_shell/fs_shell_command.cpp   |   75 -
.../file_systems/fs_shell/fs_shell_command.h     |   18 -
.../fs_shell/fs_shell_command_beos.cpp           |   64 -
.../fs_shell/fs_shell_command_beos.h             |   19 -
.../fs_shell/fs_shell_command_unix.cpp           |   86 -
.../fs_shell/fs_shell_command_unix.h             |   18 -
.../add-ons/kernel/file_systems/fs_shell/fsh.cpp | 2207 -----------
.../kernel/file_systems/fs_shell/fsproto.h       |  259 --
.../kernel/file_systems/fs_shell/hexdump.c       |  125 -
.../kernel/file_systems/fs_shell/initfs.c        |   82 -
.../kernel/file_systems/fs_shell/initfs.h        |    2 -
.../kernel/file_systems/fs_shell/kernel.c        | 3619 ------------------
.../kernel/file_systems/fs_shell/kprotos.h       |   85 -
.../add-ons/kernel/file_systems/fs_shell/lock.h  |   37 -
.../kernel/file_systems/fs_shell/makefile        |   65 -
.../kernel/file_systems/fs_shell/makefs.c        |   82 -
.../add-ons/kernel/file_systems/fs_shell/mount.c |  416 --
.../add-ons/kernel/file_systems/fs_shell/mount.h |    5 -
.../add-ons/kernel/file_systems/fs_shell/myfs.h  |   24 -
.../kernel/file_systems/fs_shell/path_util.cpp   |   70 -
.../kernel/file_systems/fs_shell/path_util.h     |   20 -
.../kernel/file_systems/fs_shell/rootfs.c        | 1107 ------
.../kernel/file_systems/fs_shell/skiplist.h      |   83 -
.../add-ons/kernel/file_systems/fs_shell/sl.c    |  401 --
.../kernel/file_systems/fs_shell/stat_util.cpp   |  286 --
.../kernel/file_systems/fs_shell/stat_util.h     |   27 -
.../add-ons/kernel/file_systems/fs_shell/stub.c  |  215 --
.../kernel/file_systems/fs_shell/sysdep.c        |  546 ---
.../kernel/file_systems/fs_shell/tracker.cpp     |   78 -
.../kernel/file_systems/fs_shell/tracker.h       |   34 -
.../add-ons/kernel/file_systems/fs_shell/tstfs.c |  257 --
.../add-ons/kernel/file_systems/fs_shell/xcp.cpp | 1289 -------
.../add-ons/kernel/file_systems/fs_shell/xcp.h   |   19 -
.../file_systems/iso9660/iso9660_shell/Jamfile   |   39 +-
.../add-ons/kernel/file_systems/udf/Jamfile      |    1 -
.../udf/r5/AllocationDescriptorList.h            |  261 --
.../add-ons/kernel/file_systems/udf/r5/Array.h   |   93 -
.../kernel/file_systems/udf/r5/CachedBlock.h     |  159 -
.../kernel/file_systems/udf/r5/DString.cpp       |  114 -
.../add-ons/kernel/file_systems/udf/r5/DString.h |   47 -
.../file_systems/udf/r5/DirectoryIterator.cpp    |  105 -
.../file_systems/udf/r5/DirectoryIterator.h      |   54 -
.../add-ons/kernel/file_systems/udf/r5/Icb.cpp   |  171 -
.../add-ons/kernel/file_systems/udf/r5/Icb.h     |  321 --
.../add-ons/kernel/file_systems/udf/r5/Jamfile   |   69 -
.../kernel/file_systems/udf/r5/MemoryChunk.h     |   72 -
.../file_systems/udf/r5/MetadataPartition.cpp    |   44 -
.../file_systems/udf/r5/MetadataPartition.h      |   51 -
.../kernel/file_systems/udf/r5/Partition.h       |   29 -
.../file_systems/udf/r5/PhysicalPartition.cpp    |   39 -
[ *** stats truncated: 30 lines dropped *** ]

############################################################################

Commit:      e24a254f55044d41f28022ef7207943184404c7e
URL:         https://git.haiku-os.org/haiku/commit/?id=e24a254f5504
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 02:46:28 2018 UTC

tests/dosfs: Remove the "R5" version.

Untouched since 2006.

----------------------------------------------------------------------------

diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/Jamfile 
b/src/tests/add-ons/kernel/file_systems/dos/r5/Jamfile
deleted file mode 100644
index e230c5e35b..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/Jamfile
+++ /dev/null
@@ -1,16 +0,0 @@
-SubDir HAIKU_TOP src add-ons kernel file_systems dos ;
-
-KernelAddon dos :
-       attr.c
-       dir.c
-       dlist.c
-       dosfs.c
-       encodings.cpp
-       fat.c
-       file.c
-       iter.c
-       mime_table.c
-       util.c
-       vcache.c
-       version.c 
-;
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/LICENSE 
b/src/tests/add-ons/kernel/file_systems/dos/r5/LICENSE
deleted file mode 100644
index a32b62b750..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/LICENSE
+++ /dev/null
@@ -1,31 +0,0 @@
-----------------------
-Be Sample Code License
-----------------------
-
-Copyright 1991-2001, Be Incorporated.
-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. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR 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.    
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/attr.c 
b/src/tests/add-ons/kernel/file_systems/dos/r5/attr.c
deleted file mode 100644
index f394910946..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/attr.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-/* attr.c
- * handles mime type information for dosfs
- * gets/sets mime information in vnode
- */
-
-
-#define MIME_STRING_TYPE 'MIMS'
-
-#include <SupportDefs.h>
-#include <KernelExport.h>
-
-#include <dirent.h>
-#include <fs_attr.h>
-#include <string.h>
-#include <malloc.h>
-
-#include <fsproto.h>
-#include <lock.h>
-
-#include "dosfs.h"
-#include "attr.h"
-#include "mime_table.h"
-
-#define DPRINTF(a,b) if (debug_attr > (a)) dprintf b
-
-status_t set_mime_type(vnode *node, const char *filename)
-{
-       struct ext_mime *p;
-       int32 namelen, ext_len;
-
-       DPRINTF(0, ("get_mime_type of (%s)\n", filename));
-
-       node->mime = NULL;
-
-       namelen = strlen(filename);
-
-       for (p=mimes;p->extension;p++) {
-               ext_len = strlen(p->extension);
-
-               if (namelen <= ext_len)
-                       continue;
-
-               if (filename[namelen-ext_len-1] != '.')
-                       continue;
-               
-               if (!strcasecmp(filename + namelen - ext_len, p->extension))
-                       break;
-       }
-
-       node->mime = p->mime;
-
-       return B_OK;
-}
-
-int dosfs_open_attrdir(void *_vol, void *_node, void **_cookie)
-{
-       nspace *vol = (nspace *)_vol;
-
-       TOUCH(_node);
-
-       DPRINTF(0, ("dosfs_open_attrdir called\n"));
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_open_attrdir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       if ((*_cookie = malloc(sizeof(uint32))) == NULL) {
-               UNLOCK_VOL(vol);
-               return ENOMEM;
-       }
-       *(int32 *)(*_cookie) = 0;
-       
-       UNLOCK_VOL(vol);
-       
-       return 0;
-}
-
-int dosfs_close_attrdir(void *_vol, void *_node, void *_cookie)
-{
-       nspace *vol = (nspace *)_vol;
-
-       TOUCH(_node);
-
-       DPRINTF(0, ("dosfs_close_attrdir called\n"));
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_open_attrdir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       *(int32 *)_cookie = 1;
-       
-       UNLOCK_VOL(vol);
-       
-       return 0;
-}
-
-int dosfs_free_attrcookie(void *_vol, void *_node, void *_cookie)
-{
-       TOUCH(_vol); TOUCH(_node);
-
-       DPRINTF(0, ("dosfs_free_attrcookie called\n"));
-
-       if (_cookie == NULL) {
-               dprintf("error: dosfs_free_attrcookie called with null 
cookie\n");
-               return EINVAL;
-       }
-
-       *(int32 *)_cookie = 0x87654321;
-       free(_cookie);
-
-       return 0;
-}
-
-int dosfs_rewind_attrdir(void *_vol, void *_node, void *_cookie)
-{
-       TOUCH(_vol); TOUCH(_node);
-
-       DPRINTF(0, ("dosfs_rewind_attrdir called\n"));
-
-       if (_cookie == NULL) {
-               dprintf("error: dosfs_rewind_attrcookie called with null 
cookie\n");
-               return EINVAL;
-       }
-
-       *(uint32 *)_cookie = 0;
-       return 0;
-}
-
-int dosfs_read_attrdir(void *_vol, void *_node, void *_cookie, long *num, 
-       struct dirent *entry, size_t bufsize)
-{
-       nspace *vol = (nspace *)_vol;
-       vnode *node = (vnode *)_node;
-       int32 *cookie = (int32 *)_cookie;
-
-       TOUCH(bufsize);
-
-       DPRINTF(0, ("dosfs_read_attrdir called\n"));
-
-       *num = 0;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_read_attrdir") ||
-               check_vnode_magic(node, "dosfs_read_attrdir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       if ((*cookie == 0) && (node->mime)) {
-               *num = 1;
-               
-               entry->d_ino = node->vnid;
-               entry->d_dev = vol->id;
-               entry->d_reclen = 10;
-               strcpy(entry->d_name, "BEOS:TYPE");
-       }
-
-       *cookie = 1;
-
-       UNLOCK_VOL(vol);
-       
-       return 0;
-}
-
-int dosfs_stat_attr(void *_vol, void *_node, const char *name, struct 
attr_info *buf)
-{
-       nspace *vol = (nspace *)_vol;
-       vnode *node = (vnode *)_node;
-
-       DPRINTF(0, ("dosfs_stat_attr (%s)\n", name));
-
-       if (strcmp(name, "BEOS:TYPE"))
-               return ENOENT;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_read_attr") ||
-               check_vnode_magic(node, "dosfs_read_attr")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       if (node->mime == NULL) {
-               UNLOCK_VOL(vol);
-               return ENOENT;
-       }
-       
-       buf->type = MIME_STRING_TYPE;
-       buf->size = strlen(node->mime) + 1;
-
-       UNLOCK_VOL(vol);
-       return 0;
-}
-
-int dosfs_read_attr(void *_vol, void *_node, const char *name, int type, void 
*buf, 
-       size_t *len, off_t pos)
-{
-       nspace *vol = (nspace *)_vol;
-       vnode *node = (vnode *)_node;
-
-       DPRINTF(0, ("dosfs_read_attr (%s)\n", name));
-
-       if (strcmp(name, "BEOS:TYPE"))
-               return ENOENT;
-               
-       if (type != MIME_STRING_TYPE)
-               return ENOENT;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_read_attr") ||
-               check_vnode_magic(node, "dosfs_read_attr")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       if (node->mime == NULL) {
-               UNLOCK_VOL(vol);
-               return ENOENT;
-       }
-
-       if ((pos < 0) || (pos > strlen(node->mime))) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       strncpy(buf, node->mime + pos, *len - 1);
-       ((char *)buf)[*len - 1] = 0;
-       *len = strlen(buf) + 1;
-
-       UNLOCK_VOL(vol);
-       return 0;
-}
-
-// suck up application attempts to set mime types; this hides an unsightly
-// error message printed out by zip
-int dosfs_write_attr(void *_vol, void *_node, const char *name, int type,
-       const void *buf, size_t *len, off_t pos)
-{
-       TOUCH(_vol); TOUCH(_node); TOUCH(name); TOUCH(type); TOUCH(buf);
-       TOUCH(len); TOUCH(pos);
-
-       DPRINTF(0, ("dosfs_write_attr (%s)\n", name));
-
-       *len = 0;
-
-       if (strcmp(name, "BEOS:TYPE"))
-               return ENOSYS;
-               
-       if (type != MIME_STRING_TYPE)
-               return ENOSYS;
-
-       return 0;
-}
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/attr.h 
b/src/tests/add-ons/kernel/file_systems/dos/r5/attr.h
deleted file mode 100644
index 6f9c60dcb3..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/attr.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-#ifndef _DOSFS_ATTR_H_
-#define _DOSFS_ATTR_H_
-
-status_t set_mime_type(vnode *node, const char *filename);
-
-int dosfs_open_attrdir(void *_vol, void *_node, void **_cookie);
-int dosfs_close_attrdir(void *_vol, void *_node, void *_cookie);
-int dosfs_free_attrcookie(void *_vol, void *_node, void *_cookie);
-int dosfs_rewind_attrdir(void *_vol, void *_node, void *_cookie);
-int dosfs_read_attrdir(void *_vol, void *_node, void *_cookie, long *num, 
-       struct dirent *buf, size_t bufsize);
-int dosfs_stat_attr(void *_vol, void *_node, const char *name, struct 
attr_info *buf);
-int dosfs_read_attr(void *_vol, void *_node, const char *name, int type, void 
*buf, 
-       size_t *len, off_t pos);
-int dosfs_write_attr(void *_vol, void *_node, const char *name, int type,
-       const void *buf, size_t *len, off_t pos);
-
-#endif
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/cache.h 
b/src/tests/add-ons/kernel/file_systems/dos/r5/cache.h
deleted file mode 100644
index 19e5c9f6f5..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/cache.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-
-#ifndef _CACHE_H_
-#define _CACHE_H_
-
-#include <BeBuild.h>
-
-typedef struct hash_ent {
-       int              dev;
-       off_t            bnum;
-       off_t            hash_val;
-       void            *data;
-       struct hash_ent *next;
-} hash_ent;
-
-
-typedef struct hash_table {
-    hash_ent **table;
-    int        max;
-    int        mask;          /* == max - 1 */
-    int        num_elements;
-} hash_table;
-
-
-#define HT_DEFAULT_MAX   128
-
-
-typedef struct cache_ent {
-       int               dev;
-       off_t             block_num;
-       int               bsize;
-       volatile int      flags;
-
-       void             *data;
-       void             *clone;         /* copy of data by set_block_info() */
-       int               lock;
-
-       void            (*func)(off_t bnum, size_t num_blocks, void *arg);
-       off_t             logged_bnum;
-       void             *arg;
-
-       struct cache_ent *next,          /* points toward mru end of list */
-                        *prev;          /* points toward lru end of list */
-
-} cache_ent;
-
-#define CE_NORMAL    0x0000     /* a nice clean pristine page */
-#define CE_DIRTY     0x0002     /* needs to be written to disk */
-#define CE_BUSY      0x0004     /* this block has i/o happening, don't touch 
it */
-
-
-typedef struct cache_ent_list {
-       cache_ent *lru;              /* tail of the list */
-       cache_ent *mru;              /* head of the list */
-} cache_ent_list;
-
-
-typedef struct block_cache {
-       lock            lock;
-       int             flags;
-    int                cur_blocks;
-       int             max_blocks;
-       hash_table      ht;
-
-       cache_ent_list  normal,       /* list of "normal" blocks (clean & 
dirty) */
-                           locked;       /* list of clean and locked blocks */
-} block_cache;
-
-#if 0   /* XXXdbg -- need to deal with write through caches */
-#define DC_WRITE_THROUGH    0x0001  /* cache is write-through (for floppies) */
-#endif
-
-#define ALLOW_WRITES  1
-#define NO_WRITES     0
-
-extern _IMPEXP_KERNEL int   init_block_cache(int max_blocks, int flags);
-extern _IMPEXP_KERNEL void  shutdown_block_cache(void);
-
-extern _IMPEXP_KERNEL void  force_cache_flush(int dev, int prefer_log_blocks);
-extern _IMPEXP_KERNEL int   flush_blocks(int dev, off_t bnum, int nblocks);
-extern _IMPEXP_KERNEL int   flush_device(int dev, int warn_locked);
-
-extern _IMPEXP_KERNEL int   init_cache_for_device(int fd, off_t max_blocks);
-extern _IMPEXP_KERNEL int   remove_cached_device_blocks(int dev, int 
allow_write);
-
-extern _IMPEXP_KERNEL void *get_block(int dev, off_t bnum, int bsize);
-extern _IMPEXP_KERNEL void *get_empty_block(int dev, off_t bnum, int bsize);
-extern _IMPEXP_KERNEL int   release_block(int dev, off_t bnum);
-extern _IMPEXP_KERNEL int   mark_blocks_dirty(int dev, off_t bnum, int 
nblocks);
-
-
-extern _IMPEXP_KERNEL int  cached_read(int dev, off_t bnum, void *data, off_t 
num_blocks, int bsize);
-extern _IMPEXP_KERNEL int  cached_write(int dev, off_t bnum, const void *data,
-                                 off_t num_blocks, int bsize);
-extern _IMPEXP_KERNEL int  cached_write_locked(int dev, off_t bnum, const void 
*data,
-                                                off_t num_blocks, int bsize);
-extern _IMPEXP_KERNEL int  set_blocks_info(int dev, off_t *blocks, int nblocks,
-                                        void (*func)(off_t bnum, size_t 
nblocks, void *arg),
-                                        void *arg);
-
-
-extern _IMPEXP_KERNEL size_t read_phys_blocks (int fd, off_t bnum, void *data, 
uint num_blocks, int bsize);
-extern _IMPEXP_KERNEL size_t write_phys_blocks(int fd, off_t bnum, void *data, 
uint num_blocks, int bsize);
-
-#endif /* _CACHE_H_ */
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/dir.c 
b/src/tests/add-ons/kernel/file_systems/dos/r5/dir.c
deleted file mode 100644
index 875ce35be5..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/dir.c
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-#include <KernelExport.h> 
-
-#include <fsproto.h>
-#include <lock.h>
-#include <cache.h>
-
-#include <stdlib.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-#include "iter.h"
-#include "dosfs.h"
-#include "attr.h"
-#include "dir.h"
-#include "dlist.h"
-#include "fat.h"
-#include "util.h"
-#include "vcache.h"
-
-#include "encodings.h"
-
-#define DPRINTF(a,b) if (debug_dir > (a)) dprintf b
-
-// used here and in encodings.cpp
-const char acceptable[]="!#$%&'()-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`{}~";
-const char illegal[] = "\\/:*?\"<>|";
-
-#define DIRCOOKIE_MAGIC 'AiC '
-
-typedef struct dircookie
-{
-       uint32          magic;
-       uint32          current_index;
-} dircookie;
-
-static CHECK_MAGIC(dircookie,struct dircookie, DIRCOOKIE_MAGIC)
-static status_t        findfile(nspace *vol, vnode *dir, const char *file,
-                               vnode_id *vnid, vnode **node, bool check_case,
-                               bool check_dups, bool *dups_exist);
-
-// private structure for returning data from _next_dirent_()
-struct _dirent_info_ {
-       uint32 sindex;
-       uint32 eindex;
-       uint32 mode;
-       uint32 cluster;
-       uint32 size;
-       uint32 time;
-};
-
-// scans dir for the next entry, using the state stored in a struct diri.
-static status_t _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo,
-       char *filename, int len)
-{
-       uint8           *buffer, hash = 0; /* quiet warning */
-       uchar           uni[1024];
-       uint16          *puni;
-       uint32          i;
-
-       // lfn state
-       uint32          start_index = 0xffff, filename_len = 0 /* quiet warning 
*/,
-                               lfn_count = 0 /* quiet warning */;
-
-       if (check_diri_magic(iter, "_next_dirent_")) return EINVAL;
-
-       if (iter->current_block == NULL)
-               return ENOENT;
-
-       if (len < 15) {
-               DPRINTF(0, ("_next_dirent_: len too short (%x)\n", len));
-               return ENOMEM;
-       }
-
-       buffer = iter->current_block + ((iter->current_index) % 
(iter->csi.vol->bytes_per_sector / 0x20)) * 0x20;
-
-       for (;buffer != NULL;buffer = diri_next_entry(iter)) {
-               DPRINTF(2, ("_next_dirent_: %lx/%lx/%lx\n", iter->csi.cluster, 
iter->csi.sector, iter->current_index));
-               if (buffer[0] == 0) { // quit if at end of table
-                       if (start_index != 0xffff) {
-                               dprintf("lfn entry (%s) with no alias\n", 
filename);
-                       }
-                       return ENOENT;
-               }
-       
-               if (buffer[0] == 0xe5) { // skip erased entries
-                       if (start_index != 0xffff) {
-                               dprintf("lfn entry (%s) with intervening erased 
entries\n", filename);
-                               start_index = 0xffff;
-                       }
-                       DPRINTF(2, ("entry erased, skipping...\n"));
-                       continue;
-               }
-               
-               if (buffer[0xb] == 0xf) { // long file name
-                       if ((buffer[0xc] != 0) || 
-                               (buffer[0x1a] != 0) || (buffer[0x1b] != 0)) {
-                               dprintf("invalid long file name: reserved 
fields munged\n");
-                               continue;
-                       }
-                       if (start_index == 0xffff) {
-                               if ((buffer[0] & 0x40) == 0) {
-                                       dprintf("bad lfn start entry in 
directory\n");
-                                       continue;
-                               }
-                               hash = buffer[0xd];
-                               lfn_count = buffer[0] & 0x1f;
-                               start_index = iter->current_index;
-                               puni = (uint16 *)(uni + 2*13*(lfn_count - 1));
-                               for (i=1;i<0x20;i+=2) {
-                                       if (*(uint16 *)&buffer[i] == 0xffff)
-                                               break;
-                                       *puni++ = *(uint16 *)&buffer[i]; 
-                                       if (i == 0x9) i+=3;
-                                       if (i == 0x18) i+=2;
-                               }
-                               *puni++ = 0;
-                               filename_len = (uchar *)(puni) - uni;
-
-                               continue;
-                       } else {
-                               if (buffer[0xd] != hash) {
-                                       dprintf("error in long file name: hash 
values don't match\n");
-                                       start_index = 0xffff;
-                                       continue;
-                               }
-                               if (buffer[0] != --lfn_count) {
-                                       dprintf("bad lfn entry in directory\n");
-                                       start_index = 0xffff;
-                                       continue;
-                               }
-
-                               puni = (uint16 *)(uni + 2*13*(lfn_count - 1));
-                               for (i=1;i<0x20;i+=2) {
-                                       if ((buffer[i] == 0xff) && (buffer[i+1] 
== 0xff)) {
-                                               dprintf("bad lfn entry in 
directory\n");
-                                               start_index = 0xffff;
-                                               break;
-                                       }
-                                       *puni++ = *(uint16 *)&buffer[i];
-                                       if (i == 0x9) i+=3;
-                                       if (i == 0x18) i+=2;
-                               }
-                               continue;
-                       }
-               }
-
-               break;
-       }
-
-       // hit end of directory entries with no luck
-       if (buffer == NULL)
-               return ENOENT;
-
-       // process long name
-       if (start_index != 0xffff) {
-               if (lfn_count != 1) {
-                       dprintf("unfinished lfn in directory\n"); 
-                       start_index = 0xffff;
-               } else {
-                       if (unicode_to_utf8(uni, filename_len, 
(uint8*)filename, len)) {
-                               // rewind to beginning of call
-                               dprintf("error: long file name too long\n");
-
-                               diri_free(iter);
-                               diri_init(iter->csi.vol, 
iter->starting_cluster, start_index, iter);
-                               return ENAMETOOLONG;
-                       } else if (hash_msdos_name((const char *)buffer) != 
hash) {
-                               dprintf("error: long file name (%s) hash and 
short file name don't match\n", filename);
-                               start_index = 0xffff;
-                       }
-               }
-       }
-
-       // process short name
-       if (start_index == 0xffff) {
-        start_index = iter->current_index;
-        // korli : seen on FreeBSD /src/sys/fs/msdosfs/direntry.h
-               msdos_to_utf8(buffer, (uchar *)filename, len, buffer[0xc] & 
0x18);
-       }
-
-       if (oinfo) {
-               oinfo->sindex = start_index;
-               oinfo->eindex = iter->current_index;
-               oinfo->mode = buffer[0xb];
-               oinfo->cluster = read16(buffer,0x1a);
-               if (iter->csi.vol->fat_bits == 32)
-                       oinfo->cluster += 0x10000*read16(buffer,0x14);
-               oinfo->size = read32(buffer,0x1c);
-               oinfo->time = read32(buffer,0x16);
-       }
-
-       diri_next_entry(iter);
-
-       return B_NO_ERROR;
-}
-
-static status_t get_next_dirent(nspace *vol, vnode *dir, struct diri *iter,
-                       vnode_id *vnid, char *filename, int len)
-{
-       struct _dirent_info_ info;
-       status_t result;
-
-       if (check_nspace_magic(vol, "get_next_dirent")) return EINVAL;
-
-       do {
-               result = _next_dirent_(iter, &info, filename, len);
-       
-               if (result < 0) return result;
-               // only hide volume label entries in the root directory
-       } while ((info.mode & FAT_VOLUME) && (dir->vnid == 
vol->root_vnode.vnid));
-       
-       if (!strcmp(filename, ".")) {
-               // assign vnode based on parent
-               if (vnid) *vnid = dir->vnid;
-       } else if (!strcmp(filename, "..")) {
-               // assign vnode based on parent of parent
-               if (vnid) *vnid = dir->dir_vnid;
-       } else {
-               if (vnid) {
-                       vnode_id loc = (IS_DATA_CLUSTER(info.cluster)) ?
-                                       GENERATE_DIR_CLUSTER_VNID(dir->vnid, 
info.cluster) :
-                                       GENERATE_DIR_INDEX_VNID(dir->vnid, 
info.sindex);
-                       bool added_to_vcache = false;
-
-                       /* if it matches a loc in the lookup table, we are 
done. */
-                       result = vcache_loc_to_vnid(vol, loc, vnid);
-                       if (result == ENOENT) {
-                               /* ...else check if it matches any vnid's in 
the lookup table */
-                               if (find_vnid_in_vcache(vol, loc) == B_OK) {
-                                       /* if it does, create a random one 
since we can't reuse
-                                        * existing vnid's */
-                                       *vnid = generate_unique_vnid(vol);
-                                       /* and add it to the vcache */
-                                       if ((result = add_to_vcache(vol, *vnid, 
loc)) < 0)
-                                               return result;
-                                       added_to_vcache = true;
-                               } else {
-                                       /* otherwise we are free to use it */
-                                       *vnid = loc;
-                               }
-                       } else if (result != B_OK) {
-                               dprintf("get_next_dirent: unknown error 
(%s)\n", strerror(result));
-                               return result;
-                       }
-
-                       if (info.mode & FAT_SUBDIR) {
-                               if (dlist_find(vol, info.cluster) == -1LL) {
-                                       if ((result = dlist_add(vol, *vnid)) < 
0) {
-                                               if (added_to_vcache)
-                                                       remove_from_vcache(vol, 
*vnid);
-                                               return result;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       DPRINTF(2, ("get_next_dirent: found %s (vnid %Lx)\n", filename, *vnid));
-
-       return B_NO_ERROR;
-}
-
-status_t check_dir_empty(nspace *vol, vnode *dir)
-{
-       uint32 i;
-       struct diri iter;
-       status_t result = B_ERROR; /* quiet warning */
-
-       if (check_nspace_magic(vol, "check_dir_empty")) return EINVAL;
-       if (check_vnode_magic(dir, "check_dir_empty")) return EINVAL;
-
-       if (diri_init(vol, dir->cluster, 0, &iter) == NULL) {
-               dprintf("check_dir_empty: error opening directory\n");
-               ASSERT(0);
-               return B_ERROR;
-       }
-
-       i = (dir->vnid == vol->root_vnode.vnid) ? 2 : 0;
-
-       for (;i<3;i++) {
-               char filename[512];
-               result = _next_dirent_(&iter, NULL, filename, 512);
-
-               if (result < 0) {
-                       if ((i == 2) && (result == ENOENT)) result = B_OK;
-                       break;
-               }
-
-               if (((i == 0) && strcmp(filename, ".")) ||
-                       ((i == 1) && strcmp(filename, "..")) ||
-                       // weird case where ./.. are stored as long file names
-                       ((i < 2) && (iter.current_index != i+1))) {
-                       dprintf("check_dir_empty: malformed directory\n");
-                       result = ENOTDIR;
-                       break;
-               }
-
-               result = ENOTEMPTY;             
-       }
-
-       diri_free(&iter);
-
-       return result;
-}
-
-status_t findfile_case(nspace *vol, vnode *dir, const char *file,
-               vnode_id *vnid, vnode **node)
-{
-       return findfile(vol, dir, file, vnid, node, true, false, NULL);
-}
-
-status_t findfile_nocase(nspace *vol, vnode *dir, const char *file,
-               vnode_id *vnid, vnode **node)
-{
-       return findfile(vol, dir, file, vnid, node, false, false, NULL);
-}
-
-status_t findfile_nocase_duplicates(nspace *vol, vnode *dir, const char *file,
-               vnode_id *vnid, vnode **node, bool *dups_exist)
-{
-       return findfile(vol, dir, file, vnid, node, false, true, dups_exist);
-}
-
-status_t findfile_case_duplicates(nspace *vol, vnode *dir, const char *file,
-               vnode_id *vnid, vnode **node, bool *dups_exist)
-{
-       return findfile(vol, dir, file, vnid, node, true, true, dups_exist);
-}
-
-static status_t findfile(nspace *vol, vnode *dir, const char *file,
-               vnode_id *vnid, vnode **node, bool check_case,
-               bool check_dups, bool *dups_exist)
-{
-       /* Starting at the base, find the file in the subdir
-          and return its vnode id */
-       /* The check_case flags determines whether or not the search
-          is done for the exact case or not. If it is not, it will
-          return the first occurance of the match. */
-       /* The check_dups flag instructs the function to find the
-          first filename match based on the case sensitivity in
-          check_case, but continue searching to see if there are
-          any other case-insensitive matches. If there are, the
-          dups_exist flag is set to true. */
-       int             result = 0;
-       vnode_id        found_vnid = 0;
-       bool found_file = false;
-
-//     dprintf("findfile: %s in %Lx, case %d dups %d\n", file, dir->vnid, 
check_case, check_dups);
-
-       if (check_nspace_magic(vol, "findfile")) return EINVAL;
-       if (check_vnode_magic(dir, "findfile")) return EINVAL;
-
-       DPRINTF(1, ("findfile: %s in %Lx\n", file, dir->vnid));
-
-       if(dups_exist != NULL) *dups_exist = false;
-       else check_dups = false;
-
-       if ((strcmp(file,".") == 0) && (dir->vnid == vol->root_vnode.vnid)) {
-               found_file = true;
-               found_vnid = dir->vnid;
-       } else if ((strcmp(file, "..") == 0) && (dir->vnid == 
vol->root_vnode.vnid)) {
-               found_file = true;
-               found_vnid = dir->dir_vnid;
-       } else {
-               struct diri diri;
-
-               // XXX: do it in a smarter way
-               diri_init(vol, dir->cluster, 0, &diri);
-
-               while (1)
-               {
-                       char filename[512];
-                       vnode_id        _vnid;
-
-                       result = get_next_dirent(vol, dir, &diri, &_vnid, 
filename, 512);
-
-                       if (result != B_NO_ERROR)
-                               break;
-
-                       if(check_case) {
-                               if (!found_file && !strcmp(filename, file)) {
-                                       found_file = true;
-                                       found_vnid = _vnid;
-                               } else if(check_dups && !strcasecmp(filename, 
file)) {
-                                       *dups_exist = true;
-                               }
-                       } else {
-                               if (!strcasecmp(filename, file)) {
-                                       if(check_dups && found_file) {
-                                               *dups_exist = true;
-                                       }
-                                       found_file = true;
-                                       found_vnid = _vnid;
-                               }
-                       }
-
-                       if(found_file && (!check_dups || (check_dups && 
*dups_exist))) {
-                               break;
-                       }
-               }
-               diri_free(&diri);
-       }
-       if (found_file) {
-               if (vnid) *vnid = found_vnid;
-               if (node) result = get_vnode(vol->id, found_vnid, (void 
**)node);
-               result = B_OK;
-       } else {
-               result = ENOENT;
-       }
-#if 0
-       dprintf("findfile: returning %d", result);
-       if(dups_exist)
-               dprintf(" dups_exist %d\n", *dups_exist);
-       else
-               dprintf("\n");
-#endif
-       return result;
-}
-
-status_t erase_dir_entry(nspace *vol, vnode *node)
-{
-       status_t result;
-       uint32 i;
-       char filename[512];
-       uint8 *buffer;
-       struct _dirent_info_ info;
-       struct diri diri;
-       
-       DPRINTF(0, ("erasing directory entries %lx through %lx\n", 
node->sindex, node->eindex));
-       buffer = diri_init(vol,VNODE_PARENT_DIR_CLUSTER(node), node->sindex, 
&diri);
-
-       // first pass: check if the entry is still valid
-       if (buffer == NULL) {
-               dprintf("erase_dir_entry: error reading directory\n");
-               return ENOENT;
-       }
-
-       result = _next_dirent_(&diri, &info, filename, 512);
-       diri_free(&diri);
-
-       if (result < 0) return result;
-       
-       if ((info.sindex != node->sindex) ||
-               (info.eindex != node->eindex)) {
-               // any other attributes may be in a state of flux due to wstat 
calls
-               dprintf("erase_dir_entry: directory entry doesn't match\n");
-               return B_ERROR;
-       }
-
-       // second pass: actually erase the entry
-       buffer = diri_init(vol, VNODE_PARENT_DIR_CLUSTER(node), node->sindex, 
&diri);
-       for 
(i=node->sindex;(i<=node->eindex)&&(buffer);buffer=diri_next_entry(&diri),i++) {
-               buffer[0] = 0xe5; // mark entry erased
-               diri_mark_dirty(&diri);
-       }
-       diri_free(&diri);
-
-       return 0;
-}
-
-// shrink directory to the size needed
-// errors here are neither likely nor problematic
-// w95 doesn't seem to do this, so it's possible to create a
-// really large directory that consumes all available space!
-status_t compact_directory(nspace *vol, vnode *dir)
-{
-       uint32 last = 0;
-       struct diri diri;
-       status_t error = B_ERROR; /* quiet warning */
-
-       DPRINTF(0, ("compacting directory with vnode id %Lx\n", dir->vnid));
-
-       // root directory can't shrink in fat12 and fat16
-       if (IS_FIXED_ROOT(dir->cluster))
-               return 0;
-
-       diri_init(vol, dir->cluster, 0, &diri);
-       while (diri.current_block) {
-               char filename[512];
-               struct _dirent_info_ info;
-
-               error = _next_dirent_(&diri, &info, filename, 512);
-
-               if (error == B_OK) {
-                       // don't compact away volume labels in the root dir
-                       if (!(info.mode & FAT_VOLUME) || (dir->vnid != 
vol->root_vnode.vnid))
-                               last = diri.current_index;
-               } else if (error == ENOENT) {
-                       uint32 clusters = (last + vol->bytes_per_sector / 0x20 
* vol->sectors_per_cluster - 1) / (vol->bytes_per_sector / 0x20) / 
vol->sectors_per_cluster;
-                       error = 0;
-
-                       // special case for fat32 root directory; we don't want
-                       // it to disappear
-                       if (clusters == 0) clusters = 1;
-
-                       if (clusters * vol->bytes_per_sector * 
vol->sectors_per_cluster < dir->st_size) {
-                               DPRINTF(0, ("shrinking directory to %lx 
clusters\n", clusters));
-                               error = set_fat_chain_length(vol, dir, 
clusters);
-                               dir->st_size = 
clusters*vol->bytes_per_sector*vol->sectors_per_cluster;
-                               dir->iteration++;
-                       }
-                       break;
-               } else {
-                       dprintf("compact_directory: unknown error from 
_next_dirent_ (%s)\n", strerror(error));
-                       break;
-               }
-       }
-       diri_free(&diri);
-
-       return error;
-}
-
-// name is array of char[11] as returned by findfile
-static status_t find_short_name(nspace *vol, vnode *dir, const uchar *name)
-{
-       struct diri diri;
-       uint8 *buffer;
-       status_t result = ENOENT;
-       
-       buffer = diri_init(vol, dir->cluster, 0, &diri);
-       while (buffer) {
-               if (buffer[0] == 0)
-                       break;
-
-               if (buffer[0xb] != 0xf) { // not long file name
-                       if (!memcmp(name, buffer, 11)) {
-                               result = B_OK;
-                               break;
-                       }
-               }
-
-               buffer = diri_next_entry(&diri);
-       }
-
-       diri_free(&diri);
-
-       return result;
-}
-
-struct _entry_info_ {
-       uint32 mode;
-       uint32 cluster;
-       uint32 size;
-       time_t time;
-};
-
-static status_t _create_dir_entry_(nspace *vol, vnode *dir, struct 
_entry_info_ *info,
-       const char nshort[11], const char *nlong, uint32 len, uint32 *ns, 
uint32 *ne)
-{
-       status_t error = B_ERROR; /* quiet warning */
-       uint32 required_entries, i;
-       uint8 *buffer, hash;
-       bool last_entry;
-       struct diri diri;
-
-       // short name cannot be the same as that of a device
-       // this list was created by running strings on io.sys
-       const char *device_names[] = {
-               "CON        ",
-               "AUX        ",
-               "PRN        ",
-               "CLOCK$     ",
-               "COM1       ",
-               "LPT1       ",
-               "LPT2       ",
-               "LPT3       ",
-               "COM2       ",
-               "COM3       ",
-               "COM4       ",
-               "CONFIG$    ",
-               NULL
-       };
-
-       // check short name against device names
-       for (i=0;device_names[i];i++) {
-               // only first 8 characters seem to matter
-               if (!memcmp(nshort, device_names[i], 8))
-                       return EPERM;
-       }
-
-       if ((info->cluster != 0) && !IS_DATA_CLUSTER(info->cluster)) {
-               dprintf("_create_dir_entry_ for bad cluster (%lx)\n", 
info->cluster);
-               return EINVAL;
-       }
-
-       /* convert byte length of unicode name to directory entries */
-       required_entries = (len + 24) / 26 + 1;
-
-       // find a place to put the entries
-       *ns = 0;
-       last_entry = true;
-       diri_init(vol, dir->cluster, 0, &diri);
-       while (diri.current_block) {
-               char filename[512];
-               struct _dirent_info_ info;
-               error = _next_dirent_(&diri, &info, filename, 512);
-               if (error == B_OK) {
-                       if (info.sindex - *ns >= required_entries) {
-                               last_entry = false;
-                               break;
-                       }
-                       *ns = diri.current_index;
-               } else if (error == ENOENT) {
-                       // hit end of directory marker
-                       break;
-               } else {
-                       dprintf("_create_dir_entry_: unknown error from 
_next_dirent_ (%s)\n", strerror(error));
-                       break;
-               }
-       }
-
-       // if at end of directory, last_entry flag will be true as it should be
-
-       diri_free(&diri);
-       
-       if ((error != B_OK) && (error != ENOENT)) return error;
-
-       *ne = *ns + required_entries - 1;
-
-       for (i=*ns;i<=*ne;i++) {
-               ASSERT(find_loc_in_vcache(vol, \
-                                       GENERATE_DIR_INDEX_VNID(dir->cluster, 
i)) == ENOENT);
-       }
-
-       DPRINTF(0, ("directory entry runs from %lx to %lx (dirsize = %Lx) (is%s 
last entry)\n", *ns, *ne, dir->st_size, last_entry ? "" : "n't"));
-
-       // check if the directory needs to be expanded
-       if (*ne * 0x20 >= dir->st_size) {
-               uint32 clusters_needed;
-
-               // can't expand fat12 and fat16 root directories :(
-               if (IS_FIXED_ROOT(dir->cluster)) {
-                       DPRINTF(0, ("_create_dir_entry_: out of space in root 
directory\n"));
-                       return ENOSPC;
-               }
-       
-               // otherwise grow directory to fit
-               clusters_needed = ((*ne + 1) * 0x20 +
-                       vol->bytes_per_sector*vol->sectors_per_cluster - 1) /
-                       vol->bytes_per_sector / vol->sectors_per_cluster;
-
-               DPRINTF(0, ("expanding directory from %Lx to %lx clusters\n", 
dir->st_size/vol->bytes_per_sector/vol->sectors_per_cluster, clusters_needed));
-               if ((error = set_fat_chain_length(vol, dir, clusters_needed)) < 
0)
-                       return error;
-               dir->st_size = 
vol->bytes_per_sector*vol->sectors_per_cluster*clusters_needed;
-               dir->iteration++;
-       }
-
-       // starting blitting entries
-       buffer = diri_init(vol,dir->cluster, *ns, &diri);
-       hash = hash_msdos_name(nshort);
-
-       // write lfn entries
-       for (i=1;(i<required_entries)&&buffer;i++) {
-               const char *p = nlong + (required_entries - i - 1)*26; // go to 
unicode offset
-               memset(buffer, 0, 0x20);
-               buffer[0] = required_entries - i + ((i == 1) ? 0x40 : 0);
-               buffer[0x0b] = 0x0f;
-               buffer[0x0d] = hash;
-               memcpy(buffer+1,p,10);
-               memcpy(buffer+0x0e,p+10,12);
-               memcpy(buffer+0x1c,p+22,4);
-               diri_mark_dirty(&diri);
-               buffer = diri_next_entry(&diri);
-       }
-
-       ASSERT(buffer != NULL);
-       if (buffer == NULL)     {       // this should never happen...
-               DPRINTF(0, ("_create_dir_entry_: the unthinkable has 
occured\n"));
-               diri_free(&diri);
-               return B_ERROR;
-       }
-
-       // write directory entry
-       memcpy(buffer, nshort, 11);
-       buffer[0x0b] = info->mode;
-       memset(buffer+0xc, 0, 0x16-0xc);
-       i = time_t2dos(info->time);
-       buffer[0x16] = i & 0xff;
-       buffer[0x17] = (i >> 8) & 0xff;
-       buffer[0x18] = (i >> 16) & 0xff;
-       buffer[0x19] = (i >> 24) & 0xff;
-       i = info->cluster;
-       if (info->size == 0) i = 0;             // cluster = 0 for 0 byte files
-       buffer[0x1a] = i & 0xff;
-       buffer[0x1b] = (i >> 8) & 0xff;
-       if (vol->fat_bits == 32) {
-               buffer[0x14] = (i >> 16) & 0xff;
-               buffer[0x15] = (i >> 24) & 0xff;
-       }
-       i = (info->mode & FAT_SUBDIR) ? 0 : info->size;
-       buffer[0x1c] = i & 0xff;
-       buffer[0x1d] = (i >> 8) & 0xff;
-       buffer[0x1e] = (i >> 16) & 0xff;
-       buffer[0x1f] = (i >> 24) & 0xff;
-       diri_mark_dirty(&diri);
-       
-       if (last_entry) {
-               // add end of directory markers to the rest of the
-               // cluster; need to clear all the other entries or else
-               // scandisk will complain.
-               while ((buffer = diri_next_entry(&diri)) != NULL) {
-                       memset(buffer, 0, 0x20);
-                       diri_mark_dirty(&diri);
-               }
-       }
-       
-       diri_free(&diri);
-
-       return 0;
-}
-
-// doesn't do any name checking
-status_t create_volume_label(nspace *vol, const char name[11], uint32 *index)
-{
-       status_t err;
-       uint32 dummy;
-       struct _entry_info_ info = {
-               FAT_ARCHIVE | FAT_VOLUME, 0, 0, 0
-       };
-       time(&info.time);
-
-       // check if name already exists
-       err = find_short_name(vol, &(vol->root_vnode), (uchar *)name);
-       if (err == B_OK)
-               return EEXIST;
-       if (err != ENOENT)
-               return err;
-
-       return _create_dir_entry_(vol, &(vol->root_vnode), &info, name, NULL, 
0, index, &dummy);
-}
-
-bool is_filename_legal(const char *name)
-{
-       unsigned int i;
-       unsigned int len = strlen(name);
-       
-       if (len <= 0) return false;
-       
-       // names ending with a dot are not allowed
-       if (name[len - 1] == '.') return false;
-       // names ending with a space are not allowed
-       if (name[len - 1] == ' ') return false;
-
-       // XXX illegal character search can be made faster
-       for(i=0; i<len; i++) {
-               if(name[i] & 0x80) continue; //belongs to an utf8 char
-               if(strchr(illegal, name[i])) return false;
-               if((unsigned char)name[i] < 32) return false;
-       }
-       return true;
-}
-
-status_t create_dir_entry(nspace *vol, vnode *dir, vnode *node, 
-       const char *name, uint32 *ns, uint32 *ne)
-{
-       status_t error;
-       int32 len;
-       unsigned char nlong[512], nshort[11];
-       int encoding;
-       struct _entry_info_ info;
-
-       // check name legality before doing anything
-       if(!is_filename_legal(name))
-               return EINVAL;
-
-       // check if name already exists
-       error = findfile_nocase(vol,dir,name,NULL,NULL);
-       if (error == B_OK) {
-               DPRINTF(0, ("%s already found in directory %Lx\n", name, 
dir->vnid));
-               return EEXIST;
-       }
-       if (error != ENOENT)
-               return error;
-
-       // check name legality while converting. we ignore the case conversion
-       // flag, i.e. (filename "blah" will always have a patched short name),
-       // because the whole case conversion system in dos is brain damaged;
-       // remanants of CP/M no less.
-
-       // existing names pose a problem; in these cases, we'll just live with
-       // two identical short names. not a great solution, but there's little
-       // we can do about it.
-       len = utf8_to_unicode(name, nlong, 512);
-       if (len <= 0) {
-               DPRINTF(0, ("Error converting utf8 name '%s' to unicode\n", 
name));
-               return len ? len : B_ERROR;
-       }
-       memset(nlong + len, 0xff, 512 - len); /* pad with 0xff */
-
-       error = generate_short_name((uchar *)name, nlong, len, nshort, 
&encoding);
-       if (error) {
-               DPRINTF(0, ("Error generating short name for '%s'\n", name));
-               return error;
-       }
-
-       // if there is a long name, patch short name if necessary and check for 
duplication
-       if (requires_long_name(name, nlong)) {
-               char tshort[11]; // temporary short name
-               int iter = 1;
-
-               memcpy(tshort, nshort, 11);
-
-               if (requires_munged_short_name((uchar *)name, nshort, encoding))
-                       error = B_OK;
-               else
-                       error = find_short_name(vol, dir, nshort);
-                       
-               if (error == B_OK) {
-                       do {
-                               memcpy(nshort, tshort, 11);
-                               DPRINTF(0, ("trying short name %11.11s\n", 
nshort));
-                               munge_short_name1(nshort, iter, encoding);
-                       } while (((error = find_short_name(vol, dir, nshort)) 
== B_OK) && (++iter < 10));
-               }
-
-               if ((error != B_OK) && (error != ENOENT)) return error;
-
-               if (error == B_OK) {
-                       // XXX: possible infinite loop here
-                       do {
-                               memcpy(nshort, tshort, 11);
-                               DPRINTF(0, ("trying short name %11.11s\n", 
nshort));
-                               munge_short_name2(nshort, encoding);
-                       } while ((error = find_short_name(vol, dir, nshort)) == 
B_OK);
-
-                       if (error != ENOENT) return error;
-               }
-       } else {
-               len = 0; /* entry doesn't need a long name */
-       }
-
-       DPRINTF(0, ("creating directory entry (%11.11s)\n", nshort));
-
-       info.mode = node->mode;
-       info.cluster = node->cluster;
-       info.size = node->st_size;
-       info.time = node->st_time;
-
-       return _create_dir_entry_(vol, dir, &info, (char *)nshort, (char 
*)nlong, len, ns, ne);
-}
-
-int dosfs_read_vnode(void *_vol, vnode_id vnid, char reenter, void **_node)
-{
-       nspace  *vol = (nspace*)_vol;
-       int             result = B_NO_ERROR;
-       vnode_id loc, dir_vnid;
-       vnode *entry;
-       struct _dirent_info_ info;
-       struct diri iter;
-       char filename[512]; /* need this for setting mime type */
-
-       if (!reenter) { LOCK_VOL(vol); }
-
-       *_node = NULL;
-
-       if (check_nspace_magic(vol, "dosfs_read_vnode")) {
-               if (!reenter) UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_read_vnode (vnode id %Lx)\n", vnid));
-
-       if (vnid == vol->root_vnode.vnid)
-       {
-               dprintf("??? dosfs_read_vnode called on root node ???\n");
-               *_node = (void *)&(vol->root_vnode);
-               goto bi;
-       }
-
-       if (vcache_vnid_to_loc(vol, vnid, &loc) != B_OK)
-               loc = vnid;
-
-       if (IS_ARTIFICIAL_VNID(loc) || IS_INVALID_VNID(loc)) {
-               DPRINTF(0, ("dosfs_read_vnode: unknown vnid %Lx (loc %Lx)\n", 
vnid, loc));
-               result = ENOENT;
-               goto bi;
-       }
-
-       if ((dir_vnid = dlist_find(vol, DIR_OF_VNID(loc))) == -1LL) {
-               DPRINTF(0, ("dosfs_read_vnode: unknown directory at cluster 
%lx\n", DIR_OF_VNID(loc)));
-               result = ENOENT;
-               goto bi;
-       }
-
-       if (diri_init(vol, DIR_OF_VNID(loc),
-                       IS_DIR_CLUSTER_VNID(loc) ? 0 : 
INDEX_OF_DIR_INDEX_VNID(loc),
-                       &iter) == NULL) {
-               dprintf("dosfs_read_vnode: error initializing directory for 
vnid %Lx (loc %Lx)\n", vnid, loc);
-               result = ENOENT;
-               goto bi;
-       }
-       
-       while (1) {
-               result = _next_dirent_(&iter, &info, filename, 512);
-               if (result < 0) {
-                       dprintf("dosfs_read_vnode: error finding vnid %Lx (loc 
%Lx) (%s)\n", vnid, loc, strerror(result));
-                       goto bi2;
-               }
-
-               if (IS_DIR_CLUSTER_VNID(loc)) {
-                       if (info.cluster == CLUSTER_OF_DIR_CLUSTER_VNID(loc))
-                               break;
-               } else {
-                       if (info.sindex == INDEX_OF_DIR_INDEX_VNID(loc))
-                               break;
-                       dprintf("dosfs_read_vnode: error finding vnid %Lx (loc 
%Lx) (%s)\n", vnid, loc, strerror(result));
-                       result = ENOENT;
-                       goto bi2;
-               }
-       }
-
-       if ((entry = calloc(sizeof(struct vnode), 1)) == NULL) {
-               DPRINTF(0, ("dosfs_read_vnode: out of memory\n"));
-               result = ENOMEM;
-               goto bi2;
-       }
-
-       entry->magic = VNODE_MAGIC;
-       entry->vnid = vnid;
-       entry->dir_vnid = dir_vnid;
-       entry->disk_image = 0;
-       if (vol->respect_disk_image) {
-               if ((dir_vnid == vol->root_vnode.vnid) && !strcmp(filename, 
"BEOS")) {
-                       vol->beos_vnid = vnid;
-                       entry->disk_image = 1;
-               }
-               if ((dir_vnid == vol->beos_vnid) && !strcmp(filename, 
"IMAGE.BE")) {
-                       entry->disk_image = 2;
-               }
-       }
-       entry->iteration = 0;
-       entry->sindex = info.sindex;
-       entry->eindex = info.eindex;
-       entry->cluster = info.cluster;
-       entry->mode = info.mode;
-       entry->st_size = info.size;
-       entry->dirty = false;
-       if (info.mode & FAT_SUBDIR) {
-               entry->st_size = count_clusters(vol,entry->cluster) * 
vol->sectors_per_cluster * vol->bytes_per_sector;
-       }
-       if (entry->cluster)
-               entry->end_cluster = get_nth_fat_entry(vol, info.cluster, 
-                               (entry->st_size + vol->bytes_per_sector * 
vol->sectors_per_cluster - 1) /
-                               vol->bytes_per_sector / 
vol->sectors_per_cluster - 1);
-       else
-               entry->end_cluster = 0;
-       entry->st_time = dos2time_t(info.time);
-#if TRACK_FILENAME
-       entry->filename = malloc(sizeof(filename) + 1);
-       if (entry->filename) strcpy(entry->filename, filename);
-#endif
-       if(!(entry->mode & FAT_SUBDIR))
-               set_mime_type(entry, filename);
-
-       *_node = entry;
-
-bi2:diri_free(&iter);
-bi:    if (!reenter) UNLOCK_VOL(vol);
-
-       if (result != B_OK) DPRINTF(0, ("dosfs_read_vnode (%s)\n", 
strerror(result)));
-
-       return result;
-}
-
-int dosfs_walk(void *_vol, void *_dir, const char *file, char **newpath, 
vnode_id *vnid)
-{
-       /* Starting at the base, find file in the subdir, and return path
-               string and vnode id of file. */
-       nspace  *vol = (nspace*)_vol;
-       vnode   *dir = (vnode*)_dir;
-       vnode   *vnode = NULL;
-       int             result = ENOENT;
-
-       /* we can ignore newpath since there are no symbolic links */
-       TOUCH(newpath);
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_walk") ||
-               check_vnode_magic(dir, "dosfs_walk")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_walk: find %Lx/%s\n", dir->vnid, file));
-
-       result = findfile_case(vol, dir, file, vnid, &vnode);
-       if (result != B_OK) {
-               DPRINTF(0, ("dosfs_walk (%s)\n", strerror(result)));
-       } else {
-               DPRINTF(0, ("dosfs_walk: found vnid %Lx\n", *vnid));
-       }
-
-       UNLOCK_VOL(vol);
-
-       return result;
-}
-
-int dosfs_access(void *_vol, void *_node, int mode)
-{
-       status_t result = B_OK;
-       nspace *vol = (nspace *)_vol;
-       vnode *node = (vnode *)_node;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_access") ||
-               check_vnode_magic(node, "dosfs_access")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_access (vnode id %Lx, mode %x)\n", node->vnid, 
mode));
-
-       if ((mode & O_RWMASK) != O_RDONLY) {
-               if (vol->flags & B_FS_IS_READONLY) {
-                       dprintf("dosfs_access: can't write on read-only 
volume\n");
-                       result = EROFS;
-               } else if (node->mode & FAT_READ_ONLY) {
-                       dprintf("can't open read-only file for writing\n");
-                       result = EPERM;
-               } else if (node->disk_image != 0) {
-                       dprintf("can't open disk image file for writing\n");
-                       result = EPERM;
-               }
-       }
-
-       UNLOCK_VOL(vol);
-
-       return result;
-}
-
-int dosfs_readlink(void *_vol, void *_node, char *buf, size_t *bufsize)
-{
-       TOUCH(_vol); TOUCH(_node); TOUCH(buf); TOUCH(bufsize);
-
-       // no links in fat...
-       DPRINTF(0, ("dosfs_readlink called\n"));
-
-       return EINVAL;
-}
-
-int dosfs_opendir(void *_vol, void *_node, void **_cookie)
-{
-       nspace          *vol = (nspace*)_vol;
-       vnode           *node = (vnode*)_node;
-       dircookie       *cookie = NULL;
-       int                     result;
-
-       if (_cookie == NULL) {
-               dprintf("dosfs_opendir called with null _cookie\n");
-               return EINVAL;
-       }
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_opendir") ||
-               check_vnode_magic(node, "dosfs_opendir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_opendir (vnode id %Lx)\n", node->vnid));
-
-       *_cookie = NULL;
-
-       if (!(node->mode & FAT_SUBDIR)) {
-               /* bash will try to opendir files unless OPENDIR_NOT_ROBUST is
-                * defined, so we'll suppress this message; it's more of a 
problem
-                * with the application than with the file system, anyway
-                */
-               DPRINTF(0, ("dosfs_opendir error: vnode not a directory\n"));
-               result = ENOTDIR;
-               goto bi;
-       }
-
-       if ((cookie = (dircookie *)malloc(sizeof(dircookie))) == NULL) {
-               dprintf("dosfs_opendir: out of memory error\n");
-               result = ENOMEM;
-               goto bi;
-       }
-
-       cookie->magic = DIRCOOKIE_MAGIC;
-       cookie->current_index = 0;
-
-       result = B_NO_ERROR;
-       
-bi:
-       *_cookie = (void*)cookie;
-
-       if (result != B_OK) DPRINTF(0, ("dosfs_opendir (%s)\n", 
strerror(result)));
-
-       UNLOCK_VOL(vol);
-
-       return result;
-}
-
-int dosfs_readdir(void *_vol, void *_dir, void *_cookie, long *num, 
-       struct dirent *entry, size_t bufsize)
-{
-       int             result = ENOENT;
-       nspace*         vol = (nspace*)_vol;
-       vnode           *dir = (vnode *)_dir;
-       dircookie*      cookie = (dircookie*)_cookie;
-       struct          diri diri;
-
-       LOCK_VOL(vol);
-       
-       if (check_nspace_magic(vol, "dosfs_readdir") ||
-               check_vnode_magic(dir, "dosfs_readdir") ||
-               check_dircookie_magic(cookie, "dosfs_readdir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_readdir: vnode id %Lx, index %lx\n", dir->vnid, 
cookie->current_index));
-
-       // simulate '.' and '..' entries for root directory
-       if (dir->vnid == vol->root_vnode.vnid) {
-               if (cookie->current_index >= 2) {
-                       cookie->current_index -= 2;
-               } else {
-                       if (cookie->current_index++ == 0) {
-                               strcpy(entry->d_name, ".");
-                               entry->d_reclen = 2;
-                       } else {
-                               strcpy(entry->d_name, "..");
-                               entry->d_reclen = 3;
-                       }
-                       *num = 1;
-                       entry->d_ino = vol->root_vnode.vnid;
-                       entry->d_dev = vol->id;
-                       result = B_NO_ERROR;
-                       goto bi;
-               }
-       }
-
-       diri_init(vol, dir->cluster, cookie->current_index, &diri);
-       result = get_next_dirent(vol, dir, &diri, &(entry->d_ino), 
entry->d_name, bufsize - sizeof(struct dirent) - 1);
-       cookie->current_index = diri.current_index;
-       diri_free(&diri);
-
-       if (dir->vnid == vol->root_vnode.vnid)
-               cookie->current_index += 2;
-       
-       if (result == B_NO_ERROR) {
-               *num = 1;
-               entry->d_dev = vol->id;
-               entry->d_reclen = strlen(entry->d_name) + 1;
-               DPRINTF(0, ("dosfs_readdir: found file %s\n", entry->d_name));
-       } else if (result == ENOENT) {
-               // When you get to the end, don't return an error, just return 0
-               // in *num.
-               *num = 0;
-               result = B_NO_ERROR;
-       } else {
-               dprintf("dosfs_readdir: error returned by get_next_dirent 
(%s)\n", strerror(result));
-       }
-bi:
-       if (result != B_OK) DPRINTF(0, ("dosfs_readdir (%s)\n", 
strerror(result)));
-
-       UNLOCK_VOL(vol);
-
-       return result;
-}
-                       
-int dosfs_rewinddir(void *_vol, void *_node, void* _cookie)
-{
-       nspace          *vol = _vol;
-       vnode           *node = _node;
-       dircookie       *cookie = (dircookie*)_cookie;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_rewinddir") ||
-               check_vnode_magic(node, "dosfs_rewinddir") ||
-               check_dircookie_magic(cookie, "dosfs_rewinddir")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_rewinddir (vnode id %Lx)\n", node->vnid));
-
-       cookie->current_index = 0;
-
-       UNLOCK_VOL(vol);
-
-       return B_OK;
-}
-
-int dosfs_closedir(void *_vol, void *_node, void *_cookie)
-{
-       TOUCH(_vol); TOUCH(_node); TOUCH(_cookie);
-
-       DPRINTF(0, ("dosfs_closedir called\n"));
-
-       return 0;
-}
-
-int dosfs_free_dircookie(void *_vol, void *node, void *_cookie)
-{
-       nspace *vol = _vol;
-       dircookie *cookie = _cookie;
-
-       LOCK_VOL(vol);
-
-       if (check_nspace_magic(vol, "dosfs_free_dircookie") ||
-               check_vnode_magic((vnode *)node, "dosfs_free_dircookie") ||
-               check_dircookie_magic((dircookie *)cookie, 
"dosfs_free_dircookie")) {
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       if (cookie == NULL) {
-               dprintf("error: dosfs_free_dircookie called with null 
cookie\n");
-               UNLOCK_VOL(vol);
-               return EINVAL;
-       }
-
-       DPRINTF(0, ("dosfs_free_dircookie (vnode id %Lx)\n", 
((vnode*)node)->vnid));
-
-       cookie->magic = ~DIRCOOKIE_MAGIC;
-       free(cookie);
-
-       UNLOCK_VOL(vol);
-
-       return 0;
-}
-
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/dir.h 
b/src/tests/add-ons/kernel/file_systems/dos/r5/dir.h
deleted file mode 100644
index 5683c7b398..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/dir.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-#ifndef _DOSFS_DIR_H_
-#define _DOSFS_DIR_H_
-
-bool is_filename_legal(const char *name);
-status_t       check_dir_empty(nspace *vol, vnode *dir);
-status_t       findfile_case(nspace *vol, vnode *dir, const char *file,
-                               vnode_id *vnid, vnode **node);
-status_t       findfile_nocase(nspace *vol, vnode *dir, const char *file,
-                               vnode_id *vnid, vnode **node);
-status_t       findfile_nocase_duplicates(nspace *vol, vnode *dir, const char 
*file,
-                               vnode_id *vnid, vnode **node, bool 
*dups_exist);                                
-status_t       findfile_case_duplicates(nspace *vol, vnode *dir, const char 
*file,
-                               vnode_id *vnid, vnode **node, bool 
*dups_exist);                                
-status_t       erase_dir_entry(nspace *vol, vnode *node);
-status_t       compact_directory(nspace *vol, vnode *dir);
-status_t       create_volume_label(nspace *vol, const char name[11], uint32 
*index);
-status_t       create_dir_entry(nspace *vol, vnode *dir, vnode *node, 
-                               const char *name, uint32 *ns, uint32 *ne);
-
-int                    dosfs_read_vnode(void *_vol, vnode_id vnid, char r, 
void **node);
-int                    dosfs_walk(void *_vol, void *_dir, const char *file,
-                               char **newpath, vnode_id *vnid);
-int                    dosfs_access(void *_vol, void *_node, int mode);
-int                    dosfs_readlink(void *_vol, void *_node, char *buf, 
size_t *bufsize);
-int                    dosfs_opendir(void *_vol, void *_node, void **cookie);
-int                    dosfs_readdir(void *_vol, void *_node, void *cookie,
-                               long *num, struct dirent *buf, size_t bufsize);
-int                    dosfs_rewinddir(void *_vol, void *_node, void *cookie);
-int                    dosfs_closedir(void *_vol, void *_node, void *cookie);
-int                    dosfs_free_dircookie(void *_vol, void *_node, void 
*cookie);
-
-#endif
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.c 
b/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.c
deleted file mode 100644
index c9a4512970..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-/*
-directory vnode id list
-
-We only add to this list as we encounter directories; there is no need to
-scan through the directories ourselves since we aren't worried about preserving
-vnid's across reboots.
-
-We don't worry about aliases for directories since their cluster values will
-always be the same -- searches are performed only on the starting cluster
-number of the directories.
-
-TODO:
-       XXX: make this more efficient
-*/
-
-#define DPRINTF(a,b) if (debug_dlist > (a)) dprintf b
-
-#include <KernelExport.h>
-#include <fsproto.h>
-
-#include <string.h>
-
-#include "dosfs.h"
-#include "dlist.h"
-#include "util.h"
-#include "vcache.h"
-
-#if DEBUG
-       #define DLIST_ENTRY_QUANTUM 1
-#else
-       #define DLIST_ENTRY_QUANTUM 0x20
-#endif
-
-status_t dlist_init(nspace *vol)
-{
-       DPRINTF(0, ("dlist_init called\n"));
-
-       vol->dlist.entries = 0;
-       vol->dlist.allocated = DLIST_ENTRY_QUANTUM;
-       vol->dlist.vnid_list = malloc(sizeof(vnode_id) * vol->dlist.allocated);
-       if (vol->dlist.vnid_list == NULL) {
-               vol->dlist.allocated = 0;
-               dprintf("dlist_init: out of core\n");
-               return ENOMEM;
-       }
-
-       return B_OK;
-}
-
-status_t dlist_uninit(nspace *vol)
-{
-       DPRINTF(0, ("dlist_uninit called\n"));
-
-       if (vol->dlist.vnid_list)
-               free(vol->dlist.vnid_list);
-       vol->dlist.entries = vol->dlist.allocated = 0;
-       vol->dlist.vnid_list = NULL;
-
-       return B_OK;
-}
-
-static status_t dlist_realloc(nspace *vol, uint32 allocate)
-{
-       vnode_id *vnid_list;
-
-       DPRINTF(0, ("dlist_realloc %lx -> %lx\n", vol->dlist.allocated, 
allocate));
-
-       ASSERT(allocate != vol->dlist.allocated);
-       ASSERT(allocate > vol->dlist.entries);
-
-       vnid_list = malloc(sizeof(vnode_id) * allocate);
-       if (vnid_list == NULL) {
-               dprintf("dlist_realloc: out of core\n");
-               return ENOMEM;
-       }
-
-       memcpy(vnid_list, vol->dlist.vnid_list, sizeof(vnode_id) * 
vol->dlist.entries);
-       free(vol->dlist.vnid_list);
-       vol->dlist.vnid_list = vnid_list;
-       vol->dlist.allocated = allocate;
-
-       return B_OK;
-}
-
-status_t dlist_add(nspace *vol, vnode_id vnid)
-{
-       DPRINTF(0, ("dlist_add vnid %Lx\n", vnid));
-
-       ASSERT(IS_DIR_CLUSTER_VNID(vnid) || IS_ARTIFICIAL_VNID(vnid));
-       ASSERT(vnid != 0);
-       // XXX: check for duplicate entries
-
-       if (vol->dlist.entries == vol->dlist.allocated) {
-               if (dlist_realloc(vol, vol->dlist.allocated + 
DLIST_ENTRY_QUANTUM) < 0)
-                       return B_ERROR;
-       }
-       vol->dlist.vnid_list[vol->dlist.entries++] = vnid;
-
-       return B_OK;
-}
-
-status_t dlist_remove(nspace *vol, vnode_id vnid)
-{
-       uint32 i;
-
-       DPRINTF(0, ("dlist_remove vnid %Lx\n", vnid));
-
-       for (i=0;i<vol->dlist.entries;i++)
-               if (vol->dlist.vnid_list[i] == vnid)
-                       break;
-       ASSERT(i < vol->dlist.entries);
-       if (i == vol->dlist.entries)
-               return ENOENT;
-       for (;i<vol->dlist.entries-1;i++)
-               vol->dlist.vnid_list[i] = vol->dlist.vnid_list[i+1];
-       vol->dlist.entries--;
-
-       if (vol->dlist.allocated - vol->dlist.entries > 2*DLIST_ENTRY_QUANTUM)
-               return dlist_realloc(vol, vol->dlist.allocated - 
DLIST_ENTRY_QUANTUM);
-
-       return B_OK;
-}
-
-vnode_id dlist_find(nspace *vol, uint32 cluster)
-{
-       uint32 i;
-
-       DPRINTF(1, ("dlist_find cluster %lx\n", cluster));
-
-       ASSERT(((cluster >= 2) && (cluster < vol->total_clusters + 2)) || 
(cluster == 1));
-
-       for (i=0;i<vol->dlist.entries;i++) {
-               vnode_id loc;
-
-               if (vcache_vnid_to_loc(vol, vol->dlist.vnid_list[i], &loc) < 
B_OK)
-                       loc = vol->dlist.vnid_list[i];
-               ASSERT(IS_DIR_CLUSTER_VNID(loc));
-               if (CLUSTER_OF_DIR_CLUSTER_VNID(loc) == cluster)
-                       return vol->dlist.vnid_list[i];
-       }
-
-       DPRINTF(1, ("dlist_find cluster %lx not found\n", cluster));
-
-       return -1LL;
-}
-
-void dlist_dump(nspace *vol)
-{
-       uint32 i;
-
-       dprintf("%lx/%lx dlist entries filled, QUANTUM = %x\n",
-               vol->dlist.entries, vol->dlist.allocated, DLIST_ENTRY_QUANTUM);
-
-       for (i=0;i<vol->dlist.entries;i++)
-               dprintf("%s %Lx", ((i == 0) ? "entries:" : ","), 
vol->dlist.vnid_list[i]);
-
-       dprintf("\n");
-}
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.h 
b/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.h
deleted file mode 100644
index 55fb39d0f3..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/dlist.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-#ifndef _DOSFS_DLIST_H_
-#define _DOSFS_DLIST_H_
-
-status_t dlist_init(nspace *vol);
-status_t dlist_uninit(nspace *vol);
-status_t dlist_add(nspace *vol, vnode_id vnid);
-status_t dlist_remove(nspace *vol, vnode_id vnid);
-vnode_id dlist_find(nspace *vol, uint32 cluster);
-
-void dlist_dump(nspace *vol);
-
-#endif
diff --git a/src/tests/add-ons/kernel/file_systems/dos/r5/dosfs.c 
b/src/tests/add-ons/kernel/file_systems/dos/r5/dosfs.c
deleted file mode 100644
index f08da2345c..0000000000
--- a/src/tests/add-ons/kernel/file_systems/dos/r5/dosfs.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
-       Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
-       This file may be used under the terms of the Be Sample Code License.
-*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <time.h>
-
-#include <KernelExport.h>
-#include <Drivers.h>
-#include <driver_settings.h>
-
-#include <scsi.h>
-
-#include <fsproto.h>
-#ifndef COMPILE_IN_BEOS
-#include <fs_volume.h>
-#endif
-#include <lock.h>
-#include <cache.h>
-
-#include "dosfs.h"
-#include "attr.h"
-#include "dir.h"
-#include "dlist.h"
-#include "fat.h"
-#include "file.h"
-#include "iter.h"
-#include "util.h"
-#include "vcache.h"
-
-extern const char *build_time, *build_date;
-
-/* debug levels */
-int debug_attr = 0, debug_dir = 0, debug_dlist = 0, debug_dosfs = 0,
-               debug_encodings = 0, debug_fat = 0, debug_file = 0,
-               debug_iter = 0, debug_vcache = 0;
-
-#define DPRINTF(a,b) if (debug_dosfs > (a)) dprintf b
-
-CHECK_MAGIC(vnode,struct vnode,VNODE_MAGIC)
-CHECK_MAGIC(nspace,struct _nspace, NSPACE_MAGIC)
-
-static status_t get_fsinfo(nspace *vol, uint32 *free_count, uint32 
*last_allocated);
-
-#if DEBUG
-
-int32 instances = 0;
-
-int debug_dos(int argc, char **argv)
-{
-       int i;
-       for (i=1;i<argc;i++) {
-               nspace *vol = (nspace *)strtoul(argv[i], NULL, 0);
-               if (vol == NULL)
-                       continue;
-
-               kprintf("dos nspace @ %p\n", vol);
-               kprintf("magic: %lx\n", vol->magic);
-               kprintf("id: %lx, fd: %x, device: %s, flags %lx\n",
-                               vol->id, vol->fd, vol->device, vol->flags);
-               kprintf("bytes/sector = %lx, sectors/cluster = %lx, reserved 
sectors = %lx\n",
-                               vol->bytes_per_sector, vol->sectors_per_cluster,
-                               vol->reserved_sectors);
-               kprintf("%lx fats, %lx root entries, %lx total sectors, %lx 
sectors/fat\n",
-                               vol->fat_count, vol->root_entries_count, 
vol->total_sectors,
-                               vol->sectors_per_fat);
-               kprintf("media descriptor %x, fsinfo sector %x, %lx clusters, 
%lx free\n",
-                               vol->media_descriptor, vol->fsinfo_sector, 
vol->total_clusters,
-                               vol->free_clusters);
-               kprintf("%x-bit fat, mirrored %x, active %x\n",
-                               vol->fat_bits, vol->fat_mirrored, 
vol->active_fat);
-               kprintf("root start %lx, %lx root sectors, root vnode @ %p\n",
-                               vol->root_start, vol->root_sectors, 
&(vol->root_vnode));
-               kprintf("label entry %lx, label %s\n", vol->vol_entry, 
vol->vol_label);
-               kprintf("data start %lx, last allocated %lx\n",
-                               vol->data_start, vol->last_allocated);
-               kprintf("last fake vnid %Lx, vnid cache %lx entries @ (%p 
%p)\n",
-                               vol->vcache.cur_vnid, vol->vcache.cache_size,
-                               vol->vcache.by_vnid, vol->vcache.by_loc);
-               kprintf("dlist entries: %lx/%lx @ %p\n",
-                               vol->dlist.entries, vol->dlist.allocated, 
vol->dlist.vnid_list);
-       }
-       return B_OK;
-}
-
-int debug_dvnode(int argc, char **argv)
-{
-       int i;
-
-       if (argc < 2) {
-               kprintf("dvnode vnode\n");
-               return B_OK;
-       }
-
-       for (i=1;i<argc;i++) {
-               vnode *n = (vnode *)strtoul(argv[i], NULL, 0);
-               if (!n) continue;
-
-               kprintf("vnode @ %p", n);
-#if TRACK_FILENAME
-               kprintf(" (%s)", n->filename);
-#endif
-               kprintf("\nmagic %lx, vnid %Lx, dir vnid %Lx\n",
-                               n->magic, n->vnid, n->dir_vnid);
-               kprintf("iteration %lx, si=%lx, ei=%lx, cluster=%lx\n",
-                               n->iteration, n->sindex, n->eindex, n->cluster);
-               kprintf("mode %lx, size %Lx, time %lx\n",
-                               n->mode, n->st_size, n->st_time);
-               kprintf("end cluster = %lx\n", n->end_cluster);
-               if (n->mime) kprintf("mime type %s\n", n->mime);
-       }
-
-       return B_OK;
-}
-
-int debug_dc2s(int argc, char **argv)
-{
-       int i;
-       nspace *vol;
-
-       if (argc < 3) {
-               kprintf("dc2s nspace cluster\n");
-               return B_OK;
-       }
-
-       vol = (nspace *)strtoul(argv[1], NULL, 0);
-       if (vol == NULL)
-               return B_OK;
-
-       for (i=2;i<argc;i++) {
-               uint32 cluster = strtoul(argv[i], NULL, 0);
-               kprintf("cluster %lx = block %Lx\n", cluster, vol->data_start +
-                               (off_t)(cluster - 2) * 
vol->sectors_per_cluster);
-       }
-
-       return B_OK;
-}
-
-#endif
-
-static int lock_removable_device(int fd, bool state)
-{
-       return ioctl(fd, B_SCSI_PREVENT_ALLOW, &state, sizeof(state));
-}
-
-static status_t mount_fat_disk(const char *path, nspace_id nsid,
-               const int flags, nspace** newVol, int fs_flags, int 
op_sync_mode)
-{
-       nspace          *vol = NULL;
-       uint8           buf[512];
-       int                     i;
-       device_geometry geo;
-       status_t err;
-
-       *newVol = NULL;
-       if ((vol = (nspace*)calloc(sizeof(nspace), 1)) == NULL) {
-               dprintf("dosfs error: out of memory\n");
-               return ENOMEM;
-       }
-       
-       vol->magic = NSPACE_MAGIC;
-       vol->flags = B_FS_IS_PERSISTENT | B_FS_HAS_MIME;
-       vol->fs_flags = fs_flags;
-
-       // open read-only for now
-       if ((err = (vol->fd = open(path, O_RDONLY))) < 0) {
-               dprintf("dosfs: unable to open %s (%s)\n", path, strerror(err));
-               goto error0;
-       }
-       
-       // get device characteristics
-       if (ioctl(vol->fd, B_GET_GEOMETRY, &geo) < 0) {
-               struct stat st;
-               if ((fstat(vol->fd, &st) >= 0) &&
-                   S_ISREG(st.st_mode)) {
-                       /* support mounting disk images */
-                       geo.bytes_per_sector = 0x200;
-                       geo.sectors_per_track = 1;
-                       geo.cylinder_count = st.st_size / 0x200;
-                       geo.head_count = 1;
-                       geo.read_only = !(st.st_mode & S_IWUSR);
-                       geo.removable = true;
-               } else {
-                       dprintf("dosfs: error getting device geometry\n");
-                       goto error0;
-               }
-       }
-       if ((geo.bytes_per_sector != 0x200) && (geo.bytes_per_sector != 0x400) 
&& (geo.bytes_per_sector != 0x800)) {
-               dprintf("dosfs: unsupported device block size (%lu)\n", 
geo.bytes_per_sector);
-               goto error0;
-       }
-       if (geo.removable) {
-               DPRINTF(0, ("%s is removable\n", path));
-               vol->flags |= B_FS_IS_REMOVABLE;
-       }
-       if (geo.read_only || (flags & B_MOUNT_READ_ONLY)) {
-               DPRINTF(0, ("%s is read-only\n", path));
-               vol->flags |= B_FS_IS_READONLY;
-       } else {
-               // reopen it with read/write permissions
-               close(vol->fd);
-               if ((err = (vol->fd = open(path, O_RDWR))) < 0) {
-                       dprintf("dosfs: unable to open %s (%s)\n", path, 
strerror(err));
-                       goto error0;
-               }
-               if ((vol->flags & B_FS_IS_REMOVABLE) && (vol->fs_flags & 
FS_FLAGS_LOCK_DOOR))
-                       lock_removable_device(vol->fd, true);
-       }
-
-       // see if we need to go into op sync mode
-       vol->fs_flags &= ~FS_FLAGS_OP_SYNC;
-       switch(op_sync_mode) {
-               case 1:
-                       if((vol->flags & B_FS_IS_REMOVABLE) == 0) {
-                               // we're not removable, so skip op_sync
-                               break;
-                       }
-               case 2:
-                       dprintf("dosfs: mounted with op_sync enabled\n");
-                       vol->fs_flags |= FS_FLAGS_OP_SYNC;
-                       break;
-               case 0:
-               default:
-                       ;
-       }
-
-       // read in the boot sector
-       if ((err = read_pos(vol->fd, 0, (void*)buf, 512)) != 512) {
-               dprintf("dosfs: error reading boot sector\n");
-               goto error;
-       }
-
-       // only check boot signature on hard disks to account for broken mtools
-       // behavior
-       if (((buf[0x1fe] != 0x55) || (buf[0x1ff] != 0xaa)) && (buf[0x15] == 
0xf8))
-               goto error;
-
-       if (!memcmp(buf+3, "NTFS    ", 8) || !memcmp(buf+3, "HPFS    ", 8)) {
-               dprintf("%4.4s, not FAT\n", buf+3);
-               goto error;
-       }
-
-       // first fill in the universal fields from the bpb
-       vol->bytes_per_sector = read16(buf,0xb);
-       if ((vol->bytes_per_sector != 0x200) && (vol->bytes_per_sector != 
0x400) && (vol->bytes_per_sector != 0x800)) {
-               dprintf("dosfs error: unsupported bytes per sector (%lu)\n",
-                               vol->bytes_per_sector);
-               goto error;
-       }
-       
-       vol->sectors_per_cluster = i = buf[0xd];
-       if ((i != 1) && (i != 2) && (i != 4) && (i != 8) && 
-               (i != 0x10) && (i != 0x20) && (i != 0x40) && (i != 0x80)) {
-               dprintf("dosfs: sectors/cluster = %d\n", i);
-               goto error;
-       }
-
-       vol->reserved_sectors = read16(buf,0xe);
-
-       vol->fat_count = buf[0x10];
-       if ((vol->fat_count == 0) || (vol->fat_count > 8)) {
-               dprintf("dosfs: unreasonable fat count (%lu)\n", 
vol->fat_count);
-               goto error;
-       }
-
-       vol->media_descriptor = buf[0x15];
-       // check media descriptor versus known types
-       if ((buf[0x15] != 0xF0) && (buf[0x15] < 0xf8)) {
-               dprintf("dosfs error: invalid media descriptor byte\n");
-               goto error;
-       }
-       
-       vol->vol_entry = -2;    // for now, assume there is no volume entry
-       memset(vol->vol_label, ' ', 11);
-
-       // now become more discerning citizens
-       vol->sectors_per_fat = read16(buf,0x16);
-       if (vol->sectors_per_fat == 0) {
-               // fat32 land
-               vol->fat_bits = 32;
-               vol->sectors_per_fat = read32(buf,0x24);
-               vol->total_sectors = read32(buf,0x20);
-               
-               vol->fsinfo_sector = read16(buf, 0x30);
-               if ((vol->fsinfo_sector != 0xffff) && (vol->fsinfo_sector >= 
vol->reserved_sectors)) {
-                       dprintf("dosfs: fsinfo sector too large (%x)\n", 
vol->fsinfo_sector);
-                       goto error;
-               }
-
-               vol->fat_mirrored = !(buf[0x28] & 0x80);
-               vol->active_fat = (vol->fat_mirrored) ? (buf[0x28] & 0xf) : 0;
-
-               vol->data_start = vol->reserved_sectors + 
vol->fat_count*vol->sectors_per_fat;
-               vol->total_clusters = (vol->total_sectors - vol->data_start) / 
vol->sectors_per_cluster;
-
-               vol->root_vnode.cluster = read32(buf,0x2c);
-               if (vol->root_vnode.cluster >= vol->total_clusters) {
-                       dprintf("dosfs: root vnode cluster too large (%lx)\n", 
vol->root_vnode.cluster);
-                       goto error;
-               }
-       } else {
-               // fat12 & fat16
-               if (vol->fat_count != 2) {
-                       dprintf("dosfs error: claims %ld fat tables\n", 
vol->fat_count);
-                       goto error;
-               }
-
-               vol->root_entries_count = read16(buf,0x11);
-               if (vol->root_entries_count % (vol->bytes_per_sector / 0x20)) {
-                       dprintf("dosfs error: invalid number of root 
entries\n");
-                       goto error;
-               }
-
-               vol->fsinfo_sector = 0xffff;
-               vol->total_sectors = read16(buf,0x13); // partition size
-               if (vol->total_sectors == 0)
-                       vol->total_sectors = read32(buf,0x20);
-
-               {
-                       /*
-                         Zip disks that were formatted at iomega have an 
incorrect number
-                         of sectors.  They say that they have 196576 sectors 
but they
-                         really only have 196192.  This check is a work-around 
for their
-                         brain-deadness.
-                       */  
-                       unsigned char bogus_zip_data[] = {
-                               0x00, 0x02, 0x04, 0x01, 0x00, 0x02, 0x00, 0x02, 
0x00, 0x00,
-                               0xf8, 0xc0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x20, 
0x00, 0x00
-                       };
-                       
-                       if (memcmp(buf+0x0b, bogus_zip_data, 
sizeof(bogus_zip_data)) == 0 &&
-                               vol->total_sectors == 196576 &&
-                               ((off_t)geo.sectors_per_track *
-                                (off_t)geo.cylinder_count *
-                                (off_t)geo.head_count) == 196192) {
-
-                               vol->total_sectors = 196192;
-                       }
-               }
-
-
-               if (buf[0x26] == 0x29) {
-                       // fill in the volume label
-                       if (memcmp(buf+0x2b, "           ", 11)) {
-                               memcpy(vol->vol_label, buf+0x2b, 11);
-                               vol->vol_entry = -1;
-                       }
-               }
-
-               vol->fat_mirrored = true;
-               vol->active_fat = 0;
-
-               vol->root_start = vol->reserved_sectors + vol->fat_count * 
vol->sectors_per_fat;
-               vol->root_sectors = vol->root_entries_count * 0x20 / 
vol->bytes_per_sector;
-               vol->root_vnode.cluster = 1;
-               vol->root_vnode.end_cluster = 1;
-               vol->root_vnode.st_size = vol->root_sectors * 
vol->bytes_per_sector;
-
-               vol->data_start = vol->root_start + vol->root_sectors;
-               vol->total_clusters = (vol->total_sectors - vol->data_start) / 
vol->sectors_per_cluster;        
-               
-               // XXX: uncertain about border cases; win32 sdk says cutoffs 
are at
-               //      at ff6/ff7 (or fff6/fff7), but that doesn't make much 
sense
-               if (vol->total_clusters > 0xff1)
-                       vol->fat_bits = 16;
-               else
-                       vol->fat_bits = 12;
-       }
-
-       /* check that the partition is large enough to contain the file system 
*/
-       if (vol->total_sectors > geo.sectors_per_track * geo.cylinder_count *
-                       geo.head_count) {
-               dprintf("dosfs: volume extends past end of partition\n");
-               err = B_PARTITION_TOO_SMALL;
-               goto error;
-       }
-
-       // perform sanity checks on the FAT
-               
-       // the media descriptor in active FAT should match the one in the BPB
-       if ((err = read_pos(vol->fd, 
vol->bytes_per_sector*(vol->reserved_sectors + vol->active_fat * 
vol->sectors_per_fat), (void *)buf, 0x200)) != 0x200) {
-               dprintf("dosfs: error reading FAT\n");
-               goto error;
-       }
-
-       if (buf[0] != vol->media_descriptor) {
-               dprintf("dosfs error: media descriptor mismatch (%x != %x)\n", 
buf[0], vol->media_descriptor);
-               goto error;
-       }
-
-       if (vol->fat_mirrored) {
-               uint32 i;
-               uint8 buf2[512];
-               for (i=0;i<vol->fat_count;i++) {
-                       if (i != vol->active_fat) {
-                               DPRINTF(1, ("checking fat #%ld\n", i));
-                               buf2[0] = ~buf[0];
-                               if ((err = read_pos(vol->fd, 
vol->bytes_per_sector*(vol->reserved_sectors + vol->sectors_per_fat*i), (void 
*)buf2, 0x200)) != 0x200) {
-                                       dprintf("dosfs: error reading FAT 
%ld\n", i);
-                                       goto error;
-                               }
-
-                               if (buf2[0] != vol->media_descriptor) {
-                                       dprintf("dosfs error: media descriptor 
mismatch in fat # %ld (%x != %x)\n", i, buf2[0], vol->media_descriptor);
-                                       goto error;
-                               }
-#if 0                  
-                               // checking for exact matches of fats is too
-                               // restrictive; allow these to go through in
-                               // case the fat is corrupted for some reason
-                               if (memcmp(buf, buf2, 0x200)) {
-                                       dprintf("dosfs error: fat %d doesn't 
match active fat (%d)\n", i, vol->active_fat);
-                                       goto error;
-                               }
-#endif
-                       }
-               }
-       }
-
-       // now we are convinced of the drive's validity
-
-       vol->id = nsid;
-       strncpy(vol->device,path,256);
-
-       // this will be updated later if fsinfo exists
-       vol->last_allocated = 2;
-
-       vol->beos_vnid = INVALID_VNID_BITS_MASK;
-       {
-               void *handle;
-               handle = load_driver_settings("dos");
-               vol->respect_disk_image =
-                               get_driver_boolean_parameter(handle, "respect", 
true, true);
-               unload_driver_settings(handle);
-       }
-
-       // initialize block cache
-       if (init_cache_for_device(vol->fd, (off_t)vol->total_sectors) < 0) {
-               dprintf("error initializing block cache\n");
-               goto error;
-       }
-       
-       // as well as the vnode cache
-       if (init_vcache(vol) != B_OK) {
-               dprintf("error initializing vnode cache\n");
-               goto error1;
-       }
-
-       // and the dlist cache
-       if (dlist_init(vol) != B_OK) {
-               dprintf("error initializing dlist cache\n");
-               goto error2;
-       }
-
-       if (vol->flags & B_FS_IS_READONLY)
-               vol->free_clusters = 0;
-       else {
-               uint32 free_count, last_allocated;
-               err = get_fsinfo(vol, &free_count, &last_allocated);
-               if (err >= 0) {
-                       if (free_count < vol->total_clusters) 
-                               vol->free_clusters = free_count;
-                       else {
-                               dprintf("free cluster count from fsinfo block 
invalid %lx\n", free_count);
-                               err = -1;
-                       }
-                       if (last_allocated < vol->total_clusters) 
-                               vol->last_allocated = last_allocated; //update 
to a closer match
-               }
-               if (err < 0) {
-                       if ((err = count_free_clusters(vol)) < 0) {
-                               dprintf("error counting free clusters (%s)\n", 
strerror(err));
-                               goto error3;
-                       }
-                       vol->free_clusters = err;
-               }
-       }
-
-       DPRINTF(0, ("built at %s on %s\n", build_time, build_date));
-       DPRINTF(0, ("mounting %s (id %lx, device %x, media descriptor %x)\n", 
vol->device, vol->id, vol->fd, vol->media_descriptor));
-       DPRINTF(0, ("%lx bytes/sector, %lx sectors/cluster\n", 
vol->bytes_per_sector, vol->sectors_per_cluster));
-       DPRINTF(0, ("%lx reserved sectors, %lx total sectors\n", 
vol->reserved_sectors, vol->total_sectors));
-       DPRINTF(0, ("%lx %d-bit fats, %lx sectors/fat, %lx root entries\n", 
vol->fat_count, vol->fat_bits, vol->sectors_per_fat, vol->root_entries_count));
-       DPRINTF(0, ("root directory starts at sector %lx (cluster %lx), data at 
sector %lx\n", vol->root_start, vol->root_vnode.cluster, vol->data_start));
-       DPRINTF(0, ("%lx total clusters, %lx free\n", vol->total_clusters, 
vol->free_clusters));
-       DPRINTF(0, ("fat mirroring is %s, fs info sector at sector %x\n", 
(vol->fat_mirrored) ? "on" : "off", vol->fsinfo_sector));
-       DPRINTF(0, ("last allocated cluster = %lx\n", vol->last_allocated));
-
-       if (vol->fat_bits == 32) {
-               // now that the block cache has been initialised, we can figure
-               // out the length of the root directory with count_clusters()
-               vol->root_vnode.st_size = count_clusters(vol, 
vol->root_vnode.cluster) * vol->bytes_per_sector * vol->sectors_per_cluster;
-               vol->root_vnode.end_cluster = get_nth_fat_entry(vol, 
vol->root_vnode.cluster, vol->root_vnode.st_size / vol->bytes_per_sector / 
vol->sectors_per_cluster - 1);
-       }
-
-       // initialize root vnode
-       vol->root_vnode.magic = VNODE_MAGIC;
-       vol->root_vnode.vnid = vol->root_vnode.dir_vnid = 
GENERATE_DIR_CLUSTER_VNID(vol->root_vnode.cluster,vol->root_vnode.cluster);
-       vol->root_vnode.sindex = vol->root_vnode.eindex = 0xffffffff;
-       vol->root_vnode.mode = FAT_SUBDIR;
-       time(&(vol->root_vnode.st_time));
-       vol->root_vnode.mime = NULL;
-       vol->root_vnode.dirty = false;
-       dlist_add(vol, vol->root_vnode.vnid);
-
-       // find volume label (supercedes any label in the bpb)
-       {
-               struct diri diri;
-               uint8 *buffer;
-               buffer = diri_init(vol, vol->root_vnode.cluster, 0, &diri);
-               for (;buffer;buffer=diri_next_entry(&diri)) {
-                       if ((buffer[0x0b] & FAT_VOLUME) && (buffer[0x0b] != 
0xf) && (buffer[0] != 0xe5)) {
-                               vol->vol_entry = diri.current_index;
-                               memcpy(vol->vol_label, buffer, 11);
-                               break;
-                       }
-               }
-               diri_free(&diri);
-       }
-
-       DPRINTF(0, ("root vnode id = %Lx\n", vol->root_vnode.vnid));
-       DPRINTF(0, ("volume label [%11.11s] (%lx)\n", vol->vol_label, 
vol->vol_entry));
-
-       // steal a trick from bfs
-       if (!memcmp(vol->vol_label, "__RO__     ", 11)) {
-               vol->flags |= B_FS_IS_READONLY;
-       }
-       
-       *newVol = vol;
-       return B_NO_ERROR;
-
-error3:
-       dlist_uninit(vol);
-error2:
-       uninit_vcache(vol);
-error1:
-       remove_cached_device_blocks(vol->fd, NO_WRITES);
-error:
-       if (!(vol->flags & B_FS_IS_READONLY) && (vol->flags & 
B_FS_IS_REMOVABLE) && (vol->fs_flags & FS_FLAGS_LOCK_DOOR))
-               lock_removable_device(vol->fd, false);
-error0:
-       close(vol->fd);
-       free(vol);
-       return (err >= B_NO_ERROR) ? EINVAL : err;
-}

[ *** diff truncated: 6114 lines dropped *** ]


############################################################################

Commit:      87b501a1195991749a54f01f7f71a9f138115cbf
URL:         https://git.haiku-os.org/haiku/commit/?id=87b501a11959
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 02:47:27 2018 UTC

tests/udf: Remove the "R5" version.

Largely untouched since 2006.

----------------------------------------------------------------------------

############################################################################

Commit:      38fa917c592bb4726d10f7d8bd9c3a7ce01de62f
URL:         https://git.haiku-os.org/haiku/commit/?id=38fa917c592b
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 03:04:38 2018 UTC

iso9660_shell: Use the fs_shell from src/tools; fix the build.

----------------------------------------------------------------------------

############################################################################

Commit:      52de96da042674000982858a0a3f3bb0054ba666
URL:         https://git.haiku-os.org/haiku/commit/?id=52de96da0426
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 03:16:04 2018 UTC

udf_shell: Rework to use the fs_shell in tools/.

The build appears to have been broken for quite a long time, but this
gets it slightly closer at least.

----------------------------------------------------------------------------

############################################################################

Commit:      e3db3bf84ea4934807e4104d20c3c39aeb8fe1df
URL:         https://git.haiku-os.org/haiku/commit/?id=e3db3bf84ea4
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 03:21:14 2018 UTC

btrfs_shell: Move from src/tools to src/tests/...

src/tools is for tools used in the build or other miscellaneous utilites
that go along with Haiku itself. btrfs is, at least for now, just another
filesystem addon, so its shell should live here with all the others.
No functional change intended.

----------------------------------------------------------------------------

############################################################################

Commit:      38c59f297107a8917c179bcaacd4a7690bced0ce
URL:         https://git.haiku-os.org/haiku/commit/?id=38c59f297107
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 03:37:18 2018 UTC

tests/device_manager: Remove dependence on fs_shell.

Doesn't build currently due to KPath API changes, but this seems unneeded
at least.

----------------------------------------------------------------------------

############################################################################

Revision:    hrev52213
Commit:      0f36120d8dc438596a6040c8a1b636116fcfff67
URL:         https://git.haiku-os.org/haiku/commit/?id=0f36120d8dc4
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Aug 13 03:38:10 2018 UTC

"R5" fs_shell: Remove (mostly.)

Two files remain: "argv.c" and "argv.h", as these are still used by some
other, non-FS-related tests.

This was one of the last significant chunks of "no commercial use" code
in the tree, as it originally came from the "Filesystem Construction Kit,"
the sample code distributed with "Practical Filesystem Design with the Be FS",
and contained a sigifincant amount of BeOS kernel filesystem code in it
(the original README, not preserved here, noted that "the cache code is
the real Release 4 BeOS disk cache code".)

It has long been replaced by Ingo's from-scratch, MIT-licensed fs_shell
that lives in src/tools/fs_shell. Perhaps a note should be made somewhere
of this code's prior existence, but I don't think we will have much use for
it again, so confined to the dustbin of Git history it shall be.

----------------------------------------------------------------------------


Other related posts:

  • » [haiku-commits] haiku: hrev52213 - in src/tests/add-ons/kernel/file_systems: fs_shell dos/r5 udf/r5 - waddlesplash