ieee1275: support added for multiple nvme bootpaths
PATCH v2 1/1 ieee1275: support added for multiple nvme bootpaths
This patch sets mupltiple NVMe boot-devices for more robust boot. Scenario where NVMe multipaths are available, all the available bootpaths (Max 5) will be added as the boot-device.
--- grub-core/osdep/unix/platform.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++- grub-core/osdep/linux/ofpath.c | 6 +++--- include/grub/util/install.h | 3 +++ include/grub/util/ofpath.h | 4 ++++ 4 files changed, 123 insertions(+), 4 deletion(-)
grub-core/osdep/unix/platform.c +113 -1
@@ -28,6 +28,8 @@#include <dirent.h> #include <string.h> #include <errno.h> +#include <grub/util/ofpath.h> +#define BOOTDEV_BUFFER 1000static char *get_ofpathname (const char *dev)
@@ -176,6 +178,105 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,return ret; } + +char * +add_multiple_nvme_bootdevices (const char *install_device) +{ +char *sysfs_path, *nvme_ns, *ptr, *non_splitter_path; +unsigned int nsid; +char *multipath_boot, *ofpath, *ext_dir; +struct dirent *ep, *splitter_ep; +DIR *dp, *splitter_dp; +char *cntl_id, *dirR1, *dirR2, *splitter_info_path; +int is_FC =0 , is_splitter =0 ; + + nvme_ns =grub_strstr (install_device,"nvme" ); + nsid =of_path_get_nvme_nsid (nvme_ns); +if (nsid ==0 ) +return NULL ; + + sysfs_path =nvme_get_syspath (nvme_ns); + ofpath =xasprintf ("%s" ,get_ofpathname (nvme_ns)); + +if (grub_strstr (ofpath,"fibre-channel" )) + { +strcat (sysfs_path,"/device" ); + is_FC =1 ; + } +else + { +strcat (sysfs_path,"/subsystem" ); + is_FC =0 ; + } +if (is_FC ==0 ) + { + cntl_id =grub_strstr (nvme_ns,"e" ); + dirR1 =xasprintf ("nvme%c" ,cntl_id[1 ]); + + splitter_info_path =xasprintf ("%s%s%s" ,"/sys/block/" , nvme_ns,"/device" ); + splitter_dp =opendir (splitter_info_path); +if (!splitter_dp) +return NULL ; + +while ((splitter_ep =readdir (splitter_dp)) !=NULL ) + { +if (grub_strstr (splitter_ep->d_name,"nvme" )) + { +if (grub_strstr (splitter_ep->d_name, dirR1)) +continue ; + + ext_dir =grub_strstr (splitter_ep->d_name,"e" ); +if (!(grub_strstr (ext_dir,"n" ))) + { + dirR2 =xasprintf ("%s" , splitter_ep->d_name); + is_splitter =1 ; +break ; + } + } + } +closedir (splitter_dp); + } + sysfs_path =xrealpath (sysfs_path); + dp =opendir (sysfs_path); +if (!dp) +return NULL ; + + ptr = multipath_boot =xmalloc (BOOTDEV_BUFFER ); +if (is_splitter ==0 && is_FC ==0 ) + { + non_splitter_path =xasprintf ("%s%s%x:1 " ,get_ofpathname (dirR1),"/namespace@" , nsid); +strncpy (ptr, non_splitter_path,strlen (non_splitter_path)); + ptr +=strlen (non_splitter_path); +free (non_splitter_path); + } +else + { +while ((ep =readdir (dp)) !=NULL ) + { +char *path; +if (grub_strstr (ep->d_name,"nvme" )) + { +if (is_FC ==0 && !grub_strstr (ep->d_name, dirR1) && !grub_strstr (ep->d_name, dirR2)) +continue ; + path =xasprintf ("%s%s%x " ,get_ofpathname (ep->d_name),"/namespace@" , nsid); +if ((strlen (multipath_boot) +strlen (path)) >BOOTDEV_BUFFER ) + { +grub_util_warn (_ ("Maximum five entries are allowed in the bootlist" )); +free (path); +break ; + } +strncpy (ptr, path,strlen (path)); + ptr +=strlen (path); +free (path); + } + } + } + *--ptr ='\0' ; +closedir (dp); + +return multipath_boot; +} +void grub_install_register_ieee1275 (int is_prep,const char *install_device,int partno,const char *relpath)
@@ -215,8 +316,19 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device, } *ptr ='\0' ; } +else if (grub_strstr (install_device,"nvme" )) + { + boot_device =add_multiple_nvme_bootdevices (install_device); + }else - boot_device =get_ofpathname (install_device); + { + boot_device =get_ofpathname (install_device); +if (grub_strstr (boot_device,"nvme-of" )) + { +free (boot_device); + boot_device =add_multiple_nvme_bootdevices (install_device); + } + }if (grub_util_exec ((const char * []){"nvsetenv" ,"boot-device" , boot_device,NULL }))
grub-core/osdep/linux/ofpath.c +3 -3
@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig) } } -static char * +char *xrealpath (const char *in) {char *out;
@@ -224,7 +224,7 @@ xrealpath (const char *in)return out; } -static char * +char *block_device_get_sysfs_path_and_link (const char *devicenode) {char *rpath;
@@ -684,7 +684,7 @@ of_path_get_nvme_nsid (const char* devname)return nsid; } -static char * +char *nvme_get_syspath (const char *nvmedev) {char *sysfs_path;
include/grub/util/install.h +3 -0
@@ -235,6 +235,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,const char *efifile_path, const char *efi_distributor); +char * +add_multiple_nvme_bootdevices (const char *install_device); +void grub_install_register_ieee1275 (int is_prep,const char *install_device,int partno,const char *relpath);
include/grub/util/ofpath.h +4 -0
@@ -30,5 +30,9 @@ int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);void find_file (char * filename,char * directory,struct ofpath_files_list_root * root,int max_depth,int depth);char *of_find_fc_host (char * host_wwpn);void free_ofpath_files_list (struct ofpath_files_list_root * root); +char *nvme_get_syspath (const char *nvmedev); +char *block_device_get_sysfs_path_and_link (const char *devicenode); +char *xrealpath (const char *in); +unsigned int of_path_get_nvme_nsid (const char * devname);#endif /* ! GRUB_OFPATH_MACHINE_UTIL_HEADER */
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 17 lines · Avnish Chouhan
This patch sets mupltiple NVMe boot-devices for more robust boot. Scenario where NVMe multipaths are available, all the available bootpaths (Max 5) will be added as the boot-device.
Signed-off-by Avnish Chouhan <[email protected]>--- grub-core/osdep/unix/platform.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++- grub-core/osdep/linux/ofpath.c | 6 +++--- include/grub/util/install.h | 3 +++ include/grub/util/ofpath.h | 4 ++++ 4 files changed, 123 insertions(+), 4 deletion(-)grub-core/osdep/unix/platform.c +0
-0
grub-core/osdep/unix/platform.c line 31
Quoted 4 lines
grub-core/osdep/unix/platform.c +1
-0@@ -28,6 +28,8 @@#include <dirent.h> #include <string.h> #include <errno.h> +#include <grub/util/ofpath.h>
Please add empty line here.
Quoted 9 lines
grub-core/osdep/unix/platform.c +2
-0+#define BOOTDEV_BUFFER 1000static char *get_ofpathname (const char *dev)@@ -176,6 +178,105 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,return ret; } +
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 191
Quoted 10 lines
grub-core/osdep/unix/platform.c +10
-0+char * +add_multiple_nvme_bootdevices (const char *install_device) +{ +char *sysfs_path, *nvme_ns, *ptr, *non_splitter_path; +unsigned int nsid; +char *multipath_boot, *ofpath, *ext_dir; +struct dirent *ep, *splitter_ep; +DIR *dp, *splitter_dp; +char *cntl_id, *dirR1, *dirR2, *splitter_info_path; +int is_FC =0 , is_splitter =0 ;
Please use bool type here.
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 193
Quoted 1 line
grub-core/osdep/unix/platform.c +1
-0+ nvme_ns =grub_strstr (install_device,"nvme" );
grub_strstr() may return NULL. If it is not possible here then it should be explained.
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 199
Quoted 6 lines
grub-core/osdep/unix/platform.c +6
-0+ nsid =of_path_get_nvme_nsid (nvme_ns); +if (nsid ==0 ) +return NULL ; + + sysfs_path =nvme_get_syspath (nvme_ns); + ofpath =xasprintf ("%s" ,get_ofpathname (nvme_ns));
Missing space after ",".
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 213
Quoted 13 lines
grub-core/osdep/unix/platform.c +13
-0+if (grub_strstr (ofpath,"fibre-channel" )) + { +strcat (sysfs_path,"/device" ); + is_FC =1 ; + } +else + { +strcat (sysfs_path,"/subsystem" ); + is_FC =0 ; + } +if (is_FC ==0 ) + { + cntl_id =grub_strstr (nvme_ns,"e" );
Again, missing NULL check and s/grub_strstr/grub_strchr/...
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 216
Quoted 3 lines
grub-core/osdep/unix/platform.c +3
-0+ dirR1 =xasprintf ("nvme%c" ,cntl_id[1 ]); + + splitter_info_path =xasprintf ("%s%s%s" ,"/sys/block/" , nvme_ns,"/device" );
... xasprintf ("/sys/block/%s/device", nvme_ns);
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 228
Quoted 12 lines
grub-core/osdep/unix/platform.c +12
-0+ splitter_dp =opendir (splitter_info_path); +if (!splitter_dp) +return NULL ; + +while ((splitter_ep =readdir (splitter_dp)) !=NULL ) + { +if (grub_strstr (splitter_ep->d_name,"nvme" )) + { +if (grub_strstr (splitter_ep->d_name, dirR1)) +continue ; + + ext_dir =grub_strstr (splitter_ep->d_name,"e" );
s/grub_strstr/grub_strchr/
Missing NULL check too...
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 229
Quoted 1 line
grub-core/osdep/unix/platform.c +1
-0+if (!(grub_strstr (ext_dir,"n" )))
s/grub_strstr/grub_strchr/
grub_strchr (ext_dir, 'n') == NULL
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 229
Quoted 2 lines
grub-core/osdep/unix/platform.c +2
-0+ { + dirR2 =xasprintf ("%s" , splitter_ep->d_name);
Something is off with indention...
Quoted 6 lines
grub-core/osdep/unix/platform.c +6
-0+ is_splitter =1 ; +break ; + } + } + } +closedir (splitter_dp);
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 247
Quoted 10 lines
grub-core/osdep/unix/platform.c +10
-0+ } + sysfs_path =xrealpath (sysfs_path); + dp =opendir (sysfs_path); +if (!dp) +return NULL ; + + ptr = multipath_boot =xmalloc (BOOTDEV_BUFFER ); +if (is_splitter ==0 && is_FC ==0 ) + { + non_splitter_path =xasprintf ("%s%s%x:1 " ,get_ofpathname (dirR1),"/namespace@" , nsid);
... xasprintf ("%s/namespace@%x:1 ", get_ofpathname (dirR1), nsid);
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 256
Quoted 9 lines
grub-core/osdep/unix/platform.c +9
-0+strncpy (ptr, non_splitter_path,strlen (non_splitter_path)); + ptr +=strlen (non_splitter_path); +free (non_splitter_path); + } +else + { +while ((ep =readdir (dp)) !=NULL ) + { +char *path;
Please add empty line here...
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 257
Quoted 1 line
grub-core/osdep/unix/platform.c +1
-0+if (grub_strstr (ep->d_name,"nvme" ))
grub_strstr (ep->d_name, "nvme") != NULL
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 257
Quoted 2 lines
grub-core/osdep/unix/platform.c +2
-0+ { +if (is_FC ==0 && !grub_strstr (ep->d_name, dirR1) && !grub_strstr (ep->d_name, dirR2))
... grub_strstr (ep->d_name, dirR1) == NULL && grub_strstr (ep->d_name, dirR2) == NULL ...
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 259
Quoted 2 lines
grub-core/osdep/unix/platform.c +2
-0+continue ; + path =xasprintf ("%s%s%x " ,get_ofpathname (ep->d_name),"/namespace@" , nsid);
... xasprintf ("%s/namespace@%x:1 ", get_ofpathname (ep->d_name), nsid);
Quoted 56 lines
grub-core/osdep/unix/platform.c +30
-1+if ((strlen (multipath_boot) +strlen (path)) >BOOTDEV_BUFFER ) + { +grub_util_warn (_ ("Maximum five entries are allowed in the bootlist" )); +free (path); +break ; + } +strncpy (ptr, path,strlen (path)); + ptr +=strlen (path); +free (path); + } + } + } + *--ptr ='\0' ; +closedir (dp); + +return multipath_boot; +} +void grub_install_register_ieee1275 (int is_prep,const char *install_device,int partno,const char *relpath)@@ -215,8 +316,19 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device, } *ptr ='\0' ; } +else if (grub_strstr (install_device,"nvme" )) + { + boot_device =add_multiple_nvme_bootdevices (install_device); + }else - boot_device =get_ofpathname (install_device); + { + boot_device =get_ofpathname (install_device); +if (grub_strstr (boot_device,"nvme-of" )) + { +free (boot_device); + boot_device =add_multiple_nvme_bootdevices (install_device); + } + }if (grub_util_exec ((const char * []){"nvsetenv" ,"boot-device" , boot_device,NULL }))grub-core/osdep/linux/ofpath.c +1
-1@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig) } } -static char * +char *xrealpath (const char *in) {char *out;
grub-core/osdep/linux/ofpath.c xrealpath (const char *in) · line 227
Quoted 5 lines
grub-core/osdep/linux/ofpath.c +1
-1@@ -224,7 +224,7 @@ xrealpath (const char *in)return out; } -static char * +char *
You do not need this change.
Quoted 31 lines
grub-core/osdep/linux/ofpath.c +1
-1block_device_get_sysfs_path_and_link(const char *devicenode) {char *rpath;@@ -684,7 +684,7 @@ of_path_get_nvme_nsid (const char* devname)return nsid; } -static char * +char *nvme_get_syspath (const char *nvmedev) {char *sysfs_path;include/grub/util/install.h +3
-0@@ -235,6 +235,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,const char *efifile_path, const char *efi_distributor); +char * +add_multiple_nvme_bootdevices (const char *install_device); +void grub_install_register_ieee1275 (int is_prep,const char *install_device,int partno,const char *relpath);include/grub/util/ofpath.h +0
-0
include/grub/util/ofpath.h int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root); · line 34
Quoted 5 lines
include/grub/util/ofpath.h +2
-0@@ -30,5 +30,9 @@ int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);void find_file (char * filename,char * directory,struct ofpath_files_list_root * root,int max_depth,int depth);char *of_find_fc_host (char * host_wwpn);void free_ofpath_files_list (struct ofpath_files_list_root * root); +char *nvme_get_syspath (const char *nvmedev); +char *block_device_get_sysfs_path_and_link (const char *devicenode);
Please drop this declaration.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Daniel,
Thank you so much for a review!
Quoted 14 lines · Daniel Kiper
Quoted 13 lines · Avnish Chouhan
This patch sets mupltiple NVMe boot-devices for more robust boot. Scenario where NVMe multipaths are available, all the available bootpaths (Max 5) will be added as the boot-device.
Signed-off-by Avnish Chouhan <[email protected]>--- grub-core/osdep/unix/platform.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++- grub-core/osdep/linux/ofpath.c | 6 +++--- include/grub/util/install.h | 3 +++ include/grub/util/ofpath.h | 4 ++++ 4 files changed, 123 insertions(+), 4 deletion(-)
Quoted 11 lines
grub-core/osdep/unix/platform.c line 31
Quoted 9 lines
grub-core/osdep/unix/platform.c +1
-0@@ -28,6 +28,8 @@#include <dirent.h> #include <string.h> #include <errno.h> +#include <grub/util/ofpath.h> Please add empty line here.
Sure!
Quoted 10 lines
Quoted 10 lines
grub-core/osdep/unix/platform.c +1
-0+#define BOOTDEV_BUFFER 1000static char *get_ofpathname (const char *dev)@@ -176,6 +178,105 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, return ret; }
Quoted 13 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 191
Quoted 11 lines
grub-core/osdep/unix/platform.c +11
-0+ +char * +add_multiple_nvme_bootdevices (const char *install_device) +{ +char *sysfs_path, *nvme_ns, *ptr, *non_splitter_path; +unsigned int nsid; +char *multipath_boot, *ofpath, *ext_dir; +struct dirent *ep, *splitter_ep; +DIR *dp, *splitter_dp; +char *cntl_id, *dirR1, *dirR2, *splitter_info_path; +int is_FC =0 , is_splitter =0 ;Please use bool type here.
Sure!
Quoted 6 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 193
Quoted 2 lines
grub-core/osdep/unix/platform.c +1
-0+ nvme_ns =grub_strstr (install_device,"nvme" );
grub_strstr()may return NULL. If it is not possible here then it should be explained.
NULL check not required here as this function works only on install_device as "/dev/nvme3n1p1". I'll add the comment in the next version!
Quoted 8 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 199
Quoted 6 lines
grub-core/osdep/unix/platform.c +6
-0+ nsid =of_path_get_nvme_nsid (nvme_ns); +if (nsid ==0 ) +return NULL ; + + sysfs_path =nvme_get_syspath (nvme_ns); + ofpath =xasprintf ("%s" ,get_ofpathname (nvme_ns));Missing space after ",".
Sure, I'll add a space after ','.
Quoted 15 lines
Quoted 4 lines
grub-core/osdep/unix/platform.c +3
-0+if (grub_strstr (ofpath,"fibre-channel" )) + { +strcat (sysfs_path,"/device" );grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 213
Quoted 10 lines
grub-core/osdep/unix/platform.c +10
-0+ is_FC =1 ; + } +else + { +strcat (sysfs_path,"/subsystem" ); + is_FC =0 ; + } +if (is_FC ==0 ) + { + cntl_id =grub_strstr (nvme_ns,"e" );
Quoted 2 lines
Again, missing NULL check and s/grub_strstr/grub_strchr/...
NULL check not required as explained above. I'll change grub_strstr to grub_strchr.
Quoted 7 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev,
Quoted 4 lines
grub-core/osdep/unix/platform.c +3
-0+ dirR1 =xasprintf ("nvme%c" ,cntl_id[1 ]); + + splitter_info_path =xasprintf ("%s%s%s" ,"/sys/block/" , nvme_ns,"/device" );... xasprintf ("/sys/block/%s/device",
nvme_ns);
Sure!
Quoted 6 lines
Quoted 6 lines
grub-core/osdep/unix/platform.c +6
-0+ splitter_dp =opendir (splitter_info_path); +if (!splitter_dp) +return NULL ; + +while ((splitter_ep =readdir (splitter_dp)) !=NULL ) + {
Quoted 9 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 228
Quoted 6 lines
grub-core/osdep/unix/platform.c +6
-0+if (grub_strstr (splitter_ep->d_name,"nvme" )) + { +if (grub_strstr (splitter_ep->d_name, dirR1)) +continue ; + + ext_dir =grub_strstr (splitter_ep->d_name,"e" );s/grub_strstr/grub_strchr/
Sure!
Quoted 2 lines
Missing NULL check too...
Not required as the check above "if (grub_strstr (splitter_ep->d_name, "nvme"))".
Quoted 4 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 229
Quoted 1 line
grub-core/osdep/unix/platform.c +1
-0+if (!(grub_strstr (ext_dir,"n" )))s/grub_strstr/grub_strchr/
Sure, I'll change this!
Quoted 6 lines
grub_strchr(ext_dir, 'n') == NULLgrub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t · line 231
Quoted 2 lines
grub-core/osdep/unix/platform.c +2
-0+ { + dirR2 =xasprintf ("%s" , splitter_ep->d_name);Something is off with indention...
Sure, I'll check and correct this!
Quoted 31 lines
Quoted 8 lines
grub-core/osdep/unix/platform.c +7
-0+ is_splitter =1 ; +break ; + } + } + } +closedir (splitter_dp); + }grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev,
Quoted 10 lines
grub-core/osdep/unix/platform.c +9
-0+ sysfs_path =xrealpath (sysfs_path); + dp =opendir (sysfs_path); +if (!dp) +return NULL ; + + ptr = multipath_boot =xmalloc (BOOTDEV_BUFFER ); +if (is_splitter ==0 && is_FC ==0 ) + { + non_splitter_path =xasprintf ("%s%s%x:1 " ,get_ofpathname (dirR1),"/namespace@" , nsid);... xasprintf ("%s/namespace@%x:1 ",
get_ofpathname(dirR1), nsid);grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 256
Quoted 9 lines
grub-core/osdep/unix/platform.c +9
-0+strncpy (ptr, non_splitter_path,strlen (non_splitter_path)); + ptr +=strlen (non_splitter_path); +free (non_splitter_path); + } +else + { +while ((ep =readdir (dp)) !=NULL ) + { +char *path;
Quoted 2 lines
Please add empty line here...
Sure.
Quoted 8 lines
grub-core/osdep/unix/platform.c grub_install_register_efi (grub_device_t efidir_grub_dev, · line 257
Quoted 1 line
grub-core/osdep/unix/platform.c +1
-0+if (grub_strstr (ep->d_name,"nvme" ))
grub_strstr(ep->d_name, "nvme") != NULLQuoted 3 lines
grub-core/osdep/unix/platform.c +2
-0+ { + if (is_FC == 0 && !grub_strstr (ep->d_name, dirR1) &&!grub_strstr (
ep->d_name, dirR2))
Quoted 9 lines
...
grub_strstr(ep->d_name, dirR1) == NULL &&grub_strstr(ep->d_name, dirR2) == NULL ...Quoted 3 lines
grub-core/osdep/unix/platform.c +2
-0+continue ; + path = xasprintf ("%s%s%x ", get_ofpathname(
ep->d_name), "/namespace@", nsid);... xasprintf ("%s/namespace@%x:1 ",
get_ofpathname(ep->d_name), nsid);
I'll change as suggested here and in other places too!
Quoted 64 lines
Quoted 64 lines
+ if ((strlen (
multipath_boot) + strlen (path)) >BOOTDEV_BUFFER)grub-core/osdep/unix/platform.c +2
-0+ { + grub_util_warn (_("Maximum five entries are allowedin the bootlist"));
grub-core/osdep/unix/platform.c +15
-0+free (path); +break ; + } +strncpy (ptr, path,strlen (path)); + ptr +=strlen (path); +free (path); + } + } + } + *--ptr ='\0' ; +closedir (dp); + +return multipath_boot; +} +void grub_install_register_ieee1275 (int is_prep, const char
*install_device,grub-core/osdep/unix/platform.c +12
-1int partno, const char *relpath)@@ -215,8 +316,19 @@ grub_install_register_ieee1275 (int is_prep,const char *install_device, } *ptr ='\0' ; } +else if (grub_strstr (install_device,"nvme" )) + { + boot_device =add_multiple_nvme_bootdevices (install_device); + }else - boot_device =get_ofpathname (install_device); + { + boot_device =get_ofpathname (install_device); +if (grub_strstr (boot_device,"nvme-of" )) + { +free (boot_device); + boot_device =add_multiple_nvme_bootdevices (install_device); + } + }if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",grub-core/osdep/unix/platform.c +0
-0boot_device, NULL }))grub-core/osdep/linux/ofpath.c +1
-1@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig) } } -static char * +char *xrealpath (const char *in) {char *out;@@ -224,7 +224,7 @@ xrealpath (const char *in)return out; }
Quoted 5 lines
grub-core/osdep/linux/ofpath.c xrealpath (const char *in) · line 227
Quoted 2 lines
grub-core/osdep/linux/ofpath.c +1
-1-static char * +char *You do not need this change.
We need this function as this is used by the function "of_path_get_nvme_nsid" we are using.
Quoted 34 lines
Quoted 34 lines
grub-core/osdep/linux/ofpath.c +1
-1block_device_get_sysfs_path_and_link(const char *devicenode) {char *rpath;@@ -684,7 +684,7 @@ of_path_get_nvme_nsid (const char* devname)return nsid; } -static char * +char *nvme_get_syspath (const char *nvmedev) {char *sysfs_path;include/grub/util/install.h +3
-0@@ -235,6 +235,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor); +char * +add_multiple_nvme_bootdevices (const char *install_device); +void grub_install_register_ieee1275 (int is_prep, const char
*install_device,include/grub/util/install.h +0
-0int partno, const char *relpath);include/grub/util/ofpath.h +0
-0@@ -30,5 +30,9 @@ int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);
Quoted 9 lines
include/grub/util/ofpath.h int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root); · line 34
Quoted 6 lines
include/grub/util/ofpath.h +2
-0void find_file (char * filename,char * directory,struct ofpath_files_list_root * root,int max_depth,int depth);char *of_find_fc_host (char * host_wwpn);void free_ofpath_files_list (struct ofpath_files_list_root * root); +char *nvme_get_syspath (const char *nvmedev); +char *block_device_get_sysfs_path_and_link (const char *devicenode);Please drop this declaration.
Same as explained above!
Quoted 1 line
Daniel
Regards,
Avnish Chouhan
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines · Avnish Chouhan
Hi Daniel,
Thank you so much for a review!
Quoted 1 line · Daniel Kiper
On Mon, May 19, 2025 at 04:34:34PM +0530, Avnish Chouhan wrote:
[...]
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
grub-core/osdep/linux/ofpath.c +1
-1@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig) } } -static char * +char *xrealpath (const char *in) {char *out;@@ -224,7 +224,7 @@ xrealpath (const char *in)return out; }
Quoted 7 lines
Quoted 4 lines
grub-core/osdep/linux/ofpath.c xrealpath (const char *in) · line 227
Quoted 2 lines
grub-core/osdep/linux/ofpath.c +1
-1-static char * +char *You do not need this change.
We need this function as this is used by the function "
of_path_get_nvme_nsid" we are using.
The block_device_get_sysfs_path_and_link() does not seem called from this patch. So, probably this change belongs to another one.
Quoted 43 lines
Quoted 34 lines
Quoted 34 lines
grub-core/osdep/linux/ofpath.c +1
-1block_device_get_sysfs_path_and_link(const char *devicenode) {char *rpath;@@ -684,7 +684,7 @@ of_path_get_nvme_nsid (const char* devname)return nsid; } -static char * +char *nvme_get_syspath (const char *nvmedev) {char *sysfs_path;include/grub/util/install.h +3
-0@@ -235,6 +235,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor); +char * +add_multiple_nvme_bootdevices (const char *install_device); +void grub_install_register_ieee1275 (int is_prep, const char
*install_device,include/grub/util/install.h +0
-0int partno, const char *relpath);include/grub/util/ofpath.h +0
-0@@ -30,5 +30,9 @@ int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);Quoted 8 lines
include/grub/util/ofpath.h int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root); · line 34
Quoted 6 lines
include/grub/util/ofpath.h +2
-0void find_file (char * filename,char * directory,struct ofpath_files_list_root * root,int max_depth,int depth);char *of_find_fc_host (char * host_wwpn);void free_ofpath_files_list (struct ofpath_files_list_root * root); +char *nvme_get_syspath (const char *nvmedev); +char *block_device_get_sysfs_path_and_link (const char *devicenode);Please drop this declaration.
Quoted 1 line
Same as explained above!
As above...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Daniel,
I believe we need this change. We are using this function "of_path_get_nvme_nsid" in the patch which is defined in other file, and this "of_path_get_nvme_nsid" calls the function "block_device_get_sysfs_path_and_link". If we don't define this in the header file, we get this error below. Thank you!
*****
In file included from grub-core/osdep/ofpath.c:2:grub-core/osdep/linux/ofpath.c:228:1: error: no previous prototype for ‘block_device_get_sysfs_path_and_link’ [-Werror=missing-prototypes]
228 | block_device_get_sysfs_path_and_link(const char *devicenode)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:10855: grub-core/osdep/grub_mkrescue-ofpath.o] Error 1 make[2]: Leaving directory '/root/splitupgrub/grub'
make[1]: *** [Makefile:12412: check-recursive] Error 1
make[1]: Leaving directory '/root/splitupgrub/grub'
make: *** [Makefile:13491: check] Error 2
*****
Regards,
Avnish Chouhan
Quoted 82 lines · Daniel Kiper
Quoted 6 lines · Avnish Chouhan
Hi Daniel,
Thank you so much for a review!
Quoted 1 line · Daniel Kiper
On Mon, May 19, 2025 at 04:34:34PM +0530, Avnish Chouhan wrote:
[...]
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
grub-core/osdep/linux/ofpath.c +1
-1@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig) } } -static char * +char *xrealpath (const char *in) {char *out;@@ -224,7 +224,7 @@ xrealpath (const char *in)return out; }Quoted 7 lines
Quoted 4 lines
grub-core/osdep/linux/ofpath.c xrealpath (const char *in) · line 227
Quoted 2 lines
grub-core/osdep/linux/ofpath.c +1
-1-static char * +char *You do not need this change.
We need this function as this is used by the function "
of_path_get_nvme_nsid" we are using.The
block_device_get_sysfs_path_and_link()does not seem called from this patch. So, probably this change belongs to another one.Quoted 43 lines
Quoted 42 lines
Quoted 33 lines
grub-core/osdep/linux/ofpath.c +1
-1block_device_get_sysfs_path_and_link(const char *devicenode) {char *rpath;@@ -684,7 +684,7 @@ of_path_get_nvme_nsid (const char* devname)return nsid; } -static char * +char *nvme_get_syspath (const char *nvmedev) {char *sysfs_path;include/grub/util/install.h +3
-0@@ -235,6 +235,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor); +char * +add_multiple_nvme_bootdevices (const char *install_device); +void grub_install_register_ieee1275 (int is_prep, const char
*install_device,include/grub/util/install.h +0
-0int partno, const char *relpath);include/grub/util/ofpath.h +0
-0include/grub/util/ofpath.h int add_filename_to_pile (char *filename, struct · line 36
Quoted 7 lines
include/grub/util/ofpath.h +2
-0@@ -30,5 +30,9 @@ int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);void find_file (char * filename,char * directory,struct ofpath_files_list_root * root,int max_depth,int depth);char *of_find_fc_host (char * host_wwpn);void free_ofpath_files_list (struct ofpath_files_list_root * root); +char *nvme_get_syspath (const char *nvmedev); +char *block_device_get_sysfs_path_and_link (const char *devicenode);Please drop this declaration.
Quoted 5 lines
Quoted 1 line
Same as explained above!
As above...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Avnish,
Quoted 9 lines · Avnish Chouhan
Hi Daniel,
I believe we need this change. We are using this function "
of_path_get_nvme_nsid" in the patch which is defined in other file, and this "of_path_get_nvme_nsid" calls the function "block_device_get_sysfs_path_and_link". If we don't define this in the header file, we get this error below.
Thank you!
Quoted 7 lines
*****
In file included from
grub-core/osdep/ofpath.c:2:grub-core/osdep/linux/ofpath.c:228:1: error: no previous prototype for ‘block_device_get_sysfs_path_and_link’ [-Werror=missing-prototypes]
228 |block_device_get_sysfs_path_and_link(const char *devicenode)| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you drop both changes then everything should be OK.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Daniel,
Yes, you are correct. I'll do the change as suggested. Thank you!
Regards,
Avnish Chouhan
Quoted 20 lines · Daniel Kiper
Hi Avnish,
Quoted 9 lines · Avnish Chouhan
Hi Daniel,
I believe we need this change. We are using this function "
of_path_get_nvme_nsid" in the patch which is defined in other file, and this "of_path_get_nvme_nsid" calls the function "block_device_get_sysfs_path_and_link". If we don't define this in the header file, we get this error below.
Thank you!Quoted 7 lines
*****
In file included from
grub-core/osdep/ofpath.c:2:grub-core/osdep/linux/ofpath.c:228:1: error: no previous prototype for ‘block_device_get_sysfs_path_and_link’ [-Werror=missing-prototypes]
228 |block_device_get_sysfs_path_and_link(const char *devicenode)| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
If you drop both changes then everything should be OK.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel