mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
Fix locale-specific time
In `zpool status -t`, scrub date/time is reported using the C locale, while trim time is reported using the current one. This is inconsistent. This patch fixes that. Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Maxim Filimonov <che@bein.link> Closes #15878 Closes #15879
This commit is contained in:
parent
aa5445c28b
commit
f07389d3ad
@ -2289,7 +2289,6 @@ print_status_initialize(vdev_stat_t *vs, boolean_t verbose)
|
|||||||
!vs->vs_scan_removing) {
|
!vs->vs_scan_removing) {
|
||||||
char zbuf[1024];
|
char zbuf[1024];
|
||||||
char tbuf[256];
|
char tbuf[256];
|
||||||
struct tm zaction_ts;
|
|
||||||
|
|
||||||
time_t t = vs->vs_initialize_action_time;
|
time_t t = vs->vs_initialize_action_time;
|
||||||
int initialize_pct = 100;
|
int initialize_pct = 100;
|
||||||
@ -2299,8 +2298,8 @@ print_status_initialize(vdev_stat_t *vs, boolean_t verbose)
|
|||||||
100 / (vs->vs_initialize_bytes_est + 1));
|
100 / (vs->vs_initialize_bytes_est + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) localtime_r(&t, &zaction_ts);
|
(void) ctime_r(&t, tbuf);
|
||||||
(void) strftime(tbuf, sizeof (tbuf), "%c", &zaction_ts);
|
tbuf[24] = 0;
|
||||||
|
|
||||||
switch (vs->vs_initialize_state) {
|
switch (vs->vs_initialize_state) {
|
||||||
case VDEV_INITIALIZE_SUSPENDED:
|
case VDEV_INITIALIZE_SUSPENDED:
|
||||||
@ -2340,7 +2339,6 @@ print_status_trim(vdev_stat_t *vs, boolean_t verbose)
|
|||||||
!vs->vs_scan_removing) {
|
!vs->vs_scan_removing) {
|
||||||
char zbuf[1024];
|
char zbuf[1024];
|
||||||
char tbuf[256];
|
char tbuf[256];
|
||||||
struct tm zaction_ts;
|
|
||||||
|
|
||||||
time_t t = vs->vs_trim_action_time;
|
time_t t = vs->vs_trim_action_time;
|
||||||
int trim_pct = 100;
|
int trim_pct = 100;
|
||||||
@ -2349,8 +2347,8 @@ print_status_trim(vdev_stat_t *vs, boolean_t verbose)
|
|||||||
100 / (vs->vs_trim_bytes_est + 1));
|
100 / (vs->vs_trim_bytes_est + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) localtime_r(&t, &zaction_ts);
|
(void) ctime_r(&t, tbuf);
|
||||||
(void) strftime(tbuf, sizeof (tbuf), "%c", &zaction_ts);
|
tbuf[24] = 0;
|
||||||
|
|
||||||
switch (vs->vs_trim_state) {
|
switch (vs->vs_trim_state) {
|
||||||
case VDEV_TRIM_SUSPENDED:
|
case VDEV_TRIM_SUSPENDED:
|
||||||
|
@ -1900,7 +1900,8 @@ zpool_rewind_exclaim(libzfs_handle_t *hdl, const char *name, boolean_t dryrun,
|
|||||||
(void) nvlist_lookup_int64(nv, ZPOOL_CONFIG_REWIND_TIME, &loss);
|
(void) nvlist_lookup_int64(nv, ZPOOL_CONFIG_REWIND_TIME, &loss);
|
||||||
|
|
||||||
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
|
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
|
||||||
strftime(timestr, 128, "%c", &t) != 0) {
|
ctime_r((time_t *)&rewindto, timestr) != NULL) {
|
||||||
|
timestr[24] = 0;
|
||||||
if (dryrun) {
|
if (dryrun) {
|
||||||
(void) printf(dgettext(TEXT_DOMAIN,
|
(void) printf(dgettext(TEXT_DOMAIN,
|
||||||
"Would be able to return %s "
|
"Would be able to return %s "
|
||||||
@ -1962,7 +1963,8 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
|
|||||||
"Recovery is possible, but will result in some data loss.\n"));
|
"Recovery is possible, but will result in some data loss.\n"));
|
||||||
|
|
||||||
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
|
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
|
||||||
strftime(timestr, 128, "%c", &t) != 0) {
|
ctime_r((time_t *)&rewindto, timestr) != NULL) {
|
||||||
|
timestr[24] = 0;
|
||||||
(void) printf(dgettext(TEXT_DOMAIN,
|
(void) printf(dgettext(TEXT_DOMAIN,
|
||||||
"\tReturning the pool to its state as of %s\n"
|
"\tReturning the pool to its state as of %s\n"
|
||||||
"\tshould correct the problem. "),
|
"\tshould correct the problem. "),
|
||||||
|
Loading…
Reference in New Issue
Block a user