# Pastebin bS2PX05E // envFile returns a filepath for the lkenv bootloader environment file. For // prepare-image time operations, it will be a normal config file, for runtime // operations it will be a device file from a udev-created symlink in /dev/disk. // If backup is true then the filename is suffixed with "bak" or at runtime the // partition label is suffixed with "bak". func (l *lk) envFile(backup bool) (string, error) { partitionLabelOrConfFile := l.partLabelForRole() if backup { partitionLabelOrConfFile += "bak" } if l.prepareImageTime { // at prepare-image time, we just use the env file, but append .bin // since it is a file from the gadget we will evenutally install into // a partition when flashing the image return filepath.Join(l.dir(), partitionLabelOrConfFile+".bin"), nil } if l.role == RoleSole { // for V1, we just use the partition label directly, dir() here will be // the udev by-partlabel symlink dir. // see TODO: in l.dir(), this should eventually also be using // envFileForPartName() too return filepath.Join(l.dir(), partitionLabelOrConfFile), nil } // for RoleRun or RoleRecovery, we need to find the partition securely envFile, _, err := l.envFileForPartName(partitionLabelOrConfFile) if err != nil { return "", err } return envFile, nil }