StuBS
VFS Class Reference

Virtual File System - POSIX-ähnliche Dateisystem-Schnittstelle. More...

#include <fs/vfs.h>

Inheritance diagram for VFS:
[legend]
Collaboration diagram for VFS:
[legend]

Static Public Member Functions

static int mount (const char *fstype, BlockDevice *bdev, const void *data)
 Siehe man 2 mount.
 
static int umount ()
 Siehe man 2 umount.
 
static void sync ()
 Schreibt Änderungen im Puffer auf die Festplatte. Siehe man 2 sync.
 
static int open (const char *pathname, int flags)
 Öffnet und erstellt (je nach flags) Dateien. Siehe man 2 open.
 
static int close (int fd)
 Schließt einen Dateideskriptor. Siehe man 2 close.
 
static ssize_t read (int fd, void *buf, size_t count)
 Lesen von einem Dateideskriptor fd in Speicher buf der Länge count. Siehe man 2 read.
 
static ssize_t write (int fd, const void *buf, size_t count)
 Schreiben von Daten aus Speicher buf der Länge count an Dateideskriptor fd. Siehe man 2 write.
 
static off_t lseek (int fd, off_t offset, int whence)
 Ändert den aktuellen offset für Dateideskriptor fd. Siehe man 2 lseek.
 
static int truncate (const char *path, off_t length)
 Setzt die Länge der Datei an path auf length. Siehe man 2 truncate.
 
static int ftruncate (int fd, off_t length)
 Kürzt Datei für Dateideskriptor fd auf Länge length. Siehe man 2 ftruncate.
 
static int link (const char *oldpath, const char *newpath)
 Neuer Name newpath für Datei oldpath. Siehe man 2 link.
 
static int symlink (const char *target, const char *linkpath)
 Erstellt einen symbolischen Verweis mit Inhalt target. Siehe man 2 symlink.
 
static int unlink (const char *pathname)
 Löscht Namen und bei keinem verbleibenden Verweis mehr die Datei pathname. Siehe man 2 unlink.
 
static int rmdir (const char *pathname)
 Löscht Verzeichnis pathname. Siehe man 2 rmdir.
 
static int rename (const char *oldpath, const char *newpath)
 Verschieben von Dateien/Verzeichnissen. Siehe man 2 rename.
 
static int stat (const char *pathname, struct stat *statbuf)
 Liefert Dateistatus für pathname. Siehe man 2 stat.
 
static int lstat (const char *pathname, struct stat *statbuf)
 Liefert Dateistatus für pathname. Siehe man 2 lstat.
 
static int fstat (int fd, struct stat *statbuf)
 Liefert Dateistatus für Dateideskriptor fd. Siehe man 2 fstat.
 
static ssize_t readlink (const char *pathname, char *buf, size_t bufsiz)
 Liest den Inhalt eines symbolischen Verweises. Siehe man 2 readlink.
 
static int getdents (int fd, Dirent *dirp, int count)
 Liefert Verzeichniseinträge. Siehe man 2 getdents.
 
static DIRopendir (const char *name)
 Öffnet ein Verzeichnis name. Siehe man 3 opendir.
 
static struct Direntreaddir (DIR *dirp)
 Liest einen Verzeichniseintrag. Siehe man 3 readdir.
 
static void rewinddir (DIR *dirp)
 Setzt die Position im Verzeichnis zurück. Siehe man 3 rewinddir.
 
static int closedir (DIR *dirp)
 Schließt ein Verzeichnis. Siehe man 3 closedir.
 
static int mkdir (const char *pathname)
 Erstellt Verzeichnis pathname. Siehe man 2 mkdir.
 
static int chdir (const char *path)
 Wechselt in Verzeichnis path. Siehe man 2 chdir.
 
static int fchdir (int fd)
 Wechselt in Verzeichnis fd. Siehe man 2 fchdir.
 

Static Private Member Functions

static int pathwalk_step1 (struct path *path, const char *pathname, Inode *cwd)
 
static int pathwalk_step2 (struct path *path, int depth)
 
static Inodepathwalk_step3 (struct path *path, bool follow_symlink, int depth, int *error)
 
static int pathwalk_step12 (struct path *path, const char *pathname, Inode *cwd, int depth)
 
static Inodepathwalk_step23 (struct path *path, bool follow_final_symlink, int depth, int *error)
 
static Inodepathwalk_step123 (const char *pathname, Inode *cwd, bool follow_final_symlink, int depth, int *error)
 
static Inoderesolve_symlink (Inode *symlink, Inode *cur_dir, int depth, int *error)
 
