diff options
| author | Eric Biggers <ebiggers@google.com> | 2022-01-18 23:43:35 -0800 |
|---|---|---|
| committer | Eric Biggers <ebiggers@google.com> | 2022-01-26 23:22:55 -0800 |
| commit | c2fb96c60d7678110bca14ff0a213243bd97cb08 (patch) | |
| tree | a323c2a033216353b96b19e3db36b19071fcfb97 /filesystem/mountpoint.go | |
| parent | 51c421d91172e87df30bd344b3fd3142bc388718 (diff) | |
filesystem: fall back to path-only links if UUID cannot be determined
This is needed to allow creating protector links to btrfs filesystems.
Update https://github.com/google/fscrypt/issues/339
Diffstat (limited to 'filesystem/mountpoint.go')
| -rw-r--r-- | filesystem/mountpoint.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/filesystem/mountpoint.go b/filesystem/mountpoint.go index 20a8568..182cafa 100644 --- a/filesystem/mountpoint.go +++ b/filesystem/mountpoint.go @@ -545,12 +545,19 @@ func (mnt *Mount) getFilesystemUUID() (string, error) { } // makeLink creates the contents of a link file which will point to the given -// filesystem. This will be a string of the form "UUID=<uuid>\nPATH=<path>\n". -// An error is returned if the filesystem's UUID cannot be determined. +// filesystem. This will normally be a string of the form +// "UUID=<uuid>\nPATH=<path>\n". If the UUID cannot be determined, the UUID +// portion will be omitted. func makeLink(mnt *Mount) (string, error) { uuid, err := mnt.getFilesystemUUID() if err != nil { - return "", &ErrMakeLink{mnt, err} + // The UUID could not be determined. This happens for btrfs + // filesystems, as the device number found via + // /dev/disk/by-uuid/* for btrfs filesystems differs from the + // actual device number of the mounted filesystem. Just rely + // entirely on the fallback to mountpoint path. + log.Print(err) + return fmt.Sprintf("%s=%s\n", pathToken, mnt.Path), nil } return fmt.Sprintf("%s=%s\n%s=%s\n", uuidToken, uuid, pathToken, mnt.Path), nil } |