Merge "fs_mgr: fixup 'size' attributes of fstab."

This commit is contained in:
Tom Cherry 2018-11-30 16:33:54 +00:00 committed by Gerrit Code Review
commit 9d24734b5c
3 changed files with 21 additions and 21 deletions

View file

@ -20,6 +20,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
@ -1414,7 +1415,7 @@ int fs_mgr_swapon_all(fstab* fstab) {
ret = -1;
continue;
}
fprintf(zram_fp.get(), "%u\n", fstab->recs[i].zram_size);
fprintf(zram_fp.get(), "%" PRId64 "\n", fstab->recs[i].zram_size);
}
if (fstab->recs[i].fs_mgr_flags & MF_WAIT &&

View file

@ -42,17 +42,17 @@ struct fs_mgr_flag_values {
char* key_dir;
char *verity_loc;
char *sysfs_path;
long long part_length;
off64_t part_length;
char *label;
int partnum;
int swap_prio;
int max_comp_streams;
unsigned int zram_size;
uint64_t reserved_size;
off64_t zram_size;
off64_t reserved_size;
unsigned int file_contents_mode;
unsigned int file_names_mode;
unsigned int erase_blk_size;
unsigned int logical_blk_size;
off64_t erase_blk_size;
off64_t logical_blk_size;
};
struct flag_list {
@ -160,9 +160,8 @@ static const char *flag_to_encryption_mode(const struct flag_list *list,
return nullptr;
}
static uint64_t calculate_zram_size(unsigned int percentage)
{
uint64_t total;
static off64_t calculate_zram_size(unsigned int percentage) {
off64_t total;
total = sysconf(_SC_PHYS_PAGES);
total *= percentage;
@ -173,10 +172,9 @@ static uint64_t calculate_zram_size(unsigned int percentage)
return total;
}
static uint64_t parse_size(const char *arg)
{
static off64_t parse_size(const char* arg) {
char *endptr;
uint64_t size = strtoull(arg, &endptr, 10);
off64_t size = strtoll(arg, &endptr, 10);
if (*endptr == 'k' || *endptr == 'K')
size *= 1024LL;
else if (*endptr == 'm' || *endptr == 'M')
@ -339,7 +337,7 @@ static int parse_flags(char *flags, struct flag_list *fl,
* erase block size. Get it, check that it is a power of 2 and
* at least 4096, and return it.
*/
auto val = strtoul(arg, NULL, 0);
auto val = strtoll(arg, nullptr, 0);
if (val >= 4096 && (val & (val - 1)) == 0)
flag_vals->erase_blk_size = val;
} else if (flag == MF_LOGICALBLKSIZE) {
@ -347,7 +345,7 @@ static int parse_flags(char *flags, struct flag_list *fl,
* logical block size. Get it, check that it is a power of 2 and
* at least 4096, and return it.
*/
auto val = strtoul(arg, NULL, 0);
auto val = strtoll(arg, nullptr, 0);
if (val >= 4096 && (val & (val - 1)) == 0)
flag_vals->logical_blk_size = val;
} else if (flag == MF_SYSFS) {

View file

@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <set>
#include <string>
@ -46,17 +47,17 @@ struct fstab_rec {
char* key_loc;
char* key_dir;
char* verity_loc;
long long length;
off64_t length;
char* label;
int partnum;
int swap_prio;
int max_comp_streams;
unsigned int zram_size;
uint64_t reserved_size;
unsigned int file_contents_mode;
unsigned int file_names_mode;
unsigned int erase_blk_size;
unsigned int logical_blk_size;
off64_t zram_size;
off64_t reserved_size;
off64_t file_contents_mode;
off64_t file_names_mode;
off64_t erase_blk_size;
off64_t logical_blk_size;
char* sysfs_path;
};