[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-mtools] operation not permitted while setting disk parameters
From: |
Frank Loeffler |
Subject: |
Re: [Info-mtools] operation not permitted while setting disk parameters in find_device |
Date: |
Wed, 4 Nov 2020 20:51:28 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Hi,
please allow me to ping this issue again. I could easily and happily
would provide a patch. I just wanted to discuss it before actually
suggesting it. It is a pretty small change...
On Tue, Sep 08, 2020 at 10:43:28PM +0200, Frank Loeffler wrote:
I am asking for help understanding parts of the code. Some necessary
back story: I am trying to get floppy auto configuration to work, i.e.:
mtools should set up the drive according to the geometry it finds when
accessing the boot sector (number of sectors, cylinders, ect). This
worked fine on my (old) machine, using the stock kernel for Debian 4.0
(yes, that old). Because it was so old, I decided to install Debian 8.0
(the last that supports the CPU). Now, mtools does not work anymore, at
least not without specifying the exact format of the disk before using
it. This is especially a problem because I do have 5.25 inch floppies
which are a mix between the (usual) 1.2MB and 1.44MB-formatted kind
(and several smaller ones). Guessing the correct format each time isn't
exactly fun, especially when you know that mtools should have the
necessary logic already built-in.
On the surface, where before
mdir b:
gave me a directory listing, using the same disk, I now get:
Can't set disk parameters for B: Operation not permitted
Cannot initialize 'B:'
This is, however, not a regression in mtools itself: the old binary is
still executable within the new Linux installation, but shows the same
problem, regardless of mtools version 3.9.10 or 4.0.18.
After reading the source of mtools and the kernel source of the floppy
driver and especially fs/block_dev.c, I see that ioctl-access is only
granted if mode & O_ACCMODE == 3. "3" should be O_RDWR.
The device is opened in minfo.c within find_device(), but the mode is
one of its arguments. One usage of this is within minfo.c, but there
O_RDONLY is given as mode. Changing this to O_RDWR makes minfo work
again: the ioctl call succeeds because the FD was opened with write
permissions.
Since both the old mtools (binary) and a much newer version show the
same problem: are you aware of any changes in the linux driver
concerning permissions necessary for ioctls on block devices? It does
make sense to only allow them for rw-access, but I would have expected
this problem in mtools to surface a lot earlier than 2020. Is there
another, better way to have mtools work in case they have to reset
drive parameters depending on the disk that is inserted? Could it pose
a problem to open the FD with rw-permissions instead or ro?
thanks
Frank Löffler
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Info-mtools] operation not permitted while setting disk parameters in find_device,
Frank Loeffler <=