gxqing 发表于 2003-4-19 20:00:02

cheungming请帮忙

看到你对fs block io较熟悉,想请教几个问题:
1.能否在系统初始化的过程中得到分区信息呀?类似于在源代码中check.c中add_gd_partition()函数得到的那样,包括其始扇区数和总扇区数.直接保存此处的信息得不到因为此时文件系统还没有初始化呢,不知该怎么处理?若在系统启动后获得这些信息的话,除了fdisk等,还有什么方法吗?
2.在IDE驱动中可以直接加写一个函数读取某个指定扇区的内容吗?它原来是通过do_rw_disk()的,还要一堆参数,我现在只想读取一个扇区的内容,可以直接通过端口来执行吗?若可以的话,请提示一下.
问了这么多,请指点一二,谢谢!

Dragonfly 发表于 2003-4-20 00:16:56

i am not familiar with ide.c
1) if u want to get what add_gd_partition() get, for example, see extended_partition() in msdos.c. it call read_dev_sector() to get data from disk then call add_hd_partition with these info. but i am not sure what u can do while system is init. after system init, if u want this info, in kernel space u can read the genhd list. in user space, i believe fdisk use ioctl to get this info. u can check ide_ioctl in ide.c and see HDIO_GETGEO in hdreg.h. u can use 'strace fdisk' to see that fdisk call ioctl with 0x301. and 0x301 is defined as HDIO_GETGEO in hdreg.h.

2) i thinkread_dev_sector can do what u want. but it looks that it can only be used after system init. since it use page cache, page io. and go over block layer io.

are these right? u need check it by uself.
btw, u want to code user space code or kernel module? or both?

gxqing 发表于 2003-4-20 12:57:38

谢谢cheungming的提示!
   我想直接修改IDE驱动达到目的,所以应该算 kernel module.
   "after system init, if u want this info, in kernel space u can read the genhd list. "意思是否是可以做一个模块,来完成这个功能?我有一点不明白:怎样获得genhd list呢?请继续指教

Dragonfly 发表于 2003-4-20 22:28:53

i forget this in genhd.c
/*
* Global kernel list of partitioning information.
*
* XXX: you should _never_ access this directly.
*      the o

so u had better not access gendisk_head or gendisk_array directly. i think u can use get_gendisk, walk_gendisk... in genhd.c to get the value stored by add_gd_partition.

Dragonfly 发表于 2003-4-28 06:31:07

do u solve u problem? any improvement or new idea?

gxqing 发表于 2003-4-28 12:39:21

直接通过端口寄存器操作实现了写,可是读还不行

Dragonfly 发表于 2003-4-28 21:26:39

直接通过端口寄存器操作实现了写,可是读还不行

u write to ide controller directly? i do not think this is a good idea. linux lldd already does this. so if u also do this, u may have conflict with it. u still need to use some high level functions to finish this. at least this is my thought. anyway, good luck
页: [1]
查看完整版本: cheungming请帮忙