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