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