Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create-and-mount-snapshot: improve error handling
* Add sanity check in `zfs_snapshot_postclient()` to avoid unmounting something that isn't a zfs snapshot * Use `findmnt` instead of 'mountpoint -q' to check if path/. is a mountpoint, because `mountpoint -q` will cause an automount attempt if `path` is a symlink to a zfs snapshot directory. When using `findmnt` to see if `path` is a mountpoint, use `readlink -f` instead of plain `readlink` to resolve `path`, because without `-f` `readlink` prints nothing if `path` is not a symlink. In this case, `findmnt` lists all mounted devices, causing the script to conclude that `path` is a mountpoint even though it's not. This resulted in a misleading (but otherwise benign) warning. * Workaround 'too many levels of symbolic links' issue when mounting snapshots. This can happen for filesystems mounted under the rootfs by initrd; see e.g. openzfs/zfs#9461. * When creating a recursive snapshot, skip filesystems that have their canmount property set to off. If we don't, we may mount the snapshots, which might be empty and not have the mountpoints for child filesystems. * 0.8.4 and 0.8.5 also suffer from the 'object is remote' issue when automounting snapshots, so blacklist these versions as well. Since this logic depends on `/sys/module/zfs/version`, it probably only works on Linux. If other operating systems are also affected, set `mount_method=mount` manually in the client configuration.
- Loading branch information