\documentstyle[10pt]{article}

\def\B{B-Tree}
\def\C{catalog \B}
\def\E{extents overflow \B}

\input{psfig}


\def\tm{$^{\scriptscriptstyle\tt TM}$}

% Formating commands
\setlength{\topmargin}{-0.3in}
\setlength{\textheight}{8.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textwidth}{6.5in}


% Title page
\title{MacFS -- A Portable Macintosh Filesystem for Mach}
\author{Jon C. R. Bennett \and  
        Peter A. Dinda  \and 
        George C. Necula \and 
        Morgan Price \\
 \\
School of Computer Science, Carnegie Mellon University \\
Pittsburgh, PA 15213-3891, U.S.A.
}

\begin{document}

\maketitle

\begin{abstract}

% ABSTRACT REDO
% Unix --> Mach 3.0 ???????

Driven by the need to transparently transfer data between Macintoshes
and Mach workstations, we have written a Macintosh filesystem for
Mach 3.0.  In addition, we have written a filesystem library which is
portable to a variety of operating systems and platforms.  We describe
the Macintosh filesystem and our implementation.  We point out the
advantages and disadvantages of the Macintosh filesystem design and
the difficulties encountered in making it re-enterant. In addition, we
compare the performance of our implementation to the FFS filesystem
and to the native Macintosh filesystem.

\end{abstract}

% INTRODUCTION
 
% SHRINK
\section{Introduction}
 
\subsection{Why a Macintosh Filesystem For Mach?}
 
Aside from IBM Compatibles, Apple Macintoshes are the most common
computers in the US. Apple has 10\% of the entire personal computer
market and a much larger share of the higher education market
\cite{PCWEEK}. Given this vast number of machines, transparent file
interchangeability between Macs and other computers has become
necessary.  However, although there has been some development of
utilities to access Mac filesystems from MS-DOS
\cite{MACETTE,MACSEE}, there has been surprisingly little work on making Mac
filesystems accessible from Unix, much less making them mountable. We are
aware of no existing mountable Mac filesystem for workstations.  Even systems such as
Mac Mach and Apple's own A/UX, which provide Macintosh emulation, do
not provide this feature \cite{MACMACH,AUX}.
 
Although Unix Appletalk client and server software exists \cite{CAP},
we feel that ``sneaker-net,'' using both Mac high-density floppies and external
SCSI hard disks, will remain commonplace.
 
Existing utilities to access Mac filesystems often destroy or fail to create
the per-file information which the Mac OS uses to simplify user
access to files. This results in the ``foreign file syndrome,'' where
files without this information require special handling and may
not be accessible to certain programs. Further, existing utilities
either ignore the resource portion of Mac files or destroy it,
wreaking havoc when those files are moved back to a Mac.  Finally,
today's Macintosh emulators, such as Executor \cite{EXECUTOR}, require
dedicating partitions or entire disks to the Mac filesystem, which wastes
space and is inconvenient.
 
 
% REPEAT
\subsection{Goals}
 
MacFS is a portable Macintosh Hierarchical Filesystem (MHFS) that
exports a complete programming interface.  We used this interface to
build a portable user level library for accessing Macintosh volumes
and a Unix VFS \cite{VNODE}, which allows Macintosh volumes to be mounted as if
they were native Unix volumes.  The MacFS interface is sufficient to
build installable filesystems for operating systems that support
foreign filesystems.  

Macintosh files have two sections, a data fork, which is akin to the
``stream of bytes'' definition of a Unix file, and a resource fork,
which is discussed in section \ref{description}.  Our first goal was
to permit access to the data forks of Macintosh files, while keeping
the resource fork constant. The user level library meets this goal by
exporting a set of calls that mimic the Unix I/O interface, while our
VFS directly supports standard Unix I/O calls.
 
Our second goal was to avoid the ``foreign file syndrome'' that often
occurs with when moving foreign files to the Mac or when moving a Mac
file through a foreign filesystem and back to the Mac.  We met this
goal by maintaining Finder information (see section \ref{description})
on existing files.  For files created under MacFS, we supply
appropriate default Finder information and provide a mechanism for
changing it.

%In addition,
%we will provide a mechanism to access the resource fork, so that
%specialized programs like Macintosh emulators will be able to use an
%MHFS volume even though it is mounted on the Unix tree. We expect
%performance on par with the native Macintosh for single user access to
%a file, and much better performance for multiprogrammed access.
 
