1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/ext/filesystem.h

68 lines
1.8 KiB
C
Raw Normal View History

/*
* Copyright (c) 2013, 2014, 2015 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* filesystem.h
* Filesystem.
*/
2013-05-23 08:39:54 -04:00
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
class BlockGroup;
class Device;
class Inode;
2015-07-02 16:10:26 -04:00
static const size_t INODE_HASH_LENGTH = 1 << 16;
2014-10-01 18:41:35 -04:00
2013-05-23 08:39:54 -04:00
class Filesystem
{
public:
2015-02-16 09:44:21 -05:00
Filesystem(Device* device, const char* mount_path);
2013-05-23 08:39:54 -04:00
~Filesystem();
public:
Block* sb_block;
struct ext_superblock* sb;
2013-05-23 08:39:54 -04:00
Device* device;
BlockGroup** block_groups;
2015-02-16 09:44:21 -05:00
const char* mount_path;
2013-05-23 08:39:54 -04:00
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;
2014-10-01 16:16:33 -04:00
Inode* dirty_inode;
2014-10-01 18:41:35 -04:00
Inode* hash_inodes[INODE_HASH_LENGTH];
2013-05-23 08:39:54 -04:00
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();
2013-05-23 08:39:54 -04:00
void Sync();
};
#endif