-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
system: vold2: Initial skeleton for vold2.
Let there be light. Signed-off-by: San Mehat <san@android.com>
- Loading branch information
San Mehat
committed
Oct 11, 2009
1 parent
8f8ba4d
commit f1b736b
Showing
20 changed files
with
1,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
BUILD_VOLD2 := false | ||
ifeq ($(BUILD_VOLD2),true) | ||
|
||
LOCAL_PATH:= $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
|
||
LOCAL_SRC_FILES:= \ | ||
main.cpp \ | ||
VolumeManager.cpp \ | ||
CommandListener.cpp \ | ||
VoldCommand.cpp \ | ||
NetlinkManager.cpp \ | ||
NetlinkHandler.cpp \ | ||
BlockDevice.cpp \ | ||
Volume.cpp \ | ||
DeviceVolume.cpp | ||
|
||
LOCAL_MODULE:= vold | ||
|
||
LOCAL_C_INCLUDES := $(KERNEL_HEADERS) -I../../frameworks/base/include/ | ||
|
||
LOCAL_CFLAGS := | ||
|
||
LOCAL_SHARED_LIBRARIES := libsysutils | ||
|
||
include $(BUILD_EXECUTABLE) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_SRC_FILES:= \ | ||
vdc.c \ | ||
|
||
LOCAL_MODULE:= vdc | ||
|
||
LOCAL_C_INCLUDES := $(KERNEL_HEADERS) | ||
|
||
LOCAL_CFLAGS := | ||
|
||
LOCAL_SHARED_LIBRARIES := libcutils | ||
|
||
include $(BUILD_EXECUTABLE) | ||
|
||
endif # ifeq ($(BUILD_VOLD,true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2008 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
#define LOG_TAG "Vold" | ||
|
||
#include <cutils/log.h> | ||
|
||
#include "BlockDevice.h" | ||
|
||
BlockDevice::BlockDevice(const char *devpath, int major, int minor) { | ||
mDevpath = strdup(devpath); | ||
mMajor = major; | ||
mMinor = minor; | ||
} | ||
|
||
BlockDevice::~BlockDevice() { | ||
free(mDevpath); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2008 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef _BLKDEVICE_H | ||
#define _BLKDEVICE_H | ||
|
||
#include <utils/List.h> | ||
|
||
class BlockDevice { | ||
|
||
char *mDevpath; | ||
int mMajor; | ||
int mMinor; | ||
|
||
public: | ||
BlockDevice(const char *devpath, int major, int minor); | ||
virtual ~BlockDevice(); | ||
|
||
const char *getDevpath() { return mDevpath; } | ||
int getMajor() { return mMajor; } | ||
int getMinor() { return mMinor; } | ||
}; | ||
|
||
typedef android::List<BlockDevice *> BlockDeviceCollection; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (C) 2008 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
#include <errno.h> | ||
|
||
#define LOG_TAG "CommandListener" | ||
#include <cutils/log.h> | ||
|
||
#include <sysutils/SocketClient.h> | ||
|
||
#include "CommandListener.h" | ||
#include "VolumeManager.h" | ||
#include "ErrorCode.h" | ||
|
||
CommandListener::CommandListener() : | ||
FrameworkListener("vold") { | ||
registerCmd(new ListVolumesCmd()); | ||
registerCmd(new MountVolumeCmd()); | ||
registerCmd(new UnmountVolumeCmd()); | ||
registerCmd(new ShareVolumeCmd()); | ||
registerCmd(new UnshareVolumeCmd()); | ||
} | ||
|
||
CommandListener::ListVolumesCmd::ListVolumesCmd() : | ||
VoldCommand("list_volumes") { | ||
} | ||
|
||
int CommandListener::ListVolumesCmd::runCommand(SocketClient *cli, | ||
int argc, char **argv) { | ||
return VolumeManager::Instance()->listVolumes(cli); | ||
} | ||
|
||
CommandListener::MountVolumeCmd::MountVolumeCmd() : | ||
VoldCommand("mount_volume") { | ||
} | ||
|
||
int CommandListener::MountVolumeCmd::runCommand(SocketClient *cli, | ||
int argc, char **argv) { | ||
VolumeManager *nm = VolumeManager::Instance(); | ||
errno = ENOSYS; | ||
cli->sendMsg(ErrorCode::OperationFailed, "Failed to mount volume", true); | ||
return 0; | ||
} | ||
|
||
CommandListener::UnmountVolumeCmd::UnmountVolumeCmd() : | ||
VoldCommand("unmount_volume") { | ||
} | ||
|
||
int CommandListener::UnmountVolumeCmd::runCommand(SocketClient *cli, | ||
int argc, char **argv) { | ||
VolumeManager *nm = VolumeManager::Instance(); | ||
errno = ENOSYS; | ||
cli->sendMsg(ErrorCode::OperationFailed, "Failed to unmount volume", true); | ||
return 0; | ||
} | ||
|
||
CommandListener::ShareVolumeCmd::ShareVolumeCmd() : | ||
VoldCommand("share_volume") { | ||
} | ||
|
||
int CommandListener::ShareVolumeCmd::runCommand(SocketClient *cli, | ||
int argc, char **argv) { | ||
VolumeManager *nm = VolumeManager::Instance(); | ||
errno = ENOSYS; | ||
cli->sendMsg(ErrorCode::OperationFailed, "Failed to share volume", true); | ||
return 0; | ||
} | ||
|
||
CommandListener::UnshareVolumeCmd::UnshareVolumeCmd() : | ||
VoldCommand("unshare_volume") { | ||
} | ||
|
||
int CommandListener::UnshareVolumeCmd::runCommand(SocketClient *cli, | ||
int argc, char **argv) { | ||
VolumeManager *nm = VolumeManager::Instance(); | ||
errno = ENOSYS; | ||
cli->sendMsg(ErrorCode::OperationFailed, "Failed to unshare volume", true); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2008 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef _COMMANDLISTENER_H__ | ||
#define _COMMANDLISTENER_H__ | ||
|
||
#include <sysutils/FrameworkListener.h> | ||
#include "VoldCommand.h" | ||
|
||
class CommandListener : public FrameworkListener { | ||
public: | ||
CommandListener(); | ||
virtual ~CommandListener() {} | ||
|
||
private: | ||
|
||
class ListVolumesCmd : public VoldCommand { | ||
public: | ||
ListVolumesCmd(); | ||
virtual ~ListVolumesCmd() {} | ||
int runCommand(SocketClient *c, int argc, char ** argv); | ||
}; | ||
|
||
class MountVolumeCmd : public VoldCommand { | ||
public: | ||
MountVolumeCmd(); | ||
virtual ~MountVolumeCmd() {} | ||
int runCommand(SocketClient *c, int argc, char ** argv); | ||
}; | ||
|
||
class UnmountVolumeCmd : public VoldCommand { | ||
public: | ||
UnmountVolumeCmd(); | ||
virtual ~UnmountVolumeCmd() {} | ||
int runCommand(SocketClient *c, int argc, char ** argv); | ||
}; | ||
|
||
class ShareVolumeCmd : public VoldCommand { | ||
public: | ||
ShareVolumeCmd(); | ||
virtual ~ShareVolumeCmd() {} | ||
int runCommand(SocketClient *c, int argc, char ** argv); | ||
}; | ||
|
||
class UnshareVolumeCmd : public VoldCommand { | ||
public: | ||
UnshareVolumeCmd(); | ||
virtual ~UnshareVolumeCmd() {} | ||
int runCommand(SocketClient *c, int argc, char ** argv); | ||
}; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2008 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
#define LOG_TAG "Vold" | ||
|
||
#include <cutils/log.h> | ||
|
||
#include "DeviceVolume.h" | ||
|
||
DeviceVolume::DeviceVolume(const char *label, const char *mount_point, int partIdx) : | ||
Volume(label, mount_point) { | ||
mPartIdx = partIdx; | ||
|
||
mPaths = new PathCollection(); | ||
} | ||
|
||
DeviceVolume::~DeviceVolume() { | ||
PathCollection::iterator it; | ||
|
||
for (it = mPaths->begin(); it != mPaths->end(); ++it) | ||
free(*it); | ||
delete mPaths; | ||
} | ||
|
||
int DeviceVolume::addPath(const char *path) { | ||
mPaths->push_back(strdup(path)); | ||
return 0; | ||
} | ||
|
||
int DeviceVolume::handleDiskInsertion(const char *dp, int maj, int min, | ||
int nr_parts) { | ||
PathCollection::iterator it; | ||
|
||
LOGD("Dv::diskInsertion - %s %d %d %d", dp, maj, min, nr_parts); | ||
for (it = mPaths->begin(); it != mPaths->end(); ++it) { | ||
LOGD("Dv::chk %s", *it); | ||
if (!strncmp(dp, *it, strlen(*it))) { | ||
/* | ||
* We can handle this disk. If there are no partitions then we're | ||
* good to go son! | ||
*/ | ||
mDiskMaj = maj; | ||
mDiskNumParts = nr_parts; | ||
if (nr_parts == 0) { | ||
LOGD("Dv::diskIns - No partitions - good to go"); | ||
setState(Volume::State_Idle); | ||
} else { | ||
LOGD("Dv::diskIns - waiting for %d partitions", nr_parts); | ||
setState(Volume::State_Pending); | ||
} | ||
return 0; | ||
} | ||
} | ||
errno = ENODEV; | ||
return -1; | ||
} |
Oops, something went wrong.