* Re: How to do IO across hardsector boundries
2004-08-01 0:22 How to do IO across hardsector boundries Thomas S. Iversen
@ 2004-07-31 23:32 ` Alan Cox
2004-08-01 8:53 ` Arjan van de Ven
2004-08-01 13:10 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2004-07-31 23:32 UTC (permalink / raw)
To: Thomas S. Iversen; +Cc: Linux Kernel Mailing List
On Sul, 2004-08-01 at 01:22, Thomas S. Iversen wrote:
> So my question really is, how do I go about updating for instance the
> 512 bytes located for at byte 64 to 64+511 on the actual media without
> getting in trouble regarding the data from offset 0-63 and 64+512->1023?
If you want to use the BIO layer then you need to read the two blocks,
write to the bits you care about and then write them back. That is what
will always have to happen at a lower level for this anyway. In essence
you would be implementing the small g_read/g_write equivalent routines.
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to do IO across hardsector boundries
@ 2004-08-01 0:22 Thomas S. Iversen
2004-07-31 23:32 ` Alan Cox
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas S. Iversen @ 2004-08-01 0:22 UTC (permalink / raw)
To: linux-kernel
Hi There
As part of an assignment I am trying to port a piece of software from
FreeBSD to linux. Essentially this software (crypto) makes a virtual
blockdevice with "virtual" sectors on top. Under FreeBSD these virtual
sectors are just read/written using a simple command:
buf=g_read(dev, offset, len)
error=g_write(dev,offset,buf,len)
In linux however I have only seen the BIO layer which operates on IO on
hardsector boundaries.
So my question really is, how do I go about updating for instance the
512 bytes located for at byte 64 to 64+511 on the actual media without
getting in trouble regarding the data from offset 0-63 and 64+512->1023?
Regards Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to do IO across hardsector boundries
2004-08-01 0:22 How to do IO across hardsector boundries Thomas S. Iversen
2004-07-31 23:32 ` Alan Cox
@ 2004-08-01 8:53 ` Arjan van de Ven
2004-08-01 13:10 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2004-08-01 8:53 UTC (permalink / raw)
To: Thomas S. Iversen; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 534 bytes --]
On Sun, 2004-08-01 at 02:22, Thomas S. Iversen wrote:
> Hi There
>
> As part of an assignment I am trying to port a piece of software from
> FreeBSD to linux. Essentially this software (crypto) makes a virtual
> blockdevice with "virtual" sectors on top. Under FreeBSD these virtual
> sectors are just read/written using a simple command:
I can recommend that you look at the Device Mapper layer and consider
porting your code to that, it's designed to take care of some of the
hard work for you for usages like this.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to do IO across hardsector boundries
2004-08-01 0:22 How to do IO across hardsector boundries Thomas S. Iversen
2004-07-31 23:32 ` Alan Cox
2004-08-01 8:53 ` Arjan van de Ven
@ 2004-08-01 13:10 ` Richard B. Johnson
2 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2004-08-01 13:10 UTC (permalink / raw)
To: Thomas S. Iversen; +Cc: linux-kernel
On Sun, 1 Aug 2004, Thomas S. Iversen wrote:
> Hi There
>
> As part of an assignment I am trying to port a piece of software from
> FreeBSD to linux. Essentially this software (crypto) makes a virtual
> blockdevice with "virtual" sectors on top. Under FreeBSD these virtual
> sectors are just read/written using a simple command:
>
> buf=g_read(dev, offset, len)
> error=g_write(dev,offset,buf,len)
>
> In linux however I have only seen the BIO layer which operates on IO on
> hardsector boundaries.
>
> So my question really is, how do I go about updating for instance the
> 512 bytes located for at byte 64 to 64+511 on the actual media without
> getting in trouble regarding the data from offset 0-63 and 64+512->1023?
>
> Regards Thomas
There are no hard-sector boundaries in Linux. The geometry of a drive
is really ignored. It's just used to determine the size of a disk
partition, etc. The stated Heads/cylinders/sectors is a throw-back
to the old int 0x13, DOS days where stuff had to fit into registers
for access.
If your driver expects to write physical sectors, it's broken.
Even physical sectors (on the media) don't really exist anymore.
They are now "logical" sectors and they are never really accessed
as a single unit (except in floppies). They are "extracted" from a
sector-buffer that could contain nearly a whole track.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-01 13:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-01 0:22 How to do IO across hardsector boundries Thomas S. Iversen
2004-07-31 23:32 ` Alan Cox
2004-08-01 8:53 ` Arjan van de Ven
2004-08-01 13:10 ` Richard B. Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox