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