1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

devicesfile: move opendir after fclose

Call opendir() after new file is stored within dir,
otherwise this new file would not accounted.
This commit is contained in:
Zdenek Kabelac 2024-10-24 21:19:01 +02:00
parent b88cbc7f17
commit 2c5bf25187

View File

@ -1389,11 +1389,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);
@ -1427,6 +1422,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))) {