]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add some ERRNOs for DVR & Config
authorDeltaMikeCharlie <127641886+DeltaMikeCharlie@users.noreply.github.com>
Mon, 19 Feb 2024 22:56:39 +0000 (09:56 +1100)
committerFlole998 <Flole998@users.noreply.github.com>
Tue, 20 Feb 2024 10:27:41 +0000 (11:27 +0100)
src/config.c
src/dvr/dvr_rec.c
src/dvr/dvr_vfsmgr.c

index 63ddf77325b2c0873124b17c762aef5b49a02ec6..ca4fff906f51cc43e9d94fdd8af03fe3bd945900 100644 (file)
@@ -135,7 +135,7 @@ config_migrate_v1_dvb_svcs
         htsmsg_add_str(svc, "svcname", str);
       if ((str = htsmsg_get_str(e, "provider")))
         htsmsg_add_str(svc, "provider", str);
-      if (!(htsmsg_get_u32(e, "type", &u32))) 
+      if (!(htsmsg_get_u32(e, "type", &u32)))
         htsmsg_add_u32(svc, "dvb_servicetype", u32);
       if (!htsmsg_get_u32(e, "channel", &u32))
         htsmsg_add_u32(svc, "lcn", u32);
@@ -143,9 +143,9 @@ config_migrate_v1_dvb_svcs
         htsmsg_add_u32(svc, "enabled", u32 ? 0 : 1);
       if ((str = htsmsg_get_str(e, "charset")))
         htsmsg_add_str(svc, "charset", str);
-      if ((str = htsmsg_get_str(e, "default_authority"))) 
+      if ((str = htsmsg_get_str(e, "default_authority")))
         htsmsg_add_str(svc, "cridauth", str);
-  
+
       // TODO: dvb_eit_enable
 
       hts_settings_save(svc, "input/linuxdvb/networks/%s/muxes/%s/services/%s",
@@ -185,7 +185,7 @@ config_migrate_v1_dvb_network
     "fec_lo",
     "fec"
   };
-    
+
 
   /* Load the adapter config */
   if (!(tun = hts_settings_load("dvbadapters/%s", name))) return;
@@ -293,7 +293,7 @@ config_migrate_v1_dvr ( const char *path, htsmsg_t *channels )
   htsmsg_t *c, *e, *m;
   htsmsg_field_t *f;
   const char *str;
-  
+
   if ((c = hts_settings_load_r(1, path))) {
     HTSMSG_FOREACH(f, c) {
       if (!(e = htsmsg_field_get_map(f))) continue;
@@ -323,7 +323,7 @@ config_migrate_v1_epggrab ( const char *path, htsmsg_t *channels )
   htsmsg_field_t *f, *f2;
   const char *str;
   uint32_t u32;
-  
+
   if ((c = hts_settings_load_r(1, path))) {
     HTSMSG_FOREACH(f, c) {
       if (!(e = htsmsg_field_get_map(f))) continue;
@@ -478,7 +478,7 @@ config_migrate_v1 ( void )
   /* Update EPG grabbers */
   hts_settings_remove("epggrab/otamux");
   config_migrate_v1_epggrab("epggrab/xmltv/channels", channels);
-  
+
   /* Save the channels */
   // Note: UUID will be stored in the file (redundant) but that's no biggy
   HTSMSG_FOREACH(f, channels) {
@@ -502,7 +502,7 @@ config_migrate_v2 ( void )
 
   /* Do we have IPTV config to migrate ? */
   if (hts_settings_exists("input/iptv/muxes")) {
-    
+
     /* Create a dummy network */
     uuid_set(&u, NULL);
     uuid_get_hex(&u, ubuf);
@@ -1564,7 +1564,7 @@ dobackup(const char *oldver)
   }
 
   if (chdir(cwd)) {
-    tvherror(LS_CONFIG, "unable to change directory to '%s'", cwd);
+    tvherror(LS_CONFIG, "unable to change directory to '%s': %s", cwd, strerror(errno));
     goto fatal;
   }
   return;
@@ -1890,7 +1890,7 @@ config_init ( int backup )
     tvh_str_set(&config.realm, "tvheadend");
     tvh_str_set(&config.http_server_name, "HTS/tvheadend");
     idnode_changed(&config.idnode);
-  
+
   /* Perform migrations */
   } else {
     if (config_migrate(backup))
index 97218580301cf1e5e1acf4914cbdb16579119c3c..278fa1dea7820ba7af6c1f74fa164380da03c9eb 100644 (file)
@@ -82,6 +82,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
   uint32_t rec_count, net_count;
   int ret = 0, pri, c1, c2;
   struct stat st;
+  int stat_ret;
 
   assert(de->de_s == NULL);
   assert(de->de_chain == NULL);
@@ -124,8 +125,18 @@ dvr_rec_subscribe(dvr_entry_t *de)
     }
   }
 
-  if(stat(de->de_config->dvr_storage, &st) || !S_ISDIR(st.st_mode)) {
-    tvherror(LS_DVR, "the directory '%s' is not accessible", de->de_config->dvr_storage);
+  stat_ret = stat(de->de_config->dvr_storage, &st);
+
+  //If the stat() failed, show the error message.
+  if(stat_ret != 0) {
+    tvherror(LS_DVR, "Directory '%s' not accessible: %s", de->de_config->dvr_storage, strerror(errno));
+    ret = -EIO;
+    goto _return;
+  }
+
+  //If the stat() worked, but the path is not a directory.
+  if(!S_ISDIR(st.st_mode) && stat_ret == 0) {
+    tvherror(LS_DVR, "'%s' is not a directory.", de->de_config->dvr_storage);
     ret = -EIO;
     goto _return;
   }
index dc6b5988013fa409cae75ed09d81ebdeaa8a5422..ed44f437a57ba168a107e8e1c34d878aa3c9e65f 100644 (file)
@@ -104,7 +104,7 @@ dvr_vfs_refresh_entry(dvr_entry_t *de)
       }
       filename = htsmsg_get_str(m, "filename");
       if (filename == NULL || stat(filename, &st) < 0) {
-        tvherror(LS_DVR, "unable to stat file '%s'", filename);
+        tvherror(LS_DVR, "unable to stat file '%s': %s", filename, strerror(errno));
         goto rem;
       }
       if (tvh_vfs_fsid_build(filename, NULL, &fsid))