blob: d2cd8a85ae34341f9277211c833283c09e2857a0 [file] [log] [blame]
Risan8c9f3322018-10-29 08:52:56 +09001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "StubVolume.h"
18
Risan82e90de2020-02-04 16:07:21 +090019#include <inttypes.h>
20
Risan8c9f3322018-10-29 08:52:56 +090021#include <android-base/logging.h>
22#include <android-base/stringprintf.h>
23
24using android::base::StringPrintf;
25
26namespace android {
27namespace vold {
28
Risan82e90de2020-02-04 16:07:21 +090029StubVolume::StubVolume(dev_t id, const std::string& sourcePath, const std::string& mountPath,
Risan8c9f3322018-10-29 08:52:56 +090030 const std::string& fsType, const std::string& fsUuid,
31 const std::string& fsLabel)
32 : VolumeBase(Type::kStub),
33 mSourcePath(sourcePath),
34 mMountPath(mountPath),
35 mFsType(fsType),
36 mFsUuid(fsUuid),
37 mFsLabel(fsLabel) {
Risan82e90de2020-02-04 16:07:21 +090038 setId(StringPrintf("stub:%llu", (unsigned long long)id));
Risan8c9f3322018-10-29 08:52:56 +090039}
40
41StubVolume::~StubVolume() {}
42
43status_t StubVolume::doCreate() {
44 return OK;
45}
46
47status_t StubVolume::doDestroy() {
48 return OK;
49}
50
51status_t StubVolume::doMount() {
52 auto listener = getListener();
53 if (listener) listener->onVolumeMetadataChanged(getId(), mFsType, mFsUuid, mFsLabel);
54 setInternalPath(mSourcePath);
55 setPath(mMountPath);
56 return OK;
57}
58
59status_t StubVolume::doUnmount() {
60 return OK;
61}
62
63// TODO: return error instead.
64status_t StubVolume::doFormat(const std::string& fsType) {
65 return OK;
66}
67
68} // namespace vold
69} // namespace android