1/*
2 * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "InitializeJob.h"
8
9#include <syscalls.h>
10
11#include "DiskDeviceUtils.h"
12#include "PartitionReference.h"
13
14
15// constructor
16InitializeJob::InitializeJob(PartitionReference* partition)
17	:
18	DiskDeviceJob(partition),
19	fDiskSystem(NULL),
20	fName(NULL),
21	fParameters(NULL)
22{
23}
24
25
26// destructor
27InitializeJob::~InitializeJob()
28{
29	free(fDiskSystem);
30	free(fName);
31	free(fParameters);
32}
33
34
35// Init
36status_t
37InitializeJob::Init(const char* diskSystem, const char* name,
38	const char* parameters)
39{
40	SET_STRING_RETURN_ON_ERROR(fDiskSystem, diskSystem);
41	SET_STRING_RETURN_ON_ERROR(fName, name);
42	SET_STRING_RETURN_ON_ERROR(fParameters, parameters);
43
44	return B_OK;
45}
46
47
48// Do
49status_t
50InitializeJob::Do()
51{
52	int32 changeCounter = fPartition->ChangeCounter();
53
54	status_t error = _kern_initialize_partition(fPartition->PartitionID(),
55		&changeCounter, fDiskSystem, fName, fParameters);
56	if (error != B_OK)
57		return error;
58
59	fPartition->SetChangeCounter(changeCounter);
60
61	return B_OK;
62}
63
64