Merge "[Bugfix]Fix userspace-reboot failure when backing_dev exists but zram not swapped on" am: 23a50b3860 am: bce0c15f3f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1674154 Change-Id: I64dcfce0607d41ee4c859dafe040013dc62cf47e
This commit is contained in:
commit
11f3ed6133
1 changed files with 15 additions and 3 deletions
|
|
@ -450,10 +450,22 @@ static UmountStat TryUmountAndFsck(unsigned int cmd, bool run_fsck,
|
|||
|
||||
// zram is able to use backing device on top of a loopback device.
|
||||
// In order to unmount /data successfully, we have to kill the loopback device first
|
||||
#define ZRAM_DEVICE "/dev/block/zram0"
|
||||
#define ZRAM_RESET "/sys/block/zram0/reset"
|
||||
#define ZRAM_BACK_DEV "/sys/block/zram0/backing_dev"
|
||||
#define ZRAM_DEVICE "/dev/block/zram0"
|
||||
#define ZRAM_RESET "/sys/block/zram0/reset"
|
||||
#define ZRAM_BACK_DEV "/sys/block/zram0/backing_dev"
|
||||
#define ZRAM_INITSTATE "/sys/block/zram0/initstate"
|
||||
static Result<void> KillZramBackingDevice() {
|
||||
std::string zram_initstate;
|
||||
if (!android::base::ReadFileToString(ZRAM_INITSTATE, &zram_initstate)) {
|
||||
return ErrnoError() << "Failed to read " << ZRAM_INITSTATE;
|
||||
}
|
||||
|
||||
zram_initstate.erase(zram_initstate.length() - 1);
|
||||
if (zram_initstate == "0") {
|
||||
LOG(INFO) << "Zram has not been swapped on";
|
||||
return {};
|
||||
}
|
||||
|
||||
if (access(ZRAM_BACK_DEV, F_OK) != 0 && errno == ENOENT) {
|
||||
LOG(INFO) << "No zram backing device configured";
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue