github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/df/dev.go (about)

     1  // Copyright 2015-2022 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  //go:build !(mips || mips64 || mips64le || mipsle || plan9 || windows)
     6  
     7  package main
     8  
     9  import (
    10  	"golang.org/x/sys/unix"
    11  )
    12  
    13  func deviceNumber(path string) (uint64, error) {
    14  	st := &unix.Stat_t{}
    15  	err := unix.Stat(path, st)
    16  	if err != nil {
    17  		return 0, err
    18  	}
    19  	return st.Dev, nil
    20  }