Skip to content

Commit

Permalink
. 修正碎片插槽计算。
Browse files Browse the repository at this point in the history
. 修正cdrom解析。issues #431
  • Loading branch information
yaya2007 committed Nov 27, 2023
1 parent eeb9ba9 commit fcaebed
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 36 deletions.
4 changes: 4 additions & 0 deletions ChangeLog_chenall.txt
@@ -1,4 +1,8 @@
更新说明:
2023-11-27 (yaya)
修正碎片插槽计算。
修正cdrom解析。issues #431

2023-10-14 (yaya)
修正增加变量menu_tab_ext引入的问题。
修正font函数。
Expand Down
31 changes: 19 additions & 12 deletions stage2/builtins.c
Expand Up @@ -318,15 +318,15 @@ disk_read_blocklist_func (unsigned long long sector, unsigned long offset, unsig
{
if (blklst_last_length == 0)
grub_printf ("%s0x%lx+0x%lx", (blklst_num_entries ? "," : ""),
(unsigned long long)(blklst_start_sector - part_start), blklst_num_sectors);
(unsigned long long)(blklst_start_sector/* - part_start*/), blklst_num_sectors);
else if (blklst_num_sectors > 1)
grub_printf ("%s0x%lx+0x%lx,0x%lx[0-0x%x]", (blklst_num_entries ? "," : ""),
(unsigned long long)(blklst_start_sector - part_start), (blklst_num_sectors-1),
(unsigned long long)(blklst_start_sector + blklst_num_sectors-1 - part_start),
(unsigned long long)(blklst_start_sector/* - part_start*/), (blklst_num_sectors-1),
(unsigned long long)(blklst_start_sector + blklst_num_sectors-1/* - part_start*/),
blklst_last_length);
else
grub_printf ("%s0x%lx[0-0x%x]", (blklst_num_entries ? "," : ""),
(unsigned long long)(blklst_start_sector - part_start), blklst_last_length);
(unsigned long long)(blklst_start_sector/* - part_start*/), blklst_last_length);
}
else if (blklst_last_length == 0 && blklst_num_entries < DRIVE_MAP_FRAGMENT)
{
Expand All @@ -342,7 +342,7 @@ disk_read_blocklist_func (unsigned long long sector, unsigned long offset, unsig
{
if (query_block_entries >= 0)
grub_printf("%s0x%lx[0x%x-0x%x]", (blklst_num_entries ? "," : ""),
(unsigned long long)(sector - part_start), offset, (offset + length));
(unsigned long long)(sector/* - part_start*/), offset, (offset + length));
blklst_num_entries++;
}
else
Expand Down Expand Up @@ -435,7 +435,7 @@ blocklist_func (char *arg, int flags)
{
if (query_block_entries >= 0)
grub_printf ("%s0x%lx+0x%lx", (blklst_num_entries ? "," : ""),
(unsigned long long)(blklst_start_sector - part_start), blklst_num_sectors);
(unsigned long long)(blklst_start_sector/* - part_start*/), blklst_num_sectors);
else if (blklst_num_entries < DRIVE_MAP_FRAGMENT)
{
map_start_sector[blklst_num_entries] = blklst_start_sector;
Expand Down Expand Up @@ -6010,7 +6010,7 @@ find_func (char *arg, int flags)
current_drive = min_cdrom_id;
else
continue;
#endif
#else
for (drive = 0xa0; drive <= 0xff; drive++)
{
for (i = 0; i < DRIVE_MAP_SIZE; i++)
Expand All @@ -6022,7 +6022,7 @@ find_func (char *arg, int flags)
current_drive = drive;
if (tmp_drive != current_drive && find_check(filename,builtin1,arg,flags) == 1)
{
tmp_drive = current_drive;
// tmp_drive = current_drive;
got_file = 1;
if (set_root)
goto found;
Expand All @@ -6031,6 +6031,7 @@ find_func (char *arg, int flags)
}
}
}
#endif
break;
case 'h':
case 'f':
Expand Down Expand Up @@ -6100,6 +6101,7 @@ find_func (char *arg, int flags)
default:
continue;
}
#if 0
if (tmp_drive == current_drive)
continue;
if (find_check(filename,builtin1,arg,flags) == 1)
Expand All @@ -6108,6 +6110,7 @@ find_func (char *arg, int flags)
if (set_root)
goto found;
}
#endif
}
saved_drive = tmp_drive;
saved_partition = tmp_partition;
Expand Down Expand Up @@ -9319,7 +9322,8 @@ fragment_map_slot_empty(struct fragment_map_slot *q)
if (!q->slot_len)
return q;
n -= q->slot_len;
q += q->slot_len;
// q += q->slot_len;
q = (struct fragment_map_slot *)((char *)q + q->slot_len); //2023-11-14
}
return 0;
}
Expand All @@ -9335,7 +9339,8 @@ fragment_map_slot_find(struct fragment_map_slot *q, unsigned long from)
if (q->from == (char)from)
return q;
n -= q->slot_len;
q += q->slot_len;
// q += q->slot_len;
q = (struct fragment_map_slot *)((char *)q + q->slot_len); //2023-11-14
}
return 0;
}
Expand Down Expand Up @@ -13072,12 +13077,14 @@ print_root_device (char *buffer,int flag)
break;
#endif /* PXE drive. */
default:
#if 0
if (tmp_drive == cdrom_drive)
{
grub_printf("(cd)");
break;
}
else if (tmp_drive == 0xFFFF)
else
#endif
if (tmp_drive == 0xFFFF)
{
grub_printf("(md");
if (md_part_base) grub_printf(",0x%lx,0x%lx",md_part_base,md_part_size);
Expand Down
58 changes: 34 additions & 24 deletions stage2/disk_io.c
Expand Up @@ -1375,7 +1375,7 @@ set_device (char *device)
#ifdef FSYS_PXE
|| (*device == 'p' && pxe_entry)
#endif /* FSYS_PXE */
|| (*device == 'c' && (cdrom_drive != GRUB_INVALID_DRIVE || atapi_dev_count)))
|| (*device == 'c' /*&& (cdrom_drive != GRUB_INVALID_DRIVE || atapi_dev_count)*/)) //清除无效参数带来的干扰 2023-11-10
{
/* user has given '([fhn]', check for resp. add 'd' and
let disk_choice handle what disks we have */
Expand Down Expand Up @@ -1404,7 +1404,7 @@ set_device (char *device)
#ifdef FSYS_FB
|| (*device == 'u' && fb_status)
#endif
|| (*device == 'c' && (cdrom_drive != GRUB_INVALID_DRIVE || atapi_dev_count)))
|| (*device == 'c' /*&& (cdrom_drive != GRUB_INVALID_DRIVE || atapi_dev_count)*/)) //清除无效参数带来的干扰 2023-11-10
&& *(++device, device++) != 'd')
errnum = ERR_NUMBER_PARSING;

