diff --git a/file_system.go b/file_system.go index 33f7a79..95b7e51 100644 --- a/file_system.go +++ b/file_system.go @@ -114,9 +114,6 @@ type FileSystem interface { // The file system is responsible for checking that the directory is empty. // // Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf) - // - // TODO(jacobsa): Add tests for the assertion about directory link counts - // above (on a real file system and on memfs). RmDir( ctx context.Context, req *RmDirRequest) (*RmDirResponse, error) diff --git a/samples/memfs/posix_test.go b/samples/memfs/posix_test.go index 4edb824..4224ced 100644 --- a/samples/memfs/posix_test.go +++ b/samples/memfs/posix_test.go @@ -24,6 +24,7 @@ import ( "path" "testing" + . "github.com/jacobsa/oglematchers" . "github.com/jacobsa/ogletest" ) @@ -297,3 +298,18 @@ func (t *PosixTest) ReadsPastEndOfFile() { ExpectEq(0, n) ExpectEq("", string(buf[:n])) } + +func (t *PosixTest) HardLinkDirectory() { + dirName := path.Join(t.dir, "dir") + + // Create a directory. + err := os.Mkdir(dirName, 0700) + AssertEq(nil, err) + + // Attempt to hard-link it to a new name. + err = os.Link(dirName, path.Join(t.dir, "other")) + + AssertNe(nil, err) + ExpectThat(err, Error(HasSubstr("link"))) + ExpectThat(err, Error(HasSubstr("not permitted"))) +}