diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-06-10 08:26:42 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-06-10 08:26:42 +0100 |
commit | 486d4e64a0a039a85b5f0b5e07df23aef26f96d7 (patch) | |
tree | cf3162eb4de45a093d26c4b8f5c29a46a41ad79b /tools/blktap2 | |
parent | a7d246473451b6c6949af961ab0971bf45c66d62 (diff) | |
download | xen-486d4e64a0a039a85b5f0b5e07df23aef26f96d7.tar.gz xen-486d4e64a0a039a85b5f0b5e07df23aef26f96d7.tar.bz2 xen-486d4e64a0a039a85b5f0b5e07df23aef26f96d7.zip |
blktap2: Add tap_ctl_find_minor
Slack 'tap-ctl find -t <type> -f <path>'.
Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
Diffstat (limited to 'tools/blktap2')
-rw-r--r-- | tools/blktap2/control/tap-ctl-list.c | 30 | ||||
-rw-r--r-- | tools/blktap2/control/tap-ctl.h | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tools/blktap2/control/tap-ctl-list.c b/tools/blktap2/control/tap-ctl-list.c index af5922772c..55de3e772d 100644 --- a/tools/blktap2/control/tap-ctl-list.c +++ b/tools/blktap2/control/tap-ctl-list.c @@ -504,3 +504,33 @@ out: return err; } + +int +tap_ctl_find_minor(const char *type, const char *path) +{ + tap_list_t **list, **_entry; + int minor, err; + + err = tap_ctl_list(&list); + if (err) + return err; + + minor = -1; + + for (_entry = list; *_entry != NULL; ++_entry) { + tap_list_t *entry = *_entry; + + if (type && (!entry->type || strcmp(entry->type, type))) + continue; + + if (path && (!entry->path || strcmp(entry->path, path))) + continue; + + minor = entry->minor; + break; + } + + tap_ctl_free_list(list); + + return minor >= 0 ? minor : -ENOENT; +} diff --git a/tools/blktap2/control/tap-ctl.h b/tools/blktap2/control/tap-ctl.h index 850f9f024b..96142e47ad 100644 --- a/tools/blktap2/control/tap-ctl.h +++ b/tools/blktap2/control/tap-ctl.h @@ -77,6 +77,7 @@ int tap_ctl_get_driver_id(const char *handle); int tap_ctl_list(tap_list_t ***list); void tap_ctl_free_list(tap_list_t **list); +int tap_ctl_find_minor(const char *type, const char *path); int tap_ctl_allocate(int *minor, char **devname); int tap_ctl_free(const int minor); |