Expand All @@ -1429,9 +1429,8 @@ set_device (char *device)
{
// if (ch == 'c' && cdrom_drive != GRUB_INVALID_DRIVE && *device == ')')
// current_drive = cdrom_drive;
if (ch == 'c' && *(device+1) == 'd' && *(device+2) == ')') //(cd)
if (ch == 'c' && *device == ')') //解析map /boot/imgd/zb40.iso (cd)"之类 2023-11-10
{
device += 2;
current_drive = (unsigned char)(0xa0 + cdrom_orig++);
}
else if (ch == 'm')
Expand Down Expand Up @@ -1465,21 +1464,6 @@ set_device (char *device)
{
unsigned long long ull;

if (ch == 'c' && *(device+1) == 'd') //(cd)
{
device += 2;
if (*device == '-' && *(device+1) == '1')
{
current_drive = 0xa0 + cdrom_orig - 1;
device += 2;
}
else
{
safe_parse_maxint (&device, &ull);
current_drive = 0xa0 + ull;
}
goto aaa;
}
safe_parse_maxint (&device, &ull);
current_drive = ull;
disk_choice = 0;
Expand All @@ -1499,14 +1483,40 @@ set_device (char *device)
// if (cdrom_drives[current_drive] != GRUB_INVALID_DRIVE)
// current_drive = cdrom_drives[current_drive];
//}
// else if (ch == 'c' && atapi_dev_count && current_drive < (unsigned long)atapi_dev_count)
// {
// current_drive += min_cdrom_id;
// }
#if 0
else if (ch == 'c' && atapi_dev_count && current_drive < (unsigned long)atapi_dev_count)
{
current_drive += min_cdrom_id;
}
#endif
else if (ch == 'c')
{
if ((long long)ull < 0) //解析chainloader (cd-1)"之类 2023-11-10
{
if ((-ull) <= (unsigned long long)cdrom_orig)
current_drive = (unsigned char)(0xa0 + cdrom_orig + current_drive);
else
return (char *)!(errnum = ERR_DEV_FORMAT);
}
else //解析chainloader (cd0)"之类 2023-11-10
current_drive |= 0xa0;
}
else if (ch == 'f')
{
if ((long long)ull < 0)
{
if ((-ull) <= (unsigned long long)((*(char*)0x410 & 1)?(*(char*)0x410 >> 6) + 1 : 0))
current_drive = (unsigned char)(((*(char*)0x410 & 1)?(*(char*)0x410 >> 6) + 1 : 0) + current_drive);
else
return (char *)!(errnum = ERR_DEV_FORMAT);
}
else
current_drive |= 0;
}
}
}
}
aaa:

if (errnum)
return 0;

Expand Down

0 comments on commit fcaebed

Please sign in to comment.