]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: add device path in sysfs (read-only info)
authorJaroslav Kysela <perex@perex.cz>
Sat, 6 May 2017 17:49:43 +0000 (19:49 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 12 May 2017 19:43:51 +0000 (21:43 +0200)
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/linuxdvb/linuxdvb_private.h

index f30ba3f0e579af5404d2601567c2376f469fc3d5..c0bea0939af0dfc7f514abdca7581c3551d02a09 100644 (file)
@@ -96,6 +96,14 @@ const idclass_t linuxdvb_frontend_class =
       .opts     = PO_RDONLY | PO_NOSAVE,
       .off      = offsetof(linuxdvb_frontend_t, lfe_number),
     },
+    {
+      .type     = PT_STR,
+      .id       = "sysfs_device",
+      .name     = N_("Device path in sysfs"),
+      .desc     = N_("The device path in sysfs filesystem (/sys)."),
+      .opts     = PO_RDONLY | PO_NOSAVE | PO_MULTILINE,
+      .off      = offsetof(linuxdvb_frontend_t, lfe_sysfs),
+    },
     {
       .type     = PT_INT,
       .id       = "pids_max",
@@ -1985,9 +1993,10 @@ linuxdvb_frontend_create
 {
   const idclass_t *idc;
   const char *str, *uuid = NULL, *muuid = NULL;
-  char id[16], lname[256];
+  char id[16], lname[256], buf[256];
   linuxdvb_frontend_t *lfe;
   htsmsg_t *scconf;
+  ssize_t r;
 
   /* Tuner slave */
   snprintf(id, sizeof(id), "master for #%d", number);
@@ -2055,6 +2064,16 @@ linuxdvb_frontend_create
   lfe = (linuxdvb_frontend_t*)mpegts_input_create0((mpegts_input_t*)lfe, idc, uuid, conf);
   if (!lfe) return NULL;
 
+  /* Sysfs path */
+  snprintf(lname, sizeof(lname), "/sys/class/dvb/dvb%d.frontend%d", la->la_dvb_number, number);
+  r = readlink(lname, buf, sizeof(buf));
+  if (r > 0) {
+    if (r == sizeof(buf)) r--;
+    buf[r] = '\0';
+    if (strncmp(str = buf, "../../", 6) == 0) str += 6;
+    lfe->lfe_sysfs = strdup(str);
+  }
+
   /* Callbacks */
   lfe->mi_get_weight   = linuxdvb_frontend_get_weight;
   lfe->mi_get_priority = linuxdvb_frontend_get_priority;
@@ -2151,6 +2170,7 @@ linuxdvb_frontend_delete ( linuxdvb_frontend_t *lfe )
   LIST_REMOVE(lfe, lfe_link);
 
   /* Free memory */
+  free(lfe->lfe_sysfs);
   free(lfe->lfe_fe_path);
   free(lfe->lfe_dmx_path);
   free(lfe->lfe_dvr_path);
index 133be6c31099872ecb13ec889dc25e99fee4cf84..3616a88188f620810f3d71c8937cdd0b9f2cc05d 100644 (file)
@@ -116,6 +116,7 @@ struct linuxdvb_frontend
   char                     *lfe_fe_path;
   char                     *lfe_dmx_path;
   char                     *lfe_dvr_path;
+  char                     *lfe_sysfs;
 
   /*
    * Reception