diff --git a/CommandListener.cpp b/CommandListener.cpp
index 781eb91..917b2fa 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -71,7 +71,7 @@
             }
         }
     }
-    LOGD("%s", buffer);
+    SLOGD("%s", buffer);
 }
 
 CommandListener::DumpCmd::DumpCmd() :
diff --git a/Devmapper.cpp b/Devmapper.cpp
index ec36fdb..c9482bf 100644
--- a/Devmapper.cpp
+++ b/Devmapper.cpp
@@ -38,21 +38,21 @@
 
     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 @@
     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 @@
         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 @@
 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 @@
     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 @@
                       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 @@
     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 @@
     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 @@
     // 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 @@
     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 @@
     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::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 @@
 
     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);
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index fd99f0c..c269303 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -92,7 +92,7 @@
                          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 @@
                     handlePartitionChanged(dp, evt);
                 }
             } else {
-                    LOGW("Ignoring non add/remove/change event");
+                    SLOGW("Ignoring non add/remove/change event");
             }
 
             return 0;
@@ -131,7 +131,7 @@
     if (tmp) {
         mDiskNumParts = atoi(tmp);
     } else {
-        LOGW("Kernel block uevent missing 'NPARTS'");
+        SLOGW("Kernel block uevent missing 'NPARTS'");
         mDiskNumParts = 1;
     }
 
@@ -146,12 +146,12 @@
 
     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 @@
     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 @@
     }
 
     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 @@
         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::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 @@
     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 @@
     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 @@
         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");
         }
     }
 }
diff --git a/Fat.cpp b/Fat.cpp
index 94b1039..7a86aac 100644
--- a/Fat.cpp
+++ b/Fat.cpp
@@ -46,7 +46,7 @@
 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 @@
 
         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 @@
     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 @@
     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 @@
              * 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 @@
     }
 
     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;
     }
diff --git a/Loop.cpp b/Loop.cpp
index c278418..374cac0 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -45,7 +45,7 @@
 
         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 @@
         }
 
         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 @@
 
         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 @@
         }
 
         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 @@
         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 @@
         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 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 @@
     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 @@
 
     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 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;
     }
diff --git a/NetlinkHandler.cpp b/NetlinkHandler.cpp
index 8a3ebcb..818db81 100644
--- a/NetlinkHandler.cpp
+++ b/NetlinkHandler.cpp
@@ -46,7 +46,7 @@
     const char *subsys = evt->getSubsystem();
 
     if (!subsys) {
-        LOGW("No subsystem found in netlink event");
+        SLOGW("No subsystem found in netlink event");
         return;
     }
 
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index 271a75f..36db0ff 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -58,23 +58,23 @@
 
     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::stop() {
     if (mHandler->stop()) {
-        LOGE("Unable to stop NetlinkHandler: %s", strerror(errno));
+        SLOGE("Unable to stop NetlinkHandler: %s", strerror(errno));
         return -1;
     }
     delete mHandler;
diff --git a/Process.cpp b/Process.cpp
index 4eff92a..ea5fbc7 100644
--- a/Process.cpp
+++ b/Process.cpp
@@ -182,7 +182,7 @@
     struct dirent* de;
 
     if (!(dir = opendir("/proc"))) {
-        LOGE("opendir failed (%s)", strerror(errno));
+        SLOGE("opendir failed (%s)", strerror(errno));
         return;
     }
 
@@ -198,23 +198,23 @@
         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);
         }
     }
diff --git a/ResponseCode.cpp b/ResponseCode.cpp
index cb9f98c..d7e778d 100644
--- a/ResponseCode.cpp
+++ b/ResponseCode.cpp
@@ -37,6 +37,6 @@
         return(ResponseCode::OpFailedStorageNotFound);
     }
 
-    LOGW("Returning OperationFailed - no handler for errno %d", errno);
+    SLOGW("Returning OperationFailed - no handler for errno %d", errno);
     return(ResponseCode::OperationFailed);
 }
diff --git a/Volume.cpp b/Volume.cpp
index eae70d1..2f3cad5 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -117,7 +117,7 @@
 
     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 @@
         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 @@
     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 @@
     }
 
     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 @@
             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 @@
             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 @@
     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 @@
     }
 
     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 @@
 
     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 @@
         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 @@
          */
         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 @@
          * 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 @@
         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 @@
     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 @@
     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 @@
      * 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 @@
      * 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 @@
     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 @@
                 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 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 @@
             }
         }
 
-        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 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 @@
      * 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 @@
      */
 
     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 @@
      */
 
     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 @@
      * 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 @@
      */
 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 @@
     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 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;
     }
 
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index c72482e..10dbbb5 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -69,7 +69,7 @@
     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 @@
     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 @@
             notifyUmsConnected(false);
         }
     } else {
-        LOGW("Ignoring unknown switch '%s'", name);
+        SLOGW("Ignoring unknown switch '%s'", name);
     }
 }
 
@@ -154,7 +154,7 @@
     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 @@
 
     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 @@
     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 @@
     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 @@
 
     // 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 @@
         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 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 @@
 
     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 @@
 
     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 @@
 
     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 @@
         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 @@
 
         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 @@
             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 @@
 
     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 @@
 
     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 @@
 
     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 @@
             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 @@
 
     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 @@
             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 @@
         }
     }
     if (it == mActiveContainers->end()) {
-        LOGW("mActiveContainers is inconsistent!");
+        SLOGW("mActiveContainers is inconsistent!");
     }
     return 0;
 }
@@ -548,21 +548,21 @@
 
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
         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 @@
 
     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 @@
     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 @@
 
     mActiveContainers->push_back(strdup(id));
     if (mDebug) {
-        LOGD("ASEC %s mounted", id);
+        SLOGD("ASEC %s mounted", id);
     }
     return 0;
 }
@@ -808,12 +808,12 @@
 
     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 @@
              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 @@
     }
 
     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 @@
 
     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 @@
     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;
     }
 
diff --git a/Xwarp.cpp b/Xwarp.cpp
index 1435a53..2973ff8 100644
--- a/Xwarp.cpp
+++ b/Xwarp.cpp
@@ -73,7 +73,7 @@
     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;
     }
diff --git a/main.cpp b/main.cpp
index 551003b..530321c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -42,18 +42,18 @@
     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 @@
     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 @@
                     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 @@
      * 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 @@
         sleep(1000);
     }
 
-    LOGI("Vold exiting");
+    SLOGI("Vold exiting");
     exit(0);
 }
 
@@ -187,15 +187,15 @@
             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 @@
             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 @@
 
             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 @@
             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 @@
     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);
