diff --git a/universal7885-common/interfaces/hardware/parts/1.0/default/Swap.cpp b/universal7885-common/interfaces/hardware/parts/1.0/default/Swap.cpp index 09c0443..b9f3319 100644 --- a/universal7885-common/interfaces/hardware/parts/1.0/default/Swap.cpp +++ b/universal7885-common/interfaces/hardware/parts/1.0/default/Swap.cpp @@ -32,7 +32,7 @@ Return SwapOnData::setSwapSize(int32_t size) { } Return SwapOnData::setSwapOn() { - mkfile(mSwapSize * 1024 * 1024 * 10, SWAP_PATH); + mkfile(mSwapSize * 10, SWAP_PATH); mkswap(SWAP_PATH); swapon(SWAP_PATH.c_str(), (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK); return Void(); diff --git a/universal7885-common/interfaces/hardware/parts/1.0/default/SwapHelpers.cpp b/universal7885-common/interfaces/hardware/parts/1.0/default/SwapHelpers.cpp index 49bfcd7..8e9f111 100644 --- a/universal7885-common/interfaces/hardware/parts/1.0/default/SwapHelpers.cpp +++ b/universal7885-common/interfaces/hardware/parts/1.0/default/SwapHelpers.cpp @@ -1,12 +1,14 @@ #include -#include +#include #include #include -#include +#include #include #include #include #include +#include +#include /* XXX This needs to be obtained from kernel headers. See b/9336527 */ struct linux_swap_header { char bootbits[1024]; /* Space for disklabel etc. */ @@ -19,10 +21,13 @@ struct linux_swap_header { u_int32_t badpages[1]; }; void mkfile(int filesize, std::string name){ - FILE *fp = fopen(name.c_str(), "we"); - fseek(fp, filesize , SEEK_SET); - fputc('\0', fp); - fclose(fp); + std::vector empty(1024, 0); + std::ofstream ofs(name, std::ios::binary | std::ios::out); + + for(int i = 0; i < 1024 * filesize; i++) + { + ofs.write(&empty[0], empty.size()); + } } #define MAGIC_SWAP_HEADER "SWAPSPACE2" #define MAGIC_SWAP_HEADER_LEN 10