//go:build linux && rootrunner package rootstate import ( "github.com/carlosframework/platform/internal/safefile" "os" ) type faultStore struct { Store step func(string, string, func() error) error } func WithWriteFault(s Store, step func(string, string, func() error) error) Store { return faultStore{Store: s, step: step} } func (s faultStore) Write(name string, body []byte) error { d, ok := s.Store.(*directory) if !ok { return os.ErrPermission } return d.write(name, body, func(fd int, name string, body []byte, mode os.FileMode) error { return safefile.WriteAtFault(fd, name, body, mode, func(stage string, op func() error) error { return s.step(name, stage, op) }) }) }