github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/cmds/core/mkfifo/mkfifo.go (about) 1 // Copyright 2013-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 // mkfifo creates a named pipe. 6 // 7 // Synopsis: 8 // mkfifo [OPTIONS] NAME... 9 // 10 // Options: 11 // -m: mode (default 0600) 12 // 13 package main 14 15 import ( 16 "flag" 17 "log" 18 "os" 19 20 "golang.org/x/sys/unix" 21 ) 22 23 const ( 24 defaultMode = 0660 | unix.S_IFIFO 25 cmd = "mkfifo [-m] NAME..." 26 ) 27 28 var mode = flag.Int("mode", defaultMode, "Mode to create fifo") 29 30 func init() { 31 defUsage := flag.Usage 32 flag.Usage = func() { 33 os.Args[0] = cmd 34 defUsage() 35 } 36 flag.Parse() 37 } 38 39 func main() { 40 flag.Parse() 41 42 if flag.NArg() < 1 { 43 log.Fatal("please provide a path, or multiple, to create a fifo") 44 } 45 46 for _, path := range flag.Args() { 47 if err := unix.Mkfifo(path, uint32(*mode)); err != nil { 48 log.Fatalf("Error while creating fifo, %v", err) 49 } 50 } 51 }