From: Jaroslav Kysela Date: Sat, 6 May 2017 17:49:43 +0000 (+0200) Subject: linuxdvb: add device path in sysfs (read-only info) X-Git-Tag: v4.2.2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4995af34ff50d7915bf01bce601bc3c4e7160e05;p=thirdparty%2Ftvheadend.git linuxdvb: add device path in sysfs (read-only info) --- diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index f30ba3f0e..c0bea0939 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -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); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 133be6c31..3616a8818 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -116,6 +116,7 @@ struct linuxdvb_frontend char *lfe_fe_path; char *lfe_dmx_path; char *lfe_dvr_path; + char *lfe_sysfs; /* * Reception