You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
6.2 KiB
200 lines
6.2 KiB
From 219285adf56da85171fa90f42714341484750856 Mon Sep 17 00:00:00 2001
|
|
From: "Darrick J. Wong" <darrick.wong@oracle.com>
|
|
Date: Fri, 20 Nov 2020 17:03:27 -0500
|
|
Subject: [PATCH] xfs_quota: convert time_to_string to use time64_t
|
|
|
|
Rework the time_to_string helper to be capable of dealing with 64-bit
|
|
timestamps.
|
|
|
|
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
|
|
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
|
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
|
---
|
|
|
|
diff --git a/quota/quota.c b/quota/quota.c
|
|
index 9545cc4..8ba0995 100644
|
|
--- a/quota/quota.c
|
|
+++ b/quota/quota.c
|
|
@@ -48,6 +48,7 @@ quota_mount(
|
|
uint flags)
|
|
{
|
|
fs_disk_quota_t d;
|
|
+ time64_t timer;
|
|
char *dev = mount->fs_name;
|
|
char c[8], h[8], s[8];
|
|
uint qflags;
|
|
@@ -100,6 +101,7 @@ quota_mount(
|
|
}
|
|
|
|
if (form & XFS_BLOCK_QUOTA) {
|
|
+ timer = d.d_btimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_blk_hardlimit && d.d_bcount > d.d_blk_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -111,16 +113,17 @@ quota_mount(
|
|
bbs_to_string(d.d_blk_softlimit, s, sizeof(s)),
|
|
bbs_to_string(d.d_blk_hardlimit, h, sizeof(h)),
|
|
d.d_bwarns,
|
|
- time_to_string(d.d_btimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s ",
|
|
(unsigned long long)d.d_bcount >> 1,
|
|
(unsigned long long)d.d_blk_softlimit >> 1,
|
|
(unsigned long long)d.d_blk_hardlimit >> 1,
|
|
d.d_bwarns,
|
|
- time_to_string(d.d_btimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
if (form & XFS_INODE_QUOTA) {
|
|
+ timer = d.d_itimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_ino_hardlimit && d.d_icount > d.d_ino_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -132,16 +135,17 @@ quota_mount(
|
|
num_to_string(d.d_ino_softlimit, s, sizeof(s)),
|
|
num_to_string(d.d_ino_hardlimit, h, sizeof(h)),
|
|
d.d_iwarns,
|
|
- time_to_string(d.d_itimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s ",
|
|
(unsigned long long)d.d_icount,
|
|
(unsigned long long)d.d_ino_softlimit,
|
|
(unsigned long long)d.d_ino_hardlimit,
|
|
d.d_iwarns,
|
|
- time_to_string(d.d_itimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
if (form & XFS_RTBLOCK_QUOTA) {
|
|
+ timer = d.d_rtbtimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_rtb_hardlimit && d.d_rtbcount > d.d_rtb_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -153,14 +157,14 @@ quota_mount(
|
|
bbs_to_string(d.d_rtb_softlimit, s, sizeof(s)),
|
|
bbs_to_string(d.d_rtb_hardlimit, h, sizeof(h)),
|
|
d.d_rtbwarns,
|
|
- time_to_string(d.d_rtbtimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s ",
|
|
(unsigned long long)d.d_rtbcount >> 1,
|
|
(unsigned long long)d.d_rtb_softlimit >> 1,
|
|
(unsigned long long)d.d_rtb_hardlimit >> 1,
|
|
d.d_rtbwarns,
|
|
- time_to_string(d.d_rtbtimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
fprintf(fp, "%s\n", mount->fs_dir);
|
|
return 1;
|
|
diff --git a/quota/quota.h b/quota/quota.h
|
|
index b7f259e..13ae450 100644
|
|
--- a/quota/quota.h
|
|
+++ b/quota/quota.h
|
|
@@ -40,7 +40,7 @@ enum {
|
|
*/
|
|
extern char *type_to_string(uint __type);
|
|
extern char *form_to_string(uint __form);
|
|
-extern char *time_to_string(time_t __time, uint __flags);
|
|
+extern char *time_to_string(time64_t __time, uint __flags);
|
|
extern char *bbs_to_string(uint64_t __v, char *__c, uint __size);
|
|
extern char *num_to_string(uint64_t __v, char *__c, uint __size);
|
|
extern char *pct_to_string(uint64_t __v, uint64_t __t, char *__c, uint __s);
|
|
diff --git a/quota/report.c b/quota/report.c
|
|
index e6def91..2d5024e 100644
|
|
--- a/quota/report.c
|
|
+++ b/quota/report.c
|
|
@@ -330,6 +330,7 @@ report_mount(
|
|
uint flags)
|
|
{
|
|
fs_disk_quota_t d;
|
|
+ time64_t timer;
|
|
char *dev = mount->fs_name;
|
|
char c[8], h[8], s[8];
|
|
uint qflags;
|
|
@@ -397,6 +398,7 @@ report_mount(
|
|
}
|
|
|
|
if (form & XFS_BLOCK_QUOTA) {
|
|
+ timer = d.d_btimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_blk_hardlimit && d.d_bcount > d.d_blk_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -408,16 +410,17 @@ report_mount(
|
|
bbs_to_string(d.d_blk_softlimit, s, sizeof(s)),
|
|
bbs_to_string(d.d_blk_hardlimit, h, sizeof(h)),
|
|
d.d_bwarns,
|
|
- time_to_string(d.d_btimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s",
|
|
(unsigned long long)d.d_bcount >> 1,
|
|
(unsigned long long)d.d_blk_softlimit >> 1,
|
|
(unsigned long long)d.d_blk_hardlimit >> 1,
|
|
d.d_bwarns,
|
|
- time_to_string(d.d_btimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
if (form & XFS_INODE_QUOTA) {
|
|
+ timer = d.d_itimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_ino_hardlimit && d.d_icount > d.d_ino_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -429,16 +432,17 @@ report_mount(
|
|
num_to_string(d.d_ino_softlimit, s, sizeof(s)),
|
|
num_to_string(d.d_ino_hardlimit, h, sizeof(h)),
|
|
d.d_iwarns,
|
|
- time_to_string(d.d_itimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s",
|
|
(unsigned long long)d.d_icount,
|
|
(unsigned long long)d.d_ino_softlimit,
|
|
(unsigned long long)d.d_ino_hardlimit,
|
|
d.d_iwarns,
|
|
- time_to_string(d.d_itimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
if (form & XFS_RTBLOCK_QUOTA) {
|
|
+ timer = d.d_rtbtimer;
|
|
qflags = (flags & HUMAN_FLAG);
|
|
if (d.d_rtb_hardlimit && d.d_rtbcount > d.d_rtb_hardlimit)
|
|
qflags |= LIMIT_FLAG;
|
|
@@ -450,14 +454,14 @@ report_mount(
|
|
bbs_to_string(d.d_rtb_softlimit, s, sizeof(s)),
|
|
bbs_to_string(d.d_rtb_hardlimit, h, sizeof(h)),
|
|
d.d_rtbwarns,
|
|
- time_to_string(d.d_rtbtimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
else
|
|
fprintf(fp, " %10llu %10llu %10llu %02d %9s",
|
|
(unsigned long long)d.d_rtbcount >> 1,
|
|
(unsigned long long)d.d_rtb_softlimit >> 1,
|
|
(unsigned long long)d.d_rtb_hardlimit >> 1,
|
|
d.d_rtbwarns,
|
|
- time_to_string(d.d_rtbtimer, qflags));
|
|
+ time_to_string(timer, qflags));
|
|
}
|
|
fputc('\n', fp);
|
|
return 1;
|
|
diff --git a/quota/util.c b/quota/util.c
|
|
index 50470ab..361d2a8 100644
|
|
--- a/quota/util.c
|
|
+++ b/quota/util.c
|
|
@@ -18,11 +18,12 @@
|
|
|
|
char *
|
|
time_to_string(
|
|
- time_t origin,
|
|
+ time64_t origin,
|
|
uint flags)
|
|
{
|
|
static char timestamp[32];
|
|
- time_t now, timer;
|
|
+ time64_t timer;
|
|
+ time_t now;
|
|
uint days, hours, minutes, seconds;
|
|
|
|
if (flags & ABSOLUTE_FLAG) {
|