mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
bc928e99a4
This cleans up constructors so fields are initialized in the same order they are declared in. This makes it trivial to spot accidentally uninitialized fields. This fixes a minor argument parsing bug when the mount path isn't set, but fortunately argv[argc] is NULL and we wanted to set it to NULL anyway. This prevents excessively large block sizes from being used. This improves inode value range checks in the fsmarshall code. Inode 0 is not a valid inode. The new code for this is also simpler. This prevents creating links with names larger than 255 bytes. This adds a check to ensure inodes don't overflow the hardlink count. This ensures the dirent filetype is only set if supported.
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
/*******************************************************************************
|
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the Free
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
filesystem.h
|
|
Filesystem.
|
|
|
|
*******************************************************************************/
|
|
|
|
#ifndef FILESYSTEM_H
|
|
#define FILESYSTEM_H
|
|
|
|
class BlockGroup;
|
|
class Device;
|
|
class Inode;
|
|
|
|
static const size_t INODE_HASH_LENGTH = 1 << 16;
|
|
|
|
class Filesystem
|
|
{
|
|
public:
|
|
Filesystem(Device* device, const char* mount_path);
|
|
~Filesystem();
|
|
|
|
public:
|
|
Block* sb_block;
|
|
struct ext_superblock* sb;
|
|
Device* device;
|
|
BlockGroup** block_groups;
|
|
const char* mount_path;
|
|
uint32_t block_size;
|
|
uint32_t inode_size;
|
|
uint32_t num_blocks;
|
|
uint32_t num_groups;
|
|
uint32_t num_inodes;
|
|
Inode* mru_inode;
|
|
Inode* lru_inode;
|
|
Inode* dirty_inode;
|
|
Inode* hash_inodes[INODE_HASH_LENGTH];
|
|
time_t mtime_realtime;
|
|
time_t mtime_monotonic;
|
|
bool dirty;
|
|
|
|
public:
|
|
BlockGroup* GetBlockGroup(uint32_t group_id);
|
|
Inode* GetInode(uint32_t inode_id);
|
|
uint32_t AllocateBlock(BlockGroup* preferred = NULL);
|
|
uint32_t AllocateInode(BlockGroup* preferred = NULL);
|
|
void FreeBlock(uint32_t block_id);
|
|
void FreeInode(uint32_t inode_id);
|
|
void BeginWrite();
|
|
void FinishWrite();
|
|
void Sync();
|
|
|
|
};
|
|
|
|
#endif
|