github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/df/dev_uint32.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 "golang.org/x/sys/unix"
    10  
    11  func deviceNumber(path string) (uint64, error) {
    12  	st := &unix.Stat_t{}
    13  	err := unix.Stat(path, st)
    14  	if err != nil {
    15  		return 0, err
    16  	}
    17  	return uint64(st.Dev), nil
    18  }