打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Re: Finding size of a raw device
Hi ,Probably I found the answer to this .On a filesystem, by doing an lseek the OS cantrack the size of the file via the inodes .Thus, an lseek with SEEK_END would give thefile size , as the inode tables provide theneeded support for the OS .But since a raw device bound to a file is adirect interface , there is no way in whichthe OS can figure out its limits , and thuslseek with SEEK_END would yield a zero .It would be nice if somebody could confirmthe above explanation .Cheers !--- Learner <ruxyz@xxxxxxxxx> wrote: > Hi ,>>   I was trying to find the size of a raw partition> using the below program , but the output is not> correct. Can anybody suggest how to rectify this> program.>>   Is it that "lseek" should be used only on regular> files and not special files ?Is there a proc entry> which reflects the currently bound raw devices ?>>    I'am aware that "raw -qa" gives the complete list> of raw devices , but I wanted to know if there is> any other method to do so .>>> PROGRAM :->> #include <sys/types.h>> #include <sys/stat.h>> #include <fcntl.h>> #include <unistd.h>>> main()> {>    int fd ;>    int start, end ;>>    fd=open( "/dev/raw/raw1", O_RDONLY );>>    start=lseek( fd, 0, SEEK_SET );>>    printf("The Start pt size is %d \n", start);>>    end=lseek( fd, 0, SEEK_END );>>    printf("The End pt size is %d \n", end);> }>> OUTPUT :->> The Start pt size is 0> The End pt size is 0>>> Cheers!>>>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
test_write.c
python里fd是什么意思
Linux系统编程lseek
lseek()函数的使用说明
UNIX环境编程学习笔记(4)
linux设备驱动归纳总结(三):3.设备驱动面向对象思想和lseek的实现
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服