% NEW AND IMPROVED!!
% section The Mac HFS
%   subsection Catalog Btree
%   subsection Extents
\input{MacHFS}

% NEW AND IMPROVED!! (Structure then btree and catalog)
% section MacFS software structure
%   subsection data types
%   subsection device io, partition & mounting
%   subsection btree
%   subsection btree SDI problems (MOVE?)
%   subsection catalog support
%   subsection file read/write
\input{softwarestruct}

%section MHFS Design vs MacFS Implementation
\input{sdi}

\section{MacFS Interface Support}
%   subsection Vnode interface support
\input{vnode}
%   subsection userlevel support
\input{userlevel}

\section{Implementation Evaluation}

  To evaluate MacFS, the issues of functionality and performance
must be addressed.  The user-level tests involved both floppies and a
70 MB SCSI disk; the VFS-level tests involved only the SCSI disk.

\subsection{Functionality testing}

  We used the Macintosh Finder and the Macintosh Norton Utilites 2.0
to test that disks modified by our user-level and VFS-level MacFS
implementations remain Macintosh compatible.  Although we are able to
copy any type of file, all new files created have the Finder Info of
text files.

\subsection{Performance}

  To test our performance, we created five simple benchmarks.

\begin{itemize}
\item Create: Create a large number of files, then delete them.

\item Write: Create, open, write, close, and delete one 5000000-file with
request sizes of 500, 5000, and 50000 bytes.

\item Overwrite: Overwrite and close one 5000000-byte file using the same
range of block sizes.

\item Read: Read one 5000000-byte file using the same range of block
and file sizes.

\end{itemize}

  Note that all reads and writes are sequential.  These benchmarks
were run on a IBM WDS280 disk on a Macintosh Powerbook 145B with a 25
MHz 68030 CPU and on a Rodime R03000T disk on a DECstation 5000/120
with a 24 MHz MIPS R3000 CPU.  On the Macintosh the benchmarks were
run using the native OS and filesystem, with APS SCSI driver 2.7.  On
the workstation we ran the benchmarks using the User-level calls and
Unix calls on a mounted filesystem.  All of these tests used a 1.5K
logical block size (the size produced by initializing the disk on a
Macintosh).  Finally, for a comparison with standard workstation
filesystems, we produced an FFS volume with a 4K logical block size on
the same disk and ran the same benchmarks.  Because the file systems
we are comparing do not have the same blocksize, and are not even
powers of 2, we chose an arbitrary log scale of request sizes instead
of the traditional powers of 2.

  In table \ref{Performance} we give the performance figures.  The
numbers for the Create test is in files per second; the numbers
for the Write, Overwrite, and Read test are in bytes per second.  The
difference between the Write and Overwrite tests is that the Write
test includes overhead for growing the size of a file.  The tests with
a request size of 50000 bytes were not run on the Macintosh because of
16-bit integer sizes.

\begin{table}
\begin{center}
\begin{tabular}[h]{|l|r||r|r|r||r|r|r||r|r|r|}
\hline
& \multicolumn{1}{c||}{}
& \multicolumn{3}{c||}{500 bytes/request}
& \multicolumn{3}{c||}{5000 bytes/request}
& \multicolumn{3}{c|}{50000 bytes/request} \\
\hline Platform & Create
& Write & Over. & Read
& Write & Over. & Read
& Write & Over. & Read \\
\hline Macintosh & 7.5
& 62500 & - & -
& 1428000 & - & -
& 1492537 & - & - \\
\hline Unix FFS & 230
& 25367 & 26539 & 83893
& 114635 & 121852 & 300000
& 513698 & 529100 & 666667 \\
\hline Unix MacFS & 
& 18212 & - & -
& 24107 & - & -
& - & - & - \\
\hline User level & 46.7
 & 89032 & 93310 & 246533
 & 170739 & 166962 & 461494
 & 233781 & 238521 & 577617 \\
\hline
\end{tabular}
\end{center}
\caption{MacFS Performance}
\label{Performance}
\end{table}

  There is an extra copy of data to handle I/O requests in the MacFS
VFS implementation.  We believe that this may be the source of the
poor performance of the VFS implementation relative to the user-level
library, but it is surprising.  There is an additional copy in both
MacFS implementations for the small block sizes.

  Also surprising is the poor relative performance of the
