mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 00:33:57 +00:00
fs: Include filename in mknod errors
This commit is contained in:
parent
986d981bf6
commit
3c82fe6ef5
@ -3,8 +3,16 @@
|
|||||||
|
|
||||||
package restic
|
package restic
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
func mknod(path string, mode uint32, dev uint64) (err error) {
|
"golang.org/x/sys/unix"
|
||||||
return unix.Mknod(path, mode, int(dev))
|
)
|
||||||
|
|
||||||
|
func mknod(path string, mode uint32, dev uint64) error {
|
||||||
|
err := unix.Mknod(path, mode, int(dev))
|
||||||
|
if err != nil {
|
||||||
|
err = &os.PathError{Op: "mknod", Path: path, Err: err}
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,21 @@
|
|||||||
|
|
||||||
package restic
|
package restic
|
||||||
|
|
||||||
import "syscall"
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
func (node Node) restoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
|
func (node Node) restoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func mknod(path string, mode uint32, dev uint64) (err error) {
|
func mknod(path string, mode uint32, dev uint64) error {
|
||||||
return syscall.Mknod(path, mode, dev)
|
err := syscall.Mknod(path, mode, dev)
|
||||||
|
if err != nil {
|
||||||
|
err = &os.PathError{Op: "mknod", Path: path, Err: err}
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s statT) atim() syscall.Timespec { return s.Atimespec }
|
func (s statT) atim() syscall.Timespec { return s.Atimespec }
|
||||||
|
@ -7,10 +7,12 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -145,3 +147,12 @@ func TestNodeFromFileInfo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMknodError(t *testing.T) {
|
||||||
|
d := t.TempDir()
|
||||||
|
// Call mkfifo, which calls mknod, as mknod may give
|
||||||
|
// "operation not permitted" on Mac.
|
||||||
|
err := mkfifo(d, 0)
|
||||||
|
rtest.Assert(t, errors.Is(err, os.ErrExist), "want ErrExist, got %q", err)
|
||||||
|
rtest.Assert(t, strings.Contains(err.Error(), d), "filename not in %q", err)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user