126 lines
3.6 KiB
Diff
126 lines
3.6 KiB
Diff
autofs-5.1.8 - add function master_find_mapent_by_devid()
|
|
|
|
From: Ian Kent <raven@themaw.net>
|
|
|
|
Add a helper function that can locate an automount given its device id.
|
|
|
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
---
|
|
CHANGELOG | 1 +
|
|
daemon/master.c | 28 ++++++++++++++++++++++++++++
|
|
include/master.h | 1 +
|
|
include/mounts.h | 1 +
|
|
lib/mounts.c | 34 ++++++++++++++++++++++++++++++++++
|
|
5 files changed, 65 insertions(+)
|
|
|
|
--- autofs-5.1.4.orig/CHANGELOG
|
|
+++ autofs-5.1.4/CHANGELOG
|
|
@@ -117,6 +117,7 @@
|
|
- make signal handling consistent.
|
|
- fix incorrect print format specifiers in get_pkt().
|
|
- eliminate last remaining state_pipe usage.
|
|
+- add function master_find_mapent_by_devid().
|
|
|
|
xx/xx/2018 autofs-5.1.5
|
|
- fix flag file permission.
|
|
--- autofs-5.1.4.orig/daemon/master.c
|
|
+++ autofs-5.1.4/daemon/master.c
|
|
@@ -739,6 +739,34 @@ struct master_mapent *master_find_mapent
|
|
return NULL;
|
|
}
|
|
|
|
+struct autofs_point *master_find_mapent_by_devid(struct master *master, dev_t devid)
|
|
+{
|
|
+ struct autofs_point *ap = NULL;
|
|
+ struct list_head *head, *p;
|
|
+
|
|
+ master_mutex_lock();
|
|
+
|
|
+ head = &master->mounts;
|
|
+ list_for_each(p, head) {
|
|
+ struct master_mapent *entry;
|
|
+
|
|
+ entry = list_entry(p, struct master_mapent, list);
|
|
+
|
|
+ if (entry->ap->dev == devid) {
|
|
+ ap = entry->ap;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ ap = mnt_find_submount_by_devid(&entry->ap->submounts, devid);
|
|
+ if (ap)
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ master_mutex_unlock();
|
|
+
|
|
+ return ap;
|
|
+}
|
|
+
|
|
static unsigned int master_partial_match_amd_mapent(struct master *master, const char *path)
|
|
{
|
|
struct list_head *head, *p;
|
|
--- autofs-5.1.4.orig/include/master.h
|
|
+++ autofs-5.1.4/include/master.h
|
|
@@ -110,6 +110,7 @@ void master_source_lock_cleanup(void *);
|
|
void master_source_current_wait(struct master_mapent *);
|
|
void master_source_current_signal(struct master_mapent *);
|
|
struct master_mapent *master_find_mapent(struct master *, const char *);
|
|
+struct autofs_point *master_find_mapent_by_devid(struct master *master, dev_t devid);
|
|
struct master_mapent *master_new_mapent(struct master *, const char *, time_t);
|
|
void master_add_mapent(struct master *, struct master_mapent *);
|
|
void master_remove_mapent(struct master_mapent *);
|
|
--- autofs-5.1.4.orig/include/mounts.h
|
|
+++ autofs-5.1.4/include/mounts.h
|
|
@@ -160,6 +160,7 @@ int ext_mount_inuse(const char *);
|
|
struct mnt_list *mnts_lookup_mount(const char *mp);
|
|
void mnts_put_mount(struct mnt_list *mnt);
|
|
struct mnt_list *mnts_find_submount(const char *path);
|
|
+struct autofs_point *mnt_find_submount_by_devid(struct list_head *submounts, dev_t devid);
|
|
struct mnt_list *mnts_add_submount(struct autofs_point *ap);
|
|
void mnts_remove_submount(const char *mp);
|
|
struct mnt_list *mnts_find_amdmount(const char *path);
|
|
--- autofs-5.1.4.orig/lib/mounts.c
|
|
+++ autofs-5.1.4/lib/mounts.c
|
|
@@ -1059,6 +1059,40 @@ struct mnt_list *mnts_find_submount(cons
|
|
return NULL;
|
|
}
|
|
|
|
+static struct autofs_point *__mnt_find_submount_by_devid(struct list_head *submounts, dev_t devid)
|
|
+{
|
|
+ struct autofs_point *ap = NULL;
|
|
+ struct list_head *p;
|
|
+
|
|
+ list_for_each(p, submounts) {
|
|
+ struct mnt_list *this;
|
|
+
|
|
+ this = list_entry(p, struct mnt_list, submount);
|
|
+
|
|
+ if (this->ap->dev == devid) {
|
|
+ ap = this->ap;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ ap = mnt_find_submount_by_devid(&this->ap->submounts, devid);
|
|
+ if (ap)
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ return ap;
|
|
+}
|
|
+
|
|
+struct autofs_point *mnt_find_submount_by_devid(struct list_head *submounts, dev_t devid)
|
|
+{
|
|
+ struct autofs_point *ap = NULL;
|
|
+
|
|
+ mnts_hash_mutex_lock();
|
|
+ ap = __mnt_find_submount_by_devid(submounts, devid);
|
|
+ mnts_hash_mutex_unlock();
|
|
+
|
|
+ return ap;
|
|
+}
|
|
+
|
|
struct mnt_list *mnts_add_submount(struct autofs_point *ap)
|
|
{
|
|
struct mnt_list *this;
|