Skip to content

Commit

Permalink
[direct floppy] Fix block driver media size after probe
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Sep 24, 2023
1 parent 7a37aa1 commit 3516c08
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ static unsigned char seek_track;
static unsigned char current_track = NO_TRACK;
static unsigned char command;
static unsigned char fdc_version;
static struct inode *open_inode; /* to reset inode->i_size after probe */

static void DFPROC floppy_ready(void);
static void DFPROC redo_fd_request(void);
Expand Down Expand Up @@ -500,6 +501,7 @@ static void DFPROC setup_DMA(void)
use_xms = req->rq_seg >> 16; /* will be nonzero only if XMS configured & XMS buffer */
physaddr = (req->rq_seg << 4) + (unsigned int)req->rq_buffer;

/* FIXME req->rq_nr_sectors will be 0 for TLVC only */
count = req->rq_nr_sectors? (unsigned)req->rq_nr_sectors << 9: BLOCK_SIZE;
if (use_xms || (physaddr + count) < physaddr)
dma_addr = LAST_DMA_ADDR + 1; /* force use of bounce buffer */
Expand Down Expand Up @@ -738,6 +740,7 @@ static void rw_interrupt(void)
if (probing) {
int drive = DEVICE_NR(CURRENT->rq_dev);

open_inode->i_size = (sector_t)floppy->size << 9;
printk("df%d: Auto-detected floppy type %s\n", drive, floppy->name);
current_type[drive] = floppy;
probing = 0;
Expand Down Expand Up @@ -1371,7 +1374,8 @@ static int floppy_open(struct inode *inode, struct file *filp)
}

fd_ref[dev]++;
inode->i_size = ((sector_t)floppy->size) << 9; /* NOTE: assumes sector size 512 */
inode->i_size = (sector_t)floppy->size << 9; /* NOTE: assumes sector size 512 */
open_inode = inode;
DEBUG("df%d: open dv %x, sz %lu, %s\n", drive, inode->i_rdev, inode->i_size,
floppy->name);

Expand Down

0 comments on commit 3516c08

Please sign in to comment.