Merge "Add a new unwind method on error."
diff --git a/base/include/android-base/logging.h b/base/include/android-base/logging.h
index f18cc0c..f93c696 100644
--- a/base/include/android-base/logging.h
+++ b/base/include/android-base/logging.h
@@ -440,11 +440,33 @@
namespace std {
-// Delete << with string* to avoid mistakes. The intention was most likely to print *string.
-// If you really want to print the pointer, consider static_cast<void*>.
+// Emit a warning of ostream<< with std::string*. The intention was most likely to print *string.
//
// Note: for this to work, we need to have this in a namespace.
-std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) = delete;
+// Note: lots of ifdef magic to make this work with Clang (platform) vs GCC (windows tools)
+// Note: using diagnose_if(true) under Clang and nothing under GCC/mingw as there is no common
+// attribute support.
+// Note: using a pragma because "-Wgcc-compat" (included in "-Weverything") complains about
+// diagnose_if.
+// Note: to print the pointer, use "<< static_cast<const void*>(string_pointer)" instead.
+// Note: a not-recommended alternative is to let Clang ignore the warning by adding
+// -Wno-user-defined-warnings to CPPFLAGS.
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgcc-compat"
+#define OSTREAM_STRING_POINTER_USAGE_WARNING \
+ __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning")))
+#else
+#define OSTREAM_STRING_POINTER_USAGE_WARNING /* empty */
+#endif
+inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer)
+ OSTREAM_STRING_POINTER_USAGE_WARNING {
+ return stream << static_cast<const void*>(string_pointer);
+}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+#undef OSTREAM_STRING_POINTER_USAGE_WARNING
} // namespace std
diff --git a/debuggerd/tombstoned/intercept_manager.cpp b/debuggerd/tombstoned/intercept_manager.cpp
index 24960bc..c446dbb 100644
--- a/debuggerd/tombstoned/intercept_manager.cpp
+++ b/debuggerd/tombstoned/intercept_manager.cpp
@@ -185,8 +185,8 @@
}
InterceptManager::InterceptManager(event_base* base, int intercept_socket) : base(base) {
- this->listener = evconnlistener_new(base, intercept_accept_cb, this, -1, LEV_OPT_CLOSE_ON_FREE,
- intercept_socket);
+ this->listener = evconnlistener_new(base, intercept_accept_cb, this, LEV_OPT_CLOSE_ON_FREE,
+ /* backlog */ -1, intercept_socket);
}
bool InterceptManager::GetIntercept(pid_t pid, DebuggerdDumpType dump_type,
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 77d5a91..343a903 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -319,31 +319,17 @@
LOG(FATAL) << "terminated prematurely";
}
-static bool sdcardfs_setup(const std::string& source_path, const std::string& dest_path,
- uid_t fsuid, gid_t fsgid, bool multi_user, userid_t userid, gid_t gid,
- mode_t mask, bool derive_gid) {
- std::string opts = android::base::StringPrintf(
- "fsuid=%d,fsgid=%d,%s%smask=%d,userid=%d,gid=%d", fsuid, fsgid,
- multi_user ? "multiuser," : "", derive_gid ? "derive_gid," : "", mask, userid, gid);
+static bool sdcardfs_setup(const std::string& source_path, const std::string& dest_path, uid_t fsuid,
+ gid_t fsgid, bool multi_user, userid_t userid, gid_t gid, mode_t mask) {
+ std::string opts = android::base::StringPrintf("fsuid=%d,fsgid=%d,%smask=%d,userid=%d,gid=%d",
+ fsuid, fsgid, multi_user?"multiuser,":"", mask, userid, gid);
if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs",
MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) {
- if (derive_gid) {
- PLOG(ERROR) << "trying to mount sdcardfs filesystem without derive_gid";
- /* Maybe this isn't supported on this kernel. Try without. */
- opts = android::base::StringPrintf("fsuid=%d,fsgid=%d,%smask=%d,userid=%d,gid=%d",
- fsuid, fsgid, multi_user ? "multiuser," : "", mask,
- userid, gid);
- if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs",
- MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) {
- PLOG(ERROR) << "failed to mount sdcardfs filesystem";
- return false;
- }
- } else {
- PLOG(ERROR) << "failed to mount sdcardfs filesystem";
- return false;
- }
+ PLOG(ERROR) << "failed to mount sdcardfs filesystem";
+ return false;
}
+
return true;
}
@@ -369,8 +355,7 @@
}
static void run_sdcardfs(const std::string& source_path, const std::string& label, uid_t uid,
- gid_t gid, userid_t userid, bool multi_user, bool full_write,
- bool derive_gid) {
+ gid_t gid, userid_t userid, bool multi_user, bool full_write) {
std::string dest_path_default = "/mnt/runtime/default/" + label;
std::string dest_path_read = "/mnt/runtime/read/" + label;
std::string dest_path_write = "/mnt/runtime/write/" + label;
@@ -380,10 +365,10 @@
// Multi-user storage is fully isolated per user, so "other"
// permissions are completely masked off.
if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid,
- AID_SDCARD_RW, 0006, derive_gid) ||
- !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 0027) ||
- !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY,
- full_write ? 0007 : 0027)) {
+ AID_SDCARD_RW, 0006)
+ || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 0027)
+ || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write,
+ AID_EVERYBODY, full_write ? 0007 : 0027)) {
LOG(FATAL) << "failed to sdcardfs_setup";
}
} else {
@@ -391,11 +376,11 @@
// the Android directories are masked off to a single user
// deep inside attr_from_stat().
if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid,
- AID_SDCARD_RW, 0006, derive_gid) ||
- !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY,
- full_write ? 0027 : 0022) ||
- !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY,
- full_write ? 0007 : 0022)) {
+ AID_SDCARD_RW, 0006)
+ || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read,
+ AID_EVERYBODY, full_write ? 0027 : 0022)
+ || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write,
+ AID_EVERYBODY, full_write ? 0007 : 0022)) {
LOG(FATAL) << "failed to sdcardfs_setup";
}
}
@@ -452,8 +437,7 @@
<< " -g: specify GID to run as"
<< " -U: specify user ID that owns device"
<< " -m: source_path is multi-user"
- << " -w: runtime write mount has full write access"
- << " -P preserve owners on the lower file system";
+ << " -w: runtime write mount has full write access";
return 1;
}
@@ -465,13 +449,12 @@
userid_t userid = 0;
bool multi_user = false;
bool full_write = false;
- bool derive_gid = false;
int i;
struct rlimit rlim;
int fs_version;
int opt;
- while ((opt = getopt(argc, argv, "u:g:U:mwG")) != -1) {
+ while ((opt = getopt(argc, argv, "u:g:U:mw")) != -1) {
switch (opt) {
case 'u':
uid = strtoul(optarg, NULL, 10);
@@ -488,9 +471,6 @@
case 'w':
full_write = true;
break;
- case 'G':
- derive_gid = true;
- break;
case '?':
default:
return usage();
@@ -534,7 +514,7 @@
}
if (should_use_sdcardfs()) {
- run_sdcardfs(source_path, label, uid, gid, userid, multi_user, full_write, derive_gid);
+ run_sdcardfs(source_path, label, uid, gid, userid, multi_user, full_write);
} else {
run(source_path, label, uid, gid, userid, multi_user, full_write);
}