Macintosh on creating and deleting files.  This results from
disparately slow file creation time, and may relate to initializing
extra data for the Finder.

% RELATED WORK    KEEP
\section{Related Work}

  We are aware of no existing mountable Macintosh filesystems for
Unix. There are emulators that run the Macintosh operating system on
top of other operating systems \cite{AUX,MACMACH,EXECUTOR}; however as
far as we can determine, none of these allow Unix access to native Mac
filesystems.  In addition, we feel that requiring the user to run both
operating systems on one machine is a severe restriction.

  There are network solutions that permit a Unix workstation to act as
an Appleshare server to a network of Macintoshes \cite{CAP}.  In this
environment it is possible to copy a file from a Mac to the Unix
server's shared volumes, but Unix still cannot access a Mac hierarchy.
It also requires a network and a Macintosh.  Of course, FTP can be
used, but this again requires a network.

  There are several MS-DOS utilities \cite{MACSEE,MACETTE} that allow
read/write operations on Macintosh volumes but none have been
integrated with the native filesystem and thus they have the same
inconvenience as FTP.

  The implementors of the DOS filesystem for Mach 3.0 \cite{DOSFS}
have dealt with similar concerns about mapping foreign filesystem
semantics to Unix.

% section Future Work

\section{Conclusions and Future Work}

We have presented a portable Macintosh filesystem and described its
implementation.  MacFS provides access to the data forks of Macintosh
files and maintains and creates Finder information so that the ``foreign
file syndrome'' is avoided.  On top of MacFS, we have written a
user-level library that presents Unix-like functions for accessing
Macintosh volumes.  The library was used to implement a set of utility
programs to access Macintosh volumes.  We also created a VFS on top of
MacFS, which permits Macintosh volumes to be mounted on Unix systems.
Our performance measurements show that...

Performance tuning is our immediate concern.  Beyond this it should be
fairly easy to extend MacFS to provide access to the resource fork as
a ``stream of bytes.''  This is sufficient for Macintosh emulators,
which will provide a resource manager anyway.  We intend to implement
this in the near future.  A larger project is to implement a resource
manager within MacFS so that file resources could be accessed
individually, perhaps as files in their own right. We hope to write an
OS/2 installable filesystem based on MacFS.


% BIBLIOGRAPHY
\begin{thebibliography}{MacMach}
% By now MacMach is the longest label in the bibliography

%\input{biblio.tex}

\bibitem[Gulliver]{Gulliver} J. Swift. {\em Gulliver's Travels}, 
   New York Modern Library, 1950.

\bibitem[PCWeek]{PCWEEK} {\em PC Week}, Nov 16, 1992, p33.

\bibitem[Mac-Ette]{MACETTE} {\em MAC-ETTE}. A shareware 
   MS-DOS program for accessing MAC high-density floppies, Paul E.
   Thomson, 1992.

\bibitem[MacSee]{MACSEE} {\em MacSee 3.1}. A shareware MS Windows 
   program for reading and writing MAC HD floppies, Mac format CD ROMs,
   and Mac-formatted Syquest cartridges, REEVEsoft, 1993.

\bibitem[MacMach]{MACMACH} Several variants of Mach for the Macintosh exist,
   including the CMU project, and Mach Ten.

\bibitem[A/UX]{AUX} The Macintosh A/UX Operating System Release 3.0. 
   In {\em IEEE Computer}, 26(2):103--106, February 1993.

\bibitem[CAP]{CAP} {\em Columbia Appletalk Protocols for Unix}.  A
   freely dis\-tri\-butable Appleshare server for Unix, Columbia
University of New York.

\bibitem[Executor]{EXECUTOR} Executor. In {\em MacWeek}, September 24,
   1991, p16.  

\bibitem[IMF]{IM4} {\em Inside Macintosh: Files}, Apple Computer, 
   1992, p23--76.

\bibitem[DosFs]{DOSFS} A. Forin and G. Malan. {\em An MS-DOS
   Filesystem for Unix}. To appear in {\em Proceedings of the
   Winter 1994 USENIX Conference}, January 1994.   

\bibitem[Vnode]{VNODE} S.R. Kleiman. {\em Vnodes: An Architecture for
Multiple File System Types in Sun Unix} in {\em USENIX Association:
Summer Conference Proceedings}, Atlanta, 1986.

\end{thebibliography}

\end{document}
