summaryrefslogtreecommitdiffstats
path: root/Loop.cpp
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-07-12 09:59:49 -0700
committerKenny Root <kroot@google.com>2010-07-15 12:41:01 -0700
commit508c0e1605b795bbb51cb47d955b89f3df26ca94 (patch)
treef81d933fa05f1653d6e67d75c756689371316638 /Loop.cpp
parentfb7c4d5a8a1031cf0e493ff182dcf458e5fe8c77 (diff)
downloadandroid_system_vold-508c0e1605b795bbb51cb47d955b89f3df26ca94.tar.gz
android_system_vold-508c0e1605b795bbb51cb47d955b89f3df26ca94.tar.bz2
android_system_vold-508c0e1605b795bbb51cb47d955b89f3df26ca94.zip
Additional Obb functionality
* Rename all functions dealing with OBB files to mention Obb * Add 'path' and 'list' functionality to OBB commands * Store hashed filename in loop's lo_crypt_name and keep lo_file_name for the real source filename. That way we can recover it later with an ioctl call. Change-Id: I29e468265988bfb931d981532d86d7be7b3adfc8
Diffstat (limited to 'Loop.cpp')
-rw-r--r--Loop.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/Loop.cpp b/Loop.cpp
index 374cac0..2209f1a 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -38,7 +38,7 @@ int Loop::dumpState(SocketClient *c) {
char filename[256];
for (i = 0; i < LOOP_MAX; i++) {
- struct loop_info li;
+ struct loop_info64 li;
int rc;
sprintf(filename, "/dev/block/loop%d", i);
@@ -52,7 +52,7 @@ int Loop::dumpState(SocketClient *c) {
return -1;
}
- rc = ioctl(fd, LOOP_GET_STATUS, &li);
+ rc = ioctl(fd, LOOP_GET_STATUS64, &li);
close(fd);
if (rc < 0 && errno == ENXIO) {
continue;
@@ -64,9 +64,10 @@ int Loop::dumpState(SocketClient *c) {
return -1;
}
char *tmp = NULL;
- asprintf(&tmp, "%s %d %d:%d %lu %d:%d %d 0x%x {%s}", filename, li.lo_number,
+ asprintf(&tmp, "%s %d %lld:%lld %llu %lld:%lld %lld 0x%x {%s} {%s}", filename, li.lo_number,
MAJOR(li.lo_device), MINOR(li.lo_device), li.lo_inode, MAJOR(li.lo_rdevice),
- MINOR(li.lo_rdevice), li.lo_offset, li.lo_flags, li.lo_name);
+ MINOR(li.lo_rdevice), li.lo_offset, li.lo_flags, li.lo_crypt_name,
+ li.lo_file_name);
c->sendMsg(0, tmp, false);
free(tmp);
}
@@ -81,7 +82,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
memset(buffer, 0, len);
for (i = 0; i < LOOP_MAX; i++) {
- struct loop_info li;
+ struct loop_info64 li;
int rc;
sprintf(filename, "/dev/block/loop%d", i);
@@ -95,7 +96,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
return -1;
}
- rc = ioctl(fd, LOOP_GET_STATUS, &li);
+ rc = ioctl(fd, LOOP_GET_STATUS64, &li);
close(fd);
if (rc < 0 && errno == ENXIO) {
continue;
@@ -106,7 +107,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
strerror(errno));
return -1;
}
- if (!strncmp(li.lo_name, id, LO_NAME_SIZE)) {
+ if (!strncmp((const char*) li.lo_crypt_name, id, LO_NAME_SIZE)) {
break;
}
}
@@ -148,7 +149,7 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
return -1;
}
- rc = ioctl(fd, LOOP_GET_STATUS, &li);
+ rc = ioctl(fd, LOOP_GET_STATUS64, &li);
if (rc < 0 && errno == ENXIO)
break;
@@ -184,12 +185,13 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
return -1;
}
- struct loop_info li;
+ struct loop_info64 li;
memset(&li, 0, sizeof(li));
- strncpy(li.lo_name, id, LO_NAME_SIZE);
+ strncpy((char*) li.lo_crypt_name, id, LO_NAME_SIZE);
+ strncpy((char*) li.lo_file_name, loopFile, LO_NAME_SIZE);
- if (ioctl(fd, LOOP_SET_STATUS, &li) < 0) {
+ if (ioctl(fd, LOOP_SET_STATUS64, &li) < 0) {
SLOGE("Error setting loopback status (%s)", strerror(errno));
close(file_fd);
close(fd);