[automerger skipped] Merge commit '635193ab36302e5f65e99c7df2f256cfd37068c7' into am-b7f1a67b-2024-4274-aa7d-e88e8cceb407 am: 9a35ab6a4f am: f707f1bb88 am: 2b9a343319 -s ours
am: 8e7c2624bb
Change-Id: Id3d4b780bab0e36da7d6bb3abf932c947a8fad86
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 2ab3d09..b15306c 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -20,49 +20,54 @@
*
*/
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <linux/dm-ioctl.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <sys/param.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <openssl/evp.h>
-#include <openssl/sha.h>
-#include <errno.h>
+#define LOG_TAG "Cryptfs"
+
+#include "cryptfs.h"
+
+#include "EncryptInplace.h"
+#include "Ext4Crypt.h"
+#include "Keymaster.h"
+#include "Process.h"
+#include "ScryptParameters.h"
+#include "VoldUtil.h"
+#include "VolumeManager.h"
+#include "secontext.h"
+
+#include <android-base/properties.h>
+#include <bootloader_message/bootloader_message.h>
+#include <cutils/android_reboot.h>
+#include <cutils/properties.h>
#include <ext4_utils/ext4_crypt.h>
#include <ext4_utils/ext4_utils.h>
-#include <linux/kdev_t.h>
+#include <f2fs_sparseblock.h>
#include <fs_mgr.h>
-#include <time.h>
-#include <math.h>
-#include <selinux/selinux.h>
-#include "cryptfs.h"
-#include "secontext.h"
-#define LOG_TAG "Cryptfs"
-#include "cutils/log.h"
-#include "cutils/properties.h"
-#include "cutils/android_reboot.h"
-#include "hardware_legacy/power.h"
+#include <hardware_legacy/power.h>
+#include <log/log.h>
#include <logwrap/logwrap.h>
-#include "ScryptParameters.h"
-#include "VolumeManager.h"
-#include "VoldUtil.h"
-#include "Ext4Crypt.h"
-#include "f2fs_sparseblock.h"
-#include "EncryptInplace.h"
-#include "Process.h"
-#include "Keymaster.h"
-#include "android-base/properties.h"
-#include <bootloader_message/bootloader_message.h>
+#include <openssl/evp.h>
+#include <openssl/sha.h>
+#include <selinux/selinux.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <libgen.h>
+#include <linux/dm-ioctl.h>
+#include <linux/kdev_t.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
extern "C" {
#include <crypto_scrypt.h>
}
diff --git a/cryptfs.h b/cryptfs.h
index d6c7dc5..dc7a8c3 100644
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -29,8 +29,10 @@
* partition.
*/
+#include <linux/types.h>
#include <stdbool.h>
#include <stdint.h>
+
#include <cutils/properties.h>
/* The current cryptfs version */
diff --git a/fs/Ext4.cpp b/fs/Ext4.cpp
index 89b8414..717c8b7 100644
--- a/fs/Ext4.cpp
+++ b/fs/Ext4.cpp
@@ -35,12 +35,9 @@
#include <linux/kdev_t.h>
-#define LOG_TAG "Vold"
-
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
-#include <cutils/log.h>
#include <cutils/properties.h>
#include <ext4_utils/ext4_crypt.h>
#include <logwrap/logwrap.h>
@@ -102,7 +99,8 @@
if (result == 0) {
break;
}
- ALOGW("%s(): umount(%s)=%d: %s\n", __func__, c_target, result, strerror(errno));
+ LOG(WARNING) << __func__ << "(): umount(" << c_target << ")=" << result << ": "
+ << strerror(errno);
sleep(1);
}
}
@@ -112,10 +110,10 @@
* (e.g. recent SDK system images). Detect these and skip the check.
*/
if (access(kFsckPath, X_OK)) {
- ALOGD("Not running %s on %s (executable not in system image)\n",
- kFsckPath, c_source);
+ LOG(DEBUG) << "Not running " << kFsckPath << " on " << c_source
+ << " (executable not in system image)";
} else {
- ALOGD("Running %s on %s\n", kFsckPath, c_source);
+ LOG(DEBUG) << "Running " << kFsckPath << " on " << c_source;
std::vector<std::string> cmd;
cmd.push_back(kFsckPath);
diff --git a/model/Disk.cpp b/model/Disk.cpp
index d7b19ac..781d3e9 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -76,6 +76,8 @@
static const unsigned int kMajorBlockMmc = 179;
static const unsigned int kMajorBlockExperimentalMin = 240;
static const unsigned int kMajorBlockExperimentalMax = 254;
+static const unsigned int kMajorBlockDynamicMin = 234;
+static const unsigned int kMajorBlockDynamicMax = 512;
static const char* kGptBasicData = "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7";
static const char* kGptAndroidMeta = "19A710A2-B3CA-11E4-B026-10604B889DCF";
@@ -114,6 +116,12 @@
&& major <= kMajorBlockExperimentalMax;
}
+static bool isNvmeBlkDevice(unsigned int major, const std::string& sysPath) {
+ return sysPath.find("nvme") != std::string::npos
+ && major >= kMajorBlockDynamicMin
+ && major <= kMajorBlockDynamicMax;
+}
+
Disk::Disk(const std::string& eventPath, dev_t device,
const std::string& nickname, int flags) :
mDevice(device), mSize(-1), mNickname(nickname), mFlags(flags), mCreated(
@@ -292,6 +300,16 @@
mLabel = "Virtual";
break;
}
+ if (isNvmeBlkDevice(majorId, mSysPath)) {
+ std::string path(mSysPath + "/device/model");
+ std::string tmp;
+ if (!ReadFileToString(path, &tmp)) {
+ PLOG(WARNING) << "Failed to read vendor from " << path;
+ return -errno;
+ }
+ mLabel = tmp;
+ break;
+ }
LOG(WARNING) << "Unsupported block major type " << majorId;
return -ENOTSUP;
}
@@ -576,6 +594,13 @@
// 2^4 - 1 = 15
return 15;
}
+ if (isNvmeBlkDevice(majorId, mSysPath)) {
+ // despite kernel nvme driver supports up to 1M minors,
+ // #define NVME_MINORS (1U << MINORBITS)
+ // sgdisk can not support more than 127 partitions, due to
+ // #define MAX_MBR_PARTS 128
+ return 127;
+ }
}
}
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index 31c3924..6e1ffce 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -114,8 +114,8 @@
}
}
/* sdcardfs will have exited already. FUSE will still be running */
- if (TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)) == mFusePid)
- mFusePid = 0;
+ TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
+ mFusePid = 0;
return OK;
}
@@ -130,12 +130,6 @@
ForceUnmount(mFuseRead);
ForceUnmount(mFuseWrite);
- if (mFusePid > 0) {
- kill(mFusePid, SIGTERM);
- TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
- mFusePid = 0;
- }
-
rmdir(mFuseDefault.c_str());
rmdir(mFuseRead.c_str());
rmdir(mFuseWrite.c_str());
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index fc7e96f..9f2ed85 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -211,8 +211,8 @@
}
}
/* sdcardfs will have exited already. FUSE will still be running */
- if (TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)) == mFusePid)
- mFusePid = 0;
+ TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
+ mFusePid = 0;
return OK;
}
@@ -231,12 +231,6 @@
ForceUnmount(mFuseWrite);
ForceUnmount(mRawPath);
- if (mFusePid > 0) {
- kill(mFusePid, SIGTERM);
- TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
- mFusePid = 0;
- }
-
rmdir(mFuseDefault.c_str());
rmdir(mFuseRead.c_str());
rmdir(mFuseWrite.c_str());