bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: Bug-grub digest, Vol 1 #669 - 6 msgs


From: Gary Poppitz
Subject: Fw: Bug-grub digest, Vol 1 #669 - 6 msgs
Date: Tue, 14 May 2002 17:40:09 -0700

> >
>
> >2) Allow the specification of a vendor class identifier on the command
> >line, such that dhcp servers could behave differently for different
> >clients.
>
> >Damian
>
> I, for one, would very much like this ability. We use grub in our
> development to download new images
> for testing. This would allow use to test multiple systems at the same
time.
> Here is a routine I made to allow the transfer
> of an image from the network to a specified partition. It is quite handy
for
> our use. Caveat -- I am not sure of all
> the ramifications of trying to talk to multiple drives at the same time
with
> grub. Its high use of globals
> makes that difficult. However, it does seem to function which is what I
cared
> about. Sorry about the tabs not coming thru...
>
>
>
>
> #define SECTORCOUNT 16
> #define BUFSIZE SECTORCOUNT *512
> #define YPOS 20
> #define false 0
> #define true 1
>
> int wait = 0;
> char copy_buf[BUFSIZE], comp_buf[BUFSIZE];
>
> static int
> copy_func (char *arg, int flags)
> {
> /* The filenames.  */
> char *file1 = 0, *file2 = 0;
> /* The addresses.  */
> int read_size, loop, verify = 0, done = false;
> unsigned long write_drive, write_part, write_part_start, read_drive,
> read_part, read_part_start, sector;
>
> if (*arg == 'v') {
> verify = 1;
> arg = skip_to(0, arg);
> }
>
> while (! done) {
> /* Get the filenames from ARG.  */
> if (verify != 2) {
> file1 = arg;
> file2 = skip_to (0, arg);
> if (! *file1 || ! *file2){
> errnum = ERR_BAD_ARGUMENT;
> return 1;
> }
> } else grub_printf("\nVerifying...\n");
>
> /* Terminate the filenames for convenience.  */
> nul_terminate (file1);
> nul_terminate (file2);
>
> if (!  setup_part(file2))
> return 1;
>
> write_drive = current_drive;
> write_part = current_partition;
> write_part_start = part_start;
>
> if (!  grub_open(file1))
> return 1;
> read_drive = current_drive;
> read_part = current_partition;
> read_part_start = part_start;
>
>
> sector = 0;
>
> loop = 1;
> grub_printf("\nTransferring %d bytes", filemax);
> gotoxy(0, YPOS);
> while ((read_size = grub_read (copy_buf, BUFSIZE)) > 0) {
> if ((loop ++ % 400) == 0) {
> gotoxy(0, YPOS);
> grub_printf("
> ");
> gotoxy(0, YPOS);
> grub_printf("\n%d",sector*512);
> }
> current_partition = write_part;
> current_drive = write_drive;
> part_start = write_part_start;
> if (verify == 2) {
> char *src, *dst;
> int scan;
> if (! devread(sector, 0, read_size , comp_buf))
> return 1;
> src = copy_buf;
> dst = comp_buf;
> for (scan = 0; scan < read_size; scan ++) {
> if (*src ++ != *dst ++) {
> gotoxy(0, YPOS);
> grub_printf("Data Mismatch offset %d (%d, %d)\n", sector * 512 + scan,
> src[-1]&0xff, dst[-1]&0xff);
> if (pause_func("wait.\n", 0))
> break;
> }
> }
> } else {
> if (! devwrite(sector, (read_size + 511)/ 512 , copy_buf))
> return 1;
> }
> current_partition = read_part;
> current_drive = read_drive;
> part_start = read_part_start;
> sector += SECTORCOUNT;
> }
> grub_close ();
> if (read_size != 0)
> return 1;
> if (verify == 1)
> verify = 2;
> else done = true;
> }
> if (verify == 2) {
> gotoxy(0, YPOS);
> pause_func("Copy/Verify completed.\n", 0);
> }
> return 0;
> }
>
> static struct builtin builtin_copy =
> {
>   "copy",
>   copy_func,
>   BUILTIN_CMDLINE,
>   "copy [v] FILE PARTITION",
>   "Copies a file to a specified partition. The v flag performs a post
> verify"
> };
>
>
>
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]