xref: /haiku/src/kits/storage/disk_device/jobs/UninitializeJob.cpp (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include "UninitializeJob.h"
7 
8 #include <syscalls.h>
9 
10 #include "PartitionReference.h"
11 
12 
13 // constructor
14 UninitializeJob::UninitializeJob(PartitionReference* partition,
15 		PartitionReference* parent)
16 	: DiskDeviceJob(parent, partition)
17 {
18 }
19 
20 
21 // destructor
22 UninitializeJob::~UninitializeJob()
23 {
24 }
25 
26 
27 // Do
28 status_t
29 UninitializeJob::Do()
30 {
31 	bool haveParent = fPartition != NULL;
32 	int32 changeCounter = fChild->ChangeCounter();
33 	int32 parentChangeCounter = haveParent ? fPartition->ChangeCounter() : 0;
34 	partition_id parentID = haveParent ? fPartition->PartitionID() : -1;
35 
36 	status_t error = _kern_uninitialize_partition(fChild->PartitionID(),
37 		&changeCounter, parentID, &parentChangeCounter);
38 
39 	if (error != B_OK)
40 		return error;
41 
42 	fChild->SetChangeCounter(changeCounter);
43 	if (haveParent)
44 		fPartition->SetChangeCounter(parentChangeCounter);
45 
46 	return B_OK;
47 }
48 
49