static int stat (Inode *inode, struct stat *statbuf)
 
static int chdir (Inode *inode)
 
static int truncate (Inode *inode, off_t length)
 
static int sync_fs (Filesystem *fs)
 

Static Private Attributes

static Filesystemroot_fs = nullptr
 
static FD_Table fd_table
 
static Inodeglobal_cwd = nullptr
 

Detailed Description

Virtual File System - POSIX-ähnliche Dateisystem-Schnittstelle.

Alle Funktionen geben im Fehlerfall eine negative errno zurück.

Limitierungen: -Zeitstempel werden nie aktualisiert -Zugriffsrechte werden nie überprüft -setzt die UID und GID von neu erstellte Dateien auf 0 (root) -setzt die Zeitstempel von neu erstellen Dateien auf 0 (1.1.1970) -Dateideskriptoren und das aktuelle Arbeitsverzeichnis sind global

Member Function Documentation

◆ mount()

int VFS::mount ( const char *  fstype,
BlockDevice bdev,
const void *  data 
)
static

Siehe man 2 mount.

Limitierungen: -target (siehe manpage) ist immer "/". -es werden keine Flags unterstützt -an Stelle des source Strings wird ein BlockDevice übergeben

◆ umount()

int VFS::umount ( )
static

Siehe man 2 umount.

Gibt -EBUSY zurück, falls das Dateisystem noch verwendet wird (offene Dateien). Limitierungen: -target (siehe manpage) ist immer "/".

◆ sync()

void VFS::sync ( )
static

Schreibt Änderungen im Puffer auf die Festplatte. Siehe man 2 sync.

Zurzeit nur nötig, um Änderungen an Inodes zu schreiben.

◆ open()

int VFS::open ( const char *  pathname,
int  flags 
)
static

Öffnet und erstellt (je nach flags) Dateien. Siehe man 2 open.

Limitierungen: -mode ist immer 0777 -unterstützte Flags sind: O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL

◆ close()

int VFS::close ( int  fd)
static

Schließt einen Dateideskriptor. Siehe man 2 close.

Parameters
fdFiledeskriptor zum Schließen.

Es gelten die "NOTES" aus der manpage.

◆ read()

ssize_t VFS::read ( int  fd,
void *  buf,
size_t  count 
)
static

Lesen von einem Dateideskriptor fd in Speicher buf der Länge count. Siehe man 2 read.

◆ write()

ssize_t VFS::write ( int  fd,
const void *  buf,
size_t  count 
)
static

Schreiben von Daten aus Speicher buf der Länge count an Dateideskriptor fd. Siehe man 2 write.

◆ lseek()

off_t VFS::lseek ( int  fd,
off_t  offset,
int  whence 
)
static

Ändert den aktuellen offset für Dateideskriptor fd. Siehe man 2 lseek.

Unterstützt kein SEEK_DATA oder SEEK_HOLE. (Mit lseek(fd, 0, SEEK_END) lässt sich die Größe einer Datei herausfinden.)

◆ truncate() [1/2]

int VFS::truncate ( const char *  path,
off_t  length 
)
static

Setzt die Länge der Datei an path auf length. Siehe man 2 truncate.

◆ ftruncate()

int VFS::ftruncate ( int  fd,
off_t  length 
)
static

Kürzt Datei für Dateideskriptor fd auf Länge length. Siehe man 2 ftruncate.

◆ link()

int VFS::link ( const char *  oldpath,
const char *  newpath 
)
static

Neuer Name newpath für Datei oldpath. Siehe man 2 link.

Falls oldpath ein Symlink ist wird ein Hardlink auf den Symlink erstellt, nicht auf die Datei auf die der Symlink zeigt. (Selbes Verhalten wie Linux, siehe NOTES in der Manpage.)

◆ symlink()

int VFS::symlink ( const char *  target,
const char *  linkpath 
)
static

Erstellt einen symbolischen Verweis mit Inhalt target. Siehe man 2 symlink.

◆ unlink()

int VFS::unlink ( const char *  pathname)
static

Löscht Namen und bei keinem verbleibenden Verweis mehr die Datei pathname. Siehe man 2 unlink.

◆ rmdir()

int VFS::rmdir ( const char *  pathname)
static

Löscht Verzeichnis pathname. Siehe man 2 rmdir.

◆ rename()

int VFS::rename ( const char *  oldpath,
const char *  newpath 
)
static

Verschieben von Dateien/Verzeichnissen. Siehe man 2 rename.

◆ stat() [1/2]

