diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:54:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:54:16 +0000 |
commit | 485f6ecd453d8a2fd8b9b9fadea03159d8b50797 (patch) | |
tree | 32451fa3cdd9321fb2591fada9891b2cb70a9cd1 /include/grub/emu | |
parent | Initial commit. (diff) | |
download | grub2-485f6ecd453d8a2fd8b9b9fadea03159d8b50797.tar.xz grub2-485f6ecd453d8a2fd8b9b9fadea03159d8b50797.zip |
Adding upstream version 2.06.upstream/2.06upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/grub/emu')
-rw-r--r-- | include/grub/emu/config.h | 48 | ||||
-rw-r--r-- | include/grub/emu/console.h | 28 | ||||
-rw-r--r-- | include/grub/emu/exec.h | 42 | ||||
-rw-r--r-- | include/grub/emu/getroot.h | 104 | ||||
-rw-r--r-- | include/grub/emu/hostdisk.h | 98 | ||||
-rw-r--r-- | include/grub/emu/hostfile.h | 68 | ||||
-rw-r--r-- | include/grub/emu/misc.h | 75 | ||||
-rw-r--r-- | include/grub/emu/net.h | 37 |
8 files changed, 500 insertions, 0 deletions
diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h new file mode 100644 index 0000000..875d589 --- /dev/null +++ b/include/grub/emu/config.h @@ -0,0 +1,48 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_CONFIG_EMU_HEADER +#define GRUB_CONFIG_EMU_HEADER 1 + +#include <grub/disk.h> +#include <grub/partition.h> +#include <grub/emu/hostfile.h> +#include <stdio.h> + +const char * +grub_util_get_config_filename (void); +const char * +grub_util_get_pkgdatadir (void); +const char * +grub_util_get_pkglibdir (void); +const char * +grub_util_get_localedir (void); + +struct grub_util_config +{ + int is_cryptodisk_enabled; + char *grub_distributor; +}; + +void +grub_util_load_config (struct grub_util_config *cfg); + +void +grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple); + +#endif diff --git a/include/grub/emu/console.h b/include/grub/emu/console.h new file mode 100644 index 0000000..1e55682 --- /dev/null +++ b/include/grub/emu/console.h @@ -0,0 +1,28 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_CONSOLE_UTIL_HEADER +#define GRUB_CONSOLE_UTIL_HEADER 1 + +/* Initialize the console system. */ +void grub_console_init (void); + +/* Finish the console system. */ +void grub_console_fini (void); + +#endif /* ! GRUB_CONSOLE_UTIL_HEADER */ diff --git a/include/grub/emu/exec.h b/include/grub/emu/exec.h new file mode 100644 index 0000000..d1073ef --- /dev/null +++ b/include/grub/emu/exec.h @@ -0,0 +1,42 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMU_EXEC_H +#define GRUB_EMU_EXEC_H 1 + +#include <config.h> +#include <stdarg.h> + +#include <sys/types.h> +pid_t +grub_util_exec_pipe (const char *const *argv, int *fd); +pid_t +grub_util_exec_pipe_stderr (const char *const *argv, int *fd); + +int +grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, + const char *stdout_file, const char *stderr_file); +int +grub_util_exec (const char *const *argv); +int +grub_util_exec_redirect (const char *const *argv, const char *stdin_file, + const char *stdout_file); +int +grub_util_exec_redirect_null (const char *const *argv); + +#endif diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h new file mode 100644 index 0000000..73fa2d3 --- /dev/null +++ b/include/grub/emu/getroot.h @@ -0,0 +1,104 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2007, 2008, 2009 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_UTIL_GETROOT_HEADER +#define GRUB_UTIL_GETROOT_HEADER 1 + +#include <grub/types.h> +#include <grub/device.h> + +#include <sys/types.h> +#include <stdio.h> + +enum grub_dev_abstraction_types { + GRUB_DEV_ABSTRACTION_NONE, + GRUB_DEV_ABSTRACTION_LVM, + GRUB_DEV_ABSTRACTION_RAID, + GRUB_DEV_ABSTRACTION_LUKS, + GRUB_DEV_ABSTRACTION_GELI, +}; + +char *grub_find_device (const char *dir, dev_t dev); +void grub_util_pull_device (const char *osname); +char **grub_guess_root_devices (const char *dir); +int grub_util_get_dev_abstraction (const char *os_dev); +char *grub_make_system_path_relative_to_its_root (const char *path); +char * +grub_make_system_path_relative_to_its_root_os (const char *path); +char *grub_util_get_grub_dev (const char *os_dev); +#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) +void grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, + char **name_out); +#endif + +#include <sys/stat.h> + +#ifdef __linux__ +char ** +grub_find_root_devices_from_mountinfo (const char *dir, char **relroot); +#endif + +/* Devmapper functions provided by getroot_devmapper.c. */ +void +grub_util_pull_devmapper (const char *os_dev); +int +grub_util_device_is_mapped_stat (struct stat *st); +void grub_util_devmapper_cleanup (void); +enum grub_dev_abstraction_types +grub_util_get_dm_abstraction (const char *os_dev); +char * +grub_util_get_vg_uuid (const char *os_dev); +char * +grub_util_devmapper_part_to_disk (struct stat *st, + int *is_part, const char *os_dev); +char * +grub_util_get_devmapper_grub_dev (const char *os_dev); + +void +grub_util_pull_lvm_by_command (const char *os_dev); +char ** +grub_util_find_root_devices_from_poolname (char *poolname); + +grub_disk_addr_t +grub_util_find_partition_start (const char *dev); + +/* OS-specific functions provided by getroot_*.c. */ +enum grub_dev_abstraction_types +grub_util_get_dev_abstraction_os (const char *os_dev); +char * +grub_util_part_to_disk (const char *os_dev, struct stat *st, + int *is_part); +int +grub_util_pull_device_os (const char *osname, + enum grub_dev_abstraction_types ab); +char * +grub_util_get_grub_dev_os (const char *os_dev); +grub_disk_addr_t +grub_util_find_partition_start_os (const char *dev); + +char * +grub_util_guess_bios_drive (const char *orig_path); +char * +grub_util_guess_efi_drive (const char *orig_path); +char * +grub_util_guess_baremetal_drive (const char *orig_path); +void +grub_util_fprint_full_disk_name (FILE *f, + const char *drive, grub_device_t dev); + +#endif /* ! GRUB_UTIL_GETROOT_HEADER */ diff --git a/include/grub/emu/hostdisk.h b/include/grub/emu/hostdisk.h new file mode 100644 index 0000000..e006f0b --- /dev/null +++ b/include/grub/emu/hostdisk.h @@ -0,0 +1,98 @@ +/* biosdisk.h - emulate biosdisk */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2007 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_BIOSDISK_MACHINE_UTIL_HEADER +#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1 + +#include <grub/disk.h> +#include <grub/partition.h> +#include <sys/types.h> +#include <grub/emu/hostfile.h> + +grub_util_fd_t +grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags, + grub_disk_addr_t *max); + +void grub_util_biosdisk_init (const char *dev_map); +void grub_util_biosdisk_fini (void); +char *grub_util_biosdisk_get_grub_dev (const char *os_dev); +const char *grub_util_biosdisk_get_osdev (grub_disk_t disk); +int grub_util_biosdisk_is_present (const char *name); +int grub_util_biosdisk_is_floppy (grub_disk_t disk); +const char * +grub_util_biosdisk_get_compatibility_hint (grub_disk_t disk); +grub_err_t grub_util_biosdisk_flush (struct grub_disk *disk); +grub_err_t +grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat); +const char * +grub_util_cryptodisk_get_uuid (grub_disk_t disk); +char * +grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start); +int +grub_util_is_ldm (grub_disk_t disk); +#ifdef GRUB_UTIL +grub_err_t +grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors, + unsigned int max_nsectors, + grub_embed_type_t embed_type, + grub_disk_addr_t **sectors); +#endif +const char * +grub_hostdisk_os_dev_to_grub_drive (const char *os_dev, int add); + + +char * +grub_util_get_os_disk (const char *os_dev); + +int +grub_util_get_dm_node_linear_info (dev_t dev, + int *maj, int *min, + grub_disk_addr_t *st); + + +/* Supplied by hostdisk_*.c. */ +grub_int64_t +grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize); +/* REturns partition offset in 512B blocks. */ +grub_disk_addr_t +grub_hostdisk_find_partition_start_os (const char *dev); +void +grub_hostdisk_flush_initial_buffer (const char *os_dev); + +#ifdef __GNU__ +int +grub_util_hurd_get_disk_info (const char *dev, grub_uint32_t *secsize, grub_disk_addr_t *offset, + grub_disk_addr_t *size, char **parent); +#endif + +struct grub_util_hostdisk_data +{ + char *dev; + int access_mode; + grub_util_fd_t fd; + int is_disk; + int device_map; +}; + +void grub_host_init (void); +void grub_host_fini (void); +void grub_hostfs_init (void); +void grub_hostfs_fini (void); + +#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */ diff --git a/include/grub/emu/hostfile.h b/include/grub/emu/hostfile.h new file mode 100644 index 0000000..cfb1e2b --- /dev/null +++ b/include/grub/emu/hostfile.h @@ -0,0 +1,68 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_HOSTFILE_EMU_HEADER +#define GRUB_HOSTFILE_EMU_HEADER 1 + +#include <grub/disk.h> +#include <grub/partition.h> +#include <sys/types.h> +#include <grub/osdep/hostfile.h> + +int +grub_util_is_directory (const char *path); +int +grub_util_is_special_file (const char *path); +int +grub_util_is_regular (const char *path); + +char * +grub_util_path_concat (size_t n, ...); +char * +grub_util_path_concat_ext (size_t n, ...); + +int +grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off); +ssize_t +EXPORT_FUNC(grub_util_fd_read) (grub_util_fd_t fd, char *buf, size_t len); +ssize_t +EXPORT_FUNC(grub_util_fd_write) (grub_util_fd_t fd, const char *buf, size_t len); + +grub_util_fd_t +EXPORT_FUNC(grub_util_fd_open) (const char *os_dev, int flags); +const char * +EXPORT_FUNC(grub_util_fd_strerror) (void); +int +grub_util_fd_sync (grub_util_fd_t fd); +void +grub_util_disable_fd_syncs (void); +int +EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd); + +grub_uint64_t +grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsize); +char * +grub_util_make_temporary_file (void); +char * +grub_util_make_temporary_dir (void); +void +grub_util_unlink_recursive (const char *name); +grub_uint32_t +grub_util_get_mtime (const char *name); + +#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */ diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h new file mode 100644 index 0000000..ff9c48a --- /dev/null +++ b/include/grub/emu/misc.h @@ -0,0 +1,75 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMU_MISC_H +#define GRUB_EMU_MISC_H 1 + +#include <config.h> +#include <stdarg.h> + +#include <stdio.h> + +#include <grub/compiler.h> +#include <grub/symbol.h> +#include <grub/types.h> +#include <grub/misc.h> +#include <grub/util/misc.h> + +extern int verbosity; +extern const char *program_name; + +void grub_init_all (void); +void grub_fini_all (void); + +void grub_find_zpool_from_dir (const char *dir, + char **poolname, char **poolfs); + +char *grub_make_system_path_relative_to_its_root (const char *path) + WARN_UNUSED_RESULT; +int +grub_util_device_is_mapped (const char *dev); + +#define GRUB_HOST_PRIuLONG_LONG "llu" +#define GRUB_HOST_PRIxLONG_LONG "llx" + +void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT; +void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; +void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; +char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; +char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; + +void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn)); + +grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); + +#ifdef HAVE_DEVICE_MAPPER +int grub_device_mapper_supported (void); +#endif + +#ifdef GRUB_BUILD +#define grub_util_fopen fopen +#else +FILE * +grub_util_fopen (const char *path, const char *mode); +#endif + +int grub_util_file_sync (FILE *f); + +#endif /* GRUB_EMU_MISC_H */ diff --git a/include/grub/emu/net.h b/include/grub/emu/net.h new file mode 100644 index 0000000..a5d4fcb --- /dev/null +++ b/include/grub/emu/net.h @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 3 of the License, or + * (at your option) any later version. + * + * GRUB 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_EMUNET_HEADER +#define GRUB_EMUNET_HEADER 1 + +#include <grub/types.h> +#include <grub/symbol.h> + +grub_ssize_t +EXPORT_FUNC(grub_emunet_send) (const void *packet, grub_size_t sz); + +grub_ssize_t +EXPORT_FUNC(grub_emunet_receive) (void *packet, grub_size_t sz); + +int +EXPORT_FUNC(grub_emunet_create) (grub_size_t *mtu); + +void +EXPORT_FUNC(grub_emunet_close) (void); + +#endif |