1 /* 2 * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 */ 8 #ifndef _K_DISK_DEVICE_SYSTEM_H 9 #define _K_DISK_DEVICE_SYSTEM_H 10 11 #include "disk_device_manager.h" 12 13 14 struct user_disk_system_info; 15 16 17 namespace BPrivate { 18 namespace DiskDevice { 19 20 21 class KPartition; 22 23 24 //! \brief Common ancestor for disk system add-on wrappers 25 class KDiskSystem { 26 public: 27 KDiskSystem(const char *name); 28 virtual ~KDiskSystem(); 29 30 virtual status_t Init(); 31 32 // void SetID(disk_system_id id); 33 disk_system_id ID() const; 34 35 const char* Name() const; 36 const char* PrettyName(); 37 uint32 Flags() const; 38 39 bool IsFileSystem() const; 40 bool IsPartitioningSystem() const; 41 42 void GetInfo(user_disk_system_info* info); 43 44 // manager will be locked 45 status_t Load(); // load/unload -- can be nested 46 void Unload(); // 47 bool IsLoaded() const; 48 49 // Scanning 50 // Device must be write locked. 51 52 virtual float Identify(KPartition* partition, void** cookie); 53 virtual status_t Scan(KPartition* partition, void* cookie); 54 virtual void FreeIdentifyCookie(KPartition* partition, 55 void* cookie); 56 virtual void FreeCookie(KPartition* partition); 57 virtual void FreeContentCookie(KPartition* partition); 58 59 // Writing 60 // Device should not be locked, but all affected partitions are marked 61 // busy, meaning that no one else is allowed to modify it (and we only, 62 // if we get a write lock). 63 64 virtual status_t Defragment(KPartition* partition, 65 disk_job_id job); 66 virtual status_t Repair(KPartition* partition, bool checkOnly, 67 disk_job_id job); 68 virtual status_t Resize(KPartition* partition, off_t size, 69 disk_job_id job); 70 virtual status_t ResizeChild(KPartition* child, off_t size, 71 disk_job_id job); 72 virtual status_t Move(KPartition* partition, off_t offset, 73 disk_job_id job); 74 virtual status_t MoveChild(KPartition* child, off_t offset, 75 disk_job_id job); 76 virtual status_t SetName(KPartition* partition, const char* name, 77 disk_job_id job); 78 virtual status_t SetContentName(KPartition* partition, 79 const char* name, disk_job_id job); 80 virtual status_t SetType(KPartition* partition, const char* type, 81 disk_job_id job); 82 virtual status_t SetParameters(KPartition* partition, 83 const char* parameters, disk_job_id job); 84 virtual status_t SetContentParameters(KPartition* partition, 85 const char* parameters, disk_job_id job); 86 virtual status_t Initialize(KPartition* partition, 87 const char* name, const char* parameters, 88 disk_job_id job); 89 virtual status_t CreateChild(KPartition* partition, off_t offset, 90 off_t size, const char* type, 91 const char* name, const char* parameters, 92 disk_job_id job, KPartition** child = NULL, 93 partition_id childID = -1); 94 virtual status_t DeleteChild(KPartition* child, disk_job_id job); 95 96 protected: 97 virtual status_t LoadModule(); 98 virtual void UnloadModule(); 99 100 status_t SetPrettyName(const char* name); 101 void SetFlags(uint32 flags); 102 103 static int32 _NextID(); 104 105 private: 106 disk_system_id fID; 107 char* fName; 108 char* fPrettyName; 109 uint32 fFlags; 110 int32 fLoadCounter; 111 112 static int32 fNextID; 113 }; 114 115 116 } // namespace DiskDevice 117 } // namespace BPrivate 118 119 using BPrivate::DiskDevice::KDiskSystem; 120 121 #endif // _K_DISK_DEVICE_SYSTEM_H 122