PowerFailure simulates power failure with drop all the writes.
(mntOpt string)
| 279 | |
| 280 | // PowerFailure simulates power failure with drop all the writes. |
| 281 | func (f *flakeyT) PowerFailure(mntOpt string) error { |
| 282 | if err := f.DropWrites(); err != nil { |
| 283 | return fmt.Errorf("failed to drop_writes: %w", err) |
| 284 | } |
| 285 | |
| 286 | if err := unmountAll(f.rootDir); err != nil { |
| 287 | return fmt.Errorf("failed to unmount rootfs %s: %w", f.rootDir, err) |
| 288 | } |
| 289 | |
| 290 | if mntOpt == "" { |
| 291 | mntOpt = f.mntOpt |
| 292 | } |
| 293 | |
| 294 | if err := f.AllowWrites(); err != nil { |
| 295 | return fmt.Errorf("failed to allow_writes: %w", err) |
| 296 | } |
| 297 | |
| 298 | if err := unix.Mount(f.DevicePath(), f.rootDir, string(f.Filesystem()), 0, mntOpt); err != nil { |
| 299 | return fmt.Errorf("failed to mount rootfs %s (%s): %w", f.rootDir, mntOpt, err) |
| 300 | } |
| 301 | return nil |
| 302 | } |
| 303 | |
| 304 | func unmountAll(target string) error { |
| 305 | for i := 0; i < 50; i++ { |
nothing calls this directly
no test coverage detected