mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00:00
Get rid of deprecated_enumerateDirectoryInode.
This was a vestige from the pre-CoreInode implementation of Ext2FS.
This commit is contained in:
parent
407bb3e76e
commit
d824442e3e
2 changed files with 9 additions and 36 deletions
|
@ -523,45 +523,20 @@ bool Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ext2FS::deprecated_enumerateDirectoryInode(InodeIdentifier inode, Function<bool(const DirectoryEntry&)> callback) const
|
bool Ext2FS::add_inode_to_directory(InodeIndex parent, InodeIndex child, const String& name, byte fileType, int& error)
|
||||||
{
|
{
|
||||||
ASSERT(inode.fsid() == id());
|
auto e2inodeForDirectory = lookup_ext2_inode(parent);
|
||||||
ASSERT(is_directory_inode(inode.index()));
|
|
||||||
|
|
||||||
#ifdef EXT2_DEBUG
|
|
||||||
kprintf("ext2fs: Enumerating directory contents of inode %u:\n", inode.index());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto buffer = read_entire_inode(inode);
|
|
||||||
ASSERT(buffer);
|
|
||||||
auto* entry = reinterpret_cast<ext2_dir_entry_2*>(buffer.pointer());
|
|
||||||
|
|
||||||
while (entry < buffer.endPointer()) {
|
|
||||||
if (entry->inode != 0) {
|
|
||||||
#ifdef EXT2_DEBUG
|
|
||||||
kprintf("inode: %u, name_len: %u, rec_len: %u, file_type: %u, name: %s\n", entry->inode, entry->name_len, entry->rec_len, entry->file_type, namebuf);
|
|
||||||
#endif
|
|
||||||
if (!callback({ entry->name, entry->name_len, { id(), entry->inode }, entry->file_type }))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
entry = (ext2_dir_entry_2*)((char*)entry + entry->rec_len);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Ext2FS::add_inode_to_directory(unsigned directoryInode, unsigned inode, const String& name, byte fileType, int& error)
|
|
||||||
{
|
|
||||||
auto e2inodeForDirectory = lookup_ext2_inode(directoryInode);
|
|
||||||
ASSERT(e2inodeForDirectory);
|
ASSERT(e2inodeForDirectory);
|
||||||
ASSERT(isDirectory(e2inodeForDirectory->i_mode));
|
ASSERT(isDirectory(e2inodeForDirectory->i_mode));
|
||||||
|
|
||||||
//#ifdef EXT2_DEBUG
|
//#ifdef EXT2_DEBUG
|
||||||
dbgprintf("Ext2FS: Adding inode %u with name '%s' to directory %u\n", inode, name.characters(), directoryInode);
|
dbgprintf("Ext2FS: Adding inode %u with name '%s' to directory %u\n", child, name.characters(), parent);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
Vector<DirectoryEntry> entries;
|
Vector<DirectoryEntry> entries;
|
||||||
bool nameAlreadyExists = false;
|
bool nameAlreadyExists = false;
|
||||||
deprecated_enumerateDirectoryInode({ id(), directoryInode }, [&] (const DirectoryEntry& entry) {
|
auto directory = get_inode({ id(), parent });
|
||||||
|
directory->traverse_as_directory([&] (auto& entry) {
|
||||||
if (!strcmp(entry.name, name.characters())) {
|
if (!strcmp(entry.name, name.characters())) {
|
||||||
nameAlreadyExists = true;
|
nameAlreadyExists = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -570,13 +545,13 @@ bool Ext2FS::add_inode_to_directory(unsigned directoryInode, unsigned inode, con
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (nameAlreadyExists) {
|
if (nameAlreadyExists) {
|
||||||
kprintf("Ext2FS: Name '%s' already exists in directory inode %u\n", name.characters(), directoryInode);
|
kprintf("Ext2FS: Name '%s' already exists in directory inode %u\n", name.characters(), parent);
|
||||||
error = -EEXIST;
|
error = -EEXIST;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.append({ name.characters(), name.length(), { id(), inode }, fileType });
|
entries.append({ name.characters(), name.length(), { id(), child }, fileType });
|
||||||
return write_directory_inode(directoryInode, move(entries));
|
return write_directory_inode(parent, move(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ext2FS::write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&& entries)
|
bool Ext2FS::write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&& entries)
|
||||||
|
|
|
@ -92,7 +92,7 @@ private:
|
||||||
template<typename F> void traverse_inode_bitmap(unsigned groupIndex, F) const;
|
template<typename F> void traverse_inode_bitmap(unsigned groupIndex, F) const;
|
||||||
template<typename F> void traverse_block_bitmap(unsigned groupIndex, F) const;
|
template<typename F> void traverse_block_bitmap(unsigned groupIndex, F) const;
|
||||||
|
|
||||||
bool add_inode_to_directory(unsigned directoryInode, unsigned inode, const String& name, byte fileType, int& error);
|
bool add_inode_to_directory(InodeIndex parent, InodeIndex child, const String& name, byte fileType, int& error);
|
||||||
bool write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&&);
|
bool write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&&);
|
||||||
bool set_inode_allocation_state(unsigned inode, bool);
|
bool set_inode_allocation_state(unsigned inode, bool);
|
||||||
bool set_block_allocation_state(GroupIndex, BlockIndex, bool);
|
bool set_block_allocation_state(GroupIndex, BlockIndex, bool);
|
||||||
|
@ -101,8 +101,6 @@ private:
|
||||||
|
|
||||||
unsigned m_blockGroupCount { 0 };
|
unsigned m_blockGroupCount { 0 };
|
||||||
|
|
||||||
bool deprecated_enumerateDirectoryInode(InodeIdentifier, Function<bool(const DirectoryEntry&)>) const;
|
|
||||||
|
|
||||||
mutable ByteBuffer m_cached_super_block;
|
mutable ByteBuffer m_cached_super_block;
|
||||||
mutable ByteBuffer m_cached_group_descriptor_table;
|
mutable ByteBuffer m_cached_group_descriptor_table;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue