Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces/mount: add high-level Profile functions #3135
Conversation
zyga
added some commits
Apr 4, 2017
zyga
referenced this pull request
Apr 4, 2017
Merged
interfaces/mount: add function for saving fstab-like file #3114
| + "github.com/snapcore/snapd/osutil" | ||
| +) | ||
| + | ||
| +// Profile represents an array of mount entries. |
| +} | ||
| + | ||
| +// Save saves a mount profile (fstab-like) to a given file. | ||
| +// The profile is saved with an atomic write+rename+sync operation. |
| +// ReadProfile reads and parses a mount profile. | ||
| +// | ||
| +// The supported format is described by fstab(5). | ||
| +func ReadProfile(reader io.Reader) (*Profile, error) { |
| +// | ||
| +// The supported format is described by fstab(5). | ||
| +// Note that there is no support for comments. | ||
| +func (p *Profile) WriteTo(writer io.Writer) (int64, error) { |
zyga
Apr 6, 2017
Contributor
I used it to write tests. We don't need it but I'd keep it just because it tests nicely.
| + if _, err := p.WriteTo(&buf); err != nil { | ||
| + return err | ||
| + } | ||
| + return osutil.AtomicWriteFile(fname, buf.Bytes(), 0600, osutil.AtomicWriteFlags(0)) |
zyga
merged commit 2da4b43
into
snapcore:master
Apr 6, 2017
6 checks passed
continuous-integration/travis-ci/pr
The Travis CI build passed
Details
xenial-amd64
autopkgtest finished (success)
Details
xenial-i386
autopkgtest finished (success)
Details
xenial-ppc64el
autopkgtest finished (success)
Details
yakkety-amd64
autopkgtest finished (success)
Details
zesty-amd64
autopkgtest finished (success)
Details
zyga
deleted the
zyga:profile-apis
branch
Apr 6, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
zyga commentedApr 4, 2017
This code tweaks earlier functions that operated on []Entry to operate
on *Profile (profile being simply a struct with []Entry field for now).
There are two more functions, one that loads and one that saves a profile
from a given file. Everything is fully tested.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com