xref: /haiku/headers/private/kernel/boot/partitions.h (revision f4ff9cb02c1d292908407314ed023af25e0995da)
16f7c2dc6SAxel Dörfler /*
2eef8417eSAxel Dörfler  * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de.
30c3888b9SAxel Dörfler  * Distributed under the terms of the MIT License.
46f7c2dc6SAxel Dörfler  */
56f7c2dc6SAxel Dörfler #ifndef KERNEL_BOOT_PARTITIONS_H
66f7c2dc6SAxel Dörfler #define KERNEL_BOOT_PARTITIONS_H
76f7c2dc6SAxel Dörfler 
86f7c2dc6SAxel Dörfler 
96f7c2dc6SAxel Dörfler #include <boot/vfs.h>
106f7c2dc6SAxel Dörfler #include <disk_device_manager.h>
116f7c2dc6SAxel Dörfler 
126f7c2dc6SAxel Dörfler 
13e3fcb58eSAxel Dörfler struct file_system_module_info;
14e3fcb58eSAxel Dörfler 
15da42afdfSAxel Dörfler namespace boot {
16da42afdfSAxel Dörfler 
17c3e36ff4SAxel Dörfler class Partition : public Node, public partition_data {
18da42afdfSAxel Dörfler 	public:
19da42afdfSAxel Dörfler 		Partition(int deviceFD);
20da42afdfSAxel Dörfler 		virtual ~Partition();
21da42afdfSAxel Dörfler 
22da42afdfSAxel Dörfler 		virtual ssize_t ReadAt(void *cookie, off_t offset, void *buffer, size_t bufferSize);
23da42afdfSAxel Dörfler 		virtual ssize_t WriteAt(void *cookie, off_t offset, const void *buffer, size_t bufferSize);
24da42afdfSAxel Dörfler 
25da42afdfSAxel Dörfler 		virtual off_t Size() const;
26da42afdfSAxel Dörfler 		virtual int32 Type() const;
27da42afdfSAxel Dörfler 
28da42afdfSAxel Dörfler 		Partition *AddChild();
29b337ddf6SAxel Dörfler 
30e3fcb58eSAxel Dörfler 		status_t Mount(Directory **_fileSystem = NULL, bool isBootDevice = false);
31e3fcb58eSAxel Dörfler 		status_t Scan(bool mountFileSystems, bool isBootDevice = false);
32da42afdfSAxel Dörfler 
33*495efc38SFrançois Revol 		static Partition *Lookup(partition_id id, NodeList *list = NULL);
34*495efc38SFrançois Revol 
3588212335SMarcus Overhagen 		void SetParent(Partition *parent);
3688212335SMarcus Overhagen 		Partition *Parent() const;
37ec5d7064SAxel Dörfler 
IsFileSystem()38da42afdfSAxel Dörfler 		bool IsFileSystem() const { return fIsFileSystem; }
IsPartitioningSystem()39ec5d7064SAxel Dörfler 		bool IsPartitioningSystem() const { return fIsPartitioningSystem; }
ModuleName()407765cbf6SAxel Dörfler 		const char *ModuleName() const { return fModuleName; }
41da42afdfSAxel Dörfler 
FD()420c3888b9SAxel Dörfler 		int FD() const { return fFD; }
430c3888b9SAxel Dörfler 
44da42afdfSAxel Dörfler 	private:
45e3fcb58eSAxel Dörfler 		status_t _Mount(file_system_module_info *module, Directory **_fileSystem);
46e3fcb58eSAxel Dörfler 
47da42afdfSAxel Dörfler 		int			fFD;
48c3e36ff4SAxel Dörfler 		NodeList	fChildren;
49da42afdfSAxel Dörfler 		Partition	*fParent;
50ec5d7064SAxel Dörfler 		bool		fIsFileSystem, fIsPartitioningSystem;
517765cbf6SAxel Dörfler 		const char	*fModuleName;
52da42afdfSAxel Dörfler };
53da42afdfSAxel Dörfler 
54da42afdfSAxel Dörfler }	// namespace boot
55da42afdfSAxel Dörfler 
566f7c2dc6SAxel Dörfler // DiskDeviceTypes we need/support in the boot loader
576f7c2dc6SAxel Dörfler #define kPartitionTypeAmiga		"Amiga RDB"
58d832aa7eSIngo Weinhold #define kPartitionTypeIntel		"Intel Partition Map"
59d832aa7eSIngo Weinhold #define kPartitionTypeIntelExtended "Intel Extended Partition"
60d832aa7eSIngo Weinhold 	// Note: The naming of these two at least must be consistent with
61d832aa7eSIngo Weinhold 	// DiskDeviceTypes.cpp.
626f7c2dc6SAxel Dörfler #define kPartitionTypeApple		"Apple"
636f7c2dc6SAxel Dörfler 
64fd5b59d2SAxel Dörfler #define kPartitionTypeBFS		"BFS Filesystem"
65fd5b59d2SAxel Dörfler #define kPartitionTypeAmigaFFS	"AmigaFFS Filesystem"
6601929b0cSJérôme Duval #define kPartitionTypeBTRFS		"BTRFS Filesystem"
67245df7abSJérôme Duval #define kPartitionTypeEXFAT		"exFAT Filesystem"
68fd5b59d2SAxel Dörfler #define kPartitionTypeEXT2		"EXT2 Filesystem"
69fd5b59d2SAxel Dörfler #define kPartitionTypeEXT3		"EXT3 Filesystem"
70fd5b59d2SAxel Dörfler #define kPartitionTypeFAT12		"FAT12 Filesystem"
71fd5b59d2SAxel Dörfler #define kPartitionTypeFAT32		"FAT32 Filesystem"
72ab78c7cbSAxel Dörfler #define kPartitionTypeHFS		"HFS Filesystem"
73ab78c7cbSAxel Dörfler #define kPartitionTypeHFSPlus	"HFS+ Filesystem"
74fd5b59d2SAxel Dörfler #define kPartitionTypeISO9660	"ISO9660 Filesystem"
75fd5b59d2SAxel Dörfler #define kPartitionTypeReiser	"Reiser Filesystem"
7683333bf2SAxel Dörfler #define kPartitionTypeTarFS		"TAR Filesystem"
77fd5b59d2SAxel Dörfler #define kPartitionTypeUDF		"UDF Filesystem"
78e5d542baSAxel Dörfler 
79fd5b59d2SAxel Dörfler // structure definitions as used in the boot loader
806f7c2dc6SAxel Dörfler struct partition_module_info;
816f7c2dc6SAxel Dörfler extern partition_module_info gAmigaPartitionModule;
82eef8417eSAxel Dörfler extern partition_module_info gApplePartitionModule;
83eef8417eSAxel Dörfler extern partition_module_info gEFIPartitionModule;
84e5d542baSAxel Dörfler extern partition_module_info gIntelPartitionMapModule;
85e5d542baSAxel Dörfler extern partition_module_info gIntelExtendedPartitionModule;
866f7c2dc6SAxel Dörfler 
87fd5b59d2SAxel Dörfler // the file system module info is not a standard module info;
88fd5b59d2SAxel Dörfler // their modules are specifically written for the boot loader,
89fd5b59d2SAxel Dörfler // and hence, don't need to follow the standard module specs.
90fd5b59d2SAxel Dörfler 
91fd5b59d2SAxel Dörfler struct file_system_module_info {
927765cbf6SAxel Dörfler 	const char	*module_name;
93fd5b59d2SAxel Dörfler 	const char	*pretty_name;
9467486592SIngo Weinhold 	float		(*identify_file_system)(boot::Partition *device);
95da42afdfSAxel Dörfler 	status_t	(*get_file_system)(boot::Partition *device, Directory **_root);
96fd5b59d2SAxel Dörfler };
97fd5b59d2SAxel Dörfler 
98fd5b59d2SAxel Dörfler extern file_system_module_info gBFSFileSystemModule;
992cf4975bSFrançois Revol extern file_system_module_info gFATFileSystemModule;
1002cf4975bSFrançois Revol extern file_system_module_info gHFSPlusFileSystemModule;
10169a8a407SAxel Dörfler extern file_system_module_info gAmigaFFSFileSystemModule;
10283333bf2SAxel Dörfler extern file_system_module_info gTarFileSystemModule;
103fd5b59d2SAxel Dörfler 
1046f7c2dc6SAxel Dörfler #endif	/* KERNEL_BOOT_PARTITIONS_H */
105