Skip to content

Commit a141a7a

Browse files
committed
Handle 32-bit PCI domains in procfs
1 parent 391c4b6 commit a141a7a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/nvc_mount.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,22 @@ mount_procfs_gpu(struct error *err, const char *root, const struct nvc_container
297297
char *mnt = NULL;
298298
mode_t mode;
299299

300-
/* XXX The driver procfs uses 16-bit PCI domain */
301-
if (xasprintf(err, &gpu, "%s/gpus/%s", NV_PROC_DRIVER, busid + 4) < 0)
302-
return (NULL);
303-
if (path_join(err, src, root, gpu) < 0)
304-
goto fail;
305-
if (path_resolve_full(err, dst, cnt->cfg.rootfs, gpu) < 0)
306-
goto fail;
307-
if (file_mode(err, src, &mode) < 0)
308-
goto fail;
300+
for (int off = 0;; off += 4) {
301+
/* XXX Check if the driver procfs uses 32-bit or 16-bit PCI domain */
302+
if (xasprintf(err, &gpu, "%s/gpus/%s", NV_PROC_DRIVER, busid + off) < 0)
303+
return (NULL);
304+
if (path_join(err, src, root, gpu) < 0)
305+
goto fail;
306+
if (path_resolve_full(err, dst, cnt->cfg.rootfs, gpu) < 0)
307+
goto fail;
308+
if (file_mode(err, src, &mode) == 0)
309+
break;
310+
if (err->code != ENOENT || off != 0)
311+
goto fail;
312+
*dst = '\0';
313+
free(gpu);
314+
gpu = NULL;
315+
}
309316
if (file_create(err, dst, NULL, cnt->uid, cnt->gid, mode) < 0)
310317
goto fail;
311318

0 commit comments

Comments
 (0)