Commit graph

114 commits

Author SHA1 Message Date
Vladimir Serbinenko
18e76955be Use %I64 and not %ll when using OS printf if compiling for windows. 2013-12-17 16:04:47 +01: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
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
64db14b0cb * grub-core/kern/emu/hostdisk.c (grub_util_check_file_presence): Use
windows method on other platforms without good stat as well.
2013-10-28 02:17:56 +01:00
Vladimir 'phcoder' Serbinenko
887c0bb61a * grub-core/kern/emu/hostdisk.c: Remove few leftover includes. 2013-10-19 16:32:28 +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
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
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
bab7b1ebeb * include/grub/emu/hostdisk.h (GRUB_FD_STAT_IS_FUNTIONAL): New define.
Migrate all explicit defines to this new one.
2013-09-24 19:17:24 +02:00
Vladimir 'phcoder' Serbinenko
43b1c99d53 * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_open): Use
grub_util_fd_strerror when using grub_util_fd_*.
	(grub_util_fd_open_device): Likewise.
	(grub_util_biosdisk_read): Likewise.
	(grub_util_biosdisk_write): Likewise.
	* grub-core/kern/emu/hostdisk_unix.c (grub_util_fd_open): New function.
	(grub_util_fd_strerror): Likewise.
	(grub_util_fd_sync): Likewise.
	(grub_util_fd_close): Likewise.
	* grub-core/kern/emu/hostdisk_windows.c (grub_util_fd_sync): Likewise.
	(grub_util_fd_close): Likewise.
	(grub_util_fd_strerror): Likewise.
	* include/grub/emu/hostdisk.h (grub_util_fd_close): Make into real
	function proto rather than macro.
	(grub_util_fd_sync): Likewise.
	(grub_util_fd_open): Likewise.
	(grub_util_fd_strerror): New proto.
2013-09-24 19:08:34 +02:00
Vladimir 'phcoder' Serbinenko
bf645fda03 * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_open): Move struct
stat immediately to where it's used.
2013-09-24 18:57:19 +02:00
Vladimir 'phcoder' Serbinenko
9db826e149 * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_close): Fix
disk closing logic.
2013-09-24 18:36:51 +02:00
Vladimir 'phcoder' Serbinenko
7e518ca84f Use Winapi on both cygwin and mingw32 to share more code between both. 2013-09-23 11:21:09 +02:00
Vladimir 'phcoder' Serbinenko
3ff4063dd3 * grub-core/kern/emu/hostdisk.c: Disentagle into a series of OS-specific
files rather than one file with loads of #if's.
	* util/getroot.c: Likewise.
2013-09-22 07:36:17 +02:00
Vladimir 'phcoder' Serbinenko
386701a8fe Handle the case of partitioned LVM properly.
* grub-core/kern/emu/hostdisk.c (grub_util_get_dm_node_linear_info):
	Stop on meeting LVM, mpath or DMRAID.
	(grub_hostdisk_os_dev_to_grub_drive): Canonicalize os device.
	(read_device_map): Likewise.
	* util/getroot.c (convert_system_partition_to_system_disk): Assume that
	device is full disk rather than erroring out on LVM and similar cases.
2013-09-19 08:48:54 +02:00
Vladimir 'phcoder' Serbinenko
984cfd8a79 * grub-core/kern/emu/hostdisk.c (grub_util_get_fd_size): Adapt for
mingw32 as well based on grub_util_get_disk_size.
	* util/misc.c (grub_util_get_disk_size): Removed. all users switched to
	grub_util_get_fd_size.
	(sync): Removed.
	(fsync): Moved to ...
	* grub-core/kern/emu/misc.c (fsync): ... here.
2013-08-22 16:50:12 +02:00
Ilya Bakulin
0031b22993 * grub-core/kern/emu/hostdisk.c: Add conditionals for OpenBSD.
* util/getroot.c: Likewise.
2013-08-21 21:05:01 +02:00
Vladimir 'phcoder' Serbinenko
f0b94ded6d * grub-core/kern/emu/misc.c (grub_device_mapper_supported): Move from
here ...
	* grub-core/kern/emu/hostdisk.c (grub_device_mapper_supported): ... to
	here.
2013-08-14 17:55:15 +02:00
Vladimir 'phcoder' Serbinenko
053cfcddf1 Import new gnulib. 2013-04-11 21:12:46 +02:00
Vladimir 'phcoder' Serbinenko
49818a594a Fix missing PVs if they don't contain "interesting" LV. Closes #38677.
Fix few warining messages and leaks while on it.
2013-04-11 00:08:27 +02:00
Vladimir 'phcoder' Serbinenko
ca9c260868 * grub-core/kern/emu/hostdisk.c (read_device_map): Remove nested
function.
2013-03-01 13:46:24 +01:00
Colin Watson
25239370fd Remove nested functions from device iterators.
* include/grub/arc/arc.h (grub_arc_iterate_devs_hook_t): New type.
(grub_arc_iterate_devs): Add hook_data argument.
* include/grub/ata.h (grub_ata_dev_iterate_hook_t): New type.
(struct grub_ata_dev.iterate): Add hook_data argument.
* include/grub/device.h (grub_device_iterate_hook_t): New type.
(grub_device_iterate): Add hook_data argument.
* include/grub/disk.h (grub_disk_dev_iterate_hook_t): New type.
(struct grub_disk_dev.iterate): Add hook_data argument.
(grub_disk_dev_iterate): Likewise.
* include/grub/gpt_partition.h (grub_gpt_partition_map_iterate):
Likewise.
* include/grub/msdos_partition.h (grub_partition_msdos_iterate):
Likewise.
* include/grub/partition.h (grub_partition_iterate_hook_t): New
type.
(struct grub_partition_map.iterate): Add hook_data argument.
(grub_partition_iterate): Likewise.
* include/grub/scsi.h (grub_scsi_dev_iterate_hook_t): New type.
(struct grub_scsi_dev.iterate): Add hook_data argument.

Update all callers.
2013-01-20 15:52:15 +00:00
Vladimir 'phcoder' Serbinenko
22099030ad * grub-core/kern/emu/hostdisk.c (read_device_map): Explicitly
delimit path in strings using quotes.
	* util/getroot.c (grub_guess_root_devices): Likewise.
	(grub_make_system_path_relative_to_its_root): Likewise.
	* util/grub-probe.c (probe): Likewise.
	* util/ieee1275/ofpath.c (find_obppath): Likewise.
	(xrealpath): Likewise.
2013-01-13 22:45:16 +01:00
Grégoire Sutre
650cfcfea2 Fix overflow in grub_util_get_fd_size for NetBSD. 2012-06-25 10:09:57 +02:00
Vladimir 'phcoder' Serbinenko
558d3a6023 * util/getroot.c (grub_util_get_dm_node_linear_info): Moved from here...
* grub-core/kern/emu/hostdisk.c (grub_util_get_dm_node_linear_info):
	to here. New return value start. All users updated.
	Recursively scan linear mappings.
	* include/grub/emu/hostdisk.h (grub_util_get_dm_node_linear_info): New
	proto.
	* grub-core/kern/emu/hostdisk.c (grub_hostdisk_find_partition_start):
	Use grub_util_get_dm_node_linear_info.
	* util/getroot.c (convert_system_partition_to_system_disk): Use
	grub_util_info rather than grub_dprintf.
	(grub_util_biosdisk_get_grub_dev): Add a new grub_util_info.
2012-06-07 14:24:48 +02:00
Vladimir 'phcoder' Serbinenko
6297e19736 * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_write) [__linux__]:
Fix MBR remapping workaround.
	(grub_util_biosdisk_read) [__linux__]: Likewise.
2012-06-02 13:48:44 +02:00
Vladimir 'phcoder' Serbinenko
1d80c62a8f * grub-core/kern/emu/hostdisk.c (open_device): Set dest->dev to 0 after
freeing.
2012-05-27 13:19:09 +02:00
Vladimir 'phcoder' Serbinenko
5eae317511 * grub-core/kern/emu/hostdisk.c (read_device_map): Improve TRANSLATORS
comment.
2012-05-12 14:15:45 +02:00
Vladimir 'phcoder' Serbinenko
f1a6254cf1 Flush block cache on adding disk to device map.
* grub-core/kern/emu/hostdisk.c (flush_initial_buffer): New function.
	(grub_hostdisk_os_dev_to_grub_drive): Call flush_initial_buffer on
	adding.
	(read_device_map): Likewise.
	(open_device): Flush on opening.
2012-05-11 21:03:47 +02:00
Vladimir 'phcoder' Serbinenko
5f6ac15e84 * grub-core/kern/emu/hostdisk.c (read_device_map): Skip invalid Fedora
entries.
2012-05-04 00:07:55 +02:00
Vladimir 'phcoder' Serbinenko
11858300e9 * grub-core/commands/menuentry.c: Add TRANSLATORS comments.
* grub-core/kern/emu/hostdisk.c: Likewise.
2012-05-03 23:43:59 +02:00
Vladimir 'phcoder' Serbinenko
e3282399ad * grub-core/kern/emu/hostdisk.c (read_device_map): Reject non-standard
disk names.
	* docs/grub.texi: Update device.map parts.
2012-05-01 15:02:34 +02:00
Vladimir 'phcoder' Serbinenko
385f9abbe3 * grub-core/kern/emu/hostdisk.c (map): Make static. 2012-04-23 17:14:48 +02:00
Samuel Thibault
524b5d3a7c Fix hurd build.
* grub-core/kern/emu/hostdisk.c (grub_util_get_fd_size) [__GNU__]: Do
not define nr variable.
2012-04-22 18:44:19 +02:00
Vladimir 'phcoder' Serbinenko
9a06490c07 Fix kfreebsd compile and behaviour.
* grub-core/kern/emu/hostdisk.c (grub_util_follow_gpart_up): Fix
	format-security.
	* util/getroot.c: Fix wait.h include.
	(grub_guess_root_devices): Error if grub_find_device fails.
	(grub_util_get_geom_abstraction): Fix shadowing and format-security.
	(grub_util_get_dev_abstraction): Likewise.
	(grub_util_pull_device): Likewise.
	(grub_util_get_grub_dev): Likewise.
	* util/lvm.c (grub_util_lvm_isvolume): Likewise.
2012-04-21 16:49:56 +02:00
Vladimir 'phcoder' Serbinenko
ebbd24f3eb * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_write): Fix opening
mode.
2012-04-19 20:35:06 +02:00
Vladimir 'phcoder' Serbinenko
59e2651a06 * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_write): Fix message
disunification.
2012-04-18 23:48:52 +02:00
Vladimir 'phcoder' Serbinenko
cb7f944e44 * grub-core/kern/emu/hostdisk.c (open_device): New argument max. All
users updated.
	(grub_util_biosdisk_read): Handle Linux partitions not exactly
	corresponding to GRUB partitions.
	(grub_util_biosdisk_write): Likewise.
2012-04-18 23:18:51 +02:00
Vladimir 'phcoder' Serbinenko
40211ab884 * grub-core/commands/acpihalt.c: Add TRANSLATORS comments.
* grub-core/commands/keystatus.c: Likewise.
	* grub-core/commands/loadenv.c: Likewise.
	* grub-core/commands/probe.c: Likewise.
	* grub-core/commands/regexp.c: Likewise.
	* grub-core/commands/true.c: Likewise.
	* grub-core/commands/videoinfo.c: Likewise.
	* grub-core/disk/cryptodisk.c: Likewise.
	* grub-core/disk/ldm.c: Likewise.
	* grub-core/disk/loopback.c: Likewise.
	* grub-core/disk/luks.c: Likewise.
	* grub-core/fs/zfs/zfsinfo.c: Likewise.
	* grub-core/kern/disk.c: Likewise.
	* grub-core/kern/emu/hostdisk.c: Likewise.
2012-03-03 12:59:28 +01:00
Vladimir 'phcoder' Serbinenko
88d51eff35 * util/resolve.c (read_dep_list): Use grub_isspace instead of isspace.
* grub-core/kern/emu/hostdisk.c (read_device_map): Likewise.
2012-03-02 11:18:11 +01:00
Vladimir 'phcoder' Serbinenko
a121c9648e Use the common size routine in hostfs so we can read disks as well.
* grub-core/kern/emu/hostdisk.c (grub_util_get_fd_sectors): Rename to ..
	(grub_util_get_fd_size): ... this. Return size in bytes.
	All users updated.
	* grub-core/kern/emu/hostfs.c (grub_hostfs_open): Use
	grub_util_get_fd_size.
2012-02-29 15:23:31 +01:00
Vladimir 'phcoder' Serbinenko
c66d641020 * grub-core/kern/emu/hostdisk.c (grub_util_get_fd_sectors) [__APPLE__]:
Add blocksize retrieval.
2012-02-29 15:17:59 +01:00
Vladimir 'phcoder' Serbinenko
67093bc0ed Another round of string clarification and adding TRANSLATORS comments. 2012-02-26 17:28:05 +01:00
Vladimir 'phcoder' Serbinenko
c44866b2a6 * grub-core/kern/emu/hostdisk.c (read_device_map): Add missing noreturn
on show_error.
2012-02-22 05:16:26 +01:00
Vladimir 'phcoder' Serbinenko
7e94d044ad * grub-core/disk/geli.c (grub_md_sha256_real): Respect format security.
(grub_md_sha512_real): Likewise.
	(grub_util_get_geli_uuid): Likewise.
	* grub-core/kern/emu/hostdisk.c (grub_util_get_fd_sectors): Likewise.
	(grub_util_biosdisk_open): Fix format specification.
	Respect format security.
	* grub-core/kern/emu/misc.c (xmalloc): Respect format security.
	(xrealloc): Likewise.
	(xasprintf): Likewise.
2012-02-10 14:01:53 +01:00
Vladimir 'phcoder' Serbinenko
9c4b5c13e6 Improve gettext support. Stylistic fixes and error handling fixes while
on it.
2012-02-08 19:26:01 +01:00
Vladimir 'phcoder' Serbinenko
b525fd834d Clarify and unify messages.
* grub-core/commands/hashsum.c (options): Unify messages.
	* grub-core/commands/keystatus.c (GRUB_MOD_INIT): Don't mark a
	literal-only message as translatable.
	* grub-core/commands/lsacpi.c (GRUB_MOD_INIT): Likewise.
	* grub-core/loader/ia64/efi/linux.c (GRUB_MOD_INIT): Likewise.
	* grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Add quoting around
	commands.
	* grub-core/commands/menuentry.c (options): Clarify that it's a keyboard
	key, not the key used to unlock. Clarify what it's used for.
	* grub-core/kern/emu/hostdisk.c (read_device_map): Unify error message.
	* grub-core/loader/xnu.c (grub_xnu_load_driver): Remove erroneous colon.
	* grub-core/script/main.c (GRUB_MOD_INIT): Clarify [n] to be [NUM].
	* util/grub-editenv.c (options): Unify "verbose" message.
	* util/grub-fstest.c (read_file): Unify error message.
	(fstest): Add quotes around commands.
	(options): Unify "verbose" message.
	* util/grub-install.in: Add quotes around variable name.
	* util/grub-kbdcomp.in: Unify error message.
	* util/grub-mkfont.c (main): Likewise.
	* util/grub-mkrescue.in: Likewise.
	* util/grub-mklayout.c (options): Unify "verbose" message.
	* util/grub-mkstandalone.in: Unify help and verbose messages.
	* util/grub-mount.c (options): Unify "verbose" message.
	* util/grub-probe.c (options): Likewise.
	* util/grub-script-check.c (options): Likewise.
	* util/grub-setup.c (setup): Unify no-terminator message.
	(options): Use DEVICE and not DEV.
	Unify "verbose" message.
	* util/ieee1275/ofpath.c (xrealpath): Unify error message.
2012-02-05 11:23:47 +01:00
Vladimir 'phcoder' Serbinenko
0ae70393ba Improve and unify messages.
* grub-core/kern/emu/hostdisk.c (grub_util_get_fd_sectors): Add argument
	name. All users updated.
	Print filename in error.
	(read_device_map): Print filename in error.
	* util/getroot.c (grub_guess_root_devices): Print filename in error.
	(grub_util_get_os_disk): Likewise.
	(grub_util_biosdisk_get_grub_dev): Likewise.
	(grub_util_check_block_device): Likewise.
	(grub_util_check_char_device): Likewise.
	(grub_make_system_path_relative_to_its_root): Likewise.
	* util/grub-editenv.c (create_envblk_file): Likewise.
	(open_envblk_file): Likewise.
	(write_envblk): Likewise.
	* util/grub-fstest.c (cmd_cp): Likewise.
	(cmd_cat): Likewise.
	(cmd_cmp): Likewise.
	* util/grub-menulst2cfg.c (main): Likewise.
	* util/grub-mkfont.c (write_font_ascii_bitmap): Likewise.
	(write_font_width_spec): Likewise.
	(write_font_pf2): Likewise.
	* util/grub-mkimage.c (generate_image): New argument outname.
	All users updated.
	Remove unreacheable message.
	(options): Unify messages.
	(help_filter): Likewise.
	* util/grub-mklayout.c (usage): Removed (unused).
	(main): Print filename in error.
	* util/grub-mkrescue.in: Fix wrong quoting.
	* util/grub-setup.c (setup): Print filename in error.
	* util/ieee1275/ofpath.c (vendor_is_ATA): Likewise.
	(check_sas): Likewise.
	* util/misc.c (grub_util_get_fp_size): Removed.
	(grub_util_get_image_size): Print filename in error.
	(grub_util_read_at): Removed.
	(grub_util_read_image): Print filename in error.
	(grub_util_load_image): Likewise.
	(grub_util_write_image_at): New argument filename. All users updated.
	Print filename in error.
	(grub_util_write_image): New argument filename. All users updated.
	Print filename in error.
	* util/raid.c (grub_util_raid_getmembers): Print filename in error.
	* util/resolve.c (grub_util_resolve_dependencies): Likewise.
2012-02-05 11:07:33 +01:00
Grégoire Sutre
dc87d45a7a NetBSD disk wedge support. 2012-02-03 12:32:21 +01:00