xref: /haiku/headers/private/kernel/boot/partitions.h (revision b028e77473189065f2baefc6f5e10d451cf591e2)
1 /*
2  * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef KERNEL_BOOT_PARTITIONS_H
6 #define KERNEL_BOOT_PARTITIONS_H
7 
8 
9 #include <boot/vfs.h>
10 #include <disk_device_manager.h>
11 
12 
13 struct file_system_module_info;
14 
15 namespace boot {
16 
17 class Partition : public Node, public partition_data {
18 	public:
19 		Partition(int deviceFD);
20 		virtual ~Partition();
21 
22 		virtual ssize_t ReadAt(void *cookie, off_t offset, void *buffer, size_t bufferSize);
23 		virtual ssize_t WriteAt(void *cookie, off_t offset, const void *buffer, size_t bufferSize);
24 
25 		virtual off_t Size() const;
26 		virtual int32 Type() const;
27 
28 		Partition *AddChild();
29 
30 		status_t Mount(Directory **_fileSystem = NULL, bool isBootDevice = false);
31 		status_t Scan(bool mountFileSystems, bool isBootDevice = false);
32 
33 		void SetParent(Partition *parent) { fParent = parent; }
34 		Partition *Parent() const { return fParent; }
35 
36 		bool IsFileSystem() const { return fIsFileSystem; }
37 		bool IsPartitioningSystem() const { return fIsPartitioningSystem; }
38 		const char *ModuleName() const { return fModuleName; }
39 
40 		int FD() const { return fFD; }
41 
42 	private:
43 		status_t _Mount(file_system_module_info *module, Directory **_fileSystem);
44 
45 		int			fFD;
46 		NodeList	fChildren;
47 		Partition	*fParent;
48 		bool		fIsFileSystem, fIsPartitioningSystem;
49 		const char	*fModuleName;
50 };
51 
52 }	// namespace boot
53 
54 // DiskDeviceTypes we need/support in the boot loader
55 #define kPartitionTypeAmiga		"Amiga RDB"
56 #define kPartitionTypeIntel		"Intel Partition Map"
57 #define kPartitionTypeIntelExtended "Intel Extended Partition"
58 	// Note: The naming of these two at least must be consistent with
59 	// DiskDeviceTypes.cpp.
60 #define kPartitionTypeApple		"Apple"
61 
62 #define kPartitionTypeBFS		"BFS Filesystem"
63 #define kPartitionTypeAmigaFFS	"AmigaFFS Filesystem"
64 #define kPartitionTypeBFS		"BFS Filesystem"
65 #define kPartitionTypeEXT2		"EXT2 Filesystem"
66 #define kPartitionTypeEXT3		"EXT3 Filesystem"
67 #define kPartitionTypeFAT12		"FAT12 Filesystem"
68 #define kPartitionTypeFAT32		"FAT32 Filesystem"
69 #define kPartitionTypeHFS		"HFS Filesystem"
70 #define kPartitionTypeHFSPlus	"HFS+ Filesystem"
71 #define kPartitionTypeISO9660	"ISO9660 Filesystem"
72 #define kPartitionTypeReiser	"Reiser Filesystem"
73 #define kPartitionTypeTarFS		"TAR Filesystem"
74 #define kPartitionTypeUDF		"UDF Filesystem"
75 
76 // structure definitions as used in the boot loader
77 struct partition_module_info;
78 extern partition_module_info gAmigaPartitionModule;
79 extern partition_module_info gApplePartitionModule;
80 extern partition_module_info gEFIPartitionModule;
81 extern partition_module_info gIntelPartitionMapModule;
82 extern partition_module_info gIntelExtendedPartitionModule;
83 
84 // the file system module info is not a standard module info;
85 // their modules are specifically written for the boot loader,
86 // and hence, don't need to follow the standard module specs.
87 
88 struct file_system_module_info {
89 	const char	*module_name;
90 	const char	*pretty_name;
91 	status_t	(*get_file_system)(boot::Partition *device, Directory **_root);
92 };
93 
94 extern file_system_module_info gBFSFileSystemModule;
95 extern file_system_module_info gAmigaFFSFileSystemModule;
96 extern file_system_module_info gTarFileSystemModule;
97 
98 #endif	/* KERNEL_BOOT_PARTITIONS_H */
99