Commit graph

114 commits

Author SHA1 Message Date
Vladimir Serbinenko
a19293cb75 Move OS-dependent mprotect for module loading to grub-core/osdep/*/dl.c
and implement windows variant.
2013-12-08 18:08:23 +01:00
Colin Watson
59b38922a1 Pacify compiler warning
* grub-core/osdep/linux/hostdisk.c
(grub_util_find_partition_start_os): Initialise start to avoid
spurious compiler warning.
2013-12-05 15:48:27 +00:00
Colin Watson
0480665b9d On Linux, read partition start offsets from sysfs if possible
This lets us cope with block device drivers that don't implement
HDIO_GETGEO.  Fixes Ubuntu bug #1237519.

* grub-core/osdep/linux/hostdisk.c (sysfs_partition_path): New
function.
(sysfs_partition_start): Likewise.
(grub_util_find_partition_start_os): Try sysfs_partition_start
before HDIO_GETGEO.
2013-12-05 13:51:52 +00:00
Vladimir Serbinenko
cd15c394cc * grub-core/osdep/windows/emuconsole.c (grub_console_putchar):
Remove variable length arrays.
	* grub-core/term/efi/console.c (grub_console_putchar): Likewise.
2013-12-04 10:05:33 +01:00
Vladimir Serbinenko
d54f647a4a * grub-core/osdep/linux/ofpath.c: Check return value of read. 2013-11-29 05:46:19 +01:00
Vladimir Serbinenko
83c256ba42 * grub-core/osdep/unix/password.c (grub_password_get): Check that
fgets succeeded.
2013-11-29 03:32:57 +01:00
Vladimir Serbinenko
4f9541226c Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
2013-11-27 14:13:50 +01:00
Colin Watson
16ef26fd3a * grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove
references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
2013-11-27 11:22:31 +00:00
Colin Watson
5c7206e45e Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into
no-ops, and use it in programs that copy files but do not need to take
special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).

On my laptop, this reduces partmap_test's runtime from 1236 seconds to
204 seconds.
2013-11-27 10:10:22 +00:00
Vladimir Serbinenko
61e1b9a49d * grub-core/osdep/unix/platform.c (get_ofpathname): Trim ending newline.
Don't rely on PATH_MAX.
2013-11-25 07:34:49 +01:00
Colin Watson
3bf4088b8b * grub-core/osdep/unix/hostdisk.c (grub_util_make_temporary_file):
Handle errors from mkstemp.
(grub_util_make_temporary_dir): Handle errors from mkdtemp.
2013-11-18 12:27:44 +00:00
Vladimir Serbinenko
cd46aa6cef Rewrite grub-install, grub-mkrescue, grub-mkstandalone and grub-mknetdir
the function of these files exceeds what can be sanely handled in shell
	in posix-comaptible way. Also writing it in C extends the functionality
	to non-UNIX-like OS and minimal environments.
2013-11-16 20:21:16 +01:00
Vladimir Serbinenko
da5ed5cf6b * grub-core/osdep/bsd/hostdisk.c (grub_util_get_fd_size_os): Fix
compilation on NetBSD.
2013-11-14 22:38:36 +01:00
Colin Watson
9b45c0733e * grub-core/osdep/unix/emuconsole.c (put): Pacify the compiler on
systems that require checking the return value of write.
2013-11-13 13:34:57 +00:00
Vladimir Serbinenko
08772054e9 * grub-core/osdep/windows/hostdisk.c (grub_util_fd_strerror): Silence
strict-aliasing warning.
	(fsync): Silence cast warning.
2013-11-12 16:09:42 +01:00
Vladimir Serbinenko
6a74c4dfff * grub-core/osdep/unix/getroot.c [HAVE_STRUCT_STATFS_F_FSTYPENAME
&& HAVE_STRUCT_STATFS_F_MNTFROMNAME]: Include sys/param.h and
	sys/mount.h.
2013-11-11 23:10:30 +01:00
Vladimir Serbinenko
394c3e0ac2 * grub-core/osdep/apple/hostdisk.c (grub_util_get_fd_size): Rename to ..
(grub_util_get_fd_size_os): ...this.
	(grub_hostdisk_flush_initial_buffer): New empty function.
2013-11-11 23:08:51 +01:00
Vladimir Serbinenko
090d7c81cf * grub-core/osdep/linux/getroot.c: Fix cast-align problems. 2013-11-03 00:43:49 +01:00
neil
a86865891a * grub-core/osdep/linux/blocklist.c: Include linux/types.h for some
broken linux headers.
2013-11-02 22:19:34 +01:00
Vladimir Serbinenko
cb72aa1809 Rewrite blocklist functions in order to get progress when
reading large extents and decrease amount of blocklist hook calls.
2013-11-01 23:28:03 +01:00
Vladimir Serbinenko
effe203677 * grub-core/osdep/linux/getroot.c: Add new btrfs defines. 2013-10-28 01:45:06 +01:00
Vladimir Serbinenko
82591fa6e7 Make / in btrfs refer to real root, not the default volume.
Modify mkrelpath to work even if device is mounted with subvolid option.
2013-10-28 01:37:19 +01:00
Paulo Flabiano Smorigo
84a0e9699f Add progress module to display load progress of files.
* grub-core/lib/progress.c: New file.
	* grub-core/Makefile.core.def (progress): New module.
	* grub-core/kern/file.c (grub_file_open): File name added.
	* (grub_file_read): Progress hook added.
	* grub-core/fs/cbfs.c (grub_cbfs_read): Likewise.
	* grub-core/fs/cpio_common.c (grub_cpio_read): Likewise.
	* grub-core/net/net.c (grub_net_fs_read_real): Likewise.
	* include/grub/file.h (struct grub_file): Add progress module
	* members.
	* include/grub/term.h (struct grub_term_output): Likewise.
	* grub-core/osdep/unix/emuconsole.c (grub_console_term_output):
	Terminal velocity added.
	* grub-core/osdep/windows/emuconsole.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/arc/console.c (grub_console_term_output): Likewise.
	* grub-core/term/efi/console.c (grub_console_term_output): Likewise.
	* grub-core/term/gfxterm.c (grub_video_term): Likewise.
	* grub-core/term/i386/coreboot/cbmemc.c (grub_cbmemc_term_output):
	* Likewise.
	* grub-core/term/i386/pc/console.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/i386/pc/vga_text.c (grub_vga_text_term): Likewise.
	* grub-core/term/ieee1275/console.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/morse.c (grub_audio_term_output): Likewise.
	* grub-core/term/serial.c (grub_serial_term_output): Likewise.
	* grub-core/term/spkmodem.c (grub_spkmodem_term_output): Likewise.
	* grub-core/term/uboot/console.c (uboot_console_term_output):
	* Likewise.
2013-10-22 16:42:20 -02:00
Vladimir 'phcoder' Serbinenko
e89c2d48a9 Lift 255x255 erminal sie restriction to 65535x65535. Also change from
bitmasks to small structures of size chosen to fit in registers.
2013-10-19 23:59:32 +02:00
Vladimir 'phcoder' Serbinenko
518864c05b * grub-core/osdep/unix/exec.c: Fix compilation error on emu. 2013-10-19 23:53:48 +02:00
Vladimir 'phcoder' Serbinenko
2028576504 Add haiku-specific functions. 2013-10-19 16:39:38 +02:00
Vladimir 'phcoder' Serbinenko
cd78a56fb2 Move stat () and device mode checking into OS-dependent files as
long as performance doesn't suffer.
2013-10-19 16:29:20 +02:00
Vladimir 'phcoder' Serbinenko
a4012f0764 Split make_system_path_relative_to_its_root into separate file
relpath.c from getroot.c as it's common between unix and haiku
	but otherwise haiku doesn't use any functions from unix getroot.c.
2013-10-19 16:21:08 +02:00
Vladimir 'phcoder' Serbinenko
31de274d29 * grub-core/osdep/aros/hostdisk.c (grub_util_is_directory):
New function.
	(grub_util_is_special_file): Likewise.
2013-10-19 16:14:30 +02:00
Vladimir 'phcoder' Serbinenko
40346de6d3 * grub-core/osdep/unix/getroot.c: Move exec functions to ...
* osdep/unix/exec.c: ... here. Add few additional exec_* variants.
2013-10-19 02:56:40 +02:00
Vladimir 'phcoder' Serbinenko
d0a116ee5a * grub-core/osdep/random.c: Use unix/random.c on haiku. Haiku uses
yarrow (by B. Schneier et al) for its /dev/urandom (similar to FreeBSD).
2013-10-19 02:30:05 +02:00
Vladimir 'phcoder' Serbinenko
b47fcae6cb * grub-core/osdep/generic/blocklist.c: Add missing include to string.h. 2013-10-19 02:24:40 +02:00
Vladimir 'phcoder' Serbinenko
f90a3cc0a8 * grub-core/osdep/unix/getroot.c (grub_util_check_block_device): Remove.
(grub_util_check_char_device): Likewise.
	* include/grub/emu/getroot.h: Likewise.
2013-10-19 00:51:08 +02:00
Vladimir 'phcoder' Serbinenko
669fc44923 * grub-core/osdep/unix/hostdisk.c (grub_util_fd_read): Return correct
value in case of incomplete read.
	(grub_util_fd_write): Likewise.
2013-10-16 00:20:07 +02:00
Vladimir 'phcoder' Serbinenko
f7c4957068 * grub-core/osdep/unix/getroot.c (grub_guess_root_devices):
canonicalize file name before doing the rest.
2013-10-15 21:04:10 +02:00
Vladimir 'phcoder' Serbinenko
df1e64c98e Define grub_util_is_directory/regular/special_file and
use OS-dependent versions rather than to rely on stat().
2013-10-15 20:27:58 +02:00
Vladimir 'phcoder' Serbinenko
f4e0adc0f9 Remove leftover references to some of the system headers. 2013-10-15 17:59:54 +02:00
Vladimir 'phcoder' Serbinenko
5a869940de Split out blocklist retrieving from setup.c to
grub-core/osdep/blocklist.c and add windows implementation since
	generic version doesn't work on NTFS on Windows due to aggressive
	unflushable cache.
2013-10-15 17:02:26 +02:00
Vladimir 'phcoder' Serbinenko
8f53bb3fd2 * grub-core/osdep/windows/hostdisk.c (grub_util_fd_strerror):
Cut tailing newline. Remove arbitrary limitation. Always use
	grub_util_tchar_to_utf8.
2013-10-15 15:14:58 +02:00
Vladimir 'phcoder' Serbinenko
af3b06be14 * grub-core/osdep/windows/hostdisk.c (fsync) [__MINGW32__]: Really
implement fsync.
2013-10-15 15:06:20 +02:00
Vladimir 'phcoder' Serbinenko
f6a81f0aaf Add wrappers around rename, unlink, mkdir, opendir, readdir and
closedir to handle filename charset translation.
2013-10-15 14:11:34 +02:00
Vladimir 'phcoder' Serbinenko
2859196e5f * grub-core/osdep/windows/hostdisk.c (canonicalize_file_name): Handle
unicode path.
2013-10-15 13:34:03 +02:00
Vladimir 'phcoder' Serbinenko
7e45abcef4 Move cpu time retrieval to separate grub_util_get_cpu_time_ms
and remove export.h.
2013-10-15 13:13:53 +02:00
Vladimir 'phcoder' Serbinenko
c11ebcc84f * grub-core/osdep/windows/emuconsole.c: Add missing config.h and
config-util.h include.
2013-10-15 12:43:52 +02:00
Vladimir 'phcoder' Serbinenko
70671037c8 Split emunet into platform-dependent and GRUB-binding parts. Keep
platform-dependent part in kernel for easy access to OS functions.
2013-10-15 11:55:20 +02:00
Vladimir 'phcoder' Serbinenko
25ac643a54 * grub-core/tests/video_checksum.c: Use grub_util_fd_* rather than
open/read/write.
2013-10-15 11:06:57 +02:00
Vladimir 'phcoder' Serbinenko
69ca587652 * grub-core/osdep/windows/emuconsole.c: New file. 2013-10-14 21:33:55 +02:00
Vladimir 'phcoder' Serbinenko
b73249d260 Make grub_util_fd_seek match behaviour of other grub_util_fd_* and
fseeko.
2013-10-14 12:47:09 +02:00
Vladimir 'phcoder' Serbinenko
6de292cb9b Define GRUB_UTIL_FD_O_* and always use them with grub_util_fd_open. 2013-10-14 02:11:59 +02:00
Vladimir 'phcoder' Serbinenko
21d85db12f * grub-core/Makefile.core.def: Add osdep/init.c on emu.
* grub-core/kern/emu/main.c: Add missing include.
	* grub-core/osdep/basic/init.c (grub_util_host_init) [!GRUB_UTIL]:
	Don't call grub_util_init_nls.
	* grub-core/osdep/windows/init.c (grub_util_host_init) [!GRUB_UTIL]:
	Likewise.
2013-10-14 02:06:43 +02:00
Vladimir 'phcoder' Serbinenko
bb338aaf24 Add a wrapper for fopen. On unix-like systems just pass-through. On
windows use unicode version.
2013-10-13 20:36:28 +02:00
Vladimir 'phcoder' Serbinenko
ae5540d3d4 Move set_program_name and init_nls to host_init. On windows
fix in this fuction console and argument charset as well.
2013-10-13 20:03:42 +02:00
Vladimir 'phcoder' Serbinenko
2fe53a22b8 * grub-core/osdep/aros/getroot.c: Change to //: prefix as discussed
with AROS devs.
	* grub-core/osdep/aros/hostdisk.c: Likewise.
2013-10-10 09:21:33 +02:00
Vladimir 'phcoder' Serbinenko
37149a2f20 * include/grub/emu/hostdisk.h (grub_hostdisk_linux_find_partition):
Removed.
	* grub-core/osdep/linux/hostdisk.c (grub_hostdisk_linux_find_partition):
	Made static.
2013-10-09 07:16:20 +02:00
Vladimir 'phcoder' Serbinenko
caca1c70cf Move OS-specific driver configuration to grub_util_fd_open. This
moves OS-dependent parts from kern/emu/hostdisk.c to
	grub-core/osdep/*/hostdisk.c.
2013-10-09 07:04:25 +02:00
Vladimir 'phcoder' Serbinenko
b102ce6909 * grub-core/osdep/basic/random.c: New file. Abort on an attempt to
get random when no RNG is available.
	* grub-core/osdep/random.c: Use basic/random.c on OS out of whitelist.
2013-10-08 21:28:14 +02:00
Vladimir 'phcoder' Serbinenko
acbbe5cbad * include/grub/util/lvm.h: Removed. 2013-10-08 21:01:09 +02:00
Vladimir 'phcoder' Serbinenko
2112fb3fef * grub-core/kern/emu/misc.c (fsync) [__MINGW32__]: Move to ...
* grub-core/osdep/windows/hostdisk.c (fsync) [__MINGW32__]: ... here.
2013-10-08 20:05:24 +02:00
Vladimir 'phcoder' Serbinenko
79f78fbf06 * grub-core/osdep/windows/sleep.c: Add missing config.h. 2013-10-08 20:02:07 +02:00
Vladimir 'phcoder' Serbinenko
aabe433afe * grub-core/net/drivers/emu/emunet.c: Move to ..
* grub-core/osdep/linux/emunet.c: ..here.
2013-10-08 18:42:46 +02:00
Vladimir 'phcoder' Serbinenko
9a2c903f28 * util/ieee1275/ofpath.c: Move to ...
* grub-core/osdep/linux/ofpath.c: ..here, split stub into ...
	* grub-core/osdep/basic/ofpath.c: ..here.
2013-10-08 18:25:49 +02:00
Vladimir 'phcoder' Serbinenko
4a445f580b Move password-querying (util-version) routines to grub-core/osdep. 2013-10-08 17:51:39 +02:00
Vladimir 'phcoder' Serbinenko
c1ca424476 Move sleep routines to grub-core/osdep. 2013-10-08 17:38:46 +02:00
Vladimir 'phcoder' Serbinenko
672fa55e81 Move OS-dependent files to grub-core/osdep and document it. 2013-10-08 17:30:22 +02:00