@@ -1867,7 +1867,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18671867 ctx -> pos = oldpos ;
18681868 goto out ;
18691869 }
1870- vtoy_len_ssprintf (ctx -> buf , ctx -> pos , ctx -> len , " echo \"Downloading kernel ...\"\n linux %s " , tag );
1870+ vtoy_len_ssprintf (ctx -> buf , ctx -> pos , ctx -> len , " echo \"Loading kernel ...\"\n linux %s " , tag );
18711871
18721872 /* kernel options */
18731873 grub_memcpy (filebuf , bkbuf , file -> size );
@@ -1876,7 +1876,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18761876
18771877
18781878 /* initrd xxx xxx xxx */
1879- vtoy_len_ssprintf (ctx -> buf , ctx -> pos , ctx -> len , " echo \"Downloading initrd ...\"\n initrd " );
1879+ vtoy_len_ssprintf (ctx -> buf , ctx -> pos , ctx -> len , " echo \"Loading initrd ...\"\n %s " , ctx -> initrd_cmd );
18801880 grub_memcpy (filebuf , bkbuf , file -> size );
18811881 tag = ventoy_systemd_conf_tag (filebuf , "initrd" , 1 );
18821882 while (tag )
@@ -1893,6 +1893,34 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18931893 return 0 ;
18941894}
18951895
1896+ grub_err_t ventoy_cmd_linux_initrd (grub_extcmd_context_t ctxt , int argc , char * * args )
1897+ {
1898+ int i ;
1899+ int pos = 0 ;
1900+ char * buf = NULL ;
1901+
1902+ (void )ctxt ;
1903+
1904+ buf = (char * )grub_malloc (VTOY_SIZE_4KB );
1905+ if (!buf )
1906+ {
1907+ return 1 ;
1908+ }
1909+
1910+ pos += grub_snprintf (buf + pos , VTOY_SIZE_4KB - pos , "initrd mem:%s:size:%s" ,
1911+ grub_env_get ("ventoy_cpio_addr" ), grub_env_get ("ventoy_cpio_size" ));
1912+
1913+ for (i = 0 ; i < argc ; i ++ )
1914+ {
1915+ pos += grub_snprintf (buf + pos , VTOY_SIZE_4KB - pos , " newc:initrd%03d:%s" , i + 1 , args [i ]);
1916+ }
1917+
1918+ grub_script_execute_sourcecode (buf );
1919+ grub_free (buf );
1920+
1921+ return 0 ;
1922+ }
1923+
18961924grub_err_t ventoy_cmd_linux_systemd_menu (grub_extcmd_context_t ctxt , int argc , char * * args )
18971925{
18981926 static char * buf = NULL ;
@@ -1936,6 +1964,7 @@ grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, c
19361964
19371965 ctx .dev = args [0 ];
19381966 ctx .buf = buf ;
1967+ ctx .initrd_cmd = args [2 ] ? args [2 ] : "initrd" ;
19391968 ctx .pos = 0 ;
19401969 ctx .len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF ;
19411970 fs -> fs_dir (dev , "/loader/entries" , ventoy_systemd_conf_hook , & ctx );
0 commit comments