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
6*f75b8de3SAxel 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
InitializeJob(PartitionReference * partition)16c70623faSIngo Weinhold InitializeJob::InitializeJob(PartitionReference* partition)
17*f75b8de3SAxel Dörfler :
18*f75b8de3SAxel Dörfler DiskDeviceJob(partition),
19c70623faSIngo Weinhold fDiskSystem(NULL),
20c70623faSIngo Weinhold fName(NULL),
21c70623faSIngo Weinhold fParameters(NULL)
22c70623faSIngo Weinhold {
23c70623faSIngo Weinhold }
24c70623faSIngo Weinhold
25c70623faSIngo Weinhold
26c70623faSIngo Weinhold // destructor
~InitializeJob()27c70623faSIngo Weinhold InitializeJob::~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 Weinhold status_t
Init(const char * diskSystem,const char * name,const char * parameters)37c70623faSIngo Weinhold InitializeJob::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 Weinhold status_t
Do()50c70623faSIngo Weinhold InitializeJob::Do()
51c70623faSIngo Weinhold {
52300868ceSIngo Weinhold int32 changeCounter = fPartition->ChangeCounter();
53300868ceSIngo Weinhold
54*f75b8de3SAxel Dörfler status_t error = _kern_initialize_partition(fPartition->PartitionID(),
55*f75b8de3SAxel 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