Skip to content

Commit f2a5f9b

Browse files
committed
fix: pass file permissions to open(2) in arch_open on POSIX
The POSIX arch_open macro passed the Windows-style share flag as the mode argument of open(2) and ignored the actual permission argument. Files created by the file tape backend got mode 0200 (write-only), so a non-root user could not reopen records it had just written; mounting a freshly formatted file-backend volume failed with EDEV_RW_PERM. Running as root masked the problem.
1 parent 7d0de7c commit f2a5f9b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/libltfs/arch/ltfs_arch_ops.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ extern "C" {
151151

152152
#define arch_sscanf sscanf
153153

154-
#define arch_open( descriptor_ptr, filename_ptr, open_flg, share_flg, unused) do{ *descriptor_ptr = open(filename_ptr, open_flg, share_flg); }while(0)
154+
/* POSIX open(2) takes the permission mode as its third argument; the
155+
* Windows-style share flag is not applicable here. */
156+
#define arch_open( descriptor_ptr, filename_ptr, open_flg, share_flg, perm) do{ *descriptor_ptr = open(filename_ptr, open_flg, perm); }while(0)
155157

156158
#define arch_fopen(file, mode, file_ptr) do {file_ptr = fopen(file, mode);}while(0)
157159

0 commit comments

Comments
 (0)