Lines 35-40
Link Here
|
35 |
#include <grub/video.h> |
35 |
#include <grub/video.h> |
36 |
#include <grub/acpi.h> |
36 |
#include <grub/acpi.h> |
37 |
#include <grub/i18n.h> |
37 |
#include <grub/i18n.h> |
|
|
38 |
#include <grub/net.h> |
39 |
#include <grub/lib/cmdline.h> |
38 |
|
40 |
|
39 |
#if defined (GRUB_MACHINE_EFI) |
41 |
#if defined (GRUB_MACHINE_EFI) |
40 |
#include <grub/efi/efi.h> |
42 |
#include <grub/efi/efi.h> |
Lines 905-935
grub_err_t
Link Here
|
905 |
grub_multiboot_init_mbi (int argc, char *argv[]) |
906 |
grub_multiboot_init_mbi (int argc, char *argv[]) |
906 |
{ |
907 |
{ |
907 |
grub_ssize_t len = 0; |
908 |
grub_ssize_t len = 0; |
908 |
char *p; |
|
|
909 |
int i; |
910 |
|
909 |
|
911 |
grub_multiboot_free_mbi (); |
910 |
grub_multiboot_free_mbi (); |
912 |
|
911 |
|
913 |
for (i = 0; i < argc; i++) |
912 |
len = grub_loader_cmdline_size (argc, argv); |
914 |
len += grub_strlen (argv[i]) + 1; |
|
|
915 |
if (len == 0) |
916 |
len = 1; |
917 |
|
913 |
|
918 |
cmdline = p = grub_malloc (len); |
914 |
cmdline = grub_malloc (len); |
919 |
if (! cmdline) |
915 |
if (! cmdline) |
920 |
return grub_errno; |
916 |
return grub_errno; |
921 |
cmdline_size = len; |
917 |
cmdline_size = len; |
922 |
|
918 |
|
923 |
for (i = 0; i < argc; i++) |
919 |
grub_create_loader_cmdline (argc, argv, cmdline, |
924 |
{ |
920 |
cmdline_size); |
925 |
p = grub_stpcpy (p, argv[i]); |
|
|
926 |
*(p++) = ' '; |
927 |
} |
928 |
|
929 |
/* Remove the space after the last word. */ |
930 |
if (p != cmdline) |
931 |
p--; |
932 |
*p = '\0'; |
933 |
|
921 |
|
934 |
return GRUB_ERR_NONE; |
922 |
return GRUB_ERR_NONE; |
935 |
} |
923 |
} |
Lines 939-947
grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
Link Here
|
939 |
int argc, char *argv[]) |
927 |
int argc, char *argv[]) |
940 |
{ |
928 |
{ |
941 |
struct module *newmod; |
929 |
struct module *newmod; |
942 |
char *p; |
930 |
grub_size_t len = 0; |
943 |
grub_ssize_t len = 0; |
|
|
944 |
int i; |
945 |
|
931 |
|
946 |
newmod = grub_malloc (sizeof (*newmod)); |
932 |
newmod = grub_malloc (sizeof (*newmod)); |
947 |
if (!newmod) |
933 |
if (!newmod) |
Lines 949-961
grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
Link Here
|
949 |
newmod->start = start; |
935 |
newmod->start = start; |
950 |
newmod->size = size; |
936 |
newmod->size = size; |
951 |
|
937 |
|
952 |
for (i = 0; i < argc; i++) |
938 |
len = grub_loader_cmdline_size (argc, argv); |
953 |
len += grub_strlen (argv[i]) + 1; |
|
|
954 |
|
939 |
|
955 |
if (len == 0) |
940 |
newmod->cmdline = grub_malloc (len); |
956 |
len = 1; |
|
|
957 |
|
958 |
newmod->cmdline = p = grub_malloc (len); |
959 |
if (! newmod->cmdline) |
941 |
if (! newmod->cmdline) |
960 |
{ |
942 |
{ |
961 |
grub_free (newmod); |
943 |
grub_free (newmod); |
Lines 964-979
grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
Link Here
|
964 |
newmod->cmdline_size = len; |
946 |
newmod->cmdline_size = len; |
965 |
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN); |
947 |
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN); |
966 |
|
948 |
|
967 |
for (i = 0; i < argc; i++) |
949 |
grub_create_loader_cmdline (argc, argv, newmod->cmdline, |
968 |
{ |
950 |
newmod->cmdline_size); |
969 |
p = grub_stpcpy (p, argv[i]); |
|
|
970 |
*(p++) = ' '; |
971 |
} |
972 |
|
973 |
/* Remove the space after the last word. */ |
974 |
if (p != newmod->cmdline) |
975 |
p--; |
976 |
*p = '\0'; |
977 |
|
951 |
|
978 |
if (modules_last) |
952 |
if (modules_last) |
979 |
modules_last->next = newmod; |
953 |
modules_last->next = newmod; |