mirror of
https://github.com/versity/scoutfs-go.git
synced 2026-09-04 23:27:05 +00:00
scoutfs now adds a new ioctl to get the parent id and some extra info given an inode within the filesystem. This is less expensive than the full path resolution for an inode, so can speed up cases when the parent is all thats needed.
42 lines
790 B
Go
42 lines
790 B
Go
// Copyright (c) 2018 Versity Software, Inc.
|
|
//
|
|
// Use of this source code is governed by a BSD-3-Clause license
|
|
// that can be found in the LICENSE file in the root of the source
|
|
// tree.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
|
|
scoutfs "github.com/versity/scoutfs-go"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) != 3 || os.Args[1] == "-h" {
|
|
fmt.Fprintln(os.Stderr, "usage:", os.Args[0], "<scoutfs mount point> <inode>")
|
|
os.Exit(1)
|
|
}
|
|
|
|
f, err := os.Open(os.Args[1])
|
|
if err != nil {
|
|
log.Fatalln("error open mount:", err)
|
|
}
|
|
defer f.Close()
|
|
|
|
u, err := strconv.ParseUint(os.Args[2], 10, 64)
|
|
if err != nil {
|
|
log.Fatalln("error parsing inode:", err)
|
|
}
|
|
|
|
s, err := scoutfs.GetParents(f, u, nil)
|
|
if err != nil {
|
|
log.Fatalln("error get parents:", err)
|
|
}
|
|
|
|
fmt.Println(s)
|
|
}
|