Name a filesystem by its kernel id, never its device name (hq ADR 0325 fourth review)
An ext4 or xfs library mounted by UUID can come back from a reboot as another device (/dev/sdb1 as /dev/sdc1); naming the filesystem by mountinfo's source read that as a move, stripped the warranted library's entries and asked for a new Approve. A filesystem is now named by statfs's f_fsid (from the UUID, or the ZFS dataset), its type and its mount point. Entries left on the filesystem a folder is on now are merged back or held, never walked away, and a TakenOn naming a mount point is not taken.
This commit is contained in:
@@ -538,3 +538,13 @@ func createPath(path string, stats walkStats) (int, error) {
|
||||
unix.Close(fd)
|
||||
return made, nil
|
||||
}
|
||||
|
||||
// MountFsid is the kernel's id of the filesystem at point (statfs f_fsid), in hex; empty when it cannot be read.
|
||||
// A variable so a test can stand in for a filesystem it cannot mount.
|
||||
var MountFsid = func(point string) string {
|
||||
var st unix.Statfs_t
|
||||
if err := unix.Statfs(point, &st); err != nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%08x%08x", uint32(st.Fsid.Val[0]), uint32(st.Fsid.Val[1]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user