Commit bddfd80b authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

loopback: fix "touch" on dirs by making root path absolute

When mounting using relative paths, "touch" on directories
used to fail.

"touch" on files works accidentially because it uses a
file descriptor internally.

  $ loopback b a &
  $ cd b
  $ mkdir foo
  $ touch foo
  touch: setting times of 'foo': Not a directory

strace:

  [pid 30185] utimensat(0, "a/foo", [{1468441847, 0}, {1468441847, 0}], AT_SYMLINK_NOFOLLOW <unfinished ...>
  [pid 30185] <... utimensat resumed> )   = -1 ENOTDIR (Not a directory)
parent 3cf08068
......@@ -25,6 +25,12 @@ type loopbackFileSystem struct {
// system. Its main purpose is to provide test coverage without
// having to build a synthetic filesystem.
func NewLoopbackFileSystem(root string) FileSystem {
// Make sure the Root path is absolute to avoid problems when the
// application changes working directory.
root, err := filepath.Abs(root)
if err != nil {
panic(err)
}
return &loopbackFileSystem{
FileSystem: NewDefaultFileSystem(),
Root: root,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment