github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap-confine/mount-support-nvidia.h (about)

     1  /*
     2   * Copyright (C) 2015 Canonical Ltd
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License version 3 as
     6   * published by the Free Software Foundation.
     7   *
     8   * This program is distributed in the hope that it will be useful,
     9   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11   * GNU General Public License for more details.
    12   *
    13   * You should have received a copy of the GNU General Public License
    14   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15   *
    16   */
    17  
    18  #ifndef SNAP_CONFINE_MOUNT_SUPPORT_NVIDIA_H
    19  #define SNAP_CONFINE_MOUNT_SUPPORT_NVIDIA_H
    20  
    21  /**
    22   * Make the Nvidia driver from the classic distribution available in the snap
    23   * execution environment.
    24   *
    25   * This function may be a no-op, depending on build-time configuration options.
    26   * If enabled the behavior differs from one distribution to another because of
    27   * differences in classic packaging and perhaps version of the Nvidia driver.
    28   * This function is designed to be called before pivot_root() switched the root
    29   * filesystem.
    30   *
    31   * On Ubuntu, there are several versions of the binary Nvidia driver. The
    32   * drivers are all installed in /usr/lib/nvidia-$MAJOR_VERSION where
    33   * MAJOR_VERSION is an integer like 304, 331, 340, 346, 352 or 361.  The driver
    34   * is located by inspecting /sys/modules/nvidia/version which contains the
    35   * string "$MAJOR_VERSION.$MINOR_VERSION". The appropriate directory is then
    36   * bind mounted to /var/lib/snapd/lib/gl relative relative to the location of
    37   * the root filesystem directory provided as an argument.
    38   *
    39   * On Arch another approach is used. Because the actual driver installs a
    40   * number of shared objects into /usr/lib, they cannot be bind mounted
    41   * directly. Instead a tmpfs is mounted on /var/lib/snapd/lib/gl. The tmpfs is
    42   * subsequently populated with symlinks that point to a number of files in the
    43   * /usr/lib directory on the classic filesystem. After the pivot_root() call
    44   * those symlinks rely on the /var/lib/snapd/hostfs directory as a "gateway".
    45   **/
    46  void sc_mount_nvidia_driver(const char *rootfs_dir);
    47  
    48  #endif