From: Finn Thain <fthain@linux-m68k.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Laurent Vivier <laurent@vivier.eu>,
Stan Johnson <userm57@yahoo.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Joshua Thompson <funaho@jurai.org>,
linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] swim3: Fix FDEJECT ioctl for exclusive open
Date: Tue, 29 Sep 2026 10:19:35 +1000 [thread overview]
Message-ID: <f4cb43726ee6f1cf159a6208f77b4cceea670a3c.1790641175.git.fthain@linux-m68k.org> (raw)
In-Reply-To: <cover.1790641175.git.fthain@linux-m68k.org>
The eject command from the util-linux package does not work with the
swim3 driver: the drive doesn't eject anything and the command fails.
Apparently, ioctl(fd, FDEJECT) returns -EBUSY after fd was opened O_EXCL.
Fix this by checking ref_count for either 1 or -1. Either value means that
the caller is the sole user of the disk.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
Changed since v1:
- Simplify by removing 'err' temporary variable.
---
drivers/block/swim3.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 01f7aef3fcfb..b55cfe485beb 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -887,7 +887,6 @@ static int floppy_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
unsigned int cmd, unsigned long param)
{
struct floppy_state *fs = bdev->bd_disk->private_data;
- int err;
if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -898,10 +897,9 @@ static int floppy_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
switch (cmd) {
case FDEJECT:
- if (fs->ref_count != 1)
- return -EBUSY;
- err = fd_eject(fs);
- return err;
+ if (fs->ref_count == -1 || fs->ref_count == 1)
+ return fd_eject(fs);
+ return -EBUSY;
case FDGETPRM:
if (copy_to_user((void __user *) param, &floppy_type,
sizeof(struct floppy_struct)))
next prev parent reply other threads:[~2026-09-29 0:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 0:19 [PATCH v2 0/3] block/swim: Minor fixes Finn Thain
2026-09-29 0:19 ` Finn Thain [this message]
2026-09-29 0:19 ` [PATCH v2 2/3] swim: Fix FDEJECT ioctl for exclusive open Finn Thain
2026-09-29 0:19 ` [PATCH v2 1/3] swim: Return -EROFS when opened with BLK_OPEN_WRITE flag Finn Thain
2026-09-29 2:30 ` [PATCH v2 0/3] block/swim: Minor fixes Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f4cb43726ee6f1cf159a6208f77b4cceea670a3c.1790641175.git.fthain@linux-m68k.org \
--to=fthain@linux-m68k.org \
--cc=axboe@kernel.dk \
--cc=funaho@jurai.org \
--cc=geert@linux-m68k.org \
--cc=laurent@vivier.eu \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=userm57@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®