Kernel: Inode rename directory functions
This commit is contained in:
		
							parent
							
								
									b354b77f8b
								
							
						
					
					
						commit
						583504ebe0
					
				|  | @ -33,8 +33,8 @@ namespace Kernel | |||
| 
 | ||||
| 		virtual BAN::StringView name() const override { return "device-manager"; } | ||||
| 
 | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> read_directory_inode(BAN::StringView) override; | ||||
| 		virtual BAN::ErrorOr<void> read_next_directory_entries(off_t, DirectoryEntryList*, size_t) override; | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find_inode(BAN::StringView) override; | ||||
| 		virtual BAN::ErrorOr<void> directory_read_next_entries(off_t, DirectoryEntryList*, size_t) override; | ||||
| 
 | ||||
| 	private: | ||||
| 		DeviceManager() = default; | ||||
|  |  | |||
|  | @ -141,8 +141,8 @@ namespace Kernel | |||
| 
 | ||||
| 		virtual BAN::ErrorOr<BAN::String> link_target() override; | ||||
| 		 | ||||
| 		virtual BAN::ErrorOr<void> read_next_directory_entries(off_t, DirectoryEntryList*, size_t) override; | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> read_directory_inode(BAN::StringView) override; | ||||
| 		virtual BAN::ErrorOr<void> directory_read_next_entries(off_t, DirectoryEntryList*, size_t) override; | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find_inode(BAN::StringView) override; | ||||
| 
 | ||||
| 		virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -82,8 +82,8 @@ namespace Kernel | |||
| 
 | ||||
| 		virtual BAN::ErrorOr<BAN::String> link_target() { ASSERT_NOT_REACHED(); } | ||||
| 
 | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> read_directory_inode(BAN::StringView)				{ if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } | ||||
| 		virtual BAN::ErrorOr<void> read_next_directory_entries(off_t, DirectoryEntryList*, size_t)	{ if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } | ||||
| 		virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find_inode(BAN::StringView)				{ if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } | ||||
| 		virtual BAN::ErrorOr<void> directory_read_next_entries(off_t, DirectoryEntryList*, size_t)	{ if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } | ||||
| 
 | ||||
| 		virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t)		{ if (mode().ifdir()) return BAN::Error::from_errno(EISDIR); ASSERT_NOT_REACHED(); } | ||||
| 		virtual BAN::ErrorOr<size_t> write(size_t, const void*, size_t)	{ if (mode().ifdir()) return BAN::Error::from_errno(EISDIR); ASSERT_NOT_REACHED(); } | ||||
|  |  | |||
|  | @ -103,7 +103,7 @@ namespace Kernel | |||
| 		MUST(m_devices.push_back(device)); | ||||
| 	} | ||||
| 
 | ||||
| 	BAN::ErrorOr<BAN::RefPtr<Inode>> DeviceManager::read_directory_inode(BAN::StringView name) | ||||
| 	BAN::ErrorOr<BAN::RefPtr<Inode>> DeviceManager::directory_find_inode(BAN::StringView name) | ||||
| 	{ | ||||
| 		LockGuard _(m_lock); | ||||
| 		if (name == "."sv || name == ".."sv) | ||||
|  | @ -114,7 +114,7 @@ namespace Kernel | |||
| 		return BAN::Error::from_errno(ENOENT); | ||||
| 	} | ||||
| 
 | ||||
