Re: Read/Write bytes directly from hard drive
From: Grant Edwards (grante_at_visi.com)
Date: 04/22/05
- Next message: Peter T. Breuer: "Re: Help! libtool/autoconf"
- Previous message: Peter T. Breuer: "Re: Read/Write bytes directly from hard drive"
- In reply to: tom: "Re: Read/Write bytes directly from hard drive"
- Next in thread: tom: "Re: Read/Write bytes directly from hard drive"
- Reply: tom: "Re: Read/Write bytes directly from hard drive"
- Reply: phil-news-nospam_at_ipal.net: "Re: Read/Write bytes directly from hard drive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 22 Apr 2005 21:48:19 -0000
On 2005-04-22, tom <tom@dbservice.com> wrote:
> asharma wrote:
>> We are writing a disk partitioner from scratch. We were not sure how to
>> access any byte from the disk, including the master table or any other
>> data. Are there any system calls that handle read/write operations?
>>
>
> int fd = open("/dev/hda", O_SYNC);
>
> Read the first x bytes and you get the partition table of your first IDE
> disk. Replace x with the size of your partition table.
Be careful though. I seem to remember hearing Grub developers
complain that the Linux filesystem code or buffer cache did
something they didn't like with the first disk sector. I don't
know the details, but the end result was that they couldn't
reliably write to the boot sector when the drive had mounted
partitions. I don't know if it was just the MBR or if the boot
sectors within partitions were the problem. IIRC it wasn't an
issue if no partitions on the disk were mounted.
--
Grant Edwards grante Yow! The SAME WAVE keeps
at coming in and COLLAPSING
visi.com like a rayon MUU-MUU...
- Next message: Peter T. Breuer: "Re: Help! libtool/autoconf"
- Previous message: Peter T. Breuer: "Re: Read/Write bytes directly from hard drive"
- In reply to: tom: "Re: Read/Write bytes directly from hard drive"
- Next in thread: tom: "Re: Read/Write bytes directly from hard drive"
- Reply: tom: "Re: Read/Write bytes directly from hard drive"
- Reply: phil-news-nospam_at_ipal.net: "Re: Read/Write bytes directly from hard drive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|