Bug 481821

Summary: Write RW discs without needing exclusive access.
Product: [Applications] k3b Reporter: Gordon <gordoneki>
Component: Burning/HardwareAssignee: k3b developers <k3b>
Status: REPORTED ---    
Severity: minor CC: michalm, trueg, zhaixiang
Priority: NOR    
Version: 21.12.3   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: K3b requires exclusive access.

Description Gordon 2024-02-25 17:40:42 UTC
Created attachment 166096 [details]
K3b requires exclusive access.

Normally, it makes sense to get exclusive access to the optical drive before writing, since nothing must interfere with the writing process. However, when doing test burns with RW discs, the requirement for exclusive access can become an annoyance.

Sometimes, I have to close Firefox entirely to unlock access to the drive, even though Firefox is not reading any data and not going to read any data in the one minute it will take to add some data, so nothing would happen during a test burn finished in one minute. If an error happens on RW discs, it is not critical, given that it can be rewritten.

In the minute it takes to write some additional data, nothing will access the optical drive unless the user causes it deliberately.

Please allow optionally burning without exclusive access so the user does not have close things until the error goes away. Thank you for understanding.

STEPS TO REPRODUCE
1. Insert a *-RW or DVD+RW disc containing existing files into an optical drive. For example, a ZIP file.
2. Open that ZIP file inside `file-roller`.
3. Try writing new files to the disc using K3b.

OBSERVED RESULT
Error "unable to O_EXCL /dev/sr1" occurs, see attachment.

EXPECTED RESULT
Write data to the disc even if no exclusive access is possible. 

This should obviously not be the default behaviour but there needs to be an option for this.

This is the Linux world. The end user should have the freedom and responsibility to decide about their system. This includes being able to immediately write data without having to get exclusive access first.

SOFTWARE/OS VERSIONS
Linux Mint 21 (based on Ubuntu)
Comment 1 Gordon 2024-03-19 17:42:39 UTC
There is another problem: some software (such as forensics software and media players) might reserve access to all drives without doing anything, effectively blocking K3b from writing data to it.

Therefore, please provide an option to write data without exclusive access. It would be much appreciated.
Comment 2 Leslie Zhai 2024-03-30 06:44:35 UTC
Hi Gordon,

Perhaps it is able to hack dvd+rw-tools-7.1/growisofs.c about line 705 and 2598 to open the file descriptor:

int fd = open64 (ioctl_device,O_RDONLY|O_NONBLOCK|O_EXCL);

Opening a file descriptor with O_EXCL might not give the exclusive access: https://www.gnu.org/software/libc/manual/html_node/Open_002dtime-Flags.html

Thanks,
Leslie Zhai