github.com/craftyguy/u-root@v1.0.0/cmds/rmmod/rmmod_linux.go (about)

     1  // Copyright 2012-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Remove a module from the Linux kernel
     6  //
     7  // Synopsis:
     8  //	rmmod name
     9  //
    10  // Description:
    11  //	rmmod is a clone of rmmod(8)
    12  //
    13  // Author:
    14  //     Roland Kammerer <dev.rck@gmail.com>
    15  package main
    16  
    17  import (
    18  	"log"
    19  	"os"
    20  	"syscall"
    21  
    22  	"github.com/u-root/u-root/pkg/kmodule"
    23  )
    24  
    25  func main() {
    26  	if len(os.Args) < 2 {
    27  		log.Fatalf("rmmod: ERROR: missing module name.\n")
    28  	}
    29  
    30  	for _, modname := range os.Args[1:] {
    31  		if err := kmodule.Delete(modname, syscall.O_NONBLOCK); err != nil {
    32  			log.Fatalf("rmmod: %v", err)
    33  		}
    34  	}
    35  }