Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snap-confine/nvidia: Support legacy biarch trees for GLVND systems #4559

Merged
merged 4 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/snap-confine/mount-support-nvidia.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ static const char *nvidia_globs[] = {
"/usr/lib/libnvidia-ptxjitcompiler.so*",
"/usr/lib/libnvidia-tls.so*",
"/usr/lib/vdpau/libvdpau_nvidia.so*",
"/usr/lib/nvidia*/libGL.so*",
"/usr/lib/nvidia*/libEGL.so*",
"/usr/lib/nvidia*/libGLESv1_CM.so*",
"/usr/lib/nvidia*/libGLESv2.so*",
};

static const size_t nvidia_globs_len =
Expand Down Expand Up @@ -133,6 +137,10 @@ static const char *nvidia_globs32[] = {
"/usr/lib32/libnvidia-ptxjitcompiler.so*",
"/usr/lib32/libnvidia-tls.so*",
"/usr/lib32/vdpau/libvdpau_nvidia.so*",
"/usr/lib32/nvidia*/libGL.so*",
"/usr/lib32/nvidia*/libEGL.so*",
"/usr/lib32/nvidia*/libGLESv1_CM.so*",
"/usr/lib32/nvidia*/libGLESv2.so*",
};

static const size_t nvidia_globs32_len =
Expand Down Expand Up @@ -216,6 +224,14 @@ static void sc_populate_libgl_with_hostfs_symlinks(const char *libgl_dir,
"%s/%s", libgl_dir, filename);
debug("creating symbolic link %s -> %s", symlink_name,
symlink_target);

// Make sure we don't have some link already (merged GLVND systems)
if (lstat(symlink_name, &stat_buf) == 0) {
if (unlink(symlink_name) != 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you also be testing if S_IFLNK? lstat() will happily return 0 if regular file or symlink.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is inside our hostfs symlink farm that we create, and we only create symlinks, the code doesn't copy files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, the naming here is confusing, but symlink_name is not the source name, it is the target name for the symlink, i.e. the new inode. Confused the hell out of me going through it the first time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll probably do a small update here to use consistent terminology (oldname vs whatever the other one was).

die("cannot remove symbolic link target %s", symlink_name);
}
}

if (symlink(symlink_target, symlink_name) != 0) {
die("cannot create symbolic link %s -> %s",
symlink_name, symlink_target);
Expand Down
2 changes: 1 addition & 1 deletion interfaces/builtin/opengl.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const openglConnectedPlugAppArmor = `
/var/lib/snapd/hostfs/usr/share/vulkan/icd.d/*nvidia*.json r,

# Main bi-arch GL libraries
/var/lib/snapd/hostfs/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}lib{GL,EGL,GLX}.so{,.*} rm,
/var/lib/snapd/hostfs/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}{,nvidia*/}lib{GL,EGL,GLX}.so{,.*} rm,

/dev/dri/ r,
/dev/dri/card0 rw,
Expand Down