mirror of
https://github.com/octoleo/restic.git
synced 2024-11-27 15:26:37 +00:00
fs: Include filename in mknod errors
This commit is contained in:
parent
efec1a5e96
commit
e10e2bb50f
@ -3,8 +3,16 @@
|
|||||||
|
|
||||||
package fs
|
package fs
|
||||||
|
|
||||||
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,12 +3,19 @@
|
|||||||
|
|
||||||
package fs
|
package fs
|
||||||
|
|
||||||
import "syscall"
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
func nodeRestoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
|
func nodeRestoreSymlinkTimestamps(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
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
@ -134,3 +136,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