diff --git a/ChangeLog b/ChangeLog index cef584158..dda583cc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-08-01 Yoshinori K. Okuji + + * DISTLIST: Added util/i386/pc/grub-probefs.c. + + * conf/i386-pc.rmk (sbin_UTILITIES): Added grub-probefs. + (grub_setup_SOURCES): Removed partmap/amiga.c, partmap/apple.c and + partmap/sun.c. + (grub_probefs_SOURCES): New variable. + + * util/i386/pc/grub-probefs.c: New file. + + * util/i386/pc/grub-setup.c (main): Call + grub_pc_partition_map_init, grub_ufs_init, grub_minix_init, + grub_hfs_init and grub_jfs_init to initialize the system. Call + grub_ufs_fini, grub_minix_fini, grub_hfs_fini, grub_jfs_init and + grub_pc_partition_map_fini to finish the system. + 2005-07-31 Yoshinori K. Okuji * loader/i386/pc/multiboot.c (grub_multiboot_is_elf32): New diff --git a/DISTLIST b/DISTLIST index fbc6f9b9e..21fa67c58 100644 --- a/DISTLIST +++ b/DISTLIST @@ -169,6 +169,7 @@ util/i386/pc/getroot.c util/i386/pc/grub-install.in util/i386/pc/grub-mkdevicemap.c util/i386/pc/grub-mkimage.c +util/i386/pc/grub-probefs.c util/i386/pc/grub-setup.c util/i386/pc/misc.c util/powerpc/ieee1275/grub-mkimage.c diff --git a/conf/i386-pc.mk b/conf/i386-pc.mk index b697a00e7..01bc34082 100644 --- a/conf/i386-pc.mk +++ b/conf/i386-pc.mk @@ -269,7 +269,7 @@ kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh # Utilities. bin_UTILITIES = grub-mkimage -sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap +sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs noinst_UTILITIES = genmoddep # For grub-mkimage. @@ -311,12 +311,12 @@ grub_mkimage_LDFLAGS = -llzo grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ kern/err.c kern/misc.c fs/fat.c fs/ext2.c \ - kern/partition.c partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + kern/partition.c partmap/pc.c \ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c -CLEANFILES += grub-setup grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_partition.o grub_setup-partmap_amiga.o grub_setup-partmap_apple.o grub_setup-partmap_pc.o grub_setup-partmap_sun.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o -MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d grub_setup-util_i386_pc_biosdisk.d grub_setup-util_misc.d grub_setup-util_i386_pc_getroot.d grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-fs_fat.d grub_setup-fs_ext2.d grub_setup-kern_partition.d grub_setup-partmap_amiga.d grub_setup-partmap_apple.d grub_setup-partmap_pc.d grub_setup-partmap_sun.d grub_setup-fs_ufs.d grub_setup-fs_minix.d grub_setup-fs_hfs.d grub_setup-fs_jfs.d grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d grub_setup-fs_fshelp.d +CLEANFILES += grub-setup grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o +MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d grub_setup-util_i386_pc_biosdisk.d grub_setup-util_misc.d grub_setup-util_i386_pc_getroot.d grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-fs_fat.d grub_setup-fs_ext2.d grub_setup-kern_partition.d grub_setup-partmap_pc.d grub_setup-fs_ufs.d grub_setup-fs_minix.d grub_setup-fs_hfs.d grub_setup-fs_jfs.d grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d grub_setup-fs_fshelp.d -grub-setup: grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_partition.o grub_setup-partmap_amiga.o grub_setup-partmap_apple.o grub_setup-partmap_pc.o grub_setup-partmap_sun.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o +grub-setup: grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_setup_LDFLAGS) grub_setup-util_i386_pc_grub_setup.o: util/i386/pc/grub-setup.c @@ -407,22 +407,6 @@ grub_setup-kern_partition.d: kern/partition.c -include grub_setup-kern_partition.d -grub_setup-partmap_amiga.o: partmap/amiga.c - $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< - -grub_setup-partmap_amiga.d: partmap/amiga.c - set -e; $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,amiga\.o[ :]*,grub_setup-partmap_amiga.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ - --include grub_setup-partmap_amiga.d - -grub_setup-partmap_apple.o: partmap/apple.c - $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< - -grub_setup-partmap_apple.d: partmap/apple.c - set -e; $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,apple\.o[ :]*,grub_setup-partmap_apple.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ - --include grub_setup-partmap_apple.d - grub_setup-partmap_pc.o: partmap/pc.c $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< @@ -431,14 +415,6 @@ grub_setup-partmap_pc.d: partmap/pc.c -include grub_setup-partmap_pc.d -grub_setup-partmap_sun.o: partmap/sun.c - $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< - -grub_setup-partmap_sun.d: partmap/sun.c - set -e; $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,sun\.o[ :]*,grub_setup-partmap_sun.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ - --include grub_setup-partmap_sun.d - grub_setup-fs_ufs.o: fs/ufs.c $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< @@ -529,6 +505,171 @@ grub_mkdevicemap-util_misc.d: util/misc.c -include grub_mkdevicemap-util_misc.d +# For grub-probefs. +grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \ + util/i386/pc/biosdisk.c util/misc.c util/i386/pc/getroot.c \ + kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ + fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \ + fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c +CLEANFILES += grub-probefs grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o +MOSTLYCLEANFILES += grub_probefs-util_i386_pc_grub_probefs.d grub_probefs-util_i386_pc_biosdisk.d grub_probefs-util_misc.d grub_probefs-util_i386_pc_getroot.d grub_probefs-kern_device.d grub_probefs-kern_disk.d grub_probefs-kern_err.d grub_probefs-kern_misc.d grub_probefs-fs_fat.d grub_probefs-fs_ext2.d grub_probefs-kern_partition.d grub_probefs-partmap_pc.d grub_probefs-fs_ufs.d grub_probefs-fs_minix.d grub_probefs-fs_hfs.d grub_probefs-fs_jfs.d grub_probefs-kern_fs.d grub_probefs-kern_env.d grub_probefs-fs_fshelp.d + +grub-probefs: grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o + $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_probefs_LDFLAGS) + +grub_probefs-util_i386_pc_grub_probefs.o: util/i386/pc/grub-probefs.c + $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-util_i386_pc_grub_probefs.d: util/i386/pc/grub-probefs.c + set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,grub\-probefs\.o[ :]*,grub_probefs-util_i386_pc_grub_probefs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-util_i386_pc_grub_probefs.d + +grub_probefs-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c + $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c + set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,grub_probefs-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-util_i386_pc_biosdisk.d + +grub_probefs-util_misc.o: util/misc.c + $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-util_misc.d: util/misc.c + set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_probefs-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-util_misc.d + +grub_probefs-util_i386_pc_getroot.o: util/i386/pc/getroot.c + $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-util_i386_pc_getroot.d: util/i386/pc/getroot.c + set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,grub_probefs-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-util_i386_pc_getroot.d + +grub_probefs-kern_device.o: kern/device.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_device.d: kern/device.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,device\.o[ :]*,grub_probefs-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_device.d + +grub_probefs-kern_disk.o: kern/disk.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_disk.d: kern/disk.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,disk\.o[ :]*,grub_probefs-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_disk.d + +grub_probefs-kern_err.o: kern/err.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_err.d: kern/err.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,err\.o[ :]*,grub_probefs-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_err.d + +grub_probefs-kern_misc.o: kern/misc.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_misc.d: kern/misc.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_probefs-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_misc.d + +grub_probefs-fs_fat.o: fs/fat.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_fat.d: fs/fat.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,fat\.o[ :]*,grub_probefs-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_fat.d + +grub_probefs-fs_ext2.o: fs/ext2.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_ext2.d: fs/ext2.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,grub_probefs-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_ext2.d + +grub_probefs-kern_partition.o: kern/partition.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_partition.d: kern/partition.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,partition\.o[ :]*,grub_probefs-kern_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_partition.d + +grub_probefs-partmap_pc.o: partmap/pc.c + $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-partmap_pc.d: partmap/pc.c + set -e; $(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,pc\.o[ :]*,grub_probefs-partmap_pc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-partmap_pc.d + +grub_probefs-fs_ufs.o: fs/ufs.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_ufs.d: fs/ufs.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,ufs\.o[ :]*,grub_probefs-fs_ufs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_ufs.d + +grub_probefs-fs_minix.o: fs/minix.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_minix.d: fs/minix.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,minix\.o[ :]*,grub_probefs-fs_minix.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_minix.d + +grub_probefs-fs_hfs.o: fs/hfs.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_hfs.d: fs/hfs.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,hfs\.o[ :]*,grub_probefs-fs_hfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_hfs.d + +grub_probefs-fs_jfs.o: fs/jfs.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_jfs.d: fs/jfs.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,jfs\.o[ :]*,grub_probefs-fs_jfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_jfs.d + +grub_probefs-kern_fs.o: kern/fs.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_fs.d: kern/fs.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,fs\.o[ :]*,grub_probefs-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_fs.d + +grub_probefs-kern_env.o: kern/env.c + $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-kern_env.d: kern/env.c + set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,env\.o[ :]*,grub_probefs-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-kern_env.d + +grub_probefs-fs_fshelp.o: fs/fshelp.c + $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $< + +grub_probefs-fs_fshelp.d: fs/fshelp.c + set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,fshelp\.o[ :]*,grub_probefs-fs_fshelp.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include grub_probefs-fs_fshelp.d + + # For grub-emu. grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/default.c commands/help.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 72f40f8b1..ce01d0e93 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -49,7 +49,7 @@ kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh # Utilities. bin_UTILITIES = grub-mkimage -sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap +sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs noinst_UTILITIES = genmoddep # For grub-mkimage. @@ -61,12 +61,19 @@ grub_mkimage_LDFLAGS = -llzo grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ kern/err.c kern/misc.c fs/fat.c fs/ext2.c \ - kern/partition.c partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + kern/partition.c partmap/pc.c \ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c # For grub-mkdevicemap. grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c +# For grub-probefs. +grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \ + util/i386/pc/biosdisk.c util/misc.c util/i386/pc/getroot.c \ + kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ + fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \ + fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c + # For grub-emu. grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/default.c commands/help.c \ diff --git a/util/i386/pc/grub-probefs.c b/util/i386/pc/grub-probefs.c new file mode 100644 index 000000000..b88574720 --- /dev/null +++ b/util/i386/pc/grub-probefs.c @@ -0,0 +1,209 @@ +/* grub-probefs.c - probe a filesystem module for a given path */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * GRUB is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define _GNU_SOURCE 1 +#include + +#ifdef __NetBSD__ +/* NetBSD uses /boot for its boot block. */ +# define DEFAULT_DIRECTORY "/grub" +#else +# define DEFAULT_DIRECTORY "/boot/grub" +#endif + +#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" + +void +grub_putchar (int c) +{ + putchar (c); +} + +void +grub_refresh (void) +{ +} + +static void +probe (const char *path) +{ + char *device_name; + grub_device_t dev; + grub_fs_t fs; + + device_name = grub_guess_root_device (path); + if (! device_name) + { + fprintf (stderr, "cannot find a GRUB device for %s.\n", path); + return; + } + + grub_util_info ("opening %s", device_name); + dev = grub_device_open (device_name); + if (! dev) + grub_util_error ("%s", grub_errmsg); + + fs = grub_fs_probe (dev); + if (! fs) + grub_util_error ("%s", grub_errmsg); + + printf ("%s\n", fs->name); + + grub_device_close (dev); + free (device_name); +} + +static struct option options[] = + { + {"device-map", required_argument, 0, 'm'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {"verbose", no_argument, 0, 'v'}, + {0, 0, 0, 0} + }; + +static void +usage (int status) +{ + if (status) + fprintf (stderr, + "Try ``grub-probefs --help'' for more information.\n"); + else + printf ("\ +Usage: grub-probefs [OPTION]... PATH\n\ +\n\ +Probe a filesystem module for a given path.\n\ +\n\ + -m, --device-map=FILE use FILE as the device map [default=%s]\n\ + -h, --help display this message and exit\n\ + -V, --version print version information and exit\n\ + -v, --verbose print verbose messages\n\ +\n\ +Report bugs to <%s>.\n\ +", + DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT); + + exit (status); +} + +int +main (int argc, char *argv[]) +{ + char *dev_map = 0; + char *path; + + progname = "grub-probefs"; + + /* Check for options. */ + while (1) + { + int c = getopt_long (argc, argv, "m:hVv", options, 0); + + if (c == -1) + break; + else + switch (c) + { + case 'm': + if (dev_map) + free (dev_map); + + dev_map = xstrdup (optarg); + break; + + case 'h': + usage (0); + break; + + case 'V': + printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION); + return 0; + + case 'v': + verbosity++; + break; + + default: + usage (1); + break; + } + } + + /* Obtain PATH. */ + if (optind >= argc) + { + fprintf (stderr, "No path is specified.\n"); + usage (1); + } + + if (optind + 1 != argc) + { + fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]); + usage (1); + } + + path = argv[optind]; + + /* Initialize the emulated biosdisk driver. */ + grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP); + grub_pc_partition_map_init (); + + /* Initialize filesystems. */ + grub_fat_init (); + grub_ext2_init (); + grub_ufs_init (); + grub_minix_init (); + grub_hfs_init (); + grub_jfs_init (); + + /* Do it. */ + probe (path); + + /* Free resources. */ + grub_ext2_fini (); + grub_fat_fini (); + grub_ufs_fini (); + grub_minix_fini (); + grub_hfs_fini (); + grub_jfs_fini (); + + grub_pc_partition_map_fini (); + grub_util_biosdisk_fini (); + + free (dev_map); + + return 0; +} diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index d0eb17dd0..2c987f9bb 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -607,6 +607,7 @@ main (int argc, char *argv[]) /* Initialize the emulated biosdisk driver. */ grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP); + grub_pc_partition_map_init (); dest_dev = get_device_name (argv[optind]); if (! dest_dev) @@ -628,6 +629,10 @@ main (int argc, char *argv[]) /* Initialize filesystems. */ grub_fat_init (); grub_ext2_init (); + grub_ufs_init (); + grub_minix_init (); + grub_hfs_init (); + grub_jfs_init (); if (root_dev) { @@ -661,7 +666,12 @@ main (int argc, char *argv[]) /* Free resources. */ grub_ext2_fini (); grub_fat_fini (); + grub_ufs_fini (); + grub_minix_fini (); + grub_hfs_fini (); + grub_jfs_fini (); + grub_pc_partition_map_fini (); grub_util_biosdisk_fini (); free (boot_file);