}
}
- r = fwrite_uint(SWAP_ZRAM_DISK_SIZE, swap_size_bytes);
- if (r < 0) {
- _E("fail to write disk_size");
- return r;
- }
-
r = fread_uint(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
if (r < 0) {
_E("fail to read zram disk_size");
return r;
}
- /* Check if zram was sucessfully initialized (zcomp rollback case) */
- if (read_size_bytes < swap_size_bytes) {
- _E("swap size (%d) less than expected swap size (%d)",
- read_size_bytes, swap_size_bytes);
- return RESOURCED_ERROR_OUT_OF_MEMORY;
+ /* disksize can be pre-fixed by other means, do not set size in that case */
+ if (read_size_bytes == 0) {
+ r = fwrite_uint(SWAP_ZRAM_DISK_SIZE, swap_size_bytes);
+ if (r < 0) {
+ _E("fail to write disk_size");
+ return r;
+ }
+
+ r = fread_uint(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
+ if (r < 0) {
+ _E("fail to read zram disk_size");
+ return r;
+ }
+
+ /* Check if zram was sucessfully initialized (zcomp rollback case) */
+ if (read_size_bytes < swap_size_bytes) {
+ _E("swap size (%d) less than expected swap size (%d)",
+ read_size_bytes, swap_size_bytes);
+ return RESOURCED_ERROR_OUT_OF_MEMORY;
+ }
}
r = do_mkswap(swap->path);