Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +4 −0 Original line number Diff line number Diff line Loading @@ -540,6 +540,10 @@ class SnapshotManager final { bool ProcessUpdateStateOnDataWipe(bool allow_forward_merge, const std::function<bool()>& callback); // Return device string of a mapped image, or if it is not available, the mapped image path. bool GetMappedImageDeviceStringOrPath(const std::string& device_name, std::string* device_string_or_mapped_path); std::string gsid_dir_; std::string metadata_dir_; std::unique_ptr<IDeviceInfo> device_; Loading fs_mgr/libsnapshot/snapshot.cpp +22 −4 Original line number Diff line number Diff line Loading @@ -1691,7 +1691,7 @@ bool SnapshotManager::MapPartitionWithSnapshot(LockedFile* lock, return false; } std::string cow_device; if (!dm.GetDeviceString(cow_name, &cow_device)) { if (!GetMappedImageDeviceStringOrPath(cow_name, &cow_device)) { LOG(ERROR) << "Could not determine major/minor for: " << cow_name; return false; } Loading Loading @@ -1788,7 +1788,7 @@ bool SnapshotManager::MapCowDevices(LockedFile* lock, const CreateLogicalPartiti // If the COW image exists, append it as the last extent. if (snapshot_status.cow_file_size() > 0) { std::string cow_image_device; if (!dm.GetDeviceString(cow_image_name, &cow_image_device)) { if (!GetMappedImageDeviceStringOrPath(cow_image_name, &cow_image_device)) { LOG(ERROR) << "Cannot determine major/minor for: " << cow_image_name; return false; } Loading Loading @@ -2364,7 +2364,6 @@ Return SnapshotManager::InitializeUpdateSnapshots( const std::map<std::string, SnapshotStatus>& all_snapshot_status) { CHECK(lock); auto& dm = DeviceMapper::Instance(); CreateLogicalPartitionParams cow_params{ .block_device = LP_METADATA_DEFAULT_PARTITION_NAME, .metadata = exported_target_metadata, Loading @@ -2389,7 +2388,7 @@ Return SnapshotManager::InitializeUpdateSnapshots( } std::string cow_path; if (!dm.GetDmDevicePathByName(cow_name, &cow_path)) { if (!images_->GetMappedImageDevice(cow_name, &cow_path)) { LOG(ERROR) << "Cannot determine path for " << cow_name; return Return::Error(); } Loading Loading @@ -2738,5 +2737,24 @@ bool SnapshotManager::UpdateForwardMergeIndicator(bool wipe) { return true; } bool SnapshotManager::GetMappedImageDeviceStringOrPath(const std::string& device_name, std::string* device_string_or_mapped_path) { auto& dm = DeviceMapper::Instance(); // Try getting the device string if it is a device mapper device. if (dm.GetState(device_name) != DmDeviceState::INVALID) { return dm.GetDeviceString(device_name, device_string_or_mapped_path); } // Otherwise, get path from IImageManager. if (!images_->GetMappedImageDevice(device_name, device_string_or_mapped_path)) { return false; } LOG(WARNING) << "Calling GetMappedImageDevice with local image manager; device " << (device_string_or_mapped_path ? *device_string_or_mapped_path : "(nullptr)") << "may not be available in first stage init! "; return true; } } // namespace snapshot } // namespace android libcutils/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ cc_library_headers { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", native_bridge_supported: true, export_include_dirs: ["include"], target: { Loading @@ -59,6 +60,7 @@ cc_library { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", export_include_dirs: ["include"], Loading Loading @@ -142,6 +144,7 @@ cc_library { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", native_bridge_supported: true, srcs: [ "config_utils.cpp", Loading libgrallocusage/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -26,4 +26,5 @@ cc_library { export_include_dirs: ["include"], shared_libs: ["android.hardware.graphics.allocator@2.0"], header_libs: ["libhardware_headers"], min_sdk_version: "29", } libnetutils/packet.c +13 −16 Original line number Diff line number Diff line Loading @@ -37,25 +37,22 @@ #include "dhcpmsg.h" int fatal(); int open_raw_socket(const char *ifname __attribute__((unused)), uint8_t *hwaddr, int if_index) { int s; struct sockaddr_ll bindaddr; if((s = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { return fatal("socket(PF_PACKET)"); } memset(&bindaddr, 0, sizeof(bindaddr)); bindaddr.sll_family = AF_PACKET; bindaddr.sll_protocol = htons(ETH_P_IP); bindaddr.sll_halen = ETH_ALEN; int fatal(const char*); int open_raw_socket(const char* ifname __unused, uint8_t hwaddr[ETH_ALEN], int if_index) { int s = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (s < 0) return fatal("socket(PF_PACKET)"); struct sockaddr_ll bindaddr = { .sll_family = AF_PACKET, .sll_protocol = htons(ETH_P_IP), .sll_ifindex = if_index, .sll_halen = ETH_ALEN, }; memcpy(bindaddr.sll_addr, hwaddr, ETH_ALEN); bindaddr.sll_ifindex = if_index; if (bind(s, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) { close(s); return fatal("Cannot bind raw socket to interface"); } Loading Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +4 −0 Original line number Diff line number Diff line Loading @@ -540,6 +540,10 @@ class SnapshotManager final { bool ProcessUpdateStateOnDataWipe(bool allow_forward_merge, const std::function<bool()>& callback); // Return device string of a mapped image, or if it is not available, the mapped image path. bool GetMappedImageDeviceStringOrPath(const std::string& device_name, std::string* device_string_or_mapped_path); std::string gsid_dir_; std::string metadata_dir_; std::unique_ptr<IDeviceInfo> device_; Loading
fs_mgr/libsnapshot/snapshot.cpp +22 −4 Original line number Diff line number Diff line Loading @@ -1691,7 +1691,7 @@ bool SnapshotManager::MapPartitionWithSnapshot(LockedFile* lock, return false; } std::string cow_device; if (!dm.GetDeviceString(cow_name, &cow_device)) { if (!GetMappedImageDeviceStringOrPath(cow_name, &cow_device)) { LOG(ERROR) << "Could not determine major/minor for: " << cow_name; return false; } Loading Loading @@ -1788,7 +1788,7 @@ bool SnapshotManager::MapCowDevices(LockedFile* lock, const CreateLogicalPartiti // If the COW image exists, append it as the last extent. if (snapshot_status.cow_file_size() > 0) { std::string cow_image_device; if (!dm.GetDeviceString(cow_image_name, &cow_image_device)) { if (!GetMappedImageDeviceStringOrPath(cow_image_name, &cow_image_device)) { LOG(ERROR) << "Cannot determine major/minor for: " << cow_image_name; return false; } Loading Loading @@ -2364,7 +2364,6 @@ Return SnapshotManager::InitializeUpdateSnapshots( const std::map<std::string, SnapshotStatus>& all_snapshot_status) { CHECK(lock); auto& dm = DeviceMapper::Instance(); CreateLogicalPartitionParams cow_params{ .block_device = LP_METADATA_DEFAULT_PARTITION_NAME, .metadata = exported_target_metadata, Loading @@ -2389,7 +2388,7 @@ Return SnapshotManager::InitializeUpdateSnapshots( } std::string cow_path; if (!dm.GetDmDevicePathByName(cow_name, &cow_path)) { if (!images_->GetMappedImageDevice(cow_name, &cow_path)) { LOG(ERROR) << "Cannot determine path for " << cow_name; return Return::Error(); } Loading Loading @@ -2738,5 +2737,24 @@ bool SnapshotManager::UpdateForwardMergeIndicator(bool wipe) { return true; } bool SnapshotManager::GetMappedImageDeviceStringOrPath(const std::string& device_name, std::string* device_string_or_mapped_path) { auto& dm = DeviceMapper::Instance(); // Try getting the device string if it is a device mapper device. if (dm.GetState(device_name) != DmDeviceState::INVALID) { return dm.GetDeviceString(device_name, device_string_or_mapped_path); } // Otherwise, get path from IImageManager. if (!images_->GetMappedImageDevice(device_name, device_string_or_mapped_path)) { return false; } LOG(WARNING) << "Calling GetMappedImageDevice with local image manager; device " << (device_string_or_mapped_path ? *device_string_or_mapped_path : "(nullptr)") << "may not be available in first stage init! "; return true; } } // namespace snapshot } // namespace android
libcutils/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ cc_library_headers { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", native_bridge_supported: true, export_include_dirs: ["include"], target: { Loading @@ -59,6 +60,7 @@ cc_library { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", export_include_dirs: ["include"], Loading Loading @@ -142,6 +144,7 @@ cc_library { "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", native_bridge_supported: true, srcs: [ "config_utils.cpp", Loading
libgrallocusage/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -26,4 +26,5 @@ cc_library { export_include_dirs: ["include"], shared_libs: ["android.hardware.graphics.allocator@2.0"], header_libs: ["libhardware_headers"], min_sdk_version: "29", }
libnetutils/packet.c +13 −16 Original line number Diff line number Diff line Loading @@ -37,25 +37,22 @@ #include "dhcpmsg.h" int fatal(); int open_raw_socket(const char *ifname __attribute__((unused)), uint8_t *hwaddr, int if_index) { int s; struct sockaddr_ll bindaddr; if((s = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { return fatal("socket(PF_PACKET)"); } memset(&bindaddr, 0, sizeof(bindaddr)); bindaddr.sll_family = AF_PACKET; bindaddr.sll_protocol = htons(ETH_P_IP); bindaddr.sll_halen = ETH_ALEN; int fatal(const char*); int open_raw_socket(const char* ifname __unused, uint8_t hwaddr[ETH_ALEN], int if_index) { int s = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (s < 0) return fatal("socket(PF_PACKET)"); struct sockaddr_ll bindaddr = { .sll_family = AF_PACKET, .sll_protocol = htons(ETH_P_IP), .sll_ifindex = if_index, .sll_halen = ETH_ALEN, }; memcpy(bindaddr.sll_addr, hwaddr, ETH_ALEN); bindaddr.sll_ifindex = if_index; if (bind(s, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) { close(s); return fatal("Cannot bind raw socket to interface"); } Loading