1 /*
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
19 #include <inttypes.h>
20
21 #include <android-base/logging.h>
22 #include <android-base/stringprintf.h>
23
24 using android::base::StringPrintf;
25
26 namespace android {
27 namespace vold {
28
StubVolume(dev_t id,const std::string & sourcePath,const std::string & mountPath,const std::string & fsType,const std::string & fsUuid,const std::string & fsLabel)29 StubVolume::StubVolume(dev_t id, const std::string& sourcePath, const std::string& mountPath,
30 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) {
38 setId(StringPrintf("stub:%llu", (unsigned long long)id));
39 }
40
~StubVolume()41 StubVolume::~StubVolume() {}
42
doCreate()43 status_t StubVolume::doCreate() {
44 return OK;
45 }
46
doDestroy()47 status_t StubVolume::doDestroy() {
48 return OK;
49 }
50
doMount()51 status_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
doUnmount()59 status_t StubVolume::doUnmount() {
60 return OK;
61 }
62
63 // TODO: return error instead.
doFormat(const std::string & fsType)64 status_t StubVolume::doFormat(const std::string& fsType) {
65 return OK;
66 }
67
68 } // namespace vold
69 } // namespace android
70