From 61b7db69a6bee619857a8339fa9c9d4a28b67b9f Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Fri, 7 Dec 2018 11:02:06 +0100 Subject: [PATCH] Make disk-usage functions use off_t The off_t is the same type that stat(2) uses and it's widest type that can actually hold information real disk usage. Change-Id: Id4b5d1160bdecafb065cf6792274c255619817fc --- src/crash-manager/crash-manager.c | 8 ++++---- src/shared/util.c | 4 ++-- src/shared/util.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 7768284..215904b 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -94,7 +94,7 @@ enum { struct file_info { bool isdir; - int size; + size_t size; time_t mtime; char *path; }; @@ -906,7 +906,7 @@ static int mtime_cmp(const void *_a, const void *_b) return 0; } -static int scan_dump(struct file_info **dump_list, size_t *usage) +static int scan_dump(struct file_info **dump_list, off_t *usage) { struct file_info *temp_list; struct dirent **scan_list = NULL; @@ -1026,7 +1026,7 @@ static void clean_dump(void) { struct file_info *dump_list = NULL; int i, scan_num, dump_num, remove_flag; - size_t usage = 0; + off_t usage = 0; time_t cur_time; scan_num = scan_dump(&dump_list, &usage); @@ -1065,7 +1065,7 @@ static void clean_dump(void) dump_list[i].path); break; case USAGE_EXCEED: - _I("Reached the maximum disk usage %d/%d kb, so remove (%s)", + _I("Reached the maximum disk usage %lld/%d kb, so remove (%s)", usage / 1024, system_max_use, dump_list[i].path); break; diff --git a/src/shared/util.c b/src/shared/util.c index 85879d6..564d276 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -651,12 +651,12 @@ int get_file_count(char *path) return count; } -int get_directory_usage(char *path) +off_t get_directory_usage(char *path) { DIR *dir; struct dirent *de; struct stat st; - size_t usage = 0; + off_t usage = 0; int fd = -1; fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME); diff --git a/src/shared/util.h b/src/shared/util.h index 819a19c..c45bf3c 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -59,7 +59,7 @@ int get_exec_pid(const char *execpath); int get_file_count(char *path); -int get_directory_usage(char *path); +off_t get_directory_usage(char *path); int log_kmsg(char *fmt, ...); -- 2.7.4