\section{Programming Interfaces}
\label{interface}

The programming interface of the MacFS library is referred to as the
{\em m} interface.  This interface uses only MHFS concepts.  For
example, a file or folder is named by the mount record of the volume
it is on, the catalog record of its parent folder, and its name.  In
some cases only the ID of the name is used.  This is because the parent
of the root folder has no catalog record, only a canonical ID.  

The API of the user level library we built using MacFS is referred to
as the {\em mac} API.  This interface mimics the Unix open/read/write/close
interface.  A file or folder is named by the mount record of the volume
it is on, and an absolute pathname.  Both interfaces are detailed in
table \ref{APItable}.

\begin{table}
\begin{center}
\begin{tabular}{||l|l||} \hline
{\em m} Function & {\em mac} Function \\ \hline
mmount(pn,mr)(user), mmount(vnode,mr)(VFS)& macmount(pn,mr)(user) \\
munmount(mr) & macunmount(mr) \\
mcreatefile(mr, pcr, fn, cr) & maccreatefile(mr, pn, mo, mf) \\ 
mcreatefolder(mr, pcr, fn, cr) & maccreatefolder(mr, pn) \\ 
mmove(mr, old pcr, old fn, cr, new pcr, new fn) & 
   macmove(mr, old pn, new pn) \\
mmovefile(mr, old pcr, old fn, cr, new pcr, new fn) & no equivalent \\
mmovefolder(mr, old pcr, old fn, cr, new pcr, new fn) & no equivalent \\
mdeletefile(mr, pcr, fn, cr) & macdeletefile(mr, pn) \\
mdeletefolder(mr, pcr, fn, cr) & macdeletefolder(mr, pn) \\
various functions & macgetfinderinfo(mf, field1, field2) \\
various functions & macsetfinderinfo(mf, field1, field2) \\
mopen(mr, pid, fn, cr) & macopen(mr, pn, mo, mf) \\
mclose(mr, pid, fn, cr) & macclose(mf) \\
no equivalent & macseek(mf, offset, whence) \\
mread(mr, cr, offset, numbytes, buf, actual) & 
  macread(mf, numbytes, buf, actual) \\
mwrite(mr, cr, offset, numbytes, buf, actual) & 
   macwrite(mf, numbytes, buf, actual) \\
mgrowfile(mr,cr,newsize) & no equivalent \\
mtruncatefile(mr, cr, newsize) & no equivalent \\
mdirentries(mr, pid, cr list) & macdirentries(mr, pid, cr list) \\
\hline
\end{tabular} 
\end{center}
\caption{MacFS Programming Interface ({\em m} functions) and 
  MacFS User Level API ({\em mac} functions). \ The following
abbreviations are used: [p]cr=[parent] catalog record, fn=file or
folder name, mf=user level file handle, mo=mode options, mr=mount
record, pid=parent ID, pn=pathname.}
\label{APItable}
\end{table}





