@@ -31,7 +31,8 @@ type command struct {
3131}
3232
3333type options struct {
34- driverRoot string
34+ root string
35+ devRoot string
3536
3637 dryRun bool
3738
@@ -65,11 +66,21 @@ func (m command) build() *cli.Command {
6566
6667 c .Flags = []cli.Flag {
6768 & cli.StringFlag {
68- Name : "driver-root" ,
69- Usage : "the path to the driver root. Device nodes will be created at `DRIVER_ROOT`/dev" ,
69+ Name : "root" ,
70+ // TODO: Remove this alias
71+ Aliases : []string {"driver-root" },
72+ Usage : "the path to to the root to use to load the kernel modules. This root must be a chrootable path. " +
73+ "If device nodes to be created these will be created at `ROOT`/dev unless an alternative path is specified" ,
7074 Value : "/" ,
71- Destination : & opts .driverRoot ,
72- EnvVars : []string {"NVIDIA_DRIVER_ROOT" , "DRIVER_ROOT" },
75+ Destination : & opts .root ,
76+ // TODO: Remove the NVIDIA_DRIVER_ROOT and DRIVER_ROOT envvars.
77+ EnvVars : []string {"ROOT" , "NVIDIA_DRIVER_ROOT" , "DRIVER_ROOT" },
78+ },
79+ & cli.StringFlag {
80+ Name : "dev-root" ,
81+ Usage : "specify the root where `/dev` is located. If this is not specified, the root is assumed." ,
82+ Destination : & opts .devRoot ,
83+ EnvVars : []string {"NVIDIA_DEV_ROOT" , "DEV_ROOT" },
7384 },
7485 & cli.BoolFlag {
7586 Name : "control-devices" ,
@@ -83,7 +94,7 @@ func (m command) build() *cli.Command {
8394 },
8495 & cli.BoolFlag {
8596 Name : "dry-run" ,
86- Usage : "if set, the command will not create any symlinks. " ,
97+ Usage : "if set, the command will not perform any operations " ,
8798 Value : false ,
8899 Destination : & opts .dryRun ,
89100 EnvVars : []string {"DRY_RUN" },
@@ -94,6 +105,10 @@ func (m command) build() *cli.Command {
94105}
95106
96107func (m command ) validateFlags (r * cli.Context , opts * options ) error {
108+ if opts .devRoot == "" && opts .root != "" {
109+ m .logger .Infof ("Using dev-root %q" , opts .root )
110+ opts .devRoot = opts .root
111+ }
97112 return nil
98113}
99114
@@ -102,7 +117,7 @@ func (m command) run(c *cli.Context, opts *options) error {
102117 modules := nvmodules .New (
103118 nvmodules .WithLogger (m .logger ),
104119 nvmodules .WithDryRun (opts .dryRun ),
105- nvmodules .WithRoot (opts .driverRoot ),
120+ nvmodules .WithRoot (opts .root ),
106121 )
107122 if err := modules .LoadAll (); err != nil {
108123 return fmt .Errorf ("failed to load NVIDIA kernel modules: %v" , err )
@@ -113,12 +128,12 @@ func (m command) run(c *cli.Context, opts *options) error {
113128 devices , err := nvdevices .New (
114129 nvdevices .WithLogger (m .logger ),
115130 nvdevices .WithDryRun (opts .dryRun ),
116- nvdevices .WithDevRoot (opts .driverRoot ),
131+ nvdevices .WithDevRoot (opts .devRoot ),
117132 )
118133 if err != nil {
119134 return err
120135 }
121- m .logger .Infof ("Creating control device nodes at %s" , opts .driverRoot )
136+ m .logger .Infof ("Creating control device nodes at %s" , opts .devRoot )
122137 if err := devices .CreateNVIDIAControlDevices (); err != nil {
123138 return fmt .Errorf ("failed to create NVIDIA control device nodes: %v" , err )
124139 }
0 commit comments