X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpath-util.c;h=67566bc76b2c8a0ad54b357ea41c0ad3736b49f2;hb=c73d180dc4bbd87c945a524b42b672af2ffe2609;hp=5bc5012fe89ed61900f038dd260d348593ec58fd;hpb=0c6ea3a4e2ac3f350dcb58e8f08bb74b030cd624;p=elogind.git diff --git a/src/shared/path-util.c b/src/shared/path-util.c index 5bc5012fe..67566bc76 100644 --- a/src/shared/path-util.c +++ b/src/shared/path-util.c @@ -533,7 +533,16 @@ int path_is_read_only_fs(const char *path) { if (statvfs(path, &st) < 0) return -errno; - return !!(st.f_flag & ST_RDONLY); + if (st.f_flag & ST_RDONLY) + return true; + + /* On NFS, statvfs() might not reflect whether we can actually + * write to the remote share. Let's try again with + * access(W_OK) which is more reliable, at least sometimes. */ + if (access(path, W_OK) < 0 && errno == EROFS) + return true; + + return false; } int path_is_os_tree(const char *path) { @@ -574,7 +583,7 @@ int find_binary(const char *name, char **filename) { return 0; } else { const char *path; - char *state, *w; + const char *word, *state; size_t l; /** @@ -585,10 +594,10 @@ int find_binary(const char *name, char **filename) { if (!path) path = DEFAULT_PATH; - FOREACH_WORD_SEPARATOR(w, l, path, ":", state) { + FOREACH_WORD_SEPARATOR(word, l, path, ":", state) { _cleanup_free_ char *p = NULL; - if (asprintf(&p, "%.*s/%s", (int) l, w, name) < 0) + if (asprintf(&p, "%.*s/%s", (int) l, word, name) < 0) return -ENOMEM; if (access(p, X_OK) < 0)