1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

devicesfile: move opendir after fclose

Call opendir() after new file is stored within dir,
otherwise this new file would not accounted.

(cherry picked from commit 2c5bf25187)
This commit is contained in:
Zdenek Kabelac 2024-10-24 21:19:01 +02:00 committed by Marian Csontos
parent 2371383de6
commit d6229041a5

View File

@ -1399,11 +1399,6 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
stack;
return;
}
if (!(dir = opendir(dirpath))) {
log_sys_debug("opendir", dirpath);
return;
}
tm = localtime(tp);
strftime(datetime_str, sizeof(datetime_str), "%Y%m%d.%H%M%S", tm);
@ -1437,6 +1432,12 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
fp = NULL;
log_debug("Wrote backup %s", path);
/* Open dir after backup file is written, so it can be accounted */
if (!(dir = opendir(dirpath))) {
log_sys_debug("opendir", dirpath);
return;
}
/* Possibly remove old backup files per configurable limit on backup files. */
while ((de = readdir(dir))) {