Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adeb41a8 authored by Jin Qian's avatar Jin Qian
Browse files

recovery: update mkfs.f2fs args to match f2fs-tools 1.8.0

mkfs.f2fs in 1.8.0 returns error if number of sectors is 0. Skip
this argument to let mkfs detect device size. 0 sector is also not
necessary for 1.4.1.

Test: format userdata to f2fs and boot
Bug: 37758867
Change-Id: If120988dfb678596c973d183572f870eb0b72a27
parent 89394632
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -232,14 +232,14 @@ int format_volume(const char* volume, const char* directory) {
                           << ") not supported on " << v->fs_type;
                           << ") not supported on " << v->fs_type;
                return -1;
                return -1;
            }
            }
            char *num_sectors;
            char *num_sectors = nullptr;
            if (asprintf(&num_sectors, "%zd", length / 512) <= 0) {
            if (length >= 512 && asprintf(&num_sectors, "%zd", length / 512) <= 0) {
                LOG(ERROR) << "format_volume: failed to create " << v->fs_type
                LOG(ERROR) << "format_volume: failed to create " << v->fs_type
                           << " command for " << v->blk_device;
                           << " command for " << v->blk_device;
                return -1;
                return -1;
            }
            }
            const char *f2fs_path = "/sbin/mkfs.f2fs";
            const char *f2fs_path = "/sbin/mkfs.f2fs";
            const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, NULL};
            const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, nullptr};


            result = exec_cmd(f2fs_path, (char* const*)f2fs_argv);
            result = exec_cmd(f2fs_path, (char* const*)f2fs_argv);
            free(num_sectors);
            free(num_sectors);