summaryrefslogtreecommitdiffstats
path: root/Volume.cpp
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-10-21 11:06:52 -0700
committerSan Mehat <san@google.com>2009-10-21 11:07:21 -0700
commitdd9b8e92aaf330b48ddb40a7380588ef92b53de6 (patch)
tree230fed516faca555d4a4d247ec4b24cfac3c0c70 /Volume.cpp
parent49e2bce5b74129c26a35e25d4693cbfe98c4688e (diff)
downloadsystem_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.zip
system_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.tar.gz
system_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.tar.bz2
vold2: Some more work on partitioning support
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'Volume.cpp')
-rw-r--r--Volume.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/Volume.cpp b/Volume.cpp
index 75767e9..bdd0ada 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -56,6 +56,17 @@ void Volume::setState(int state) {
mState = state;
}
+int Volume::createDeviceNode(const char *path, int major, int minor) {
+ mode_t mode = 0660 | S_IFBLK;
+ dev_t dev = (major << 8) | minor;
+ if (mknod(path, mode, dev) < 0) {
+ if (errno != EEXIST) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
int Volume::mount() {
char nodepath[255];
int major = -1, minor = -1;
@@ -65,22 +76,27 @@ int Volume::mount() {
return -1;
}
- /* Create device nodes */
- mode_t mode = 0660 | S_IFBLK;
- dev_t dev = (major << 8) | minor;
sprintf(nodepath, "/dev/block/vold/%d:%d", major, minor);
- if (mknod(nodepath, mode, dev) < 0) {
- LOGE("Error making device nodes for '%s' (%s)",
- nodepath, strerror(errno));
+
+ LOGD("nodepath = %s\n", nodepath);
+
+ /* Create device nodes */
+ if (createDeviceNode(nodepath, major, minor)) {
+ LOGE("Error making device nodes for '%s' (%s)", nodepath,
+ strerror(errno));
+ // XXX: cleanup will be needed eventually
return -1;
}
/* Run disk checker */
if (checkFilesystem(nodepath)) {
+ LOGE("Error checking filesystem (%s)", strerror(errno));
setState(Volume::State_Idle);
return -1;
}
+
+
setState(Volume::State_Idle);
return 0;
}