diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-08-09 13:40:27 +0200 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-08-09 14:49:17 +0200 |
commit | 8aa33e23d4e1b1675f9fbc5937e576105183c2ae (patch) | |
tree | 30840ce12ce9de5d1e2765891d50d008cbc73030 | |
parent | 35ab0335d710d0bec1521d4e2496384a8526b50e (diff) | |
download | buildstream-8aa33e23d4e1b1675f9fbc5937e576105183c2ae.tar.gz |
Keep original flags for create in SafeHardlinks.
When open(2) is used with flags O_CREAT|O_RDWR, the file descriptor
must be readable. Unfortunately O_RDWR was not passed which made
read fail with EBADF and mmap to signal SIGBUS.
This issue happened with man-db for example.
Fixes #143.
-rw-r--r-- | buildstream/_fuse/fuse.py | 6 | ||||
-rw-r--r-- | buildstream/_fuse/hardlinks.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/buildstream/_fuse/fuse.py b/buildstream/_fuse/fuse.py index 58febcba0..4ff6b9903 100644 --- a/buildstream/_fuse/fuse.py +++ b/buildstream/_fuse/fuse.py @@ -757,7 +757,11 @@ class FUSE(object): if self.raw_fi: return self.operations('create', path, mode, fi) else: - fi.fh = self.operations('create', path, mode) + # This line is different from upstream to fix issues + # reading file opened with O_CREAT|O_RDWR. + # See issue #143. + fi.fh = self.operations('create', path, mode, fi.flags) + # END OF MODIFICATION return 0 def ftruncate(self, path, length, fip): diff --git a/buildstream/_fuse/hardlinks.py b/buildstream/_fuse/hardlinks.py index 4da51bb22..1386f14cf 100644 --- a/buildstream/_fuse/hardlinks.py +++ b/buildstream/_fuse/hardlinks.py @@ -185,12 +185,12 @@ class SafeHardlinkOps(Operations): return os.open(full_path, flags) - def create(self, path, mode, fi=None): + def create(self, path, mode, flags): full_path = self._full_path(path) # If it already exists, ensure it's a copy first self._ensure_copy(full_path) - return os.open(full_path, os.O_WRONLY | os.O_CREAT, mode) + return os.open(full_path, flags, mode) def read(self, path, length, offset, fh): os.lseek(fh, offset, os.SEEK_SET) |