M7: add verbose mode for debugging
Add -v/--verbose persistent flag that prints debug info to stderr: D-Bus connection status, token plugin directory discovery, unlock method sequencing with per-method success/failure, and full cryptsetup command lines including LD_LIBRARY_PATH. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"git.wntrmute.dev/kyle/arca/internal/cryptsetup"
|
||||
"git.wntrmute.dev/kyle/arca/internal/udisks"
|
||||
"git.wntrmute.dev/kyle/arca/internal/verbose"
|
||||
)
|
||||
|
||||
// Result holds the outcome of a successful unlock.
|
||||
@@ -35,12 +36,16 @@ func New(client *udisks.Client, opts Options) *Unlocker {
|
||||
|
||||
// Unlock tries each method in order and returns the result on first success.
|
||||
func (u *Unlocker) Unlock(dev *udisks.BlockDevice, methods []string) (*Result, error) {
|
||||
verbose.Printf("unlock %s: methods %v", dev.DevicePath, methods)
|
||||
var errs []error
|
||||
for _, method := range methods {
|
||||
verbose.Printf("trying method: %s", method)
|
||||
res, err := u.tryMethod(dev, method)
|
||||
if err == nil {
|
||||
verbose.Printf("method %s succeeded", method)
|
||||
return res, nil
|
||||
}
|
||||
verbose.Printf("method %s failed: %v", method, err)
|
||||
errs = append(errs, fmt.Errorf("%s: %w", method, err))
|
||||
}
|
||||
return nil, fmt.Errorf("all unlock methods failed for %s:\n%w", dev.DevicePath, errors.Join(errs...))
|
||||
|
||||
Reference in New Issue
Block a user