| 	BAN::ErrorOr<void> DeviceManager::read_next_directory_entries(off_t offset, DirectoryEntryList* list, size_t list_size) | ||||
| 	BAN::ErrorOr<void> DeviceManager::directory_read_next_entries(off_t offset, DirectoryEntryList* list, size_t list_size) | ||||
| 	{ | ||||
| 		if (offset != 0) | ||||
| 		{ | ||||
|  |  | |||
|  | @ -291,7 +291,7 @@ namespace Kernel | |||
| 		return n_read; | ||||
| 	} | ||||
| 
 | ||||
| 	BAN::ErrorOr<void> Ext2Inode::read_next_directory_entries(off_t offset, DirectoryEntryList* list, size_t list_size) | ||||
| 	BAN::ErrorOr<void> Ext2Inode::directory_read_next_entries(off_t offset, DirectoryEntryList* list, size_t list_size) | ||||
| 	{ | ||||
| 		if (!mode().ifdir()) | ||||
| 			return BAN::Error::from_errno(ENOTDIR); | ||||
|  | @ -368,7 +368,7 @@ namespace Kernel | |||
| 		BAN::Vector<uint8_t> block_buffer; | ||||
| 		TRY(block_buffer.resize(block_size)); | ||||
| 
 | ||||
| 		auto error_or = read_directory_inode(name); | ||||
| 		auto error_or = directory_find_inode(name); | ||||
| 		if (!error_or.is_error()) | ||||
| 			return BAN::Error::from_errno(EEXISTS); | ||||
| 		if (error_or.error().get_error_code() != ENOENT) | ||||
|  | @ -441,7 +441,7 @@ namespace Kernel | |||
| 		return {}; | ||||
| 	} | ||||
| 
 | ||||
| 	BAN::ErrorOr<BAN::RefPtr<Inode>> Ext2Inode::read_directory_inode(BAN::StringView file_name) | ||||
| 	BAN::ErrorOr<BAN::RefPtr<Inode>> Ext2Inode::directory_find_inode(BAN::StringView file_name) | ||||
| 	{ | ||||
| 		if (!mode().ifdir()) | ||||
| 			return BAN::Error::from_errno(ENOTDIR); | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ namespace Kernel | |||
| 		ASSERT(root.size() >= 5 && root.substring(0, 5) == "/dev/"sv);; | ||||
| 		root = root.substring(5); | ||||
| 
 | ||||
| 		auto partition_inode = MUST(DeviceManager::get().read_directory_inode(root)); | ||||
| 		auto partition_inode = MUST(DeviceManager::get().directory_find_inode(root)); | ||||
| 		s_instance->m_root_fs = MUST(Ext2FS::create(*(Partition*)partition_inode.ptr())); | ||||
| 
 | ||||
| 		DeviceManager::get().set_blksize(s_instance->m_root_fs->root_inode()->blksize()); | ||||
|  | @ -110,9 +110,9 @@ namespace Kernel | |||
| 			else if (path_part == ".."sv) | ||||
| 			{ | ||||
| 				if (auto* mount_point = mount_from_root_inode(inode)) | ||||
| 					inode = TRY(mount_point->host.inode->read_directory_inode(".."sv)); | ||||
| 					inode = TRY(mount_point->host.inode->directory_find_inode(".."sv)); | ||||
| 				else | ||||
| 					inode = TRY(inode->read_directory_inode(".."sv)); | ||||
| 					inode = TRY(inode->directory_find_inode(".."sv)); | ||||
| 
 | ||||
| 				if (!canonical_path.empty()) | ||||
| 				{ | ||||
|  | @ -127,7 +127,7 @@ namespace Kernel | |||
| 				if (!inode->can_access(credentials, O_RDONLY)) | ||||
| 					return BAN::Error::from_errno(EACCES); | ||||
| 
 | ||||
| 				inode = TRY(inode->read_directory_inode(path_part)); | ||||
| 				inode = TRY(inode->directory_find_inode(path_part)); | ||||
| 
 | ||||
| 				if (auto* mount_point = mount_from_host_inode(inode)) | ||||
| 					inode = mount_point->target->root_inode(); | ||||
|  |  | |||
|  | @ -199,7 +199,7 @@ namespace Kernel | |||
| 	{ | ||||
| 		TRY(validate_fd(fd)); | ||||
| 		auto& open_file = m_open_files[fd]; | ||||
| 		TRY(open_file->inode->read_next_directory_entries(open_file->offset, list, list_size)); | ||||
| 		TRY(open_file->inode->directory_read_next_entries(open_file->offset, list, list_size)); | ||||
| 		open_file->offset++; | ||||
| 		return {}; | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue