All of lore.kernel.org
 help / color / mirror / Atom feed
* Read Sectors
@ 2011-10-12  3:03 Julio Alberto Cruz Barroso
  2011-10-12  3:09 ` Julio Alberto Cruz Barroso
  2011-10-12 13:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 2 replies; 5+ messages in thread
From: Julio Alberto Cruz Barroso @ 2011-10-12  3:03 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

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.

 

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


[-- Attachment #2: Type: text/html, Size: 2518 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Read Sectors
  2011-10-12  3:03 Read Sectors Julio Alberto Cruz Barroso
@ 2011-10-12  3:09 ` Julio Alberto Cruz Barroso
  2011-10-12 13:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 0 replies; 5+ messages in thread
From: Julio Alberto Cruz Barroso @ 2011-10-12  3:09 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

I already read some files from the OS partition but now we need to read
all data partition.

 

 

From: grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org
[mailto:grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org] On Behalf
Of Julio Alberto Cruz Barroso
Sent: Tuesday, October 11, 2011 10:33 PM
To: grub-devel@gnu.org
Subject: Read Sectors

 

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.

 

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


[-- Attachment #2: Type: text/html, Size: 3658 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Read Sectors
  2011-10-12  3:03 Read Sectors Julio Alberto Cruz Barroso
  2011-10-12  3:09 ` Julio Alberto Cruz Barroso
@ 2011-10-12 13:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2011-10-25  1:08   ` Julio Alberto Cruz Barroso
  1 sibling, 1 reply; 5+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2011-10-12 13:49 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

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
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Read Sectors
  2011-10-12 13:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2011-10-25  1:08   ` Julio Alberto Cruz Barroso
  2011-10-25 14:45     ` Julio Alberto Cruz Barroso
  0 siblings, 1 reply; 5+ messages in thread
From: Julio Alberto Cruz Barroso @ 2011-10-25  1:08 UTC (permalink / raw)
  To: The development of GNU GRUB

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: grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org [mailto:grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org] 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
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Read Sectors
  2011-10-25  1:08   ` Julio Alberto Cruz Barroso
@ 2011-10-25 14:45     ` Julio Alberto Cruz Barroso
  0 siblings, 0 replies; 5+ messages in thread
From: Julio Alberto Cruz Barroso @ 2011-10-25 14:45 UTC (permalink / raw)
  To: The development of GNU GRUB

I used this with success:

--------------
11.3 How to specify block lists

A block list is used for specifying a file that doesn't appear in the filesystem, like a chainloader. The syntax is [offset]+length[,[offset]+length].... Here is an example:

     0+100,200+1,300+300
This represents that GRUB should read blocks 0 through 99, block 200, and blocks 300 through 599. If you omit an offset, then GRUB assumes the offset is zero.

Like the file name syntax (see File name syntax), if a blocklist does not contain a device name, then GRUB uses GRUB's root device. So (hd0,2)+1 is the same as +1 when the root device is ‘(hd0,2)’.
---------------

Regards,

JC

-----Original Message-----
From: grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org [mailto:grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org] On Behalf Of Julio Alberto Cruz Barroso
Sent: Tuesday, October 25, 2011 9:09 AM
To: The development of GNU GRUB
Subject: RE: Read Sectors

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: grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org [mailto:grub-devel-bounces+julio.cruz=smartmatic.com@gnu.org] 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
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-25 14:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12  3:03 Read Sectors Julio Alberto Cruz Barroso
2011-10-12  3:09 ` Julio Alberto Cruz Barroso
2011-10-12 13:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-10-25  1:08   ` Julio Alberto Cruz Barroso
2011-10-25 14:45     ` Julio Alberto Cruz Barroso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.