FSExecutor fails to detect auto mounted storage
If kup-daemon is started when my NAS is offline, it fails to detect when it comes back up. I use systemd auto mounting.
My plan's destination path is: /share/nas/home/foo.bup
/etc/fstab
//nas0/homes/<some> /share/nas/home cifs user,noauto,nofail,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=0,<somemoreopts> 0 0
/proc/mounts | grep nas/home
before mount
systemd-1 /share/nas/home autofs <mountopts> 0 0
/proc/mounts | grep nas/home
after starting NAS and ls /share/nas/home
systemd-1 /share/nas/home autofs <mountopts> 0 0
//nas0/homes/<some> /share/nas/home cifs <mountopts> 0 0
MountWatcher correctly detects the appearance of the mount and calls FSExecutor::checkMountPoints.
There, mWatchedParentDir is /share/nas
which is "incorrect" as it should be /share/nas/home
.
QDir lDir(mDestinationPath);
if(!lDir.exists()) {
// Destination doesn't exist, find nearest existing parent folder and
// watch that for dirty or deleted
if(mDirWatch->contains(mDestinationPath)) {
mDirWatch->removeDir(mDestinationPath);
}
QString lExisting = mDestinationPath;
do {
lExisting += QStringLiteral("/..");
lDir = QDir(QDir::cleanPath(lExisting));
} while(!lDir.exists());
lExisting = lDir.canonicalPath();
The issue is that lDir.exists() returns false for the actual mount point /share/nas/home
when it shouldn't.
Yet various checks behave differently. [ -d /share/nas/home ] && echo ok
says 'ok'
ls,stat(1),opendir(3) error with "no such device".
Luckily stat(3) seems to work fine. So i propose to use that, at least for the parent-dir-detection.