blob: 0a22a2c950dd3b1a615e8c271d86276da82980f4 [file] [log] [blame]
Jeff Gaston9f6da312017-08-09 18:35:15 -07001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package fs
16
17import (
18 "fmt"
19 "os"
20 "syscall"
21 "time"
22)
23
24func (osFs) InodeNumber(info os.FileInfo) (number uint64, err error) {
25 sys := info.Sys()
26 linuxStats, ok := sys.(*syscall.Stat_t)
27 if ok {
28 return linuxStats.Ino, nil
29 }
30 return 0, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
31}
32
33func (osFs) DeviceNumber(info os.FileInfo) (number uint64, err error) {
34 sys := info.Sys()
35 linuxStats, ok := sys.(*syscall.Stat_t)
36 if ok {
37 return linuxStats.Dev, nil
38 }
39 return 0, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
40}
41
42func (osFs) PermTime(info os.FileInfo) (when time.Time, err error) {
43 sys := info.Sys()
44 linuxStats, ok := sys.(*syscall.Stat_t)
45 if ok {
46 return time.Unix(linuxStats.Ctim.Sec, linuxStats.Ctim.Nsec), nil
47 }
48 return time.Time{}, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
49}