mapfree: restict sharing to devices

Avoid unrelated callbacks on mapped files (e.g. aio)
by sharing only block devices.
This commit is contained in:
Thomas Schoebel-Theuer 2021-07-12 11:30:20 +02:00
parent d18290d1f9
commit ab6036de76
1 changed files with 4 additions and 1 deletions

View File

@ -168,12 +168,15 @@ loff_t mapfree_real_size(struct mapfree_info *mf)
struct mapfree_info *mapfree_get(const char *name, int flags, int *error)
{
struct kstat check_stat = {};
struct mapfree_info *mf = NULL;
struct list_head *tmp;
unsigned int hash = mf_hash(name);
flags |= O_CLOEXEC;
if (!(flags & O_DIRECT)) {
if (!(flags & O_DIRECT) &&
mars_stat(name, &check_stat, false) >= 0 &&
(S_ISBLK(check_stat.mode))) {
down_read(&mf_table[hash].hash_mutex);
for (tmp = mf_table[hash].hash_anchor.next;
tmp != &mf_table[hash].hash_anchor;