2003-01-07 Yoshinori K. Okuji <okuji@enbug.org>
* util/i386/pc/pupa-setup.c (setup): Convert the endianness of the length of a blocklist correctly. * util/i386/pc/biosdisk.c (pupa_util_biosdisk_open) [__linux__]: Use ioctl only if the OS file is a block device. (pupa_util_biosdisk_open): Don't use ST.ST_BLOCKS, because it is not very useful for normal files. * kern/main.c (pupa_set_root_dev): New function. (pupa_load_normal_mode): Likewise. (pupa_main): Call those above. * include/pupa/types.h (pupa_swap_bytes16): Cast the result to pupa_uint16_t. * include/pupa/kernel.h (pupa_enter_normal_mode): Removed.
This commit is contained in:
parent
a5ffe96617
commit
a13f92373c
6 changed files with 95 additions and 17 deletions
|
@ -177,6 +177,12 @@ pupa_util_biosdisk_open (const char *name, pupa_disk_t disk)
|
|||
if (! fd)
|
||||
return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot open `%s'", map[drive]);
|
||||
|
||||
if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
|
||||
{
|
||||
close (fd);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ioctl (fd, BLKGETSIZE, &nr))
|
||||
{
|
||||
close (fd);
|
||||
|
@ -198,11 +204,7 @@ pupa_util_biosdisk_open (const char *name, pupa_disk_t disk)
|
|||
if (stat (map[drive], &st) < 0)
|
||||
return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive]);
|
||||
|
||||
if (st.st_blocks)
|
||||
disk->total_sectors = st.st_blocks;
|
||||
else
|
||||
/* Hmm... Use st_size instead. */
|
||||
disk->total_sectors = st.st_size >> PUPA_DISK_SECTOR_BITS;
|
||||
disk->total_sectors = st.st_size >> PUPA_DISK_SECTOR_BITS;
|
||||
|
||||
pupa_util_info ("the size of %s is %lu", name, disk->total_sectors);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue