vold2: Some more work on partitioning support
Signed-off-by: San Mehat <san@google.com>
diff --git a/Volume.cpp b/Volume.cpp
index 75767e9..bdd0ada 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -56,6 +56,17 @@
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 @@
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;
}