[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Read Sectors
From: |
Julio Alberto Cruz Barroso |
Subject: |
RE: Read Sectors |
Date: |
Mon, 24 Oct 2011 21:08:35 -0400 |
OK, OK.
I use the following function to read files with success:
---------------------------------------
static int
smtt_send_file(char * pathname)
{
static unsigned char Buffer[FILE_BUFFER_SIZE];
grub_file_t file = 0;
grub_off_t ofs, len;
unsigned long long bytes_sent = 0;
file = grub_file_open (pathname);
if (!file)
{
grub_dprintf ("mcu","cannot open file %s", pathname);
return -1;
}
grub_dprintf ("mcu","file size : %lld \n", (unsigned long long) file->size);
ofs = 0;
len = file->size;
file->offset = 0;
while (len)
{
grub_ssize_t sz;
sz = grub_file_read (file, Buffer, (len > FILE_BUFFER_SIZE) ?
FILE_BUFFER_SIZE : len);
if (sz < 0)
{
grub_dprintf ("mcu","read error at offset %llu: %s\n", ofs,
grub_errmsg);
break;
}
#ifdef MCUDEBUG
grub_getkey();
grub_printf ("sending pack %llu \n", ofs);
#endif
if(!smtt_send_package ( Buffer, sz))
{
bytes_sent +=sz;
if ((sz == 0))
break;
ofs += sz;
len -= sz;
}
else
{
grub_dprintf("mcu", "Error Sending Package\n");
break;
}
}
//grub_printf ("file size : %lld \n", (unsigned long long) file->size);
//grub_printf ("Bytes Sends: %lld \n", bytes_sent);
grub_file_close (file);
return 0;
}
---------------------------------------------------------
Now, I need to read the OS partition sectors (not files). For example, from
sector 1 to sector 500.
I'm not sure which function to use to get this. For example, the functions
"read" and "write" in a C/C++ Linux program.
Julio
-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Vladimir
'f-coder/phcoder' Serbinenko
Sent: Wednesday, October 12, 2011 9:49 PM
To: The development of GNU GRUB
Subject: Re: Read Sectors
On 12.10.2011 05:03, Julio Alberto Cruz Barroso wrote:
>
> Dear all,
>
>
>
> I have a module to read some byte sectors from a OS partition to get a
> HASH and validate the OS.
>
>
>
> I try to use grub_file_open and grub_disk_open function without success.
>
And I'm telepath to know what exactly the code you're trying. And if you code
for anything have a look around for the use of the function in question e.g. in
ntldr.c
>
>
>
> My system have two (2) compact flash (hard disk). The system must boot
> with one CF or two CF (with priority setup).
>
>
>
> Thanks all,
>
>
>
> Julio
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
- Read Sectors, Julio Alberto Cruz Barroso, 2011/10/11
- RE: Read Sectors, Julio Alberto Cruz Barroso, 2011/10/11
- Re: Read Sectors, Vladimir 'φ-coder/phcoder' Serbinenko, 2011/10/12
- RE: Read Sectors,
Julio Alberto Cruz Barroso <=