2008-01-25 Robert Millan <rmh@aybabtu.com>
* conf/i386-pc.rmk (grub_setup_SOURCES, grub_emu_SOURCES): Regroup to make all filesystem sources appear together (possibly fixing omissions while at it). * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-linuxbios.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_probe_SOURCES): Likewise. Additionally, add `kern/file.c'. * conf/i386-efi.rmk (grub_probe_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_probe_SOURCES): Likewise. * conf/i386-linuxbios.rmk (grub_probe_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_probe_SOURCES): Likewise. * util/grub-probe.c: Include `<grub/file.h>' and `<sys/stat.h>'. (probe): Add a sanity check to make sure of our ability to read requested files when probing for filesystem type. * genmk.rb: Update copyright year (2007). * include/grub/fs.h (grub_fat_init, grub_fat_fini, grub_ext2_init) (grub_ext2_fini, grub_ufs_init, grub_ufs_fini, grub_minix_init) (grub_minix_fini, grub_hfs_init, grub_hfs_fini, grub_jfs_init) (grub_jfs_fini, grub_xfs_init, grub_xfs_fini, grub_affs_init) (grub_affs_fini, grub_sfs_init, grub_sfs_fini, grub_iso9660_init) : Remove function prototypes.
This commit is contained in:
parent
b95f71b5a3
commit
2a9525e6c3
14 changed files with 749 additions and 522 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <grub/util/misc.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/pc_partition.h>
|
||||
|
@ -35,6 +36,7 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
#include <getopt.h>
|
||||
|
@ -77,9 +79,10 @@ probe (const char *path)
|
|||
{
|
||||
char *device_name;
|
||||
char *drive_name = NULL;
|
||||
char *grub_path = NULL;
|
||||
char *filebuf_via_grub = NULL, *filebuf_via_sys = NULL;
|
||||
int abstraction_type;
|
||||
grub_device_t dev;
|
||||
grub_fs_t fs;
|
||||
grub_device_t dev = NULL;
|
||||
|
||||
device_name = grub_guess_root_device (path);
|
||||
if (! device_name)
|
||||
|
@ -148,16 +151,50 @@ probe (const char *path)
|
|||
goto end;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe (dev);
|
||||
if (! fs)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
if (print == PRINT_FS)
|
||||
{
|
||||
struct stat st;
|
||||
grub_fs_t fs;
|
||||
|
||||
printf ("%s\n", fs->name);
|
||||
|
||||
grub_device_close (dev);
|
||||
stat (path, &st);
|
||||
|
||||
if (st.st_mode == S_IFREG)
|
||||
{
|
||||
/* Regular file. Verify that we can read it properly. */
|
||||
|
||||
grub_file_t file;
|
||||
grub_util_info ("reading %s via OS facilities", path);
|
||||
filebuf_via_sys = grub_util_read_image (path);
|
||||
|
||||
grub_util_info ("reading %s via GRUB facilities", path);
|
||||
asprintf (&grub_path, "(%s)%s", drive_name, path);
|
||||
file = grub_file_open (grub_path);
|
||||
filebuf_via_grub = xmalloc (file->size);
|
||||
grub_file_read (file, filebuf_via_grub, file->size);
|
||||
|
||||
grub_util_info ("comparing");
|
||||
|
||||
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
|
||||
grub_util_error ("files differ");
|
||||
|
||||
fs = file->fs;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs = grub_fs_probe (dev);
|
||||
if (! fs)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
}
|
||||
|
||||
printf ("%s\n", fs->name);
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
free (grub_path);
|
||||
free (filebuf_via_grub);
|
||||
free (filebuf_via_sys);
|
||||
free (device_name);
|
||||
free (drive_name);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue