canonical / canonical/chisel

feature request: atomic writes to (binary) files

Open
#233 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
424
Forks
65
Avg merge
12d 19h
Merged PRs (30d)
1

Description

When chisel is called by a `bash` instance and installs `bash_bins` into `--root /`, it will encounter an `ETXTBSY` error: `error: cannot extract from package "bash": open /usr/bin/bash: text file busy`. This is because Chisel tries to open the running `/usr/bin/bash` file, which triggers this error.

We want Chisel to be able to handle such cases, just like how `dpkg` is handling rewriting the `/usr/bin/bash` binary file by writing to a temporary file, and move this temporary file to overwrite the previous one, such that we can safely overwrite the running binary files.

References:
1. https://github.com/guillemj/dpkg/blob/0fa25abf11871c75de58e14743810609518e647e/src/main/unpack.c#L1471
2. Log from `inotifywait` on `dpkg -i bash`:
```
/proc/942119/root/usr/bin/ MOVED_FROM bash.dpkg-new
/proc/942119/root/usr/bin/ MOVED_TO bash
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.