]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
blktap2: Add tap_ctl_find_minor
authorDaniel Stodden <daniel.stodden@citrix.com>
Tue, 29 Jun 2010 20:03:09 +0000 (13:03 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Tue, 29 Jun 2010 20:03:09 +0000 (13:03 -0700)
Slack 'tap-ctl find -t <type> -f <path>'.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
control/tap-ctl-list.c
control/tap-ctl.h

index af5922772c2ef7f10527a9d13af8e0c0e32c1240..55de3e772dc6d56e2becaf5da6ba66d266b2aed6 100644 (file)
@@ -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;
+}
index 850f9f024b24b45685fe3fbef551e737150e1053..96142e47add4acb0b56857db50b266d1860e5561 100644 (file)
@@ -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);