BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / partitioning_systems / intel / PartitionLocker.cpp
blob64eb4db44d006888ad9f27dabcee5080d34d05e1
1 /*
2 * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Tomas Kucera, kucerat@centrum.cz
7 */
10 #include "PartitionLocker.h"
13 // #pragma mark - PartitionLocker
16 PartitionLocker::PartitionLocker(partition_id partitionID)
18 fDevice(NULL),
19 fPartitionID(partitionID)
24 PartitionLocker::~PartitionLocker()
29 bool
30 PartitionLocker::IsLocked() const
32 return fDevice != NULL;
36 partition_id
37 PartitionLocker::PartitionId() const
39 return fPartitionID;
43 // #pragma mark - PartitionReadLocker
46 PartitionReadLocker::PartitionReadLocker(partition_id partitionID)
48 PartitionLocker(partitionID)
50 fDevice = read_lock_disk_device(partitionID);
54 PartitionReadLocker::~PartitionReadLocker()
56 if (IsLocked())
57 read_unlock_disk_device(PartitionId());
61 // #pragma mark - PartitionWriteLocker
64 PartitionWriteLocker::PartitionWriteLocker(partition_id partitionID)
66 PartitionLocker(partitionID)
68 fDevice = write_lock_disk_device(partitionID);
72 PartitionWriteLocker::~PartitionWriteLocker()
74 if (IsLocked())
75 write_unlock_disk_device(PartitionId());