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 static Partition *Lookup(partition_id id, NodeList *list = NULL); 34 35 void SetParent(Partition *parent); 36 Partition *Parent() const; 37 IsFileSystem()38 bool IsFileSystem() const { return fIsFileSystem; } IsPartitioningSystem()39 bool IsPartitioningSystem() const { return fIsPartitioningSystem; } ModuleName()40 const char *ModuleName() const { return fModuleName; } 41 FD()42 int FD() const { return fFD; } 43 44 private: 45 status_t _Mount(file_system_module_info *module, Directory **_fileSystem); 46 47 int fFD; 48 NodeList fChildren; 49 Partition *fParent; 50 bool fIsFileSystem, fIsPartitioningSystem; 51 const char *fModuleName; 52 }; 53 54 } // namespace boot 55 56 // DiskDeviceTypes we need/support in the boot loader 57 #define kPartitionTypeAmiga "Amiga RDB" 58 #define kPartitionTypeIntel "Intel Partition Map" 59 #define kPartitionTypeIntelExtended "Intel Extended Partition" 60 // Note: The naming of these two at least must be consistent with 61 // DiskDeviceTypes.cpp. 62 #define kPartitionTypeApple "Apple" 63 64 #define kPartitionTypeBFS "BFS Filesystem" 65 #define kPartitionTypeAmigaFFS "AmigaFFS Filesystem" 66 #define kPartitionTypeBTRFS "BTRFS Filesystem" 67 #define kPartitionTypeEXFAT "exFAT Filesystem" 68 #define kPartitionTypeEXT2 "EXT2 Filesystem" 69 #define kPartitionTypeEXT3 "EXT3 Filesystem" 70 #define kPartitionTypeFAT12 "FAT12 Filesystem" 71 #define kPartitionTypeFAT32 "FAT32 Filesystem" 72 #define kPartitionTypeHFS "HFS Filesystem" 73 #define kPartitionTypeHFSPlus "HFS+ Filesystem" 74 #define kPartitionTypeISO9660 "ISO9660 Filesystem" 75 #define kPartitionTypeReiser "Reiser Filesystem" 76 #define kPartitionTypeTarFS "TAR Filesystem" 77 #define kPartitionTypeUDF "UDF Filesystem" 78 79 // structure definitions as used in the boot loader 80 struct partition_module_info; 81 extern partition_module_info gAmigaPartitionModule; 82 extern partition_module_info gApplePartitionModule; 83 extern partition_module_info gEFIPartitionModule; 84 extern partition_module_info gIntelPartitionMapModule; 85 extern partition_module_info gIntelExtendedPartitionModule; 86 87 // the file system module info is not a standard module info; 88 // their modules are specifically written for the boot loader, 89 // and hence, don't need to follow the standard module specs. 90 91 struct file_system_module_info { 92 const char *module_name; 93 const char *pretty_name; 94 float (*identify_file_system)(boot::Partition *device); 95 status_t (*get_file_system)(boot::Partition *device, Directory **_root); 96 }; 97 98 extern file_system_module_info gBFSFileSystemModule; 99 extern file_system_module_info gFATFileSystemModule; 100 extern file_system_module_info gHFSPlusFileSystemModule; 101 extern file_system_module_info gAmigaFFSFileSystemModule; 102 extern file_system_module_info gTarFileSystemModule; 103 104 #endif /* KERNEL_BOOT_PARTITIONS_H */ 105