summaryrefslogtreecommitdiff
path: root/src/journal/coredump-vacuum.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-10 18:16:18 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-10 18:16:18 +0200
commit59f448cf15f94bc5ebfd5b254de6f2441d02fbec (patch)
tree1d52fd0935cca0205c78fde6870abddb7aafd360 /src/journal/coredump-vacuum.c
parentf33be3119806f96898dda6ade492fbdcdf8f79b8 (diff)
tree-wide: never use the off_t unless glibc makes us use it
off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
Diffstat (limited to 'src/journal/coredump-vacuum.c')
-rw-r--r--src/journal/coredump-vacuum.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index c0347ef569..efe418615a 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -28,10 +28,10 @@
#include "coredump-vacuum.h"
-#define DEFAULT_MAX_USE_LOWER (off_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */
-#define DEFAULT_MAX_USE_UPPER (off_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
-#define DEFAULT_KEEP_FREE_UPPER (off_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
-#define DEFAULT_KEEP_FREE (off_t) (1024ULL*1024ULL) /* 1 MB */
+#define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */
+#define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
+#define DEFAULT_KEEP_FREE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
+#define DEFAULT_KEEP_FREE (uint64_t) (1024ULL*1024ULL) /* 1 MB */
struct vacuum_candidate {
unsigned n_files;
@@ -82,8 +82,8 @@ static int uid_from_file_name(const char *filename, uid_t *uid) {
return parse_uid(u, uid);
}
-static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use) {
- off_t fs_size = 0, fs_free = (off_t) -1;
+static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t max_use) {
+ uint64_t fs_size = 0, fs_free = (uint64_t) -1;
struct statvfs sv;
assert(fd >= 0);
@@ -93,7 +93,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
fs_free = sv.f_frsize * sv.f_bfree;
}
- if (max_use == (off_t) -1) {
+ if (max_use == (uint64_t) -1) {
if (fs_size > 0) {
max_use = PAGE_ALIGN(fs_size / 10); /* 10% */
@@ -111,7 +111,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
if (max_use > 0 && sum > max_use)
return true;
- if (keep_free == (off_t) -1) {
+ if (keep_free == (uint64_t) -1) {
if (fs_size > 0) {
keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */
@@ -129,7 +129,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
return false;
}
-int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
+int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
_cleanup_closedir_ DIR *d = NULL;
struct stat exclude_st;
int r;
@@ -161,7 +161,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
_cleanup_(vacuum_candidate_hasmap_freep) Hashmap *h = NULL;
struct vacuum_candidate *worst = NULL;
struct dirent *de;
- off_t sum = 0;
+ uint64_t sum = 0;
rewinddir(d);