summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2015-05-13 17:07:53 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-05-13 17:07:53 +0000
commitb33118ac7603b459d690f524e0c64161f8ab5c0d (patch)
treebb5719fdd5a05f3837ee65ca909e2a37439388d6 /fs_mgr
parente97b11bc42eb300d140ae43f1d4a2f025d57ac1c (diff)
parent2557cd21f0af31d6dafee24d649f83314d2896d4 (diff)
downloadsystem_core-b33118ac7603b459d690f524e0c64161f8ab5c0d.zip
system_core-b33118ac7603b459d690f524e0c64161f8ab5c0d.tar.gz
system_core-b33118ac7603b459d690f524e0c64161f8ab5c0d.tar.bz2
am 2557cd21: am 8b448629: am 16092b7a: Merge "fs_mgr: allow for zramsize to be specified as percentage of total memory" into lmp-mr1-dev
* commit '2557cd21f0af31d6dafee24d649f83314d2896d4': fs_mgr: allow for zramsize to be specified as percentage of total memory
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr_fstab.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c
index 882585c..f24af1f 100644
--- a/fs_mgr/fs_mgr_fstab.c
+++ b/fs_mgr/fs_mgr_fstab.c
@@ -15,10 +15,12 @@
*/
#include <ctype.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
+#include <unistd.h>
#include "fs_mgr_priv.h"
@@ -76,6 +78,19 @@ static struct flag_list fs_mgr_flags[] = {
{ 0, 0 },
};
+static uint64_t calculate_zram_size(unsigned int percentage)
+{
+ uint64_t total;
+
+ total = sysconf(_SC_PHYS_PAGES);
+ total *= percentage;
+ total /= 100;
+
+ total *= sysconf(_SC_PAGESIZE);
+
+ return total;
+}
+
static int parse_flags(char *flags, struct flag_list *fl,
struct fs_mgr_flag_values *flag_vals,
char *fs_options, int fs_options_len)
@@ -157,7 +172,12 @@ static int parse_flags(char *flags, struct flag_list *fl,
} else if ((fl[i].flag == MF_SWAPPRIO) && flag_vals) {
flag_vals->swap_prio = strtoll(strchr(p, '=') + 1, NULL, 0);
} else if ((fl[i].flag == MF_ZRAMSIZE) && flag_vals) {
- flag_vals->zram_size = strtoll(strchr(p, '=') + 1, NULL, 0);
+ int is_percent = !!strrchr(p, '%');
+ unsigned int val = strtoll(strchr(p, '=') + 1, NULL, 0);
+ if (is_percent)
+ flag_vals->zram_size = calculate_zram_size(val);
+ else
+ flag_vals->zram_size = val;
}
break;
}