From 249259376da98d8e10e6876c80ff3905e9756bdc Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 29 Oct 2019 00:04:39 -0700 Subject: filesystem: rename Mount.Filesystem to Mount.FilesystemType Make it clear that this refers to a type of filesystem such as "ext4", rather than to a specific filesystem instance. --- actions/context.go | 8 ++++---- cmd/fscrypt/status.go | 9 +++++---- filesystem/filesystem.go | 22 +++++++++++----------- filesystem/mountpoint.go | 6 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/actions/context.go b/actions/context.go index 4a8542b..830ad03 100644 --- a/actions/context.go +++ b/actions/context.go @@ -78,7 +78,7 @@ func NewContextFromPath(path string, target *user.User) (*Context, error) { } log.Printf("%s is on %s filesystem %q (%s)", path, - ctx.Mount.Filesystem, ctx.Mount.Path, ctx.Mount.Device) + ctx.Mount.FilesystemType, ctx.Mount.Path, ctx.Mount.Device) return ctx, nil } @@ -95,7 +95,7 @@ func NewContextFromMountpoint(mountpoint string, target *user.User) (*Context, e return nil, err } - log.Printf("found %s filesystem %q (%s)", ctx.Mount.Filesystem, + log.Printf("found %s filesystem %q (%s)", ctx.Mount.FilesystemType, ctx.Mount.Path, ctx.Mount.Device) return ctx, nil } @@ -137,9 +137,9 @@ func (ctx *Context) checkContext() error { func (ctx *Context) getService() string { // For legacy configurations, we may need non-standard services if ctx.Config.HasCompatibilityOption(LegacyConfig) { - switch ctx.Mount.Filesystem { + switch ctx.Mount.FilesystemType { case "ext4", "f2fs": - return ctx.Mount.Filesystem + ":" + return ctx.Mount.FilesystemType + ":" } } return unix.FS_KEY_DESC_PREFIX diff --git a/cmd/fscrypt/status.go b/cmd/fscrypt/status.go index 9959b54..375899b 100644 --- a/cmd/fscrypt/status.go +++ b/cmd/fscrypt/status.go @@ -91,8 +91,8 @@ func writeGlobalStatus(w io.Writer) error { continue } - fmt.Fprintf(t, "%s\t%s\t%s\t%s\t%s\n", mount.Path, mount.Device, mount.Filesystem, - supportString, yesNoString(usingFscrypt)) + fmt.Fprintf(t, "%s\t%s\t%s\t%s\t%s\n", mount.Path, mount.Device, + mount.FilesystemType, supportString, yesNoString(usingFscrypt)) if supportErr == nil { supportCount++ @@ -139,8 +139,9 @@ func writeFilesystemStatus(w io.Writer, ctx *actions.Context) error { return err } - fmt.Fprintf(w, "%s filesystem %q has %s and %s\n\n", ctx.Mount.Filesystem, ctx.Mount.Path, - pluralize(len(options), "protector"), pluralize(len(policyDescriptors), "policy")) + fmt.Fprintf(w, "%s filesystem %q has %s and %s\n\n", ctx.Mount.FilesystemType, + ctx.Mount.Path, pluralize(len(options), "protector"), + pluralize(len(policyDescriptors), "policy")) if len(options) > 0 { writeOptions(w, options) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index ee332c8..3884e6e 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -64,10 +64,10 @@ var ( ) // Mount contains information for a specific mounted filesystem. -// Path - Absolute path where the directory is mounted -// Filesystem - Name of the mounted filesystem -// Options - List of options used when mounting the filesystem -// Device - Device for filesystem (empty string if we cannot find one) +// Path - Absolute path where the directory is mounted +// FilesystemType - Type of the mounted filesystem, e.g. "ext4" +// Options - List of options used when mounting the filesystem +// Device - Device for filesystem (empty string if we cannot find one) // // In order to use a Mount to store fscrypt metadata, some directories must be // setup first. Specifically, the directories created look like: @@ -90,10 +90,10 @@ var ( // allows login protectors to be created when the root filesystem is read-only, // provided that "/.fscrypt" is a symlink pointing to a writable location. type Mount struct { - Path string - Filesystem string - Options []string - Device string + Path string + FilesystemType string + Options []string + Device string } // PathSorter allows mounts to be sorted by Path. @@ -123,9 +123,9 @@ const ( func (m *Mount) String() string { return fmt.Sprintf(`%s - Filsystem: %s - Options: %v - Device: %s`, m.Path, m.Filesystem, m.Options, m.Device) + FilesystemType: %s + Options: %v + Device: %s`, m.Path, m.FilesystemType, m.Options, m.Device) } // BaseDir returns the path to the base fscrypt directory for this filesystem. diff --git a/filesystem/mountpoint.go b/filesystem/mountpoint.go index abd8232..856447f 100644 --- a/filesystem/mountpoint.go +++ b/filesystem/mountpoint.go @@ -87,9 +87,9 @@ func getMountInfo() error { // Create the Mount structure by converting types. mnt := Mount{ - Path: C.GoString(entry.mnt_dir), - Filesystem: C.GoString(entry.mnt_type), - Options: strings.Split(C.GoString(entry.mnt_opts), ","), + Path: C.GoString(entry.mnt_dir), + FilesystemType: C.GoString(entry.mnt_type), + Options: strings.Split(C.GoString(entry.mnt_opts), ","), } // Skip invalid mountpoints -- cgit v1.2.3