summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-ctl.cpp
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-12-14 01:59:54 -0200
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-14 01:59:54 -0200
commitaf2c8347ec518cf5ff646d2bf560206780775795 (patch)
tree7f2cfb3c70d3bd0eaa315f0c34da8285e06f7499 /v4l2-apps/util/v4l2-ctl.cpp
parent1a97b7617165d0c5f13812dad33afa56efb499ae (diff)
parent7820558f98ad177a1b4db0882e9f49cc93200aa6 (diff)
downloadmediapointer-dvb-s2-af2c8347ec518cf5ff646d2bf560206780775795.tar.gz
mediapointer-dvb-s2-af2c8347ec518cf5ff646d2bf560206780775795.tar.bz2
merge: http://www.linuxtv.org/hg/
From: Mauro Carvalho Chehab <mchehab@redhat.com> Priority: normal Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps/util/v4l2-ctl.cpp')
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 417721c57..7d5988571 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -1096,6 +1096,7 @@ static void list_devices()
DIR *dp;
struct dirent *ep;
dev_vec files;
+ dev_map links;
dev_map cards;
struct v4l2_capability vcap;
@@ -1119,6 +1120,37 @@ static void list_devices()
}
#endif
+ /* Find device nodes which are links to other device nodes */
+ for (dev_vec::iterator iter = files.begin();
+ iter != files.end(); ) {
+ char link[64+1];
+ int link_len;
+ std::string target;
+
+ link_len = readlink(iter->c_str(), link, 64);
+ if (link_len < 0) { /* Not a link or error */
+ iter++;
+ continue;
+ }
+ link[link_len] = '\0';
+
+ /* Only remove from files list if target itself is in list */
+ if (link[0] != '/') /* Relative link */
+ target = std::string("/dev/");
+ target += link;
+ if (find(files.begin(), files.end(), target) == files.end()) {
+ iter++;
+ continue;
+ }
+
+ /* Move the device node from files to links */
+ if (links[target].empty())
+ links[target] = *iter;
+ else
+ links[target] += ", " + *iter;
+ files.erase(iter);
+ }
+
std::sort(files.begin(), files.end(), sort_on_device_name);
for (dev_vec::iterator iter = files.begin();
@@ -1133,7 +1165,10 @@ static void list_devices()
bus_info = (const char *)vcap.bus_info;
if (cards[bus_info].empty())
cards[bus_info] += std::string((char *)vcap.card) + " (" + bus_info + "):\n";
- cards[bus_info] += "\t" + (*iter) + "\n";
+ cards[bus_info] += "\t" + (*iter);
+ if (!(links[*iter].empty()))
+ cards[bus_info] += " <- " + links[*iter];
+ cards[bus_info] += "\n";
}
for (dev_map::iterator iter = cards.begin();
iter != cards.end(); ++iter) {