Skip to content

Commit 8dbd641

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 f3fb8cc commit 8dbd641

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/libltfs/arch/ltfs_arch_ops.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ 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+
/* Share flags are a Windows concept; on POSIX the permission argument
155+
* is the mode passed to open(2). Passing the share flag as the mode
156+
* created write-only (0200) files, unreadable for non-root users. */
157+
#define arch_open( descriptor_ptr, filename_ptr, open_flg, share_flg, perm) do{ *descriptor_ptr = open(filename_ptr, open_flg, perm); }while(0)
155158

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

0 commit comments

Comments
 (0)