LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2004, 05:18 AM   #1
fa3a
LQ Newbie
 
Registered: Aug 2003
Location: Minsk
Distribution: RHEL, Fedora
Posts: 8

Rep: Reputation: 0
Question Why Linux returns the device size for 1 block more then it could be read??


The problem I observed on RedHat Linux is that ioctl() returns the device size for 1 block more then it could be read in a reality.
Code:
E.x. ioctl(devfile, BLKGETSIZE, &blksize) returns blksize=226
but
dd if=/dev/hdb6 of=hdb6.img shows that it was written 225 blocks!!!
does anybody know why it's designed in that way? or is it a bug?
I use RHEL and kernel 2.4

Thanks!

Last edited by fa3a; 01-29-2004 at 05:27 AM.
 
Old 01-29-2004, 06:23 AM   #2
fa3a
LQ Newbie
 
Registered: Aug 2003
Location: Minsk
Distribution: RHEL, Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
I got it !!

The problem seems to be in the device geometry.. sometimes system returns for 512 bytes (1 block) more then we really use:
Code:
=> hdparm -g /dev/hdb6

/dev/hdb6:
 geometry     = 119150/16/63, sectors = 205569, start = 69207327

=> fdisk -l /dev/hdb | grep hdb6
/dev/hdb6         68659     68862    102784+  83  Linux

102784*2=205568
so system detects 205569 but we really use 205568...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Block device /dev/sda3 is not a valid root device.. rincewind Linux - Hardware 7 06-09-2006 04:47 AM
calling sys_read inside sys_write returns number of bytes read as zero appas Linux - Software 0 08-28-2004 07:21 AM
(Foolish linux user deletes block device) Zander Linux - General 3 02-15-2004 11:40 PM
READ ME: red hat 7.2 /dev/cdrom not a valid block device rshaw Linux - Software 0 11-08-2001 12:54 PM
cdrecord -scanbus sez: "controller returns wrong size for capapabilities page rdaves@earthlink.net Linux - General 5 10-08-2001 09:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration