Skip to content

Commit df46dea

Browse files
DeltaMikeCharlieFlole998
authored andcommitted
Add some ERRNOs for DVR & Config
1 parent 595bbaa commit df46dea

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

‎src/config.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ config_migrate_v1_dvb_svcs
135135
htsmsg_add_str(svc, "svcname", str);
136136
if ((str = htsmsg_get_str(e, "provider")))
137137
htsmsg_add_str(svc, "provider", str);
138-
if (!(htsmsg_get_u32(e, "type", &u32)))
138+
if (!(htsmsg_get_u32(e, "type", &u32)))
139139
htsmsg_add_u32(svc, "dvb_servicetype", u32);
140140
if (!htsmsg_get_u32(e, "channel", &u32))
141141
htsmsg_add_u32(svc, "lcn", u32);
142142
if (!htsmsg_get_u32(e, "disabled", &u32))
143143
htsmsg_add_u32(svc, "enabled", u32 ? 0 : 1);
144144
if ((str = htsmsg_get_str(e, "charset")))
145145
htsmsg_add_str(svc, "charset", str);
146-
if ((str = htsmsg_get_str(e, "default_authority")))
146+
if ((str = htsmsg_get_str(e, "default_authority")))
147147
htsmsg_add_str(svc, "cridauth", str);
148-
148+
149149
// TODO: dvb_eit_enable
150150

151151
hts_settings_save(svc, "input/linuxdvb/networks/%s/muxes/%s/services/%s",
@@ -185,7 +185,7 @@ config_migrate_v1_dvb_network
185185
"fec_lo",
186186
"fec"
187187
};
188-
188+
189189

190190
/* Load the adapter config */
191191
if (!(tun = hts_settings_load("dvbadapters/%s", name))) return;
@@ -293,7 +293,7 @@ config_migrate_v1_dvr ( const char *path, htsmsg_t *channels )
293293
htsmsg_t *c, *e, *m;
294294
htsmsg_field_t *f;
295295
const char *str;
296-
296+
297297
if ((c = hts_settings_load_r(1, path))) {
298298
HTSMSG_FOREACH(f, c) {
299299
if (!(e = htsmsg_field_get_map(f))) continue;
@@ -323,7 +323,7 @@ config_migrate_v1_epggrab ( const char *path, htsmsg_t *channels )
323323
htsmsg_field_t *f, *f2;
324324
const char *str;
325325
uint32_t u32;
326-
326+
327327
if ((c = hts_settings_load_r(1, path))) {
328328
HTSMSG_FOREACH(f, c) {
329329
if (!(e = htsmsg_field_get_map(f))) continue;
@@ -478,7 +478,7 @@ config_migrate_v1 ( void )
478478
/* Update EPG grabbers */
479479
hts_settings_remove("epggrab/otamux");
480480
config_migrate_v1_epggrab("epggrab/xmltv/channels", channels);
481-
481+
482482
/* Save the channels */
483483
// Note: UUID will be stored in the file (redundant) but that's no biggy
484484
HTSMSG_FOREACH(f, channels) {
@@ -502,7 +502,7 @@ config_migrate_v2 ( void )
502502

503503
/* Do we have IPTV config to migrate ? */
504504
if (hts_settings_exists("input/iptv/muxes")) {
505-
505+
506506
/* Create a dummy network */
507507
uuid_set(&u, NULL);
508508
uuid_get_hex(&u, ubuf);
@@ -1564,7 +1564,7 @@ dobackup(const char *oldver)
15641564
}
15651565

15661566
if (chdir(cwd)) {
1567-
tvherror(LS_CONFIG, "unable to change directory to '%s'", cwd);
1567+
tvherror(LS_CONFIG, "unable to change directory to '%s': %s", cwd, strerror(errno));
15681568
goto fatal;
15691569
}
15701570
return;
@@ -1890,7 +1890,7 @@ config_init ( int backup )
18901890
tvh_str_set(&config.realm, "tvheadend");
18911891
tvh_str_set(&config.http_server_name, "HTS/tvheadend");
18921892
idnode_changed(&config.idnode);
1893-
1893+
18941894
/* Perform migrations */
18951895
} else {
18961896
if (config_migrate(backup))

‎src/dvr/dvr_rec.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
8282
uint32_t rec_count, net_count;
8383
int ret = 0, pri, c1, c2;
8484
struct stat st;
85+
int stat_ret;
8586

8687
assert(de->de_s == NULL);
8788
assert(de->de_chain == NULL);
@@ -124,8 +125,18 @@ dvr_rec_subscribe(dvr_entry_t *de)
124125
}
125126
}
126127

127-
if(stat(de->de_config->dvr_storage, &st) || !S_ISDIR(st.st_mode)) {
128-
tvherror(LS_DVR, "the directory '%s' is not accessible", de->de_config->dvr_storage);
128+
stat_ret = stat(de->de_config->dvr_storage, &st);
129+
130+
//If the stat() failed, show the error message.
131+
if(stat_ret != 0) {
132+
tvherror(LS_DVR, "Directory '%s' not accessible: %s", de->de_config->dvr_storage, strerror(errno));
133+
ret = -EIO;
134+
goto _return;
135+
}
136+
137+
//If the stat() worked, but the path is not a directory.
138+
if(!S_ISDIR(st.st_mode) && stat_ret == 0) {
139+
tvherror(LS_DVR, "'%s' is not a directory.", de->de_config->dvr_storage);
129140
ret = -EIO;
130141
goto _return;
131142
}

‎src/dvr/dvr_vfsmgr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ dvr_vfs_refresh_entry(dvr_entry_t *de)
104104
}
105105
filename = htsmsg_get_str(m, "filename");
106106
if (filename == NULL || stat(filename, &st) < 0) {
107-
tvherror(LS_DVR, "unable to stat file '%s'", filename);
107+
tvherror(LS_DVR, "unable to stat file '%s': %s", filename, strerror(errno));
108108
goto rem;
109109
}
110110
if (tvh_vfs_fsid_build(filename, NULL, &fsid))

0 commit comments

Comments
 (0)