vold: Switch from LOG -> SLOG
Change-Id: I48ee8bd90b47f5845f069cdf4d1b8ba6ecdb1b39 Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
parent
da62e7c002
commit
97ac40e4e6
13 changed files with 208 additions and 208 deletions
|
@ -71,7 +71,7 @@ void CommandListener::dumpArgs(int argc, char **argv, int argObscure) {
|
|||
}
|
||||
}
|
||||
}
|
||||
LOGD("%s", buffer);
|
||||
SLOGD("%s", buffer);
|
||||
}
|
||||
|
||||
CommandListener::DumpCmd::DumpCmd() :
|
||||
|
|
|
@ -38,21 +38,21 @@ int Devmapper::dumpState(SocketClient *c) {
|
|||
|
||||
char *buffer = (char *) malloc(1024 * 64);
|
||||
if (!buffer) {
|
||||
LOGE("Error allocating memory (%s)", strerror(errno));
|
||||
SLOGE("Error allocating memory (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
memset(buffer, 0, (1024 * 64));
|
||||
|
||||
char *buffer2 = (char *) malloc(4096);
|
||||
if (!buffer2) {
|
||||
LOGE("Error allocating memory (%s)", strerror(errno));
|
||||
SLOGE("Error allocating memory (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0) {
|
||||
LOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
SLOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
free(buffer2);
|
||||
return -1;
|
||||
|
@ -62,7 +62,7 @@ int Devmapper::dumpState(SocketClient *c) {
|
|||
ioctlInit(io, (1024 * 64), NULL, 0);
|
||||
|
||||
if (ioctl(fd, DM_LIST_DEVICES, io)) {
|
||||
LOGE("DM_LIST_DEVICES ioctl failed (%s)", strerror(errno));
|
||||
SLOGE("DM_LIST_DEVICES ioctl failed (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
free(buffer2);
|
||||
close(fd);
|
||||
|
@ -86,7 +86,7 @@ int Devmapper::dumpState(SocketClient *c) {
|
|||
ioctlInit(io2, 4096, n->name, 0);
|
||||
if (ioctl(fd, DM_DEV_STATUS, io2)) {
|
||||
if (errno != ENXIO) {
|
||||
LOGE("DM_DEV_STATUS ioctl failed (%s)", strerror(errno));
|
||||
SLOGE("DM_DEV_STATUS ioctl failed (%s)", strerror(errno));
|
||||
}
|
||||
io2 = NULL;
|
||||
}
|
||||
|
@ -127,13 +127,13 @@ void Devmapper::ioctlInit(struct dm_ioctl *io, size_t dataSize,
|
|||
int Devmapper::lookupActive(const char *name, char *ubuffer, size_t len) {
|
||||
char *buffer = (char *) malloc(4096);
|
||||
if (!buffer) {
|
||||
LOGE("Error allocating memory (%s)", strerror(errno));
|
||||
SLOGE("Error allocating memory (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0) {
|
||||
LOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
SLOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ int Devmapper::lookupActive(const char *name, char *ubuffer, size_t len) {
|
|||
ioctlInit(io, 4096, name, 0);
|
||||
if (ioctl(fd, DM_DEV_STATUS, io)) {
|
||||
if (errno != ENXIO) {
|
||||
LOGE("DM_DEV_STATUS ioctl failed for lookup (%s)", strerror(errno));
|
||||
SLOGE("DM_DEV_STATUS ioctl failed for lookup (%s)", strerror(errno));
|
||||
}
|
||||
free(buffer);
|
||||
close(fd);
|
||||
|
@ -161,13 +161,13 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
unsigned int numSectors, char *ubuffer, size_t len) {
|
||||
char *buffer = (char *) malloc(4096);
|
||||
if (!buffer) {
|
||||
LOGE("Error allocating memory (%s)", strerror(errno));
|
||||
SLOGE("Error allocating memory (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0) {
|
||||
LOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
SLOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
ioctlInit(io, 4096, name, 0);
|
||||
|
||||
if (ioctl(fd, DM_DEV_CREATE, io)) {
|
||||
LOGE("Error creating device mapping (%s)", strerror(errno));
|
||||
SLOGE("Error creating device mapping (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -193,7 +193,7 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
geoParams += strlen(geoParams) + 1;
|
||||
geoParams = (char *) _align(geoParams, 8);
|
||||
if (ioctl(fd, DM_DEV_SET_GEOMETRY, io)) {
|
||||
LOGE("Error setting device geometry (%s)", strerror(errno));
|
||||
SLOGE("Error setting device geometry (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -202,7 +202,7 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
// Retrieve the device number we were allocated
|
||||
ioctlInit(io, 4096, name, 0);
|
||||
if (ioctl(fd, DM_DEV_STATUS, io)) {
|
||||
LOGE("Error retrieving devmapper status (%s)", strerror(errno));
|
||||
SLOGE("Error retrieving devmapper status (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -231,7 +231,7 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
tgt->next = cryptParams - buffer;
|
||||
|
||||
if (ioctl(fd, DM_TABLE_LOAD, io)) {
|
||||
LOGE("Error loading mapping table (%s)", strerror(errno));
|
||||
SLOGE("Error loading mapping table (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -241,7 +241,7 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
ioctlInit(io, 4096, name, 0);
|
||||
|
||||
if (ioctl(fd, DM_DEV_SUSPEND, io)) {
|
||||
LOGE("Error Resuming (%s)", strerror(errno));
|
||||
SLOGE("Error Resuming (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -256,13 +256,13 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key,
|
|||
int Devmapper::destroy(const char *name) {
|
||||
char *buffer = (char *) malloc(4096);
|
||||
if (!buffer) {
|
||||
LOGE("Error allocating memory (%s)", strerror(errno));
|
||||
SLOGE("Error allocating memory (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0) {
|
||||
LOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
SLOGE("Error opening devmapper (%s)", strerror(errno));
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ int Devmapper::destroy(const char *name) {
|
|||
|
||||
if (ioctl(fd, DM_DEV_REMOVE, io)) {
|
||||
if (errno != ENXIO) {
|
||||
LOGE("Error destroying device mapping (%s)", strerror(errno));
|
||||
SLOGE("Error destroying device mapping (%s)", strerror(errno));
|
||||
}
|
||||
free(buffer);
|
||||
close(fd);
|
||||
|
|
|
@ -92,7 +92,7 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
|
|||
sizeof(nodepath), "/dev/block/vold/%d:%d",
|
||||
major, minor);
|
||||
if (createDeviceNode(nodepath, major, minor)) {
|
||||
LOGE("Error making device node '%s' (%s)", nodepath,
|
||||
SLOGE("Error making device node '%s' (%s)", nodepath,
|
||||
strerror(errno));
|
||||
}
|
||||
if (!strcmp(devtype, "disk")) {
|
||||
|
@ -113,7 +113,7 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
|
|||
handlePartitionChanged(dp, evt);
|
||||
}
|
||||
} else {
|
||||
LOGW("Ignoring non add/remove/change event");
|
||||
SLOGW("Ignoring non add/remove/change event");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -131,7 +131,7 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
|
|||
if (tmp) {
|
||||
mDiskNumParts = atoi(tmp);
|
||||
} else {
|
||||
LOGW("Kernel block uevent missing 'NPARTS'");
|
||||
SLOGW("Kernel block uevent missing 'NPARTS'");
|
||||
mDiskNumParts = 1;
|
||||
}
|
||||
|
||||
|
@ -146,12 +146,12 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
|
|||
|
||||
if (mDiskNumParts == 0) {
|
||||
#ifdef PARTITION_DEBUG
|
||||
LOGD("Dv::diskIns - No partitions - good to go son!");
|
||||
SLOGD("Dv::diskIns - No partitions - good to go son!");
|
||||
#endif
|
||||
setState(Volume::State_Idle);
|
||||
} else {
|
||||
#ifdef PARTITION_DEBUG
|
||||
LOGD("Dv::diskIns - waiting for %d partitions (mask 0x%x)",
|
||||
SLOGD("Dv::diskIns - waiting for %d partitions (mask 0x%x)",
|
||||
mDiskNumParts, mPendingPartMap);
|
||||
#endif
|
||||
setState(Volume::State_Pending);
|
||||
|
@ -174,7 +174,7 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt)
|
|||
if (tmp) {
|
||||
part_num = atoi(tmp);
|
||||
} else {
|
||||
LOGW("Kernel block uevent missing 'PARTN'");
|
||||
SLOGW("Kernel block uevent missing 'PARTN'");
|
||||
part_num = 1;
|
||||
}
|
||||
|
||||
|
@ -183,25 +183,25 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt)
|
|||
}
|
||||
|
||||
if (major != mDiskMajor) {
|
||||
LOGE("Partition '%s' has a different major than its disk!", devpath);
|
||||
SLOGE("Partition '%s' has a different major than its disk!", devpath);
|
||||
return;
|
||||
}
|
||||
#ifdef PARTITION_DEBUG
|
||||
LOGD("Dv:partAdd: part_num = %d, minor = %d\n", part_num, minor);
|
||||
SLOGD("Dv:partAdd: part_num = %d, minor = %d\n", part_num, minor);
|
||||
#endif
|
||||
mPartMinors[part_num -1] = minor;
|
||||
|
||||
mPendingPartMap &= ~(1 << part_num);
|
||||
if (!mPendingPartMap) {
|
||||
#ifdef PARTITION_DEBUG
|
||||
LOGD("Dv:partAdd: Got all partitions - ready to rock!");
|
||||
SLOGD("Dv:partAdd: Got all partitions - ready to rock!");
|
||||
#endif
|
||||
if (getState() != Volume::State_Formatting) {
|
||||
setState(Volume::State_Idle);
|
||||
}
|
||||
} else {
|
||||
#ifdef PARTITION_DEBUG
|
||||
LOGD("Dv:partAdd: pending mask now = 0x%x", mPendingPartMap);
|
||||
SLOGD("Dv:partAdd: pending mask now = 0x%x", mPendingPartMap);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
|
|||
return;
|
||||
}
|
||||
|
||||
LOGI("Volume %s disk has changed", getLabel());
|
||||
SLOGI("Volume %s disk has changed", getLabel());
|
||||
const char *tmp = evt->findParam("NPARTS");
|
||||
if (tmp) {
|
||||
mDiskNumParts = atoi(tmp);
|
||||
} else {
|
||||
LOGW("Kernel block uevent missing 'NPARTS'");
|
||||
SLOGW("Kernel block uevent missing 'NPARTS'");
|
||||
mDiskNumParts = 1;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
|
|||
void DirectVolume::handlePartitionChanged(const char *devpath, NetlinkEvent *evt) {
|
||||
int major = atoi(evt->findParam("MAJOR"));
|
||||
int minor = atoi(evt->findParam("MINOR"));
|
||||
LOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor);
|
||||
SLOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor);
|
||||
}
|
||||
|
||||
void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
|
||||
|
@ -250,7 +250,7 @@ void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
|
|||
int minor = atoi(evt->findParam("MINOR"));
|
||||
char msg[255];
|
||||
|
||||
LOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
|
||||
SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
|
||||
snprintf(msg, sizeof(msg), "Volume %s %s disk removed (%d:%d)",
|
||||
getLabel(), getMountpoint(), major, minor);
|
||||
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskRemoved,
|
||||
|
@ -263,7 +263,7 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
|
|||
int minor = atoi(evt->findParam("MINOR"));
|
||||
char msg[255];
|
||||
|
||||
LOGD("Volume %s %s partition %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
|
||||
SLOGD("Volume %s %s partition %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
|
||||
|
||||
/*
|
||||
* The framework doesn't need to get notified of
|
||||
|
@ -285,11 +285,11 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
|
|||
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
|
||||
msg, false);
|
||||
if (Volume::unmountVol(true)) {
|
||||
LOGE("Failed to unmount volume on bad removal (%s)",
|
||||
SLOGE("Failed to unmount volume on bad removal (%s)",
|
||||
strerror(errno));
|
||||
// XXX: At this point we're screwed for now
|
||||
} else {
|
||||
LOGD("Crisis averted");
|
||||
SLOGD("Crisis averted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
22
Fat.cpp
22
Fat.cpp
|
@ -46,7 +46,7 @@ extern "C" int mount(const char *, const char *, const char *, unsigned long, co
|
|||
int Fat::check(const char *fsPath) {
|
||||
bool rw = true;
|
||||
if (access(FSCK_MSDOS_PATH, X_OK)) {
|
||||
LOGW("Skipping fs checks\n");
|
||||
SLOGW("Skipping fs checks\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -64,26 +64,26 @@ int Fat::check(const char *fsPath) {
|
|||
|
||||
switch(rc) {
|
||||
case 0:
|
||||
LOGI("Filesystem check completed OK");
|
||||
SLOGI("Filesystem check completed OK");
|
||||
return 0;
|
||||
|
||||
case 2:
|
||||
LOGE("Filesystem check failed (not a FAT filesystem)");
|
||||
SLOGE("Filesystem check failed (not a FAT filesystem)");
|
||||
errno = ENODATA;
|
||||
return -1;
|
||||
|
||||
case 4:
|
||||
if (pass++ <= 3) {
|
||||
LOGW("Filesystem modified - rechecking (pass %d)",
|
||||
SLOGW("Filesystem modified - rechecking (pass %d)",
|
||||
pass);
|
||||
continue;
|
||||
}
|
||||
LOGE("Failing check after too many rechecks");
|
||||
SLOGE("Failing check after too many rechecks");
|
||||
errno = EIO;
|
||||
return -1;
|
||||
|
||||
default:
|
||||
LOGE("Filesystem check failed (unknown exit code %d)", rc);
|
||||
SLOGE("Filesystem check failed (unknown exit code %d)", rc);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ int Fat::doMount(const char *fsPath, const char *mountPoint,
|
|||
char value[PROPERTY_VALUE_MAX];
|
||||
property_get("persist.sampling_profiler", value, "");
|
||||
if (value[0] == '1') {
|
||||
LOGW("The SD card is world-writable because the"
|
||||
SLOGW("The SD card is world-writable because the"
|
||||
" 'persist.sampling_profiler' system property is set to '1'.");
|
||||
permMask = 0;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ int Fat::doMount(const char *fsPath, const char *mountPoint,
|
|||
rc = mount(fsPath, mountPoint, "vfat", flags, mountData);
|
||||
|
||||
if (rc && errno == EROFS) {
|
||||
LOGE("%s appears to be a read only filesystem - retrying mount RO", fsPath);
|
||||
SLOGE("%s appears to be a read only filesystem - retrying mount RO", fsPath);
|
||||
flags |= MS_RDONLY;
|
||||
rc = mount(fsPath, mountPoint, "vfat", flags, mountData);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ int Fat::doMount(const char *fsPath, const char *mountPoint,
|
|||
* lost cluster chains (fsck_msdos doesn't currently do this)
|
||||
*/
|
||||
if (mkdir(lost_path, 0755)) {
|
||||
LOGE("Unable to create LOST.DIR (%s)", strerror(errno));
|
||||
SLOGE("Unable to create LOST.DIR (%s)", strerror(errno));
|
||||
}
|
||||
}
|
||||
free(lost_path);
|
||||
|
@ -177,10 +177,10 @@ int Fat::format(const char *fsPath, unsigned int numSectors) {
|
|||
}
|
||||
|
||||
if (rc == 0) {
|
||||
LOGI("Filesystem formatted OK");
|
||||
SLOGI("Filesystem formatted OK");
|
||||
return 0;
|
||||
} else {
|
||||
LOGE("Format failed (unknown exit code %d)", rc);
|
||||
SLOGE("Format failed (unknown exit code %d)", rc);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
|
30
Loop.cpp
30
Loop.cpp
|
@ -45,7 +45,7 @@ int Loop::dumpState(SocketClient *c) {
|
|||
|
||||
if ((fd = open(filename, O_RDWR)) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
LOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
SLOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int Loop::dumpState(SocketClient *c) {
|
|||
}
|
||||
|
||||
if (rc < 0) {
|
||||
LOGE("Unable to get loop status for %s (%s)", filename,
|
||||
SLOGE("Unable to get loop status for %s (%s)", filename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
|
|||
|
||||
if ((fd = open(filename, O_RDWR)) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
LOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
SLOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
|
|||
}
|
||||
|
||||
if (rc < 0) {
|
||||
LOGE("Unable to get loop status for %s (%s)", filename,
|
||||
SLOGE("Unable to get loop status for %s (%s)", filename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -138,13 +138,13 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
|
|||
unsigned int dev = (0xff & i) | ((i << 12) & 0xfff00000) | (7 << 8);
|
||||
if (mknod(filename, mode, dev) < 0) {
|
||||
if (errno != EEXIST) {
|
||||
LOGE("Error creating loop device node (%s)", strerror(errno));
|
||||
SLOGE("Error creating loop device node (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_RDWR)) < 0) {
|
||||
LOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
SLOGE("Unable to open %s (%s)", filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,14 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
|
|||
close(fd);
|
||||
|
||||
if (rc < 0) {
|
||||
LOGE("Unable to get loop status for %s (%s)", filename,
|
||||
SLOGE("Unable to get loop status for %s (%s)", filename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == LOOP_MAX) {
|
||||
LOGE("Exhausted all loop devices");
|
||||
SLOGE("Exhausted all loop devices");
|
||||
errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
|
@ -172,13 +172,13 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
|
|||
int file_fd;
|
||||
|
||||
if ((file_fd = open(loopFile, O_RDWR)) < 0) {
|
||||
LOGE("Unable to open %s (%s)", loopFile, strerror(errno));
|
||||
SLOGE("Unable to open %s (%s)", loopFile, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, LOOP_SET_FD, file_fd) < 0) {
|
||||
LOGE("Error setting up loopback interface (%s)", strerror(errno));
|
||||
SLOGE("Error setting up loopback interface (%s)", strerror(errno));
|
||||
close(file_fd);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -190,7 +190,7 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
|
|||
strncpy(li.lo_name, id, LO_NAME_SIZE);
|
||||
|
||||
if (ioctl(fd, LOOP_SET_STATUS, &li) < 0) {
|
||||
LOGE("Error setting loopback status (%s)", strerror(errno));
|
||||
SLOGE("Error setting loopback status (%s)", strerror(errno));
|
||||
close(file_fd);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -207,12 +207,12 @@ int Loop::destroyByDevice(const char *loopDevice) {
|
|||
|
||||
device_fd = open(loopDevice, O_RDONLY);
|
||||
if (device_fd < 0) {
|
||||
LOGE("Failed to open loop (%d)", errno);
|
||||
SLOGE("Failed to open loop (%d)", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(device_fd, LOOP_CLR_FD, 0) < 0) {
|
||||
LOGE("Failed to destroy loop (%d)", errno);
|
||||
SLOGE("Failed to destroy loop (%d)", errno);
|
||||
close(device_fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -230,12 +230,12 @@ int Loop::createImageFile(const char *file, unsigned int numSectors) {
|
|||
int fd;
|
||||
|
||||
if ((fd = creat(file, 0600)) < 0) {
|
||||
LOGE("Error creating imagefile (%s)", strerror(errno));
|
||||
SLOGE("Error creating imagefile (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftruncate(fd, numSectors * 512) < 0) {
|
||||
LOGE("Error truncating imagefile (%s)", strerror(errno));
|
||||
SLOGE("Error truncating imagefile (%s)", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
|
|||
const char *subsys = evt->getSubsystem();
|
||||
|
||||
if (!subsys) {
|
||||
LOGW("No subsystem found in netlink event");
|
||||
SLOGW("No subsystem found in netlink event");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,23 +58,23 @@ int NetlinkManager::start() {
|
|||
|
||||
if ((mSock = socket(PF_NETLINK,
|
||||
SOCK_DGRAM,NETLINK_KOBJECT_UEVENT)) < 0) {
|
||||
LOGE("Unable to create uevent socket: %s", strerror(errno));
|
||||
SLOGE("Unable to create uevent socket: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setsockopt(mSock, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)) < 0) {
|
||||
LOGE("Unable to set uevent socket options: %s", strerror(errno));
|
||||
SLOGE("Unable to set uevent socket options: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bind(mSock, (struct sockaddr *) &nladdr, sizeof(nladdr)) < 0) {
|
||||
LOGE("Unable to bind uevent socket: %s", strerror(errno));
|
||||
SLOGE("Unable to bind uevent socket: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
mHandler = new NetlinkHandler(mSock);
|
||||
if (mHandler->start()) {
|
||||
LOGE("Unable to start NetlinkHandler: %s", strerror(errno));
|
||||
SLOGE("Unable to start NetlinkHandler: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -82,7 +82,7 @@ int NetlinkManager::start() {
|
|||
|
||||
int NetlinkManager::stop() {
|
||||
if (mHandler->stop()) {
|
||||
LOGE("Unable to stop NetlinkHandler: %s", strerror(errno));
|
||||
SLOGE("Unable to stop NetlinkHandler: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
delete mHandler;
|
||||
|
|
16
Process.cpp
16
Process.cpp
|
@ -182,7 +182,7 @@ void Process::killProcessesWithOpenFiles(const char *path, int action) {
|
|||
struct dirent* de;
|
||||
|
||||
if (!(dir = opendir("/proc"))) {
|
||||
LOGE("opendir failed (%s)", strerror(errno));
|
||||
SLOGE("opendir failed (%s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -198,23 +198,23 @@ void Process::killProcessesWithOpenFiles(const char *path, int action) {
|
|||
char openfile[PATH_MAX];
|
||||
|
||||
if (checkFileDescriptorSymLinks(pid, path, openfile, sizeof(openfile))) {
|
||||
LOGE("Process %s (%d) has open file %s", name, pid, openfile);
|
||||
SLOGE("Process %s (%d) has open file %s", name, pid, openfile);
|
||||
} else if (checkFileMaps(pid, path, openfile, sizeof(openfile))) {
|
||||
LOGE("Process %s (%d) has open filemap for %s", name, pid, openfile);
|
||||
SLOGE("Process %s (%d) has open filemap for %s", name, pid, openfile);
|
||||
} else if (checkSymLink(pid, path, "cwd")) {
|
||||
LOGE("Process %s (%d) has cwd within %s", name, pid, path);
|
||||
SLOGE("Process %s (%d) has cwd within %s", name, pid, path);
|
||||
} else if (checkSymLink(pid, path, "root")) {
|
||||
LOGE("Process %s (%d) has chroot within %s", name, pid, path);
|
||||
SLOGE("Process %s (%d) has chroot within %s", name, pid, path);
|
||||
} else if (checkSymLink(pid, path, "exe")) {
|
||||
LOGE("Process %s (%d) has executable path within %s", name, pid, path);
|
||||
SLOGE("Process %s (%d) has executable path within %s", name, pid, path);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (action == 1) {
|
||||
LOGW("Sending SIGHUP to process %d", pid);
|
||||
SLOGW("Sending SIGHUP to process %d", pid);
|
||||
kill(pid, SIGTERM);
|
||||
} else if (action == 2) {
|
||||
LOGE("Sending SIGKILL to process %d", pid);
|
||||
SLOGE("Sending SIGKILL to process %d", pid);
|
||||
kill(pid, SIGKILL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ int ResponseCode::convertFromErrno() {
|
|||
return(ResponseCode::OpFailedStorageNotFound);
|
||||
}
|
||||
|
||||
LOGW("Returning OperationFailed - no handler for errno %d", errno);
|
||||
SLOGW("Returning OperationFailed - no handler for errno %d", errno);
|
||||
return(ResponseCode::OperationFailed);
|
||||
}
|
||||
|
|
90
Volume.cpp
90
Volume.cpp
|
@ -117,7 +117,7 @@ void Volume::protectFromAutorunStupidity() {
|
|||
|
||||
snprintf(filename, sizeof(filename), "%s/autorun.inf", SEC_STGDIR);
|
||||
if (!access(filename, F_OK)) {
|
||||
LOGW("Volume contains an autorun.inf! - removing");
|
||||
SLOGW("Volume contains an autorun.inf! - removing");
|
||||
/*
|
||||
* Ensure the filename is all lower-case so
|
||||
* the process killer can find the inode.
|
||||
|
@ -126,7 +126,7 @@ void Volume::protectFromAutorunStupidity() {
|
|||
rename(filename, filename);
|
||||
Process::killProcessesWithOpenFiles(filename, 2);
|
||||
if (unlink(filename)) {
|
||||
LOGE("Failed to remove %s (%s)", filename, strerror(errno));
|
||||
SLOGE("Failed to remove %s (%s)", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,13 +155,13 @@ void Volume::setState(int state) {
|
|||
int oldState = mState;
|
||||
|
||||
if (oldState == state) {
|
||||
LOGW("Duplicate state (%d)\n", state);
|
||||
SLOGW("Duplicate state (%d)\n", state);
|
||||
return;
|
||||
}
|
||||
|
||||
mState = state;
|
||||
|
||||
LOGD("Volume %s state changing %d (%s) -> %d (%s)", mLabel,
|
||||
SLOGD("Volume %s state changing %d (%s) -> %d (%s)", mLabel,
|
||||
oldState, stateToStr(oldState), mState, stateToStr(mState));
|
||||
snprintf(msg, sizeof(msg),
|
||||
"Volume %s %s state changed from %d (%s) to %d (%s)", getLabel(),
|
||||
|
@ -194,7 +194,7 @@ int Volume::formatVol() {
|
|||
}
|
||||
|
||||
if (isMountpointMounted(getMountpoint())) {
|
||||
LOGW("Volume is idle but appears to be mounted - fixing");
|
||||
SLOGW("Volume is idle but appears to be mounted - fixing");
|
||||
setState(Volume::State_Mounted);
|
||||
// mCurrentlyMountedKdev = XXX
|
||||
errno = EBUSY;
|
||||
|
@ -209,12 +209,12 @@ int Volume::formatVol() {
|
|||
MAJOR(diskNode), MINOR(diskNode));
|
||||
|
||||
if (mDebug) {
|
||||
LOGI("Formatting volume %s (%s)", getLabel(), devicePath);
|
||||
SLOGI("Formatting volume %s (%s)", getLabel(), devicePath);
|
||||
}
|
||||
setState(Volume::State_Formatting);
|
||||
|
||||
if (initializeMbr(devicePath)) {
|
||||
LOGE("Failed to initialize MBR (%s)", strerror(errno));
|
||||
SLOGE("Failed to initialize MBR (%s)", strerror(errno));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ int Volume::formatVol() {
|
|||
MAJOR(partNode), MINOR(partNode));
|
||||
|
||||
if (Fat::format(devicePath, 0)) {
|
||||
LOGE("Failed to format (%s)", strerror(errno));
|
||||
SLOGE("Failed to format (%s)", strerror(errno));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ bool Volume::isMountpointMounted(const char *path) {
|
|||
char line[1024];
|
||||
|
||||
if (!(fp = fopen("/proc/mounts", "r"))) {
|
||||
LOGE("Error opening /proc/mounts (%s)", strerror(errno));
|
||||
SLOGE("Error opening /proc/mounts (%s)", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ int Volume::mountVol() {
|
|||
}
|
||||
|
||||
if (isMountpointMounted(getMountpoint())) {
|
||||
LOGW("Volume is idle but appears to be mounted - fixing");
|
||||
SLOGW("Volume is idle but appears to be mounted - fixing");
|
||||
setState(Volume::State_Mounted);
|
||||
// mCurrentlyMountedKdev = XXX
|
||||
return 0;
|
||||
|
@ -286,7 +286,7 @@ int Volume::mountVol() {
|
|||
|
||||
n = getDeviceNodes((dev_t *) &deviceNodes, 4);
|
||||
if (!n) {
|
||||
LOGE("Failed to get device nodes (%s)\n", strerror(errno));
|
||||
SLOGE("Failed to get device nodes (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -296,19 +296,19 @@ int Volume::mountVol() {
|
|||
sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(deviceNodes[i]),
|
||||
MINOR(deviceNodes[i]));
|
||||
|
||||
LOGI("%s being considered for volume %s\n", devicePath, getLabel());
|
||||
SLOGI("%s being considered for volume %s\n", devicePath, getLabel());
|
||||
|
||||
errno = 0;
|
||||
setState(Volume::State_Checking);
|
||||
|
||||
if (Fat::check(devicePath)) {
|
||||
if (errno == ENODATA) {
|
||||
LOGW("%s does not contain a FAT filesystem\n", devicePath);
|
||||
SLOGW("%s does not contain a FAT filesystem\n", devicePath);
|
||||
continue;
|
||||
}
|
||||
errno = EIO;
|
||||
/* Badness - abort the mount */
|
||||
LOGE("%s failed FS checks (%s)", devicePath, strerror(errno));
|
||||
SLOGE("%s failed FS checks (%s)", devicePath, strerror(errno));
|
||||
setState(Volume::State_Idle);
|
||||
return -1;
|
||||
}
|
||||
|
@ -319,16 +319,16 @@ int Volume::mountVol() {
|
|||
*/
|
||||
errno = 0;
|
||||
if (Fat::doMount(devicePath, "/mnt/secure/staging", false, false, 1000, 1015, 0702, true)) {
|
||||
LOGE("%s failed to mount via VFAT (%s)\n", devicePath, strerror(errno));
|
||||
SLOGE("%s failed to mount via VFAT (%s)\n", devicePath, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
LOGI("Device %s, target %s mounted @ /mnt/secure/staging", devicePath, getMountpoint());
|
||||
SLOGI("Device %s, target %s mounted @ /mnt/secure/staging", devicePath, getMountpoint());
|
||||
|
||||
protectFromAutorunStupidity();
|
||||
|
||||
if (createBindMounts()) {
|
||||
LOGE("Failed to create bindmounts (%s)", strerror(errno));
|
||||
SLOGE("Failed to create bindmounts (%s)", strerror(errno));
|
||||
umount("/mnt/secure/staging");
|
||||
setState(Volume::State_Idle);
|
||||
return -1;
|
||||
|
@ -339,7 +339,7 @@ int Volume::mountVol() {
|
|||
* whole subtree to expose it to non priviledged users.
|
||||
*/
|
||||
if (doMoveMount("/mnt/secure/staging", getMountpoint(), false)) {
|
||||
LOGE("Failed to move mount (%s)", strerror(errno));
|
||||
SLOGE("Failed to move mount (%s)", strerror(errno));
|
||||
umount("/mnt/secure/staging");
|
||||
setState(Volume::State_Idle);
|
||||
return -1;
|
||||
|
@ -349,7 +349,7 @@ int Volume::mountVol() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
LOGE("Volume %s found no suitable devices for mounting :(\n", getLabel());
|
||||
SLOGE("Volume %s found no suitable devices for mounting :(\n", getLabel());
|
||||
setState(Volume::State_Idle);
|
||||
|
||||
return -1;
|
||||
|
@ -364,7 +364,7 @@ int Volume::createBindMounts() {
|
|||
if (!access("/mnt/secure/staging/android_secure", R_OK | X_OK) &&
|
||||
access(SEC_STG_SECIMGDIR, R_OK | X_OK)) {
|
||||
if (rename("/mnt/secure/staging/android_secure", SEC_STG_SECIMGDIR)) {
|
||||
LOGE("Failed to rename legacy asec dir (%s)", strerror(errno));
|
||||
SLOGE("Failed to rename legacy asec dir (%s)", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,22 +374,22 @@ int Volume::createBindMounts() {
|
|||
if (access(SEC_STG_SECIMGDIR, R_OK | X_OK)) {
|
||||
if (errno == ENOENT) {
|
||||
if (mkdir(SEC_STG_SECIMGDIR, 0777)) {
|
||||
LOGE("Failed to create %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
SLOGE("Failed to create %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
LOGE("Failed to access %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
SLOGE("Failed to access %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
struct stat sbuf;
|
||||
|
||||
if (stat(SEC_STG_SECIMGDIR, &sbuf)) {
|
||||
LOGE("Failed to stat %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
SLOGE("Failed to stat %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (!S_ISDIR(sbuf.st_mode)) {
|
||||
LOGE("%s is not a directory", SEC_STG_SECIMGDIR);
|
||||
SLOGE("%s is not a directory", SEC_STG_SECIMGDIR);
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ int Volume::createBindMounts() {
|
|||
* have a root only accessable mountpoint for it.
|
||||
*/
|
||||
if (mount(SEC_STG_SECIMGDIR, SEC_ASECDIR, "", MS_BIND, NULL)) {
|
||||
LOGE("Failed to bind mount points %s -> %s (%s)",
|
||||
SLOGE("Failed to bind mount points %s -> %s (%s)",
|
||||
SEC_STG_SECIMGDIR, SEC_ASECDIR, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ int Volume::createBindMounts() {
|
|||
* obscure the underlying directory from everybody - sneaky eh? ;)
|
||||
*/
|
||||
if (mount("tmpfs", SEC_STG_SECIMGDIR, "tmpfs", MS_RDONLY, "size=0,mode=000,uid=0,gid=0")) {
|
||||
LOGE("Failed to obscure %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
SLOGE("Failed to obscure %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
umount("/mnt/asec_secure");
|
||||
return -1;
|
||||
}
|
||||
|
@ -425,11 +425,11 @@ int Volume::doMoveMount(const char *src, const char *dst, bool force) {
|
|||
while(retries--) {
|
||||
if (!mount(src, dst, "", flags, NULL)) {
|
||||
if (mDebug) {
|
||||
LOGD("Moved mount %s -> %s sucessfully", src, dst);
|
||||
SLOGD("Moved mount %s -> %s sucessfully", src, dst);
|
||||
}
|
||||
return 0;
|
||||
} else if (errno != EBUSY) {
|
||||
LOGE("Failed to move mount %s -> %s (%s)", src, dst, strerror(errno));
|
||||
SLOGE("Failed to move mount %s -> %s (%s)", src, dst, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
int action = 0;
|
||||
|
@ -441,14 +441,14 @@ int Volume::doMoveMount(const char *src, const char *dst, bool force) {
|
|||
action = 1; // SIGHUP
|
||||
}
|
||||
}
|
||||
LOGW("Failed to move %s -> %s (%s, retries %d, action %d)",
|
||||
SLOGW("Failed to move %s -> %s (%s, retries %d, action %d)",
|
||||
src, dst, strerror(errno), retries, action);
|
||||
Process::killProcessesWithOpenFiles(src, action);
|
||||
usleep(1000*250);
|
||||
}
|
||||
|
||||
errno = EBUSY;
|
||||
LOGE("Giving up on move %s -> %s (%s)", src, dst, strerror(errno));
|
||||
SLOGE("Giving up on move %s -> %s (%s)", src, dst, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -456,12 +456,12 @@ int Volume::doUnmount(const char *path, bool force) {
|
|||
int retries = 10;
|
||||
|
||||
if (mDebug) {
|
||||
LOGD("Unmounting {%s}, force = %d", path, force);
|
||||
SLOGD("Unmounting {%s}, force = %d", path, force);
|
||||
}
|
||||
|
||||
while (retries--) {
|
||||
if (!umount(path) || errno == EINVAL || errno == ENOENT) {
|
||||
LOGI("%s sucessfully unmounted", path);
|
||||
SLOGI("%s sucessfully unmounted", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -475,14 +475,14 @@ int Volume::doUnmount(const char *path, bool force) {
|
|||
}
|
||||
}
|
||||
|
||||
LOGW("Failed to unmount %s (%s, retries %d, action %d)",
|
||||
SLOGW("Failed to unmount %s (%s, retries %d, action %d)",
|
||||
path, strerror(errno), retries, action);
|
||||
|
||||
Process::killProcessesWithOpenFiles(path, action);
|
||||
usleep(1000*1000);
|
||||
}
|
||||
errno = EBUSY;
|
||||
LOGE("Giving up on unmount %s (%s)", path, strerror(errno));
|
||||
SLOGE("Giving up on unmount %s (%s)", path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ int Volume::unmountVol(bool force) {
|
|||
int i, rc;
|
||||
|
||||
if (getState() != Volume::State_Mounted) {
|
||||
LOGE("Volume %s unmount request when not mounted", getLabel());
|
||||
SLOGE("Volume %s unmount request when not mounted", getLabel());
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ int Volume::unmountVol(bool force) {
|
|||
* so nobody else can muck with it while we work.
|
||||
*/
|
||||
if (doMoveMount(getMountpoint(), SEC_STGDIR, force)) {
|
||||
LOGE("Failed to move mount %s => %s (%s)", getMountpoint(), SEC_STGDIR, strerror(errno));
|
||||
SLOGE("Failed to move mount %s => %s (%s)", getMountpoint(), SEC_STGDIR, strerror(errno));
|
||||
setState(Volume::State_Mounted);
|
||||
return -1;
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ int Volume::unmountVol(bool force) {
|
|||
*/
|
||||
|
||||
if (doUnmount(Volume::SEC_STG_SECIMGDIR, force)) {
|
||||
LOGE("Failed to unmount tmpfs on %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
SLOGE("Failed to unmount tmpfs on %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
|
||||
goto fail_republish;
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ int Volume::unmountVol(bool force) {
|
|||
*/
|
||||
|
||||
if (doUnmount(Volume::SEC_ASECDIR, force)) {
|
||||
LOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR, strerror(errno));
|
||||
SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR, strerror(errno));
|
||||
goto fail_remount_tmpfs;
|
||||
}
|
||||
|
||||
|
@ -534,11 +534,11 @@ int Volume::unmountVol(bool force) {
|
|||
* Finally, unmount the actual block device from the staging dir
|
||||
*/
|
||||
if (doUnmount(Volume::SEC_STGDIR, force)) {
|
||||
LOGE("Failed to unmount %s (%s)", SEC_STGDIR, strerror(errno));
|
||||
SLOGE("Failed to unmount %s (%s)", SEC_STGDIR, strerror(errno));
|
||||
goto fail_recreate_bindmount;
|
||||
}
|
||||
|
||||
LOGI("%s unmounted sucessfully", getMountpoint());
|
||||
SLOGI("%s unmounted sucessfully", getMountpoint());
|
||||
|
||||
setState(Volume::State_Idle);
|
||||
mCurrentlyMountedKdev = -1;
|
||||
|
@ -549,17 +549,17 @@ int Volume::unmountVol(bool force) {
|
|||
*/
|
||||
fail_recreate_bindmount:
|
||||
if (mount(SEC_STG_SECIMGDIR, SEC_ASECDIR, "", MS_BIND, NULL)) {
|
||||
LOGE("Failed to restore bindmount after failure! - Storage will appear offline!");
|
||||
SLOGE("Failed to restore bindmount after failure! - Storage will appear offline!");
|
||||
goto out_nomedia;
|
||||
}
|
||||
fail_remount_tmpfs:
|
||||
if (mount("tmpfs", SEC_STG_SECIMGDIR, "tmpfs", MS_RDONLY, "size=0,mode=0,uid=0,gid=0")) {
|
||||
LOGE("Failed to restore tmpfs after failure! - Storage will appear offline!");
|
||||
SLOGE("Failed to restore tmpfs after failure! - Storage will appear offline!");
|
||||
goto out_nomedia;
|
||||
}
|
||||
fail_republish:
|
||||
if (doMoveMount(SEC_STGDIR, getMountpoint(), force)) {
|
||||
LOGE("Failed to republish mount after failure! - Storage will appear offline!");
|
||||
SLOGE("Failed to republish mount after failure! - Storage will appear offline!");
|
||||
goto out_nomedia;
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,7 @@ int Volume::initializeMbr(const char *deviceNode) {
|
|||
memset(&dinfo, 0, sizeof(dinfo));
|
||||
|
||||
if (!(dinfo.part_lst = (struct part_info *) malloc(MAX_NUM_PARTS * sizeof(struct part_info)))) {
|
||||
LOGE("Failed to malloc prt_lst");
|
||||
SLOGE("Failed to malloc prt_lst");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ int Volume::initializeMbr(const char *deviceNode) {
|
|||
int rc = apply_disk_config(&dinfo, 0);
|
||||
|
||||
if (rc) {
|
||||
LOGE("Failed to apply disk configuration (%d)", rc);
|
||||
SLOGE("Failed to apply disk configuration (%d)", rc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ char *VolumeManager::asecHash(const char *id, char *buffer, size_t len) {
|
|||
unsigned char sig[MD5_DIGEST_LENGTH];
|
||||
|
||||
if (len < MD5_ASCII_LENGTH) {
|
||||
LOGE("Target hash buffer size < %d bytes (%d)", MD5_ASCII_LENGTH, len);
|
||||
SLOGE("Target hash buffer size < %d bytes (%d)", MD5_ASCII_LENGTH, len);
|
||||
errno = ESPIPE;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ void VolumeManager::handleSwitchEvent(NetlinkEvent *evt) {
|
|||
const char *state = evt->findParam("SWITCH_STATE");
|
||||
|
||||
if (!name || !state) {
|
||||
LOGW("Switch %s event missing name/state info", devpath);
|
||||
SLOGW("Switch %s event missing name/state info", devpath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ void VolumeManager::handleSwitchEvent(NetlinkEvent *evt) {
|
|||
notifyUmsConnected(false);
|
||||
}
|
||||
} else {
|
||||
LOGW("Ignoring unknown switch '%s'", name);
|
||||
SLOGW("Ignoring unknown switch '%s'", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
|||
for (it = mVolumes->begin(); it != mVolumes->end(); ++it) {
|
||||
if (!(*it)->handleBlockEvent(evt)) {
|
||||
#ifdef NETLINK_DEBUG
|
||||
LOGD("Device '%s' event handled by volume %s\n", devpath, (*it)->getLabel());
|
||||
SLOGD("Device '%s' event handled by volume %s\n", devpath, (*it)->getLabel());
|
||||
#endif
|
||||
hit = true;
|
||||
break;
|
||||
|
@ -163,7 +163,7 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
|||
|
||||
if (!hit) {
|
||||
#ifdef NETLINK_DEBUG
|
||||
LOGW("No volumes handled block event for '%s'", devpath);
|
||||
SLOGW("No volumes handled block event for '%s'", devpath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -217,13 +217,13 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
sb.ver = ASEC_SB_VER;
|
||||
|
||||
if (numSectors < ((1024*1024)/512)) {
|
||||
LOGE("Invalid container size specified (%d sectors)", numSectors);
|
||||
SLOGE("Invalid container size specified (%d sectors)", numSectors);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lookupVolume(id)) {
|
||||
LOGE("ASEC id '%s' currently exists", id);
|
||||
SLOGE("ASEC id '%s' currently exists", id);
|
||||
errno = EADDRINUSE;
|
||||
return -1;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
snprintf(asecFileName, sizeof(asecFileName), "%s/%s.asec", Volume::SEC_ASECDIR, id);
|
||||
|
||||
if (!access(asecFileName, F_OK)) {
|
||||
LOGE("ASEC file '%s' currently exists - destroy it first! (%s)",
|
||||
SLOGE("ASEC file '%s' currently exists - destroy it first! (%s)",
|
||||
asecFileName, strerror(errno));
|
||||
errno = EADDRINUSE;
|
||||
return -1;
|
||||
|
@ -250,20 +250,20 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
// Add +1 for our superblock which is at the end
|
||||
if (Loop::createImageFile(asecFileName, numImgSectors + 1)) {
|
||||
LOGE("ASEC image file creation failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC image file creation failed (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
char idHash[33];
|
||||
if (!asecHash(id, idHash, sizeof(idHash))) {
|
||||
LOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
SLOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
unlink(asecFileName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char loopDevice[255];
|
||||
if (Loop::create(idHash, asecFileName, loopDevice, sizeof(loopDevice))) {
|
||||
LOGE("ASEC loop device creation failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC loop device creation failed (%s)", strerror(errno));
|
||||
unlink(asecFileName);
|
||||
return -1;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
sb.c_cipher = ASEC_SB_C_CIPHER_TWOFISH;
|
||||
if (Devmapper::create(idHash, loopDevice, key, numImgSectors, dmDevice,
|
||||
sizeof(dmDevice))) {
|
||||
LOGE("ASEC device mapping failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC device mapping failed (%s)", strerror(errno));
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
unlink(asecFileName);
|
||||
return -1;
|
||||
|
@ -293,7 +293,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
int sbfd = open(loopDevice, O_RDWR);
|
||||
if (sbfd < 0) {
|
||||
LOGE("Failed to open new DM device for superblock write (%s)", strerror(errno));
|
||||
SLOGE("Failed to open new DM device for superblock write (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
if (lseek(sbfd, (numImgSectors * 512), SEEK_SET) < 0) {
|
||||
close(sbfd);
|
||||
LOGE("Failed to lseek for superblock (%s)", strerror(errno));
|
||||
SLOGE("Failed to lseek for superblock (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
if (write(sbfd, &sb, sizeof(sb)) != sizeof(sb)) {
|
||||
close(sbfd);
|
||||
LOGE("Failed to write superblock (%s)", strerror(errno));
|
||||
SLOGE("Failed to write superblock (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -327,11 +327,11 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
if (strcmp(fstype, "none")) {
|
||||
if (strcmp(fstype, "fat")) {
|
||||
LOGW("Unknown fstype '%s' specified for container", fstype);
|
||||
SLOGW("Unknown fstype '%s' specified for container", fstype);
|
||||
}
|
||||
|
||||
if (Fat::format(dmDevice, numImgSectors)) {
|
||||
LOGE("ASEC FAT format failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC FAT format failed (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
|
||||
if (mkdir(mountPoint, 0777)) {
|
||||
if (errno != EEXIST) {
|
||||
LOGE("Mountpoint creation failed (%s)", strerror(errno));
|
||||
SLOGE("Mountpoint creation failed (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
|
||||
if (Fat::doMount(dmDevice, mountPoint, false, false, ownerUid,
|
||||
0, 0000, false)) {
|
||||
LOGE("ASEC FAT mount failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC FAT mount failed (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
|
|||
return -1;
|
||||
}
|
||||
} else {
|
||||
LOGI("Created raw secure container %s (no filesystem)", id);
|
||||
SLOGI("Created raw secure container %s (no filesystem)", id);
|
||||
}
|
||||
|
||||
mActiveContainers->push_back(strdup(id));
|
||||
|
@ -381,24 +381,24 @@ int VolumeManager::finalizeAsec(const char *id) {
|
|||
|
||||
char idHash[33];
|
||||
if (!asecHash(id, idHash, sizeof(idHash))) {
|
||||
LOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
SLOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Loop::lookupActive(idHash, loopDevice, sizeof(loopDevice))) {
|
||||
LOGE("Unable to finalize %s (%s)", id, strerror(errno));
|
||||
SLOGE("Unable to finalize %s (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
|
||||
// XXX:
|
||||
if (Fat::doMount(loopDevice, mountPoint, true, true, 0, 0, 0227, false)) {
|
||||
LOGE("ASEC finalize mount failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC finalize mount failed (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mDebug) {
|
||||
LOGD("ASEC %s finalized", id);
|
||||
SLOGD("ASEC %s finalized", id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -413,26 +413,26 @@ int VolumeManager::renameAsec(const char *id1, const char *id2) {
|
|||
|
||||
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id1);
|
||||
if (isMountpointMounted(mountPoint)) {
|
||||
LOGW("Rename attempt when src mounted");
|
||||
SLOGW("Rename attempt when src mounted");
|
||||
errno = EBUSY;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id2);
|
||||
if (isMountpointMounted(mountPoint)) {
|
||||
LOGW("Rename attempt when dst mounted");
|
||||
SLOGW("Rename attempt when dst mounted");
|
||||
errno = EBUSY;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (!access(asecFilename2, F_OK)) {
|
||||
LOGE("Rename attempt when dst exists");
|
||||
SLOGE("Rename attempt when dst exists");
|
||||
errno = EADDRINUSE;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (rename(asecFilename1, asecFilename2)) {
|
||||
LOGE("Rename of '%s' to '%s' failed (%s)", asecFilename1, asecFilename2, strerror(errno));
|
||||
SLOGE("Rename of '%s' to '%s' failed (%s)", asecFilename1, asecFilename2, strerror(errno));
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
|
@ -456,12 +456,12 @@ int VolumeManager::unmountAsec(const char *id, bool force) {
|
|||
|
||||
char idHash[33];
|
||||
if (!asecHash(id, idHash, sizeof(idHash))) {
|
||||
LOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
SLOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!isMountpointMounted(mountPoint)) {
|
||||
LOGE("Unmount request for ASEC %s when not mounted", id);
|
||||
SLOGE("Unmount request for ASEC %s when not mounted", id);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -473,11 +473,11 @@ int VolumeManager::unmountAsec(const char *id, bool force) {
|
|||
break;
|
||||
}
|
||||
if (rc && (errno == EINVAL || errno == ENOENT)) {
|
||||
LOGI("Secure container %s unmounted OK", id);
|
||||
SLOGI("Secure container %s unmounted OK", id);
|
||||
rc = 0;
|
||||
break;
|
||||
}
|
||||
LOGW("ASEC %s unmount attempt %d failed (%s)",
|
||||
SLOGW("ASEC %s unmount attempt %d failed (%s)",
|
||||
id, i, strerror(errno));
|
||||
|
||||
int action = 0; // default is to just complain
|
||||
|
@ -495,7 +495,7 @@ int VolumeManager::unmountAsec(const char *id, bool force) {
|
|||
|
||||
if (rc) {
|
||||
errno = EBUSY;
|
||||
LOGE("Failed to unmount container %s (%s)", id, strerror(errno));
|
||||
SLOGE("Failed to unmount container %s (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -506,23 +506,23 @@ int VolumeManager::unmountAsec(const char *id, bool force) {
|
|||
break;
|
||||
}
|
||||
|
||||
LOGW("Failed to rmdir %s (%s)", mountPoint, strerror(errno));
|
||||
SLOGW("Failed to rmdir %s (%s)", mountPoint, strerror(errno));
|
||||
usleep(1000 * 1000);
|
||||
}
|
||||
|
||||
if (!retries) {
|
||||
LOGE("Timed out trying to rmdir %s (%s)", mountPoint, strerror(errno));
|
||||
SLOGE("Timed out trying to rmdir %s (%s)", mountPoint, strerror(errno));
|
||||
}
|
||||
|
||||
if (Devmapper::destroy(idHash) && errno != ENXIO) {
|
||||
LOGE("Failed to destroy devmapper instance (%s)", strerror(errno));
|
||||
SLOGE("Failed to destroy devmapper instance (%s)", strerror(errno));
|
||||
}
|
||||
|
||||
char loopDevice[255];
|
||||
if (!Loop::lookupActive(idHash, loopDevice, sizeof(loopDevice))) {
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
} else {
|
||||
LOGW("Failed to find loop device for {%s} (%s)", asecFileName, strerror(errno));
|
||||
SLOGW("Failed to find loop device for {%s} (%s)", asecFileName, strerror(errno));
|
||||
}
|
||||
|
||||
AsecIdCollection::iterator it;
|
||||
|
@ -534,7 +534,7 @@ int VolumeManager::unmountAsec(const char *id, bool force) {
|
|||
}
|
||||
}
|
||||
if (it == mActiveContainers->end()) {
|
||||
LOGW("mActiveContainers is inconsistent!");
|
||||
SLOGW("mActiveContainers is inconsistent!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -548,21 +548,21 @@ int VolumeManager::destroyAsec(const char *id, bool force) {
|
|||
|
||||
if (isMountpointMounted(mountPoint)) {
|
||||
if (mDebug) {
|
||||
LOGD("Unmounting container before destroy");
|
||||
SLOGD("Unmounting container before destroy");
|
||||
}
|
||||
if (unmountAsec(id, force)) {
|
||||
LOGE("Failed to unmount asec %s for destroy (%s)", id, strerror(errno));
|
||||
SLOGE("Failed to unmount asec %s for destroy (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlink(asecFileName)) {
|
||||
LOGE("Failed to unlink asec '%s' (%s)", asecFileName, strerror(errno));
|
||||
SLOGE("Failed to unlink asec '%s' (%s)", asecFileName, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mDebug) {
|
||||
LOGD("ASEC %s destroyed", id);
|
||||
SLOGD("ASEC %s destroyed", id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -575,29 +575,29 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
|
||||
|
||||
if (isMountpointMounted(mountPoint)) {
|
||||
LOGE("ASEC %s already mounted", id);
|
||||
SLOGE("ASEC %s already mounted", id);
|
||||
errno = EBUSY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char idHash[33];
|
||||
if (!asecHash(id, idHash, sizeof(idHash))) {
|
||||
LOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
SLOGE("Hash of '%s' failed (%s)", id, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
char loopDevice[255];
|
||||
if (Loop::lookupActive(idHash, loopDevice, sizeof(loopDevice))) {
|
||||
if (Loop::create(idHash, asecFileName, loopDevice, sizeof(loopDevice))) {
|
||||
LOGE("ASEC loop device creation failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC loop device creation failed (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (mDebug) {
|
||||
LOGD("New loop device created at %s", loopDevice);
|
||||
SLOGD("New loop device created at %s", loopDevice);
|
||||
}
|
||||
} else {
|
||||
if (mDebug) {
|
||||
LOGD("Found active loopback for %s at %s", asecFileName, loopDevice);
|
||||
SLOGD("Found active loopback for %s at %s", asecFileName, loopDevice);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,13 +607,13 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
unsigned int nr_sec = 0;
|
||||
|
||||
if ((fd = open(loopDevice, O_RDWR)) < 0) {
|
||||
LOGE("Failed to open loopdevice (%s)", strerror(errno));
|
||||
SLOGE("Failed to open loopdevice (%s)", strerror(errno));
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, BLKGETSIZE, &nr_sec)) {
|
||||
LOGE("Failed to get loop size (%s)", strerror(errno));
|
||||
SLOGE("Failed to get loop size (%s)", strerror(errno));
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -625,13 +625,13 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
struct asec_superblock sb;
|
||||
memset(&sb, 0, sizeof(sb));
|
||||
if (lseek(fd, ((nr_sec-1) * 512), SEEK_SET) < 0) {
|
||||
LOGE("lseek failed (%s)", strerror(errno));
|
||||
SLOGE("lseek failed (%s)", strerror(errno));
|
||||
close(fd);
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
return -1;
|
||||
}
|
||||
if (read(fd, &sb, sizeof(sb)) != sizeof(sb)) {
|
||||
LOGE("superblock read failed (%s)", strerror(errno));
|
||||
SLOGE("superblock read failed (%s)", strerror(errno));
|
||||
close(fd);
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
return -1;
|
||||
|
@ -640,10 +640,10 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
close(fd);
|
||||
|
||||
if (mDebug) {
|
||||
LOGD("Container sb magic/ver (%.8x/%.2x)", sb.magic, sb.ver);
|
||||
SLOGD("Container sb magic/ver (%.8x/%.2x)", sb.magic, sb.ver);
|
||||
}
|
||||
if (sb.magic != ASEC_SB_MAGIC || sb.ver != ASEC_SB_VER) {
|
||||
LOGE("Bad container magic/version (%.8x/%.2x)", sb.magic, sb.ver);
|
||||
SLOGE("Bad container magic/version (%.8x/%.2x)", sb.magic, sb.ver);
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
errno = EMEDIUMTYPE;
|
||||
return -1;
|
||||
|
@ -654,16 +654,16 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
if (Devmapper::lookupActive(idHash, dmDevice, sizeof(dmDevice))) {
|
||||
if (Devmapper::create(idHash, loopDevice, key, nr_sec,
|
||||
dmDevice, sizeof(dmDevice))) {
|
||||
LOGE("ASEC device mapping failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC device mapping failed (%s)", strerror(errno));
|
||||
Loop::destroyByDevice(loopDevice);
|
||||
return -1;
|
||||
}
|
||||
if (mDebug) {
|
||||
LOGD("New devmapper instance created at %s", dmDevice);
|
||||
SLOGD("New devmapper instance created at %s", dmDevice);
|
||||
}
|
||||
} else {
|
||||
if (mDebug) {
|
||||
LOGD("Found active devmapper for %s at %s", asecFileName, dmDevice);
|
||||
SLOGD("Found active devmapper for %s at %s", asecFileName, dmDevice);
|
||||
}
|
||||
}
|
||||
cleanupDm = true;
|
||||
|
@ -673,7 +673,7 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
|
||||
if (mkdir(mountPoint, 0777)) {
|
||||
if (errno != EEXIST) {
|
||||
LOGE("Mountpoint creation failed (%s)", strerror(errno));
|
||||
SLOGE("Mountpoint creation failed (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
if (Fat::doMount(dmDevice, mountPoint, true, false, ownerUid, 0,
|
||||
0222, false)) {
|
||||
// 0227, false)) {
|
||||
LOGE("ASEC mount failed (%s)", strerror(errno));
|
||||
SLOGE("ASEC mount failed (%s)", strerror(errno));
|
||||
if (cleanupDm) {
|
||||
Devmapper::destroy(idHash);
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
|
|||
|
||||
mActiveContainers->push_back(strdup(id));
|
||||
if (mDebug) {
|
||||
LOGD("ASEC %s mounted", id);
|
||||
SLOGD("ASEC %s mounted", id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -808,12 +808,12 @@ int VolumeManager::shareVolume(const char *label, const char *method) {
|
|||
|
||||
if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0/file",
|
||||
O_WRONLY)) < 0) {
|
||||
LOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
||||
SLOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write(fd, nodepath, strlen(nodepath)) < 0) {
|
||||
LOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
||||
SLOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -850,13 +850,13 @@ int VolumeManager::unshareVolume(const char *label, const char *method) {
|
|||
MAJOR(d), MINOR(d));
|
||||
|
||||
if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0/file", O_WRONLY)) < 0) {
|
||||
LOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
||||
SLOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
char ch = 0;
|
||||
if (write(fd, &ch, 1) < 0) {
|
||||
LOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
||||
SLOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ int VolumeManager::unmountVolume(const char *label, bool force) {
|
|||
}
|
||||
|
||||
if (v->getState() != Volume::State_Mounted) {
|
||||
LOGW("Attempt to unmount volume which isn't mounted (%d)\n",
|
||||
SLOGW("Attempt to unmount volume which isn't mounted (%d)\n",
|
||||
v->getState());
|
||||
errno = EBUSY;
|
||||
return -1;
|
||||
|
@ -888,9 +888,9 @@ int VolumeManager::unmountVolume(const char *label, bool force) {
|
|||
|
||||
while(mActiveContainers->size()) {
|
||||
AsecIdCollection::iterator it = mActiveContainers->begin();
|
||||
LOGI("Unmounting ASEC %s (dependant on %s)", *it, v->getMountpoint());
|
||||
SLOGI("Unmounting ASEC %s (dependant on %s)", *it, v->getMountpoint());
|
||||
if (unmountAsec(*it, force)) {
|
||||
LOGE("Failed to unmount ASEC %s (%s)", *it, strerror(errno));
|
||||
SLOGE("Failed to unmount ASEC %s (%s)", *it, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -925,7 +925,7 @@ bool VolumeManager::isMountpointMounted(const char *mp)
|
|||
char line[1024];
|
||||
|
||||
if (!(fp = fopen("/proc/mounts", "r"))) {
|
||||
LOGE("Error opening /proc/mounts (%s)", strerror(errno));
|
||||
SLOGE("Error opening /proc/mounts (%s)", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ int Xwarp::doEnableDisable(bool enable) {
|
|||
tmp = (enable ? XWARP_BACKINGFILE : "");
|
||||
|
||||
if (write(fd, tmp, strlen(tmp)+1) < 0) {
|
||||
LOGE("Failed to write xwarp cfg (%s)", strerror(errno));
|
||||
SLOGE("Failed to write xwarp cfg (%s)", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
|
36
main.cpp
36
main.cpp
|
@ -42,18 +42,18 @@ int main() {
|
|||
CommandListener *cl;
|
||||
NetlinkManager *nm;
|
||||
|
||||
LOGI("Vold 2.1 (the revenge) firing up");
|
||||
SLOGI("Vold 2.1 (the revenge) firing up");
|
||||
|
||||
mkdir("/dev/block/vold", 0755);
|
||||
|
||||
/* Create our singleton managers */
|
||||
if (!(vm = VolumeManager::Instance())) {
|
||||
LOGE("Unable to create VolumeManager");
|
||||
SLOGE("Unable to create VolumeManager");
|
||||
exit(1);
|
||||
};
|
||||
|
||||
if (!(nm = NetlinkManager::Instance())) {
|
||||
LOGE("Unable to create NetlinkManager");
|
||||
SLOGE("Unable to create NetlinkManager");
|
||||
exit(1);
|
||||
};
|
||||
|
||||
|
@ -63,16 +63,16 @@ int main() {
|
|||
nm->setBroadcaster((SocketListener *) cl);
|
||||
|
||||
if (vm->start()) {
|
||||
LOGE("Unable to start VolumeManager (%s)", strerror(errno));
|
||||
SLOGE("Unable to start VolumeManager (%s)", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (process_config(vm)) {
|
||||
LOGE("Error reading configuration (%s)... continuing anyways", strerror(errno));
|
||||
SLOGE("Error reading configuration (%s)... continuing anyways", strerror(errno));
|
||||
}
|
||||
|
||||
if (nm->start()) {
|
||||
LOGE("Unable to start NetlinkManager (%s)", strerror(errno));
|
||||
SLOGE("Unable to start NetlinkManager (%s)", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -95,12 +95,12 @@ int main() {
|
|||
vm->notifyUmsConnected(false);
|
||||
}
|
||||
} else {
|
||||
LOGE("Failed to read switch state (%s)", strerror(errno));
|
||||
SLOGE("Failed to read switch state (%s)", strerror(errno));
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
} else {
|
||||
LOGW("No UMS switch available");
|
||||
SLOGW("No UMS switch available");
|
||||
}
|
||||
}
|
||||
// coldboot("/sys/class/switch");
|
||||
|
@ -109,7 +109,7 @@ int main() {
|
|||
* Now that we're up, we can respond to commands
|
||||
*/
|
||||
if (cl->startListener()) {
|
||||
LOGE("Unable to start CommandListener (%s)", strerror(errno));
|
||||
SLOGE("Unable to start CommandListener (%s)", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ int main() {
|
|||
sleep(1000);
|
||||
}
|
||||
|
||||
LOGI("Vold exiting");
|
||||
SLOGI("Vold exiting");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -187,15 +187,15 @@ static int process_config(VolumeManager *vm) {
|
|||
continue;
|
||||
|
||||
if (!(type = strsep(&next, " \t"))) {
|
||||
LOGE("Error parsing type");
|
||||
SLOGE("Error parsing type");
|
||||
goto out_syntax;
|
||||
}
|
||||
if (!(label = strsep(&next, " \t"))) {
|
||||
LOGE("Error parsing label");
|
||||
SLOGE("Error parsing label");
|
||||
goto out_syntax;
|
||||
}
|
||||
if (!(mount_point = strsep(&next, " \t"))) {
|
||||
LOGE("Error parsing mount point");
|
||||
SLOGE("Error parsing mount point");
|
||||
goto out_syntax;
|
||||
}
|
||||
|
||||
|
@ -204,11 +204,11 @@ static int process_config(VolumeManager *vm) {
|
|||
char *part, *sysfs_path;
|
||||
|
||||
if (!(part = strsep(&next, " \t"))) {
|
||||
LOGE("Error parsing partition");
|
||||
SLOGE("Error parsing partition");
|
||||
goto out_syntax;
|
||||
}
|
||||
if (strcmp(part, "auto") && atoi(part) == 0) {
|
||||
LOGE("Partition must either be 'auto' or 1 based index instead of '%s'", part);
|
||||
SLOGE("Partition must either be 'auto' or 1 based index instead of '%s'", part);
|
||||
goto out_syntax;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ static int process_config(VolumeManager *vm) {
|
|||
|
||||
while((sysfs_path = strsep(&next, " \t"))) {
|
||||
if (dv->addPath(sysfs_path)) {
|
||||
LOGE("Failed to add devpath %s to volume %s", sysfs_path,
|
||||
SLOGE("Failed to add devpath %s to volume %s", sysfs_path,
|
||||
label);
|
||||
goto out_fail;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ static int process_config(VolumeManager *vm) {
|
|||
vm->addVolume(dv);
|
||||
} else if (!strcmp(type, "map_mount")) {
|
||||
} else {
|
||||
LOGE("Unknown type '%s'", type);
|
||||
SLOGE("Unknown type '%s'", type);
|
||||
goto out_syntax;
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ static int process_config(VolumeManager *vm) {
|
|||
return 0;
|
||||
|
||||
out_syntax:
|
||||
LOGE("Syntax error on config line %d", n);
|
||||
SLOGE("Syntax error on config line %d", n);
|
||||
errno = -EINVAL;
|
||||
out_fail:
|
||||
fclose(fp);
|
||||
|
|
Loading…
Reference in a new issue