[dvblast-devel] [PATCH] Only turn off the ASI timestamps if they are on

Andy Lindsay andy.lindsay at tripleplay-services.com
Wed Jul 11 14:59:22 CEST 2012


Without this change, dvblast was always trying to write to the /sys
timestamps control file when using ASI and that failed if dvblast was
not running as root and caused it to exit.

Now, dvblast only tries to write to the file if the timestamps are
currently on.  This means that it can run as non-root.
---
  NEWS  |    4 ++++
  asi.c |   24 ++++++++++++++++++++----
  2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 93db983..f77fd84 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,8 @@
  +Changes between 2.2 and 2.3:
+----------------------------
+  * Fixed a problem that stopped running as non-root with ASI.
+
  Changes between 2.1 and 2.2:
  ----------------------------
    * Fixed a regression that prevented ECM pass-through (-Y) from working.
diff --git a/asi.c b/asi.c
index bc0a43e..97d5cbb 100644
--- a/asi.c
+++ b/asi.c
@@ -123,15 +123,31 @@ static ssize_t WriteULSysfs( const char *psz_fmt, 
unsigned int i_link,
  void asi_Open( void )
  {
      char psz_dev[MAXLEN];
+    int i_timestamps_mode;
  -    /* No timestamp - we wouldn't know what to do with them */
-    if ( WriteULSysfs( ASI_TIMESTAMPS_FILE, i_asi_adapter, 0 ) < 0 )
+    /* Check the timestamps mode */
+    if ( (i_timestamps_mode = ReadULSysfs( ASI_TIMESTAMPS_FILE, 
i_asi_adapter )) < 0 )
      {
-        msg_Err( NULL, "couldn't write file " ASI_TIMESTAMPS_FILE,
-                 i_asi_adapter );
+        msg_Err( NULL, "couldn't read file " ASI_TIMESTAMPS_FILE, 
i_asi_adapter );
          exit(EXIT_FAILURE);
      }
  +    if(i_timestamps_mode)
+    {
+        /* Timestamps are currently enabled, so turn them off- we 
wouldn't know what to do
+           with them.
+
+           This may fail if the process is not running as root, in that 
case, before running
+           dvblast either write 0 to the timestamps file or use "asicfg 
-t ...".
+        */
+        if ( WriteULSysfs( ASI_TIMESTAMPS_FILE, i_asi_adapter, 0 ) < 0 )
+        {
+            msg_Err( NULL, "couldn't write file " ASI_TIMESTAMPS_FILE,
+                     i_asi_adapter );
+            exit(EXIT_FAILURE);
+        }
+    }
+
      if ( (i_bufsize = ReadULSysfs( ASI_BUFSIZE_FILE, i_asi_adapter )) 
< 0 )
      {
          msg_Err( NULL, "couldn't read file " ASI_BUFSIZE_FILE, 
i_asi_adapter );
-- 
1.7.10.4



More information about the dvblast-devel mailing list