Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[direct floppy] Fix block driver media size after probe #1734

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading