From 319958545e61e996dc1f8fac3ed1705608177da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 21 Mar 2012 18:48:38 +0100 Subject: [PATCH] Made sure directories are not hard linked On OpenIndiana the fuse kernel module does not prevent link(2) from hard linking directories, so this has to be done in the lowntfs-3g driver. --- src/lowntfs-3g.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index c592a65e..814f28bc 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -2091,6 +2091,12 @@ static int ntfs_fuse_newlink(fuse_req_t req __attribute__((unused)), goto exit; } + /* Do not accept linking to a directory (except for renaming) */ + if (e && (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + errno = EPERM; + res = -errno; + goto exit; + } /* Generate unicode filename. */ uname_len = ntfs_mbstoucs(newname, &uname); if ((uname_len < 0)