\documentclass[a4paper, 12pt, openright, english]{scrbook}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{listings}
\usepackage{xcolor}
\usepackage[
  pdftitle={StupidFS},
  pdfauthor={\@author},
]{hyperref}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}

\date{\today}
\title{%
	StupidFS Algorithm \& Data Structure \\
	\large 1st Edition}
\author{d0p1}

\lowertitleback{Copyright \copyright{} 2022 d0p1
    \medskip\\
    \begin{tabular}{lp{.8\textwidth}}
        \raisebox{-12pt}{\includegraphics[height=18pt]{fig/gfdl}} &
        Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. \\
    \end{tabular}
}

\begin{document}
	\frontmatter
	
	\maketitle
	\tableofcontents

	\mainmatter

	\chapter{Magic Numbers}

	\begin{center}
		\begin{tabular}{ |c|c|c|c| } 
 			\hline
 			\textbf{Flag} & \textbf{Hexadecimal} & \textbf{ASCII} & \textbf{Data structure}  \\ 
			\hline
 			STPDFS\_SB\_MAGIC & 0x44505453 & STPD & Superblock \\ 
 			\hline
		\end{tabular}
	\end{center}

	\chapter{Structures}

	\section{Superblocks}

	\begin{lstlisting}[language=C]
struct stpdfs_sb {
	uint32_t magic;
	uint32_t isize;
	uint32_t fsize;
	uint32_t free[100];
	uint8_t nfree;
	uint8_t revision;
	uint8_t state;
	uint64_t time;
};
	\end{lstlisting}

	\section{INodes}

	\begin{lstlisting}[language=C]
struct inode {
	uint16_t mode;
	uint16_t nlink;
	uint16_t uid;
	uint16_t gid;
	uint16_t flags;
	uint32_t size;
	uint32_t zones[10];
	uint64_t actime;
	uint64_t modtime;
};
	\end{lstlisting}
	\appendix

\end{document}