int VFS::stat ( const char *  pathname,
struct stat statbuf 
)
static

Liefert Dateistatus für pathname. Siehe man 2 stat.

Limitierungen: -st_dev und st_rdev sind immer 0

◆ lstat()

int VFS::lstat ( const char *  pathname,
struct stat statbuf 
)
static

Liefert Dateistatus für pathname. Siehe man 2 lstat.

Es gelten dieselben Limitierungen wie für stat. Falls pathname ein Symlink ist liefert lstat im Gegensatz zu stat Informationen über den Symlink, nicht über die Datei auf die der Symlink zeigt.

◆ fstat()

int VFS::fstat ( int  fd,
struct stat statbuf 
)
static

Liefert Dateistatus für Dateideskriptor fd. Siehe man 2 fstat.

Es gelten dieselben Limitierungen wie für stat.

◆ readlink()

ssize_t VFS::readlink ( const char *  pathname,
char *  buf,
size_t  bufsiz 
)
static

Liest den Inhalt eines symbolischen Verweises. Siehe man 2 readlink.

Achtung: Der Buffer wird nicht null-terminiert.

◆ getdents()

int VFS::getdents ( int  fd,
Dirent dirp,
int  count 
)
static

Liefert Verzeichniseinträge. Siehe man 2 getdents.

Wird verwendet um readdir zu implementieren. Das Dirent struct ähnelt dem linux_dirent64 struct aus der manpage, allerdings sind d_ino und d_off nicht unbedingt 64-bit Werte. Limitierungen: -d_off ist immer 0

◆ opendir()

DIR * VFS::opendir ( const char *  name)
static

Öffnet ein Verzeichnis name. Siehe man 3 opendir.

◆ readdir()

Dirent * VFS::readdir ( DIR dirp)
static

Liest einen Verzeichniseintrag. Siehe man 3 readdir.

◆ rewinddir()

void VFS::rewinddir ( DIR dirp)
static

Setzt die Position im Verzeichnis zurück. Siehe man 3 rewinddir.

◆ closedir()

int VFS::closedir ( DIR dirp)
static

Schließt ein Verzeichnis. Siehe man 3 closedir.

◆ mkdir()

int VFS::mkdir ( const char *  pathname)
static

Erstellt Verzeichnis pathname. Siehe man 2 mkdir.

Limitierungen: -pathname darf nicht mit einem '/' enden.

◆ chdir() [1/2]

int VFS::chdir ( const char *  path)
static

Wechselt in Verzeichnis path. Siehe man 2 chdir.

◆ fchdir()

int VFS::fchdir ( int  fd)
static

Wechselt in Verzeichnis fd. Siehe man 2 fchdir.

◆ pathwalk_step1()

int VFS::pathwalk_step1 ( struct path path,
const char *  pathname,
Inode cwd 
)
staticprivate

◆ pathwalk_step2()

int VFS::pathwalk_step2 ( struct path path,
int  depth 
)
staticprivate

◆ pathwalk_step3()

Inode * VFS::pathwalk_step3 ( struct path path,
bool  follow_symlink,
int  depth,
int *  error 
)
staticprivate

◆ pathwalk_step12()

int VFS::pathwalk_step12 ( struct path path,
const char *  pathname,
Inode cwd,
int  depth 
)
inlinestaticprivate

◆ pathwalk_step23()

Inode * VFS::pathwalk_step23 ( struct path path,
bool  follow_final_symlink,
int  depth,
int *  error 
)
inlinestaticprivate

◆ pathwalk_step123()

Inode * VFS::pathwalk_step123 ( const char *  pathname,
Inode cwd,
bool  follow_final_symlink,
int  depth,
int *  error 
)
inlinestaticprivate

◆ resolve_symlink()

Inode * VFS::resolve_symlink ( Inode symlink,
Inode cur_dir,
int  depth,
int *  error 
)
inlinestaticprivate

◆ stat() [2/2]

int VFS::stat ( Inode inode,
struct stat statbuf 
)
staticprivate

◆ chdir() [2/2]

int VFS::chdir ( Inode inode)
staticprivate

◆ truncate() [2/2]

int VFS::truncate ( Inode inode,
off_t  length 
)
staticprivate

◆ sync_fs()

int VFS::sync_fs ( Filesystem fs)
staticprivate

Member Data Documentation

◆ root_fs

Filesystem * VFS::root_fs = nullptr
staticprivate

◆ fd_table

FD_Table VFS::fd_table
staticprivate

◆ global_cwd

Inode * VFS::global_cwd = nullptr
staticprivate

The documentation for this class was generated from the following files: