@@ -244,50 +244,52 @@ void find_loadable_drivers(fidl::WireSyncClient<fuchsia_boot::Arguments>* boot_a
244
244
}
245
245
246
246
zx_status_t load_driver_vmo (fidl::WireSyncClient<fuchsia_boot::Arguments>* boot_args,
247
- std::string_view libname, zx::vmo vmo, DriverLoadCallback func) {
247
+ std::string_view libname_view, zx::vmo vmo, DriverLoadCallback func) {
248
+ std::string libname (libname_view);
248
249
zx_handle_t vmo_handle = vmo.get ();
249
- AddContext context = {boot_args, libname.data (), std::move (func), std::move (vmo)};
250
+ AddContext context = {boot_args, libname.c_str (), std::move (func), std::move (vmo)};
250
251
251
252
auto di_vmo_read = [](void * vmo, void * data, size_t len, size_t off) {
252
253
return zx_vmo_read (*((zx_handle_t *)vmo), data, off, len);
253
254
};
254
255
zx_status_t status = di_read_driver_info_etc (&vmo_handle, di_vmo_read, &context, found_driver);
255
256
256
257
if (status == ZX_ERR_NOT_FOUND) {
257
- LOGF (INFO, " Missing info from driver '%s'" , libname.data ());
258
+ LOGF (INFO, " Missing info from driver '%s'" , libname.c_str ());
258
259
} else if (status != ZX_OK) {
259
- LOGF (ERROR, " Failed to read info from driver '%s': %s" , libname.data (),
260
+ LOGF (ERROR, " Failed to read info from driver '%s': %s" , libname.c_str (),
260
261
zx_status_get_string (status));
261
262
}
262
263
return status;
263
264
}
264
265
265
- zx_status_t load_vmo (std::string_view libname, zx::vmo* out_vmo) {
266
+ zx_status_t load_vmo (std::string_view libname_view, zx::vmo* out_vmo) {
267
+ std::string libname (libname_view);
266
268
int fd = -1 ;
267
- zx_status_t r = fdio_open_fd (libname.data (),
269
+ zx_status_t r = fdio_open_fd (libname.c_str (),
268
270
static_cast <uint32_t >(fio::wire::OpenFlags::kRightReadable |
269
271
fio::wire::OpenFlags::kRightExecutable ),
270
272
&fd);
271
273
if (r != ZX_OK) {
272
- LOGF (ERROR, " Cannot open driver '%s': %d" , libname.data (), r);
274
+ LOGF (ERROR, " Cannot open driver '%s': %d" , libname.c_str (), r);
273
275
return ZX_ERR_IO;
274
276
}
275
277
zx::vmo vmo;
276
278
r = fdio_get_vmo_exec (fd, vmo.reset_and_get_address ());
277
279
close (fd);
278
280
if (r != ZX_OK) {
279
- LOGF (ERROR, " Cannot get driver VMO '%s'" , libname.data ());
281
+ LOGF (ERROR, " Cannot get driver VMO '%s'" , libname.c_str ());
280
282
return r;
281
283
}
282
- const char * vmo_name = strrchr (libname.data (), ' /' );
284
+ const char * vmo_name = strrchr (libname.c_str (), ' /' );
283
285
if (vmo_name != nullptr ) {
284
286
++vmo_name;
285
287
} else {
286
- vmo_name = libname.data ();
288
+ vmo_name = libname.c_str ();
287
289
}
288
290
r = vmo.set_property (ZX_PROP_NAME, vmo_name, strlen (vmo_name));
289
291
if (r != ZX_OK) {
290
- LOGF (ERROR, " Cannot set name on driver VMO to '%s'" , libname.data ());
292
+ LOGF (ERROR, " Cannot set name on driver VMO to '%s'" , libname.c_str ());
291
293
return r;
292
294
}
293
295
*out_vmo = std::move (vmo);
0 commit comments