FreeNOS
Public Member Functions | Private Member Functions | Private Attributes
LinnDirectory Class Reference

Represents an directory on a LinnFS filesystem. More...

#include <LinnDirectory.h>

Inheritance diagram for LinnDirectory:
Directory File

Public Member Functions

 LinnDirectory (LinnFileSystem *fs, const u32 inode, LinnInode *inodeData)
 Constructor function. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read directory entries. More...
 
virtual Filelookup (const char *name)
 Retrieves a File pointer for the given entry name. More...
 
- Public Member Functions inherited from Directory
 Directory (const u32 inode)
 Constructor. More...
 
virtual ~Directory ()
 Destructor. More...
 
void insert (FileSystem::FileType type, const char *name)
 Insert a new directory entry. More...
 
void remove (const char *name)
 Remove a directory entry. More...
 
void clear ()
 Clears the internal list of entries. More...
 
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
 
virtual ~File ()
 Destructor function. More...
 
u32 getInode () const
 Get inode number. More...
 
FileSystem::FileType getType () const
 Retrieve our filetype. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the file. More...
 
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
 
virtual bool canRead () const
 Check if the File has data ready for reading. More...
 
virtual bool canWrite () const
 Check if the File can be written to. More...
 

Private Member Functions

bool getLinnDirectoryEntry (LinnDirectoryEntry *dent, const char *name)
 Retrieve a directory entry. More...
 

Private Attributes

LinnFileSystemm_fs
 Filesystem pointer. More...
 
LinnInodem_inodeData
 Inode which describes the directory. More...
 

Additional Inherited Members

- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
 
const FileSystem::FileType m_type
 Type of this file. More...
 
UserID m_uid
 Owner of the file. More...
 
GroupID m_gid
 Group of the file. More...
 
FileSystem::FileModes m_access
 Access permissions. More...
 
Size m_size
 Size of the file, in bytes. More...
 

Detailed Description

Represents an directory on a LinnFS filesystem.

See also
Directory
LinnDirectoryEntry
LinnFileSystem

Definition at line 44 of file LinnDirectory.h.

Constructor & Destructor Documentation

◆ LinnDirectory()

LinnDirectory::LinnDirectory ( LinnFileSystem fs,
const u32  inode,
LinnInode inodeData 
)

Constructor function.

Parameters
fsFilesystem pointer.
inodeInode number
inodeDataInode data pointer.
See also
LinnFileSystem
LinnInode

Definition at line 25 of file LinnDirectory.cpp.

References File::m_access, m_inodeData, File::m_size, LinnInode::mode, and LinnInode::size.

Referenced by lookup().

Member Function Documentation

◆ getLinnDirectoryEntry()

bool LinnDirectory::getLinnDirectoryEntry ( LinnDirectoryEntry dent,
const char *  name 
)
private

Retrieve a directory entry.

Parameters
dentLinnDirectoryEntry buffer pointer.
nameUnique name of the entry.
Returns
True if successful, false otherwise.

Definition at line 129 of file LinnDirectory.cpp.

References LinnInode::block, LinnSuperBlock::blockSize, String::equals(), LinnFileSystem::getStorage(), LinnFileSystem::getSuperBlock(), LINN_DIRENT_PER_BLOCK, LINN_INODE_NUM_BLOCKS, m_fs, m_inodeData, LinnDirectoryEntry::name, Storage::read(), and FileSystem::Success.

Referenced by lookup().

◆ lookup()

File * LinnDirectory::lookup ( const char *  name)
virtual

Retrieves a File pointer for the given entry name.

This function reads a file from disk corresponding to the LinnInode of the given entry name. It returns an File object associated with that LinnInode.

Parameters
nameName of the entry to lookup.
Returns
Pointer to a File if found, or ZERO otherwise.
See also
File
LinnInode

Reimplemented from Directory.

Definition at line 96 of file LinnDirectory.cpp.

References assert, FileSystem::DirectoryFile, entry, LinnFileSystem::getInode(), getLinnDirectoryEntry(), LinnDirectory(), m_fs, NULL, FileSystem::RegularFile, LinnInode::type, and ZERO.

◆ read()

FileSystem::Result LinnDirectory::read ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Read directory entries.

Parameters
bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Returns
Result code

Reimplemented from Directory.

Definition at line 36 of file LinnDirectory.cpp.

References LinnInode::block, LinnSuperBlock::blockSize, MemoryBlock::copy(), LinnFileSystem::getInode(), LinnFileSystem::getStorage(), LinnFileSystem::getSuperBlock(), LinnDirectoryEntry::inode, FileSystem::InvalidArgument, LINN_DIRENT_NAME_LEN, LINN_INODE_DIR_BLOCKS, m_fs, m_inodeData, Dirent::name, LinnDirectoryEntry::name, FileSystem::NotFound, FileSystem::PermissionDenied, Storage::read(), LinnInode::size, FileSystem::Success, Dirent::type, LinnInode::type, IOBuffer::write(), and ZERO.

Field Documentation

◆ m_fs

LinnFileSystem* LinnDirectory::m_fs
private

Filesystem pointer.

Definition at line 108 of file LinnDirectory.h.

Referenced by getLinnDirectoryEntry(), lookup(), and read().

◆ m_inodeData

LinnInode* LinnDirectory::m_inodeData
private

Inode which describes the directory.

Definition at line 111 of file LinnDirectory.h.

Referenced by getLinnDirectoryEntry(), LinnDirectory(), and read().


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