xref: /haiku/headers/private/kernel/boot/partitions.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
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);
34 		Partition *Parent() const;
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 kPartitionTypeBTRFS		"BTRFS Filesystem"
65 #define kPartitionTypeEXFAT		"exFAT Filesystem"
66 #define kPartitionTypeEXT2		"EXT2 Filesystem"
67 #define kPartitionTypeEXT3		"EXT3 Filesystem"
68 #define kPartitionTypeFAT12		"FAT12 Filesystem"
69 #define kPartitionTypeFAT32		"FAT32 Filesystem"
70 #define kPartitionTypeHFS		"HFS Filesystem"
71 #define kPartitionTypeHFSPlus	"HFS+ Filesystem"
72 #define kPartitionTypeISO9660	"ISO9660 Filesystem"
73 #define kPartitionTypeReiser	"Reiser Filesystem"
74 #define kPartitionTypeTarFS		"TAR Filesystem"
75 #define kPartitionTypeUDF		"UDF Filesystem"
76 
77 // structure definitions as used in the boot loader
78 struct partition_module_info;
79 extern partition_module_info gAmigaPartitionModule;
80 extern partition_module_info gApplePartitionModule;
81 extern partition_module_info gEFIPartitionModule;
82 extern partition_module_info gIntelPartitionMapModule;
83 extern partition_module_info gIntelExtendedPartitionModule;
84 
85 // the file system module info is not a standard module info;
86 // their modules are specifically written for the boot loader,
87 // and hence, don't need to follow the standard module specs.
88 
89 struct file_system_module_info {
90 	const char	*module_name;
91 	const char	*pretty_name;
92 	float		(*identify_file_system)(boot::Partition *device);
93 	status_t	(*get_file_system)(boot::Partition *device, Directory **_root);
94 };
95 
96 extern file_system_module_info gBFSFileSystemModule;
97 extern file_system_module_info gFATFileSystemModule;
98 extern file_system_module_info gHFSPlusFileSystemModule;
99 extern file_system_module_info gAmigaFFSFileSystemModule;
100 extern file_system_module_info gTarFileSystemModule;
101 
102 #endif	/* KERNEL_BOOT_PARTITIONS_H */
103