2

For my daemon, I mounted (several) remote read-only WebDAV folders¹ as "sources" to periodically pull files from. Let $SOURCE be one of them for this question's sake.

Before blindly using $SOURCE, I feel it'd be a good idea to check if the mount is still operational, as WebDAV is not known for superior stability, so checking at mount-time¹ is already done, it might also "break" later².

The following ideas don't seem to fit me:

  • Testing for presence of a known remote file: $SOURCE is not necessarily controlled by me
  • Testing for presence of anything at all: $SOURCE might as well be empty, so there'd be false negatives
  • Checking output of mount | grep " $SOURCE ": Can't this produce false positives on netdevs?
  • Checking result of mountpoint -q "$SOURCE": Same about false positives?

More:

The check should avoid using inappropriate amounts of network bandwidth and memory. So additionally curling the DAV mounted at $SOURCE and checking for differences in the entire file/folder structure should obviously solve my problem, but also blows up that requirement in any possible way.

The check should work in either bash³+"basic linux stuff" or microperl. Bloating is bad for routers.

I know davfs2 uses a cache. What if it's mounted, the structure is cached and then the connect fails? Wouldn't I end up with tons of empty files in $SOURCE?


¹ I invoke davfs2 from a script. Heard you want me to be precise.

² Actually, my daemon should primarily be deployed in dynamic-IP environments at 24/7 use, so the sources will experience daily internet reconnects.

³ busybox's ash, to be precise again.

  • why not unmount/mount periodically? – artm Oct 17 '14 at 6:57
  • @artm Seems a bit naïve to me. Would apparently clear the cache each time, thus also mitigating its benefits. Plus: Remounts of DAV are quite time consuming, so I'd be glad to keep them to a minimum. – LDericher Oct 17 '14 at 12:30
  • What about "df"? Could you copy a small/random file and then read it back (or would local caching kill that?) – barrycarter Oct 17 '14 at 16:23
  • I did some research - apparently lsing a broken source yields false positives, while cating a random file successfully identifies a failing source. Also, cating is sensibly inexpensive, as there are only "small" files expected in my scenario. My question now boils down to "How can I cat a random file in a folder?". Going to dig into that. – LDericher Oct 17 '14 at 17:07
  • cat $(find "$SOURCE" -type f | head -1) works just about fine. – LDericher Oct 17 '14 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.