1*61ba1259SAxel Dörfler /* 2*61ba1259SAxel Dörfler * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. 3*61ba1259SAxel Dörfler * Distributed under the terms of the MIT License. 4*61ba1259SAxel Dörfler * 5*61ba1259SAxel Dörfler * Authors: 6*61ba1259SAxel Dörfler * Tomas Kucera, kucerat@centrum.cz 7*61ba1259SAxel Dörfler */ 8*61ba1259SAxel Dörfler 9*61ba1259SAxel Dörfler /*! 10*61ba1259SAxel Dörfler \file PartitionLocker.h 11*61ba1259SAxel Dörfler \ingroup intel_module 12*61ba1259SAxel Dörfler \brief Structures for easy locking and automatic unlocking partitions. 13*61ba1259SAxel Dörfler */ 14*61ba1259SAxel Dörfler 15*61ba1259SAxel Dörfler #ifndef _PARTITION_LOCKER_H 16*61ba1259SAxel Dörfler #define _PARTITION_LOCKER_H 17*61ba1259SAxel Dörfler 18*61ba1259SAxel Dörfler #include <disk_device_manager.h> 19*61ba1259SAxel Dörfler 20*61ba1259SAxel Dörfler 21*61ba1259SAxel Dörfler class PartitionLocker { 22*61ba1259SAxel Dörfler public: 23*61ba1259SAxel Dörfler PartitionLocker(partition_id partitionID); 24*61ba1259SAxel Dörfler ~PartitionLocker(); 25*61ba1259SAxel Dörfler 26*61ba1259SAxel Dörfler bool IsLocked() const; 27*61ba1259SAxel Dörfler partition_id PartitionId() const; 28*61ba1259SAxel Dörfler 29*61ba1259SAxel Dörfler protected: 30*61ba1259SAxel Dörfler const disk_device_data *fDevice; 31*61ba1259SAxel Dörfler 32*61ba1259SAxel Dörfler private: 33*61ba1259SAxel Dörfler partition_id fPartitionID; 34*61ba1259SAxel Dörfler }; 35*61ba1259SAxel Dörfler 36*61ba1259SAxel Dörfler 37*61ba1259SAxel Dörfler /*! 38*61ba1259SAxel Dörfler \brief Structure which locks given partition for reading. 39*61ba1259SAxel Dörfler 40*61ba1259SAxel Dörfler When this structure is going to be destroyed, it automatically unlocks 41*61ba1259SAxel Dörfler that partition. 42*61ba1259SAxel Dörfler */ 43*61ba1259SAxel Dörfler class PartitionReadLocker : public PartitionLocker { 44*61ba1259SAxel Dörfler public: 45*61ba1259SAxel Dörfler PartitionReadLocker(partition_id partitionID); 46*61ba1259SAxel Dörfler ~PartitionReadLocker(); 47*61ba1259SAxel Dörfler }; 48*61ba1259SAxel Dörfler 49*61ba1259SAxel Dörfler 50*61ba1259SAxel Dörfler /*! 51*61ba1259SAxel Dörfler \brief Structure which locks given partition for writing. 52*61ba1259SAxel Dörfler 53*61ba1259SAxel Dörfler When this structure is going to be destroyed, it automatically unlocks 54*61ba1259SAxel Dörfler that partition. 55*61ba1259SAxel Dörfler */ 56*61ba1259SAxel Dörfler class PartitionWriteLocker : public PartitionLocker { 57*61ba1259SAxel Dörfler public: 58*61ba1259SAxel Dörfler PartitionWriteLocker(partition_id partitionID); 59*61ba1259SAxel Dörfler ~PartitionWriteLocker(); 60*61ba1259SAxel Dörfler }; 61*61ba1259SAxel Dörfler 62*61ba1259SAxel Dörfler 63*61ba1259SAxel Dörfler #endif // _PARTITION_LOCKER_H 64