infra: fix replacement of .deleted links with files

This commit is contained in:
Thomas Schoebel-Theuer 2020-09-08 09:15:45 +02:00
parent c0c468a3f7
commit f770728c72
1 changed files with 13 additions and 0 deletions

View File

@ -33,6 +33,9 @@
#include <linux/wait.h>
#include <linux/file.h>
/* needed for symlink checking */
#include "sy_old/strategy.h"
// time to wait between background mapfree operations
int mapfree_period_sec = 10;
EXPORT_SYMBOL_GPL(mapfree_period_sec);
@ -185,6 +188,16 @@ struct mapfree_info *mapfree_get(const char *name, int flags)
continue;
}
/* allow replacement of a .deleted symlink */
if (flags & O_CREAT) {
const char *check = ordered_readlink(name, NULL);
if (check && !*check)
mars_unlink(name);
brick_string_free(check);
}
mf->mf_flags = flags;
INIT_LIST_HEAD(&mf->mf_head);
INIT_LIST_HEAD(&mf->mf_dirty_anchor);