xref: /haiku/headers/private/kernel/boot/partitions.h (revision 95bac3fda53a4cb21880712d7b43f8c21db32a2e)
1 /*
2  * Copyright 2003-2004, 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 namespace boot {
14 
15 class Partition : public Node, public partition_data {
16 	public:
17 		Partition(int deviceFD);
18 		virtual ~Partition();
19 
20 		virtual ssize_t ReadAt(void *cookie, off_t offset, void *buffer, size_t bufferSize);
21 		virtual ssize_t WriteAt(void *cookie, off_t offset, const void *buffer, size_t bufferSize);
22 
23 		virtual off_t Size() const;
24 		virtual int32 Type() const;
25 
26 		Partition *AddChild();
27 
28 		status_t Mount(Directory **_fileSystem = NULL);
29 		status_t Scan(bool mountFileSystems);
30 
31 		void SetParent(Partition *parent) { fParent = parent; }
32 		Partition *Parent() const { return fParent; }
33 
34 		bool IsFileSystem() const { return fIsFileSystem; }
35 		bool IsPartitioningSystem() const { return fIsPartitioningSystem; }
36 		const char *ModuleName() const { return fModuleName; }
37 
38 		int FD() const { return fFD; }
39 
40 	private:
41 		int			fFD;
42 		NodeList	fChildren;
43 		Partition	*fParent;
44 		bool		fIsFileSystem, fIsPartitioningSystem;
45 		const char	*fModuleName;
46 };
47 
48 }	// namespace boot
49 
50 // DiskDeviceTypes we need/support in the boot loader
51 #define kPartitionTypeAmiga		"Amiga RDB"
52 #define kPartitionTypeIntel		"Intel"
53 #define kPartitionTypeIntelExtended "Intel Extended"
54 #define kPartitionTypeApple		"Apple"
55 
56 #define kPartitionTypeBFS		"BFS Filesystem"
57 #define kPartitionTypeAmigaFFS	"AmigaFFS Filesystem"
58 #define kPartitionTypeBFS		"BFS Filesystem"
59 #define kPartitionTypeEXT2		"EXT2 Filesystem"
60 #define kPartitionTypeEXT3		"EXT3 Filesystem"
61 #define kPartitionTypeFAT12		"FAT12 Filesystem"
62 #define kPartitionTypeFAT32		"FAT32 Filesystem"
63 #define kPartitionTypeISO9660	"ISO9660 Filesystem"
64 #define kPartitionTypeReiser	"Reiser Filesystem"
65 #define kPartitionTypeUDF		"UDF Filesystem"
66 
67 // structure definitions as used in the boot loader
68 struct partition_module_info;
69 extern partition_module_info gAmigaPartitionModule;
70 extern partition_module_info gIntelPartitionMapModule;
71 extern partition_module_info gIntelExtendedPartitionModule;
72 extern partition_module_info gApplePartitionModule;
73 
74 // the file system module info is not a standard module info;
75 // their modules are specifically written for the boot loader,
76 // and hence, don't need to follow the standard module specs.
77 
78 struct file_system_module_info {
79 	const char	*module_name;
80 	const char	*pretty_name;
81 	status_t	(*get_file_system)(boot::Partition *device, Directory **_root);
82 };
83 
84 extern file_system_module_info gBFSFileSystemModule;
85 extern file_system_module_info gAmigaFFSFileSystemModule;
86 
87 #endif	/* KERNEL_BOOT_PARTITIONS_H */
88