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?

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:
");

Comments

  • : 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:
    : ");
    :
    Software interrupt 13h is hard disk BIOS services. Under linux, I think, this wont work because linux forbids using BIOS calls. The linux kernel has its own hard disk driver. You must use kernel services to delete. Anyway, BIOS services are real mode programs that won't work correctly under pure protected mode, DOS extenders use special code to get bios calls work. (if my memory is ok)

    You may use /dev/hd? to access to a sector and delete it directly using IOCTL or something like that.
  • : : 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:
    : : ");
    : :
    : Software interrupt 13h is hard disk BIOS services. Under linux, I think, this wont work because linux forbids using BIOS calls. The linux kernel has its own hard disk driver. You must use kernel services to delete. Anyway, BIOS services are real mode programs that won't work correctly under pure protected mode, DOS extenders use special code to get bios calls work. (if my memory is ok)
    :
    : You may use /dev/hd? to access to a sector and delete it directly using IOCTL or something like that.
    :

    Thank you very very much. I didn't know this about using BIOS services in protected mode. I tried the way you told me and it worked.

    Regards,

    Guido.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories