Skip to contentSkip to conversation

Write sector (int 13h) under Linux?

DISCUSSION Guido Reina 2 participants 2 messages Jan 29, 2003

lore
Share & tools
lore
#0 lore raw

Hi there,

I am trying to delete a sector of my linux box from the kernel, for this I have included a small piece of code as inline assembly. With the 13h interruption I write the sector, I don't know why but it is not working. Do you know if the linux kernel avoids such accesses to the hard disk?

My code is the following:

asm ( "
movb $0x03, %si;
start:
movb $0x03, %ah;
movb $0x05, %al;
movb $0x00, %ch;
movb $0x02, %cl;
movb $0x00, %dh;
movb $0x80, %dl;
int $0x13
jnc success;
movb $0x00, %ah;
int $0x13
dec si;
jnz start;
success:
");

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

#1 lore raw
Quoted 9 lines

Subject: Write sector (int 13h) under Linux?

Hi there,

I am trying to delete a sector of my linux box from the kernel, for this I have included a small piece of code as inline assembly. With the 13h interruption I write the sector, I don't know why but it is not working. Do you know if the linux kernel avoids such accesses to the hard disk?

Yes its nasty and dirty.

If you want to delete - overwrite some sector simply open your device for read and write if it is first hardisk than open /dev/hda file with open system call. (man 2 open)
Then use lseek to get onto right sector (sector size is 512B) so if you want to get to 2nd sector (after zero and first) you should lseek to 1024. Then you can read/write via standard system calls read and write.

You can get some inspiration at my fdisk program included in asmutils package. linuxassembly.org/asmutils.html

If you really want to use BIOS you need to use VM86 callbacks. but this is nasty and unfair to system.

Regards
Rudolf