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