From 5a3aa1262a471b842e95b2e6e1dcdfbce035b75c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Nov 2010 18:24:19 +0100 Subject: update_walk: explicitly check for permission problems Call access() and print an extra error message when EACCES is returned. Hopefully this will reduce the number of support requests due to wrong file permissions. --- src/update_walk.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/update_walk.c b/src/update_walk.c index a8e09793a..95d5854a8 100644 --- a/src/update_walk.c +++ b/src/update_walk.c @@ -546,6 +546,31 @@ update_container_file( struct directory* directory, return true; } +/** + * Checks if the given permissions on the mapped file are given. + */ +static bool +directory_child_access(const struct directory *directory, + const char *name, int mode) +{ +#ifdef WIN32 + /* access() is useless on WIN32 */ + (void)directory; + (void)name; + return true; +#else + char *path = map_directory_child_fs(directory, name); + if (path == NULL) + /* something went wrong, but that isn't a permission + problem */ + return true; + + bool success = access(path, mode) == 0 || errno != EACCES; + g_free(path); + return success; +#endif +} + static void update_regular_file(struct directory *directory, const char *name, const struct stat *st) @@ -562,6 +587,14 @@ update_regular_file(struct directory *directory, { struct song* song = songvec_find(&directory->songs, name); + if (!directory_child_access(directory, name, R_OK)) { + g_warning("no read permissions on %s/%s", + directory_get_path(directory), name); + if (song != NULL) + delete_song(directory, song); + return; + } + if (!(song != NULL && st->st_mtime == song->mtime && !walk_discard) && plugin->container_scan != NULL) -- cgit v1.2.3