github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/cmds/exp/partprobe/partprobe.go (about)

     1  // Copyright 2020 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  // partprobe prompts the OS to re-read partition tables.
     6  //
     7  // Synopsis:
     8  //   partprobe [device]...
     9  //
    10  package main
    11  
    12  import (
    13  	"flag"
    14  	"log"
    15  	"os"
    16  
    17  	"github.com/u-root/u-root/pkg/mount/block"
    18  )
    19  
    20  func main() {
    21  	flag.Parse()
    22  
    23  	devs := flag.Args()
    24  
    25  	if len(devs) == 0 {
    26  		log.Printf("Usage: partprobe [device]...")
    27  		os.Exit(0)
    28  	}
    29  
    30  	for _, dev := range devs {
    31  		d, err := block.Device(dev)
    32  		if err != nil {
    33  			log.Printf("Failed to find device %s: %v", dev, err)
    34  			continue
    35  		}
    36  
    37  		if err := d.ReadPartitionTable(); err != nil {
    38  			log.Printf("Failed to read partition table for %s: %v", dev, err)
    39  		}
    40  	}
    41  }