/*
goredo -- djb's redo implementation on pure Go
-Copyright (C) 2020-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
}
-func inodeFromFileByFd(fd *os.File) (*Inode, error) {
+func inodeFromFileByFd(fd *os.File) (inode *Inode, isDir bool, err error) {
fi, err := fd.Stat()
if err != nil {
- return nil, err
+ return
+ }
+ if fi.IsDir() {
+ isDir = true
+ return
}
var stat unix.Stat_t
err = unix.Fstat(int(fd.Fd()), &stat)
if err != nil {
- return nil, err
+ return
}
- return inodeFromFileStat(fi, stat), nil
+ inode = inodeFromFileStat(fi, stat)
+ return
}
func inodeFromFileByPath(p string) (*Inode, error) {