]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: show a proper error if the DVR directory is not accessible, fixes #4757
authorJaroslav Kysela <perex@perex.cz>
Thu, 25 Jan 2018 14:39:21 +0000 (15:39 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 25 Jan 2018 14:40:36 +0000 (15:40 +0100)
src/dvr/dvr_rec.c

index a08f198e7f68f29e1880f8789ab85d6f54d94fab..b47de2b75130f85b2021577ad329afd63cffba6c 100644 (file)
@@ -70,6 +70,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
   access_t *aa;
   uint32_t rec_count, net_count;
   int c1, c2;
+  struct stat st;
 
   assert(de->de_s == NULL);
   assert(de->de_chain == NULL);
@@ -109,6 +110,11 @@ dvr_rec_subscribe(dvr_entry_t *de)
   }
   access_destroy(aa);
 
+  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);
+    return -EIO;
+  }
+
   pro = de->de_config->dvr_profile;
   prch = malloc(sizeof(*prch));
   profile_chain_init(prch, pro, de->de_channel);
@@ -848,7 +854,7 @@ cut1:
       }
     }
 
-    if(stat(path, &st) == -1) {
+    if (stat(path, &st) == -1) {
       tvhdebug(LS_DVR, "File \"%s\" -- %s -- Using for recording",
               path, strerror(errno));
       break;
@@ -928,6 +934,7 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss)
   htsmsg_t *info, *e;
   htsmsg_field_t *f;
   muxer_t *muxer;
+  struct stat st;
   int i;
 
   if (!cfg) {
@@ -940,6 +947,11 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss)
     return -1;
   }
 
+  if (stat(cfg->dvr_storage, &st) || !S_ISDIR(st.st_mode)) {
+    dvr_rec_fatal_error(de, "Unable to create file in directory '%s", cfg->dvr_storage);
+    return -1;
+  }
+
   if (!dvr_vfs_rec_start_check(cfg)) {
     dvr_rec_fatal_error(de, "Not enough free disk space");
     return SM_CODE_NO_SPACE;