]> 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:39:21 +0000 (15:39 +0100)
src/dvr/dvr_rec.c

index 3de952724b7424400766fb9ee5b42568dfec23db..903a661ce4251aa60806885e8f671b6ca3772a0d 100644 (file)
@@ -71,6 +71,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
   access_t *aa;
   uint32_t rec_count, net_count;
   int pri, c1, c2;
+  struct stat st;
 
   assert(de->de_s == NULL);
   assert(de->de_chain == NULL);
@@ -112,6 +113,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);
@@ -1082,7 +1088,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;
@@ -1162,6 +1168,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) {
@@ -1174,6 +1181,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;