source tree reorg for emu platform
This commit is contained in:
commit
f4fc97d02a
32 changed files with 562 additions and 435 deletions
57
ChangeLog
57
ChangeLog
|
@ -1,3 +1,60 @@
|
||||||
|
2010-05-17 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
Source tree is reorganized for emu build.
|
||||||
|
|
||||||
|
* include/grub/util/console.h: Move from here...
|
||||||
|
* include/grub/emu/console.h: ...to here.
|
||||||
|
* include/grub/util/getroot.h: Move from here...
|
||||||
|
* include/grub/emu/getroot.h: ...to here.
|
||||||
|
* include/grub/util/hostdisk.h: Move from here...
|
||||||
|
* include/grub/emu/hostdisk.h: ...to here.
|
||||||
|
* util/console.c: Move from here...
|
||||||
|
* kern/emu/console.c: ...to here.
|
||||||
|
* util/getroot.c: Move from here...
|
||||||
|
* kern/emu/getroot.c: ...to here.
|
||||||
|
* util/grub-emu.c: Move from here...
|
||||||
|
* kern/emu/main.c: ...to here.
|
||||||
|
* util/hostdisk.c: Move from here...
|
||||||
|
* kern/emu/hostdisk.c: ...to here.
|
||||||
|
* util/hostfs.c: Move from here...
|
||||||
|
* kern/emu/hostfs.c: ...to here.
|
||||||
|
* util/mm.c: Move from here...
|
||||||
|
* kern/emu/mm.c: ...to here.
|
||||||
|
* util/pci.c: Move from here...
|
||||||
|
* bus/emu/pci.c: ...to here.
|
||||||
|
* util/sdl.c: Move from here...
|
||||||
|
* video/emu/sdl.c: ...to here.
|
||||||
|
* util/time.c: Move from here...
|
||||||
|
* kern/emu/time.c: ...to here.
|
||||||
|
* util/usb.c: Move from here...
|
||||||
|
* bus/usb/emu/usb.c: ...to here.
|
||||||
|
|
||||||
|
* include/grub/emu/misc.h: New header for grub-emu functions.
|
||||||
|
* kern/emu/misc.c: grub-emu functions separated from util/misc.c
|
||||||
|
|
||||||
|
* conf/any-emu.rmk: Rule updates for above renames.
|
||||||
|
* conf/common.rmk: Likewise.
|
||||||
|
* conf/i386-pc.rmk: Likewise.
|
||||||
|
* conf/i386-qemu.rmk: Likewise.
|
||||||
|
* conf/mips.rmk: Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk: Likewise.
|
||||||
|
* conf/x86-efi.rmk: Likewise.
|
||||||
|
|
||||||
|
* disk/lvm.h: #include updates for above renames.
|
||||||
|
* util/grub-mkrelpath.c: Likewise.
|
||||||
|
* util/grub-probe.c: Likewise.
|
||||||
|
* util/i386/pc/grub-setup.c: Likewise.
|
||||||
|
* util/sparc64/ieee1275/grub-setup.c: Likewise.
|
||||||
|
* kern/emu/console.c: Likewise.
|
||||||
|
* kern/emu/getroot.c: Likewise.
|
||||||
|
* kern/emu/hostdisk.c: Likewise.
|
||||||
|
* kern/emu/main.c: Likewise. (was grub-emu.c earlier)
|
||||||
|
|
||||||
|
* include/grub/dl.h: Remove grub_dl_{ref,unref}.
|
||||||
|
* include/grub/util/misc.h: Move grub-emu functions to emu/misc.h.
|
||||||
|
* kern/dl.c: Handle null mod in grub_dl_{ref,unref}.
|
||||||
|
* util/misc.c: Remove grub-emu functions.
|
||||||
|
|
||||||
2010-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Fix gfxmenu crash.
|
Fix gfxmenu crash.
|
||||||
|
|
|
@ -105,14 +105,14 @@ grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
|
||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
||||||
grub_uint8_t request, grub_uint16_t value,
|
grub_uint8_t request, grub_uint16_t value,
|
||||||
grub_uint16_t index, grub_size_t size, char *data)
|
grub_uint16_t idx, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
usb_dev_handle *devh;
|
usb_dev_handle *devh;
|
||||||
struct usb_device *d = dev->data;
|
struct usb_device *d = dev->data;
|
||||||
|
|
||||||
devh = usb_open (d);
|
devh = usb_open (d);
|
||||||
if (usb_control_msg (devh, reqtype, request,
|
if (usb_control_msg (devh, reqtype, request,
|
||||||
value, index, data, size, 20) < 0)
|
value, idx, data, size, 20) < 0)
|
||||||
{
|
{
|
||||||
usb_close (devh);
|
usb_close (devh);
|
||||||
return GRUB_USB_ERR_STALL;
|
return GRUB_USB_ERR_STALL;
|
|
@ -9,13 +9,14 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||||
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/term.c \
|
kern/parser.c kern/partition.c kern/term.c \
|
||||||
kern/rescue_reader.c kern/rescue_parser.c \
|
kern/rescue_reader.c kern/rescue_parser.c \
|
||||||
\
|
\
|
||||||
util/console.c util/grub-emu.c util/misc.c \
|
kern/emu/main.c kern/emu/mm.c kern/emu/misc.c \
|
||||||
util/hostdisk.c util/getroot.c util/mm.c util/time.c \
|
kern/emu/getroot.c kern/emu/time.c kern/emu/hostdisk.c \
|
||||||
\
|
kern/emu/hostfs.c kern/emu/console.c \
|
||||||
gnulib/progname.c util/hostfs.c disk/host.c
|
\
|
||||||
kernel_img_HEADERS += datetime.h util/misc.h
|
gnulib/progname.c disk/host.c
|
||||||
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
kernel_img_HEADERS += datetime.h emu/misc.h
|
||||||
|
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-char-subscripts -Wno-unused -Wno-deprecated-declarations -Wno-undef -I$(srcdir)/gnulib
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
TARGET_NO_STRIP = yes
|
TARGET_NO_STRIP = yes
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ ifeq ($(enable_grub_emu_usb), yes)
|
||||||
kernel_img_HEADERS += libusb.h
|
kernel_img_HEADERS += libusb.h
|
||||||
|
|
||||||
pkglib_MODULES += libusb.mod
|
pkglib_MODULES += libusb.mod
|
||||||
libusb_mod_SOURCES = util/usb.c
|
libusb_mod_SOURCES = bus/usb/emu/usb.c
|
||||||
libusb_mod_CFLAGS =
|
libusb_mod_CFLAGS =
|
||||||
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_sdl), yes)
|
ifeq ($(enable_grub_emu_sdl), yes)
|
||||||
pkglib_MODULES += sdl.mod
|
pkglib_MODULES += sdl.mod
|
||||||
sdl_mod_SOURCES = util/sdl.c
|
sdl_mod_SOURCES = video/emu/sdl.c
|
||||||
sdl_mod_CFLAGS =
|
sdl_mod_CFLAGS =
|
||||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBSDL)
|
grub_emu_LDFLAGS += $(LIBSDL)
|
||||||
|
@ -85,7 +86,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_pci), yes)
|
ifeq ($(enable_grub_emu_pci), yes)
|
||||||
pkglib_MODULES += pci.mod
|
pkglib_MODULES += pci.mod
|
||||||
pci_mod_SOURCES = util/pci.c commands/lspci.c
|
pci_mod_SOURCES = bus/emu/pci.c commands/lspci.c
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||||
kernel_img_HEADERS += libpciaccess.h
|
kernel_img_HEADERS += libpciaccess.h
|
||||||
|
@ -104,10 +105,10 @@ DISTCLEANFILES += grub_emu_init.c
|
||||||
CLEANFILES += grub-emu
|
CLEANFILES += grub-emu
|
||||||
ifneq ($(TARGET_NO_MODULES), yes)
|
ifneq ($(TARGET_NO_MODULES), yes)
|
||||||
grub-emu: $(pkglib_PROGRAMS)
|
grub-emu: $(pkglib_PROGRAMS)
|
||||||
$(CC) -o $@ $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||||
else
|
else
|
||||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
||||||
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||||
endif
|
endif
|
||||||
GRUB_EMU=grub-emu
|
GRUB_EMU=grub-emu
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||||
sbin_UTILITIES += grub-mkdevicemap
|
sbin_UTILITIES += grub-mkdevicemap
|
||||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||||
util/deviceiter.c \
|
util/deviceiter.c \
|
||||||
util/misc.c
|
util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
||||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
||||||
|
@ -16,16 +16,15 @@ endif
|
||||||
|
|
||||||
# For grub-mkelfimage.
|
# For grub-mkelfimage.
|
||||||
bin_UTILITIES += grub-mkelfimage
|
bin_UTILITIES += grub-mkelfimage
|
||||||
grub_mkelfimage_SOURCES = gnulib/progname.c \
|
grub_mkelfimage_SOURCES = gnulib/progname.c util/elf/grub-mkimage.c \
|
||||||
util/elf/grub-mkimage.c util/misc.c \
|
util/misc.c kern/emu/misc.c util/resolve.c
|
||||||
util/resolve.c
|
|
||||||
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# For grub-probe.
|
# For grub-probe.
|
||||||
sbin_UTILITIES += grub-probe
|
sbin_UTILITIES += grub-probe
|
||||||
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
||||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||||
util/hostdisk.c util/misc.c util/getroot.c util/mm.c \
|
kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c \
|
||||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
||||||
\
|
\
|
||||||
|
@ -60,8 +59,8 @@ grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||||
|
|
||||||
# For grub-fstest.
|
# For grub-fstest.
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
||||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \
|
||||||
util/misc.c util/mm.c \
|
util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
||||||
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
||||||
|
@ -83,14 +82,14 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
||||||
# For grub-mkfont.
|
# For grub-mkfont.
|
||||||
ifeq ($(enable_grub_mkfont), yes)
|
ifeq ($(enable_grub_mkfont), yes)
|
||||||
bin_UTILITIES += grub-mkfont
|
bin_UTILITIES += grub-mkfont
|
||||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c
|
||||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
grub_mkfont_CFLAGS = $(freetype_cflags)
|
||||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
grub_mkfont_LDFLAGS = $(freetype_libs)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# For grub-mkrelpath.
|
# For grub-mkrelpath.
|
||||||
bin_UTILITIES += grub-mkrelpath
|
bin_UTILITIES += grub-mkrelpath
|
||||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
bin_UTILITIES += grub-bin2h
|
bin_UTILITIES += grub-bin2h
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||||
|
@ -104,7 +103,7 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
bin_UTILITIES += grub-script-check
|
bin_UTILITIES += grub-script-check
|
||||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||||
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
||||||
util/grub-script-check.c util/misc.c util/mm.c \
|
util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
script/main.c script/script.c script/function.c script/lexer.c \
|
script/main.c script/script.c script/function.c script/lexer.c \
|
||||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||||
|
@ -187,7 +186,7 @@ DISTCLEANFILES += grub_fstest_init.c
|
||||||
|
|
||||||
# for grub-editenv
|
# for grub-editenv
|
||||||
bin_UTILITIES += grub-editenv
|
bin_UTILITIES += grub-editenv
|
||||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c util/mm.c kern/misc.c kern/err.c
|
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/misc.c kern/err.c
|
||||||
CLEANFILES += grub-editenv
|
CLEANFILES += grub-editenv
|
||||||
|
|
||||||
# Needed for genmk.rb to work
|
# Needed for genmk.rb to work
|
||||||
|
@ -195,7 +194,7 @@ ifeq (0,1)
|
||||||
bin_UTILITIES += grub-macho2img grub-pe2elf
|
bin_UTILITIES += grub-macho2img grub-pe2elf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c
|
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c kern/emu/misc.c
|
||||||
CLEANFILES += grub-pe2elf
|
CLEANFILES += grub-pe2elf
|
||||||
|
|
||||||
grub_macho2img_SOURCES = util/grub-macho2img.c
|
grub_macho2img_SOURCES = util/grub-macho2img.c
|
||||||
|
@ -861,7 +860,7 @@ boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
||||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c util/mm.c kern/err.c
|
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/err.c
|
||||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
||||||
|
|
||||||
include $(srcdir)/conf/gcry.mk
|
include $(srcdir)/conf/gcry.mk
|
||||||
|
|
|
@ -67,30 +67,29 @@ sbin_UTILITIES = grub-setup
|
||||||
|
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
kern/emu/misc.c util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# For grub-setup.
|
# For grub-setup.
|
||||||
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||||
grub_setup_SOURCES = gnulib/progname.c \
|
grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c \
|
||||||
util/i386/pc/grub-setup.c util/hostdisk.c \
|
util/misc.c kern/emu/misc.c kern/emu/getroot.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/misc.c kern/parser.c kern/partition.c kern/file.c \
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
kern/emu/mm.c kern/fs.c kern/env.c kern/list.c fs/fshelp.c \
|
||||||
fs/fshelp.c \
|
\
|
||||||
\
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
\
|
||||||
\
|
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
||||||
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
partmap/gpt.c \
|
||||||
partmap/gpt.c \
|
\
|
||||||
\
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
util/raid.c util/lvm.c \
|
||||||
util/raid.c util/lvm.c util/mm.c \
|
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
|
|
|
@ -14,7 +14,7 @@ boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LI
|
||||||
boot_img_FORMAT = binary
|
boot_img_FORMAT = binary
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkimage
|
bin_UTILITIES += grub-mkimage
|
||||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c kern/emu/misc.c \
|
||||||
util/resolve.c gnulib/progname.c
|
util/resolve.c gnulib/progname.c
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
|
@ -13,7 +13,7 @@ bin_SCRIPTS =
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
bin_UTILITIES += grub-mkimage
|
bin_UTILITIES += grub-mkimage
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
kern/emu/misc.c util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
|
|
|
@ -44,34 +44,34 @@ bin_UTILITIES = grub-mkimage
|
||||||
sbin_UTILITIES = grub-setup grub-ofpathname
|
sbin_UTILITIES = grub-setup grub-ofpathname
|
||||||
|
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c kern/emu/misc.c \
|
||||||
util/resolve.c gnulib/progname.c
|
util/resolve.c gnulib/progname.c
|
||||||
|
|
||||||
# For grub-setup.
|
# For grub-setup.
|
||||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c \
|
||||||
util/ieee1275/ofpath.c \
|
util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/disk.c kern/err.c kern/misc.c kern/parser.c \
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
kern/partition.c kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||||
fs/fshelp.c \
|
fs/fshelp.c \
|
||||||
\
|
\
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
||||||
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
||||||
\
|
\
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c util/raid.c \
|
||||||
util/raid.c util/lvm.c util/mm.c gnulib/progname.c \
|
util/lvm.c gnulib/progname.c grub_setup_init.c
|
||||||
grub_setup_init.c
|
|
||||||
|
|
||||||
# For grub-ofpathname.
|
# For grub-ofpathname.
|
||||||
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
||||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
util/ieee1275/ofpath.c util/misc.c kern/emu/misc.c \
|
||||||
|
gnulib/progname.c
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
sbin_SCRIPTS = grub-install
|
sbin_SCRIPTS = grub-install
|
||||||
|
|
|
@ -5,7 +5,7 @@ bin_UTILITIES = grub-mkimage
|
||||||
|
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
||||||
util/misc.c util/resolve.c
|
util/misc.c kern/emu/misc.c util/resolve.c
|
||||||
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/lvm.h>
|
#include <grub/lvm.h>
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct grub_lvm_vg *vg_list;
|
static struct grub_lvm_vg *vg_list;
|
||||||
|
|
|
@ -96,23 +96,8 @@ void grub_dl_unload_all (void);
|
||||||
#else
|
#else
|
||||||
#define GRUB_NO_MODULES 0
|
#define GRUB_NO_MODULES 0
|
||||||
#endif
|
#endif
|
||||||
#if GRUB_NO_MODULES
|
|
||||||
static inline int
|
|
||||||
grub_dl_ref (grub_dl_t mod)
|
|
||||||
{
|
|
||||||
(void) mod;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static inline int
|
|
||||||
grub_dl_unref (grub_dl_t mod)
|
|
||||||
{
|
|
||||||
(void) mod;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||||
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
||||||
#endif
|
|
||||||
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
|
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
|
||||||
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
||||||
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
||||||
|
|
50
include/grub/emu/misc.h
Normal file
50
include/grub/emu/misc.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef GRUB_EMU_MISC_H
|
||||||
|
#define GRUB_EMU_MISC_H 1
|
||||||
|
|
||||||
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
# include <sys/fcntl.h>
|
||||||
|
# include <sys/cygwin.h>
|
||||||
|
# include <limits.h>
|
||||||
|
# define DEV_CYGDRIVE_MAJOR 98
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
extern const char *program_name;
|
||||||
|
|
||||||
|
void grub_init_all (void);
|
||||||
|
void grub_fini_all (void);
|
||||||
|
|
||||||
|
char *grub_make_system_path_relative_to_its_root (const char *path);
|
||||||
|
|
||||||
|
void * EXPORT_FUNC(xmalloc) (grub_size_t size);
|
||||||
|
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size);
|
||||||
|
char * EXPORT_FUNC(xstrdup) (const char *str);
|
||||||
|
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||||
|
|
||||||
|
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
||||||
|
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
||||||
|
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
int EXPORT_FUNC(vasprintf) (char **buf, const char *fmt, va_list ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif /* GRUB_EMU_MISC_H */
|
|
@ -28,26 +28,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#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"
|
|
||||||
|
|
||||||
extern char *progname;
|
|
||||||
extern int verbosity;
|
|
||||||
|
|
||||||
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
|
||||||
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
|
||||||
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
void *xmalloc (size_t size);
|
|
||||||
void *xrealloc (void *ptr, size_t size);
|
|
||||||
char *xstrdup (const char *str);
|
|
||||||
|
|
||||||
char *grub_util_get_path (const char *dir, const char *file);
|
char *grub_util_get_path (const char *dir, const char *file);
|
||||||
size_t grub_util_get_fp_size (FILE *fp);
|
size_t grub_util_get_fp_size (FILE *fp);
|
||||||
|
@ -59,20 +40,6 @@ void grub_util_write_image (const char *img, size_t size, FILE *out);
|
||||||
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
||||||
FILE *out);
|
FILE *out);
|
||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
|
||||||
|
|
||||||
int vasprintf (char **buf, const char *fmt, va_list ap);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int asprintf (char **buf, const char *fmt, ...);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *xasprintf (const char *fmt, ...);
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
#define fseeko fseeko64
|
#define fseeko fseeko64
|
||||||
|
|
|
@ -469,12 +469,14 @@ grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !GRUB_NO_MODULES
|
|
||||||
int
|
int
|
||||||
grub_dl_ref (grub_dl_t mod)
|
grub_dl_ref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_ref (dep->mod);
|
grub_dl_ref (dep->mod);
|
||||||
|
|
||||||
|
@ -486,12 +488,14 @@ grub_dl_unref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_unref (dep->mod);
|
grub_dl_unref (dep->mod);
|
||||||
|
|
||||||
return --mod->ref_count;
|
return --mod->ref_count;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_dl_flush_cache (grub_dl_t mod)
|
grub_dl_flush_cache (grub_dl_t mod)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
# define A_STANDOUT 0
|
# define A_STANDOUT 0
|
||||||
#endif /* ! A_STANDOUT */
|
#endif /* ! A_STANDOUT */
|
||||||
|
|
||||||
#include <grub/util/console.h>
|
#include <grub/emu/console.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#ifdef __CYGWIN__
|
#include <stdio.h>
|
||||||
# include <sys/fcntl.h>
|
#include <stdlib.h>
|
||||||
# include <sys/cygwin.h>
|
#include <stdint.h>
|
||||||
# include <limits.h>
|
|
||||||
# define DEV_CYGDRIVE_MAJOR 98
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNU__
|
#ifdef __GNU__
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
|
@ -36,9 +35,11 @@
|
||||||
#include <hurd/fs.h>
|
#include <hurd/fs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <grub/util/misc.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/misc.h>
|
||||||
|
#include <grub/emu/hostdisk.h>
|
||||||
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
strip_extra_slashes (char *dir)
|
strip_extra_slashes (char *dir)
|
||||||
|
@ -540,4 +541,3 @@ grub_util_check_char_device (const char *blk_dev)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/list.h>
|
#include <grub/list.h>
|
|
@ -16,7 +16,10 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -24,16 +27,17 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/setjmp.h>
|
#include <grub/setjmp.h>
|
||||||
#include <grub/fs.h>
|
#include <grub/fs.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/time.h>
|
||||||
#include <grub/util/console.h>
|
#include <grub/emu/console.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
@ -242,7 +246,7 @@ main (int argc, char *argv[])
|
||||||
if (strcmp (root_dev, "host") == 0)
|
if (strcmp (root_dev, "host") == 0)
|
||||||
dir = xstrdup (dir);
|
dir = xstrdup (dir);
|
||||||
else
|
else
|
||||||
dir = make_system_path_relative_to_its_root (dir);
|
dir = grub_make_system_path_relative_to_its_root (dir);
|
||||||
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
||||||
sprintf (prefix, "(%s)%s", root_dev, dir);
|
sprintf (prefix, "(%s)%s", root_dev, dir);
|
||||||
free (dir);
|
free (dir);
|
||||||
|
@ -261,3 +265,32 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
Sleep (ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ts.tv_sec = ms / 1000;
|
||||||
|
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||||
|
nanosleep (&ts, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if GRUB_NO_MODULES
|
||||||
|
void
|
||||||
|
grub_register_exported_symbols (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
296
kern/emu/misc.c
Normal file
296
kern/emu/misc.c
Normal file
|
@ -0,0 +1,296 @@
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/time.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_warn (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: warn:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_info (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
if (verbosity > 0)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: info:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_error (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: error:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xmalloc (grub_size_t size)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
p = malloc (size);
|
||||||
|
if (! p)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xrealloc (void *ptr, grub_size_t size)
|
||||||
|
{
|
||||||
|
ptr = realloc (ptr, size);
|
||||||
|
if (! ptr)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xstrdup (const char *str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *newstr;
|
||||||
|
|
||||||
|
len = strlen (str);
|
||||||
|
newstr = (char *) xmalloc (len + 1);
|
||||||
|
memcpy (newstr, str, len + 1);
|
||||||
|
|
||||||
|
return newstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
vasprintf (char **buf, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
/* Should be large enough. */
|
||||||
|
*buf = xmalloc (512);
|
||||||
|
|
||||||
|
return vsprintf (*buf, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
asprintf (char **buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
status = vasprintf (*buf, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *
|
||||||
|
xasprintf (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
if (vasprintf (&result, fmt, ap) < 0)
|
||||||
|
{
|
||||||
|
if (errno == ENOMEM)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_exit (void)
|
||||||
|
{
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint64_t
|
||||||
|
grub_get_time_ms (void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday (&tv, 0);
|
||||||
|
|
||||||
|
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint32_t
|
||||||
|
grub_get_rtc (void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday (&tv, 0);
|
||||||
|
|
||||||
|
return (tv.tv_sec * GRUB_TICKS_PER_SECOND
|
||||||
|
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
||||||
|
* GRUB_TICKS_PER_SECOND / 1000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
/* Convert POSIX path to Win32 path,
|
||||||
|
remove drive letter, replace backslashes. */
|
||||||
|
static char *
|
||||||
|
get_win32_path (const char *path)
|
||||||
|
{
|
||||||
|
char winpath[PATH_MAX];
|
||||||
|
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
|
||||||
|
grub_util_error ("cygwin_conv_path() failed");
|
||||||
|
|
||||||
|
int len = strlen (winpath);
|
||||||
|
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = offs; i < len; i++)
|
||||||
|
if (winpath[i] == '\\')
|
||||||
|
winpath[i] = '/';
|
||||||
|
return xstrdup (winpath + offs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This function never prints trailing slashes (so that its output
|
||||||
|
can be appended a slash unconditionally). */
|
||||||
|
char *
|
||||||
|
grub_make_system_path_relative_to_its_root (const char *path)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *p, *buf, *buf2, *buf3;
|
||||||
|
uintptr_t offset = 0;
|
||||||
|
dev_t num;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* canonicalize. */
|
||||||
|
p = canonicalize_file_name (path);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
grub_util_error ("failed to get canonical path of %s", path);
|
||||||
|
|
||||||
|
len = strlen (p) + 1;
|
||||||
|
buf = xstrdup (p);
|
||||||
|
free (p);
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
buf2 = xstrdup (buf);
|
||||||
|
num = st.st_dev;
|
||||||
|
|
||||||
|
/* This loop sets offset to the number of chars of the root
|
||||||
|
directory we're inspecting. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
p = strrchr (buf, '/');
|
||||||
|
if (p == NULL)
|
||||||
|
/* This should never happen. */
|
||||||
|
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
||||||
|
if (p != buf)
|
||||||
|
*p = 0;
|
||||||
|
else
|
||||||
|
*++p = 0;
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
/* buf is another filesystem; we found it. */
|
||||||
|
if (st.st_dev != num)
|
||||||
|
{
|
||||||
|
/* offset == 0 means path given is the mount point.
|
||||||
|
This works around special-casing of "/" in Un*x. This function never
|
||||||
|
prints trailing slashes (so that its output can be appended a slash
|
||||||
|
unconditionally). Each slash in is considered a preceding slash, and
|
||||||
|
therefore the root directory is an empty string. */
|
||||||
|
if (offset == 0)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
free (buf2);
|
||||||
|
return xstrdup ("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = p - buf;
|
||||||
|
/* offset == 1 means root directory. */
|
||||||
|
if (offset == 1)
|
||||||
|
{
|
||||||
|
/* Include leading slash. */
|
||||||
|
offset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (buf);
|
||||||
|
buf3 = xstrdup (buf2 + offset);
|
||||||
|
free (buf2);
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||||
|
{
|
||||||
|
/* Reached some mount point not below /cygdrive.
|
||||||
|
GRUB does not know Cygwin's emulated mounts,
|
||||||
|
convert to Win32 path. */
|
||||||
|
grub_util_info ("Cygwin path = %s\n", buf3);
|
||||||
|
char * temp = get_win32_path (buf3);
|
||||||
|
free (buf3);
|
||||||
|
buf3 = temp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Remove trailing slashes, return empty string if root directory. */
|
||||||
|
len = strlen (buf3);
|
||||||
|
while (len > 0 && buf3[len - 1] == '/')
|
||||||
|
{
|
||||||
|
buf3[len - 1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf3;
|
||||||
|
}
|
|
@ -17,7 +17,9 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
@ -97,7 +99,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
argument = argv[optind];
|
argument = argv[optind];
|
||||||
|
|
||||||
relpath = make_system_path_relative_to_its_root (argument);
|
relpath = grub_make_system_path_relative_to_its_root (argument);
|
||||||
printf ("%s\n", relpath);
|
printf ("%s\n", relpath);
|
||||||
free (relpath);
|
free (relpath);
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,15 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/util/misc.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/fs.h>
|
#include <grub/fs.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/raid.h>
|
#include <grub/raid.h>
|
||||||
|
@ -261,7 +262,7 @@ probe (const char *path, char *device_name)
|
||||||
grub_util_info ("reading %s via OS facilities", path);
|
grub_util_info ("reading %s via OS facilities", path);
|
||||||
filebuf_via_sys = grub_util_read_image (path);
|
filebuf_via_sys = grub_util_read_image (path);
|
||||||
|
|
||||||
rel_path = make_system_path_relative_to_its_root (path);
|
rel_path = grub_make_system_path_relative_to_its_root (path);
|
||||||
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
||||||
free (rel_path);
|
free (rel_path);
|
||||||
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
||||||
|
|
|
@ -28,14 +28,14 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/gpt_partition.h>
|
#include <grub/gpt_partition.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/util/raid.h>
|
#include <grub/util/raid.h>
|
||||||
#include <grub/util/lvm.h>
|
#include <grub/util/lvm.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ unable_to_embed:
|
||||||
/* Make sure that GRUB reads the identical image as the OS. */
|
/* Make sure that GRUB reads the identical image as the OS. */
|
||||||
tmp_img = xmalloc (core_size);
|
tmp_img = xmalloc (core_size);
|
||||||
core_path_dev_full = grub_util_get_path (dir, core_file);
|
core_path_dev_full = grub_util_get_path (dir, core_file);
|
||||||
core_path_dev = make_system_path_relative_to_its_root (core_path_dev_full);
|
core_path_dev = grub_make_system_path_relative_to_its_root (core_path_dev_full);
|
||||||
free (core_path_dev_full);
|
free (core_path_dev_full);
|
||||||
|
|
||||||
/* It is a Good Thing to sync two times. */
|
/* It is a Good Thing to sync two times. */
|
||||||
|
|
295
util/misc.c
295
util/misc.c
|
@ -53,63 +53,11 @@
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
# include <sys/cygwin.h>
|
|
||||||
# define DEV_CYGDRIVE_MAJOR 98
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int verbosity = 0;
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_warn (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: warn:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
fflush (stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_info (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
if (verbosity > 0)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: info:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
fflush (stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_error (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: error:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
int
|
int
|
||||||
grub_err_printf (const char *fmt, ...)
|
grub_err_printf (const char *fmt, ...)
|
||||||
|
@ -125,41 +73,6 @@ grub_err_printf (const char *fmt, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *
|
|
||||||
xmalloc (size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
p = malloc (size);
|
|
||||||
if (! p)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xrealloc (void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
ptr = realloc (ptr, size);
|
|
||||||
if (! ptr)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xstrdup (const char *str)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
char *newstr;
|
|
||||||
|
|
||||||
len = strlen (str);
|
|
||||||
newstr = (char *) xmalloc (len + 1);
|
|
||||||
memcpy (newstr, str, len + 1);
|
|
||||||
|
|
||||||
return newstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
grub_util_get_path (const char *dir, const char *file)
|
grub_util_get_path (const char *dir, const char *file)
|
||||||
{
|
{
|
||||||
|
@ -282,34 +195,6 @@ grub_register_exported_symbols (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
grub_exit (void)
|
|
||||||
{
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_uint32_t
|
|
||||||
grub_get_rtc (void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
gettimeofday (&tv, 0);
|
|
||||||
|
|
||||||
return (tv.tv_sec * GRUB_TICKS_PER_SECOND
|
|
||||||
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
|
||||||
* GRUB_TICKS_PER_SECOND / 1000000));
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_uint64_t
|
|
||||||
grub_get_time_ms (void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
gettimeofday (&tv, 0);
|
|
||||||
|
|
||||||
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -340,53 +225,6 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
|
||||||
|
|
||||||
int
|
|
||||||
vasprintf (char **buf, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
/* Should be large enough. */
|
|
||||||
*buf = xmalloc (512);
|
|
||||||
|
|
||||||
return vsprintf (*buf, fmt, ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int
|
|
||||||
asprintf (char **buf, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
status = vasprintf (*buf, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *
|
|
||||||
xasprintf (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
if (vasprintf (&result, fmt, ap) < 0)
|
|
||||||
{
|
|
||||||
if (errno == ENOMEM)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
void sync (void)
|
void sync (void)
|
||||||
|
@ -461,125 +299,6 @@ canonicalize_file_name (const char *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
/* Convert POSIX path to Win32 path,
|
|
||||||
remove drive letter, replace backslashes. */
|
|
||||||
static char *
|
|
||||||
get_win32_path (const char *path)
|
|
||||||
{
|
|
||||||
char winpath[PATH_MAX];
|
|
||||||
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
|
|
||||||
grub_util_error ("cygwin_conv_path() failed");
|
|
||||||
|
|
||||||
int len = strlen (winpath);
|
|
||||||
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = offs; i < len; i++)
|
|
||||||
if (winpath[i] == '\\')
|
|
||||||
winpath[i] = '/';
|
|
||||||
return xstrdup (winpath + offs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This function never prints trailing slashes (so that its output
|
|
||||||
can be appended a slash unconditionally). */
|
|
||||||
char *
|
|
||||||
make_system_path_relative_to_its_root (const char *path)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
char *p, *buf, *buf2, *buf3;
|
|
||||||
uintptr_t offset = 0;
|
|
||||||
dev_t num;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* canonicalize. */
|
|
||||||
p = canonicalize_file_name (path);
|
|
||||||
|
|
||||||
if (p == NULL)
|
|
||||||
grub_util_error ("failed to get canonical path of %s", path);
|
|
||||||
|
|
||||||
len = strlen (p) + 1;
|
|
||||||
buf = xstrdup (p);
|
|
||||||
free (p);
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
buf2 = xstrdup (buf);
|
|
||||||
num = st.st_dev;
|
|
||||||
|
|
||||||
/* This loop sets offset to the number of chars of the root
|
|
||||||
directory we're inspecting. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
p = strrchr (buf, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
/* This should never happen. */
|
|
||||||
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
|
||||||
if (p != buf)
|
|
||||||
*p = 0;
|
|
||||||
else
|
|
||||||
*++p = 0;
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
/* buf is another filesystem; we found it. */
|
|
||||||
if (st.st_dev != num)
|
|
||||||
{
|
|
||||||
/* offset == 0 means path given is the mount point.
|
|
||||||
This works around special-casing of "/" in Un*x. This function never
|
|
||||||
prints trailing slashes (so that its output can be appended a slash
|
|
||||||
unconditionally). Each slash in is considered a preceding slash, and
|
|
||||||
therefore the root directory is an empty string. */
|
|
||||||
if (offset == 0)
|
|
||||||
{
|
|
||||||
free (buf);
|
|
||||||
free (buf2);
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = p - buf;
|
|
||||||
/* offset == 1 means root directory. */
|
|
||||||
if (offset == 1)
|
|
||||||
{
|
|
||||||
/* Include leading slash. */
|
|
||||||
offset = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free (buf);
|
|
||||||
buf3 = xstrdup (buf2 + offset);
|
|
||||||
free (buf2);
|
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
|
||||||
{
|
|
||||||
/* Reached some mount point not below /cygdrive.
|
|
||||||
GRUB does not know Cygwin's emulated mounts,
|
|
||||||
convert to Win32 path. */
|
|
||||||
grub_util_info ("Cygwin path = %s\n", buf3);
|
|
||||||
char * temp = get_win32_path (buf3);
|
|
||||||
free (buf3);
|
|
||||||
buf3 = temp;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Remove trailing slashes, return empty string if root directory. */
|
|
||||||
len = strlen (buf3);
|
|
||||||
while (len > 0 && buf3[len - 1] == '/')
|
|
||||||
{
|
|
||||||
buf3[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
void
|
void
|
||||||
grub_util_init_nls (void)
|
grub_util_init_nls (void)
|
||||||
|
@ -591,3 +310,17 @@ grub_util_init_nls (void)
|
||||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_dl_ref (grub_dl_t mod)
|
||||||
|
{
|
||||||
|
(void) mod;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_dl_unref (grub_dl_t mod)
|
||||||
|
{
|
||||||
|
(void) mod;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/gpt_partition.h>
|
#include <grub/gpt_partition.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
@ -627,8 +627,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
find_dest_dev (&ginfo, argv);
|
find_dest_dev (&ginfo, argv);
|
||||||
|
|
||||||
ginfo.prefix = make_system_path_relative_to_its_root (ginfo.dir ?
|
ginfo.prefix = grub_make_system_path_relative_to_its_root (ginfo.dir ?
|
||||||
: DEFAULT_DIRECTORY);
|
: DEFAULT_DIRECTORY);
|
||||||
|
|
||||||
check_root_dev (&ginfo);
|
check_root_dev (&ginfo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue