summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-ctl.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-12-06 11:29:33 +0100
committerHans Verkuil <hverkuil@xs4all.nl>2008-12-06 11:29:33 +0100
commit7820558f98ad177a1b4db0882e9f49cc93200aa6 (patch)
tree78aaec8d150e8a6627fd3e66301dff0ffcb00595 /v4l2-apps/util/v4l2-ctl.cpp
parentc3e98daadb06990a815e0bd027c2d578c1e2ffee (diff)
downloadmediapointer-dvb-s2-7820558f98ad177a1b4db0882e9f49cc93200aa6.tar.gz
mediapointer-dvb-s2-7820558f98ad177a1b4db0882e9f49cc93200aa6.tar.bz2
v4l2-ctl: List device links as such
From: Jean Delvare <khali@linux-fr.org> Improvement to --list-devices: when a device node is actually a link to another device node, display it as such. Priority: normal Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
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) {