QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1343|回复: 6

cheungming请帮忙

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

使用道具 举报

 楼主| 发表于 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呢?请继续指教
回复

使用道具 举报

发表于 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.
回复

使用道具 举报

发表于 2003-4-28 06:31:07 | 显示全部楼层
do u solve u problem? any improvement or new idea?
回复

使用道具 举报

 楼主| 发表于 2003-4-28 12:39:21 | 显示全部楼层
直接通过端口寄存器操作实现了写,可是读还不行
回复

使用道具 举报

发表于 2003-4-28 21:26:39 | 显示全部楼层
[quote:1d5beeece7="gxqing"]直接通过端口寄存器操作实现了写,可是读还不行[/quote]

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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-12-3 04:15 , Processed in 0.080445 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表