|
|
9a499a |
autofs-5.1.7 - add ext_mount_hash_mutex lock helpers
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Coverity: check_return: Calling "pthread_mutex_lock" without checking
|
|
|
9a499a |
return value.
|
|
|
9a499a |
|
|
|
9a499a |
Well, I use helpers to do this in many places so can't really disagree.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
lib/mounts.c | 26 ++++++++++++++++++++------
|
|
|
9a499a |
2 files changed, 21 insertions(+), 6 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -65,6 +65,7 @@
|
|
|
9a499a |
- fix double free in parse_mapent().
|
|
|
9a499a |
- refactor lookup_prune_one_cache() a bit.
|
|
|
9a499a |
- cater for empty mounts list in mnts_get_expire_list().
|
|
|
9a499a |
+- add ext_mount_hash_mutex lock helpers.
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -788,6 +788,20 @@ char *make_mnt_name_string(char *path)
|
|
|
9a499a |
return mnt_name;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+static void ext_mount_hash_mutex_lock(void)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ int status = pthread_mutex_lock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ if (status)
|
|
|
9a499a |
+ fatal(status);
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+static void ext_mount_hash_mutex_unlock(void)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ int status = pthread_mutex_unlock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ if (status)
|
|
|
9a499a |
+ fatal(status);
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
static struct ext_mount *ext_mount_lookup(const char *mp)
|
|
|
9a499a |
{
|
|
|
9a499a |
uint32_t hval = hash(mp, HASH_SIZE(ext_mounts_hash));
|
|
|
9a499a |
@@ -806,7 +820,7 @@ int ext_mount_add(const char *path, cons
|
|
|
9a499a |
struct ext_mount *em;
|
|
|
9a499a |
int ret = 0;
|
|
|
9a499a |
|
|
|
9a499a |
- pthread_mutex_lock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_lock();
|
|
|
9a499a |
|
|
|
9a499a |
em = ext_mount_lookup(path);
|
|
|
9a499a |
if (em) {
|
|
|
9a499a |
@@ -840,7 +854,7 @@ int ext_mount_add(const char *path, cons
|
|
|
9a499a |
|
|
|
9a499a |
ret = 1;
|
|
|
9a499a |
done:
|
|
|
9a499a |
- pthread_mutex_unlock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_unlock();
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -849,7 +863,7 @@ int ext_mount_remove(const char *path)
|
|
|
9a499a |
struct ext_mount *em;
|
|
|
9a499a |
int ret = 0;
|
|
|
9a499a |
|
|
|
9a499a |
- pthread_mutex_lock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_lock();
|
|
|
9a499a |
|
|
|
9a499a |
em = ext_mount_lookup(path);
|
|
|
9a499a |
if (!em)
|
|
|
9a499a |
@@ -867,7 +881,7 @@ int ext_mount_remove(const char *path)
|
|
|
9a499a |
ret = 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
done:
|
|
|
9a499a |
- pthread_mutex_unlock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_unlock();
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -876,13 +890,13 @@ int ext_mount_inuse(const char *path)
|
|
|
9a499a |
struct ext_mount *em;
|
|
|
9a499a |
int ret = 0;
|
|
|
9a499a |
|
|
|
9a499a |
- pthread_mutex_lock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_lock();
|
|
|
9a499a |
em = ext_mount_lookup(path);
|
|
|
9a499a |
if (!em)
|
|
|
9a499a |
goto done;
|
|
|
9a499a |
ret = em->ref;
|
|
|
9a499a |
done:
|
|
|
9a499a |
- pthread_mutex_unlock(&ext_mount_hash_mutex);
|
|
|
9a499a |
+ ext_mount_hash_mutex_unlock();
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|