\documentclass[pdf]{prosper}
\usepackage[toc,highlight,linbit,notes,hlsections]{HA-prosper}

\title{Shadowfs}
\subtitle{A framework for LD\_PRELOAD filesystem wrappers}
\author{Clifford Wolf - www.clifford.at}

\DefaultTransition{Wipe}
\TitleSlideNav{FullScreen}
\NormalSlideNav{ShowBookmarks}
\LeftFoot{\href{http://www.clifford.at}{Clifford Wolf}, \today}
\RightFoot{\href{http://www.clifford.at/papers/2005/shadows/}{http://www.clifford.at/papers/2005/shadows/}}


\begin{document}

\maketitle

% ============================================================================

\tsectionandpart{Introduction}

\begin{slide}{Overview}
\begin{itemize}

\item shadowfs is a small framework for writing filesystem wrapper LD\_PRELOAD libraries.

\vspace*{.5cm}
\item three such libraries included in shadowfs:

\vspace*{.3cm}
\begin{itemize}

\item {\tt liblogfs} - a filesystem operations logger

\vspace*{.3cm}
\item {\tt libcowfs} - a copy-on-write translucent filesystem

\vspace*{.3cm}
\item {\tt libmmfs} (under construction) - a wrapper for simulating root permissions

\end{itemize}

\end{itemize}
\end{slide}

\begin{slide}{ROCK Linux}
\begin{itemize}

\item shadowfs has its roots in the ROCK Linux projects

\vspace*{.5cm}
\item liblogfs will replace the currently used flwrapper.so

\vspace*{.5cm}
\item libcowfs is used in the live CD target

\vspace*{.5cm}
\item libmmfs will be used for some advanced build methods

\end{itemize}
\end{slide}

\begin{slide}{Building shadowfs}
\begin{itemize}

\item Simply running "make" and "make install" should do the job

\vspace*{.5cm}
\item Maybe you need to adapt some settings in config.h:

\vspace*{.3cm}
\begin{itemize}

\item {\tt DEBUG, DEBUG\_386} - Enable internal debugging.

\vspace*{.3cm}
\item {\tt DLOPEN\_LIBC} - Try switching this option when you encounter troubles.

\vspace*{.3cm}
\item {\tt GLIBC\_IS\_UGLY} - Set this to {\tt 0} if you are not using glibc
(e.g. for dietlibc based systems).

\end{itemize}

\vspace*{.5cm}
\item Older binutils (i.e. the binutils debian package) screw up
at ``{\tt objcopy --keep-global-symbols=symbols.txt}''.

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{liblogfs}

\begin{slide}{Overview}
\begin{itemize}

\item This library monitors all file operations.

\vspace*{.5cm}
\item It is configured using environemt variables:

\vspace*{.3cm}
\begin{itemize}

\item {\tt LOGFS\_ROLOG} - the log file for read/execute operations

\vspace*{.3cm}
\item {\tt LOGFS\_RWLOG} - the log file for write operations

\end{itemize}

\vspace*{.5cm}
\item The logfiles must exist already when liblogfs is started.

\vspace*{.5cm}
\item The logfiles include the command tree and function which issued the
operation the the affected filename.

\vspace*{.5cm}
\item The command tree is terminated at the PID stored in {\tt LOGFS\_BASEPID}.
This environmant variable is set automatically by the first process.

\end{itemize}
\end{slide}

\begin{slide}{Usage scenarios}
\begin{itemize}

\item Debugging huge applications (faster than strace/ltrace)

\vspace*{.5cm}
\item Automatically create file lists for "make install".

\vspace*{.5cm}
\item Profiling which files (and packages) are used while performing a task
(e.g. when doing package selections for small distributions).

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{libcowfs}

\begin{slide}{Overview}
\begin{itemize}

\item This library creates a virtual 'translucent' filesystem.

\vspace*{.5cm}
\item The machanism uses a 'read-write' and a 'read-only' directory.

\vspace*{.5cm}
\item On default every subdir of the 'read-only' master is symlinked to the
'read-write' directory.

\vspace*{.5cm}
\item Whever a write on the 'read-write' directory is done, the symlink will
be replaced with a copy.

\vspace*{.5cm}
\item The directory paths are configured using the {\tt COWFS\_RO} and {\tt
COWFS\_RW} environment variables.

\end{itemize}
\end{slide}

\begin{slide}{Symlink Rationale}
\begin{itemize}

\item The symlink approach used here has many advantages:

\vspace*{.3cm}
\begin{itemize}

\item It is very clear what libcowfs is doing an how

\vspace*{.3cm}
\item Changes in the 'read-only' directory are visible and cause no harm
(important for NFS root environments).

\vspace*{.3cm}
\item Backing up changes or reverting to the original state is very easy.

\vspace*{.3cm}
\item Statically linked applications can still acces the filesystem and even
write after a previously done copy-on-write.

\end{itemize}

\end{itemize}
\end{slide}

\begin{slide}{The CWD hack}
\begin{itemize}

\item I is possible that a write operation must result in a chdir:

\vspace*{.3cm}
\begin{itemize}

\item Process X is in a deep subdirectory level which has not beed COWed yet.

\vspace*{.3cm}
\item The process tries to write to a file in this directory.

\vspace*{.3cm}
\item The file gets COWed. In order to do that, the directory is created on
the read-write filesystem and all files are symlinked. The target file of the
operation is copied.

\vspace*{.3cm}
\item Now process X is in the wrong directory.

\end{itemize}

\vspace*{.5cm}
\item In order to deal with this problem, libcowfs is changing the current
working directory in such cases.

\vspace*{.2cm}
\item It also can handle such a situation if a child process has triggered the
copy-on-write, but only when wait() is used to wait for the child process.

\end{itemize}
\end{slide}

\begin{slide}{Usage scenarios}
\begin{itemize}

\item Building Live-CDs

\vspace*{.5cm}
\item Building Root-NFS environments

\vspace*{.5cm}
\item Testing with ability to 'roll back' to the original state.

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{libmmfs}

\begin{slide}{Overview}
\begin{itemize}

\item libmmfs is the 'megamaniac' filesystem. It is not finished yet.

\vspace*{.5cm}
\item It allows a normal user to virtually change anything in the system.

\vspace*{.5cm}
\item Changes are written to a copy-on-write directory.

\vspace*{.5cm}
\item The copy-on-write data includes metadata such as userid an permissions.

\vspace*{.5cm}
\item It is not as stable as libcowfs because the symlink mechanism is not
possible here and so also read access must be rewritten.

\end{itemize}
\end{slide}

\begin{slide}{Usage scenarios}
\begin{itemize}

\item Building and testing software as normal users while making it look to
the application as if it would be installed system-wide.

\vspace*{.5cm}
\item For more advanced build and regression-test mehtods in ROCK Linux.

\end{itemize}
\end{slide}


% ============================================================================

\tsectionandpart{NFS Root (cowfs)}

\begin{slide}{Overview}
\begin{itemize}

\item An NFS server exports a full root filesystem and a minimalistic nfs
boot environment.

\vspace*{.3cm}
\item Both NFS exports are read-only. All local changes are written to the
workstations RAM.

\vspace*{.3cm}
\item The server config is the same for one of hundret workstations.

\vspace*{.3cm}
\item Optionally DHCP and TFTP servers may be used to PXE-boot the
workstations.

\vspace*{.3cm}
\item For the ease of administration the exported root filesystem may be
the distribution running on the NFS server.

\vspace*{.3cm}
\item A script ({\tt nfsroot.sh}) for such a setup is included in the shadowfs
sources.

\end{itemize}
\end{slide}

\begin{slide}{Using nfsroot.sh}
\begin{itemize}

\item A simple "make nfsroot" creates an {\tt nfsroot/} directory using
{\tt nfsroot.sh}.

\vspace*{.5cm}
\item The files from a user-supplied {\tt dot3/} directory are copied to {\tt
nfsroot/...} and are used by the workstations for various configurations.

\vspace*{.5cm}
\item The {\tt nfsroot/} directory must be used by the workstations as root
filesystem.

\vspace*{.3cm}
\item {\tt /} from the NFS server is automatically mounted at {\tt
/mnt/cowfs\_ro} on the workstations.

\vspace*{.3cm}
\item {\tt /home} is mounted read-write from the NFS server and is not COWed.

\end{itemize}
\end{slide}

\begin{slide}{Adapting nfsroot.sh}
\begin{itemize}

\item It might be neccassary to make some changes to {\tt nfsroot.sh} to
fitt you specific needs.

\vspace*{.5cm}
\item The script is pretty straight forward.

\vspace*{.5cm}
\item Re-running "make nfsroot" is possible without causing troubles with
already connected workstations.

\vspace*{.5cm}
\item Updating packages in the exported root filesystem is also possible
without much troubles.

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{Live CDs (cowfs)}

\begin{slide}{Implementing Live CDs}
\begin{itemize}

\item The 'usual' root filesystem data is moved to {\tt /mnt/cowfs\_ro}.

\vspace*{.3cm}
\item The {\tt /mnt/cowfs\_rw} directory just has symlinks to the entries
in {\tt /mnt/cowfs\_ro}.

\vspace*{.3cm}
\item The root directory just has symlinks to {\tt /mnt/cowfs\_rw}.

\vspace*{.3cm}
\item {\tt libcowfs.so} is loaded from {\tt /etc/ld.so.preload}.

\vspace*{.3cm}
\item Somewhere in the boot process (e.g. where usually {\tt /} is mounted
read-write), a tmpfs is created with the same content as {\tt /mnt/cowfs\_rw}
ans is moved (using {\tt mount --move}) over {\tt /mnt/cowfs\_rw}.

\vspace*{.3cm}
\item This is ver simmilar to what the init script created by {\tt nfsroot.sh}
does.

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{URLs and References}

\begin{slide}{URLs and References}
\begin{itemize}

\item The shadowfs sources: \\
http://svn.clifford.at/shadowfs/trunk/

\vspace*{.5cm}
\item ROCK Linux: \\
http://www.rocklinux.org/

\vspace*{.5cm}
\item Clifford Wolf: \\
http://www.clifford.at/

\vspace*{.5cm}
\item LINBIT Information Technologies \\
http://www.linbit.com/

\end{itemize}
\end{slide}

% ============================================================================

\end{document}

