blkpg + newbie question
Guillaume Laisney
glaisney at libertysurf.fr
Mon Oct 1 12:00:45 EDT 2001
Hello,
I'm currently trying to get Midori linux running on a disk-on-chip 2000.
It seems that there are a few missing cases in nftlcore.c (function
nftl_ioctl) that hangs midori when it calls ioctl( ...,BLKPG,...)
the code below seems to work OK.
Now a little question...
It is the first time I'm using DOCs, and I found them really slow compared
with compact-flashes. I'm I missing something ? could it be a software issue ?
Guillaume
static int nftl_ioctl(struct inode * inode, struct file * file, unsigned int
cmd, unsigned long arg)
{
struct NFTLrecord *nftl;
int p;
nftl = NFTLs[MINOR(inode->i_rdev) >> NFTL_PARTN_BITS];
if (!nftl) return -EINVAL;
switch (cmd) {
case HDIO_GETGEO: {
struct hd_geometry g;
g.heads = nftl->heads;
g.sectors = nftl->sectors;
g.cylinders = nftl->cylinders;
g.start = part_table[MINOR(inode->i_rdev)].start_sect;
return copy_to_user((void *)arg, &g, sizeof g) ? -EFAULT : 0;
}
case BLKGETSIZE: /* Return device size */
return put_user(part_table[MINOR(inode->i_rdev)].nr_sects,
(long *) arg);
case BLKGETSIZE64:
return put_user((u64)part_table[MINOR(inode->i_rdev)].nr_sects << 9,
(u64 *)arg);
case BLKFLSBUF:
if (!capable(CAP_SYS_ADMIN)) return -EACCES;
fsync_dev(inode->i_rdev);
invalidate_buffers(inode->i_rdev);
if (nftl->mtd->sync)
nftl->mtd->sync(nftl->mtd);
return 0;
case BLKRRPART:
if (!capable(CAP_SYS_ADMIN)) return -EACCES;
if (nftl->usecount > 1) return -EBUSY;
/*
* We have to flush all buffers and invalidate caches,
* or we won't be able to re-use the partitions,
* if there was a change and we don't want to reboot
*/
p = (1<<NFTL_PARTN_BITS) - 1;
while (p-- > 0) {
kdev_t devp = MKDEV(MAJOR(inode->i_dev), MINOR(inode->i_dev)+p);
if (part_table[p].nr_sects > 0)
invalidate_device (devp, 1);
part_table[MINOR(inode->i_dev)+p].start_sect = 0;
part_table[MINOR(inode->i_dev)+p].nr_sects = 0;
}
#if LINUX_VERSION_CODE < 0x20328
resetup_one_dev(&nftl_gendisk, MINOR(inode->i_rdev) >> NFTL_PARTN_BITS);
#else
grok_partitions(&nftl_gendisk, MINOR(inode->i_rdev) >> NFTL_PARTN_BITS,
1<<NFTL_PARTN_BITS, nftl->nr_sects);
#endif
return 0;
#if (LINUX_VERSION_CODE < 0x20303)
RO_IOCTLS(inode->i_rdev, arg); /* ref. linux/blk.h */
#else
case BLKROSET:
case BLKROGET:
case BLKSSZGET:
case BLKELVGET:
case BLKELVSET:
case BLKPG:
return blk_ioctl(inode->i_rdev, cmd, arg);
#endif
default:
return -EINVAL;
}
}
More information about the linux-mtd
mailing list