summaryrefslogtreecommitdiff
path: root/sys/ntfs/ntfs_vnops.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-01-03 16:06:02 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-01-03 16:06:02 +0000
commit48d7a9c8ab9b5285bde529597029762b39331c00 (patch)
tree4ccc30ec6ad358fcbb38fc2284a594cda6f9f5ab /sys/ntfs/ntfs_vnops.c
parent23b5baee572e476fee99a1b717815ab53233d31b (diff)
Ensure that a directory link count is always 1 so that things like
fts_read() do not try to be smart and end up skipping over directories. Additionally, ip->i_nlink will not be initialised until the ntnode has been loaded for the file. Makes find(1) behave predictably on a mounted NTFS file system. ok miod@
Diffstat (limited to 'sys/ntfs/ntfs_vnops.c')
-rw-r--r--sys/ntfs/ntfs_vnops.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c
index 34848d584a2..3a7e673cf41 100644
--- a/sys/ntfs/ntfs_vnops.c
+++ b/sys/ntfs/ntfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_vnops.c,v 1.26 2012/06/20 17:30:22 matthew Exp $ */
+/* $OpenBSD: ntfs_vnops.c,v 1.27 2013/01/03 16:06:01 jsing Exp $ */
/* $NetBSD: ntfs_vnops.c,v 1.6 2003/04/10 21:57:26 jdolecek Exp $ */
/*
@@ -156,6 +156,16 @@ ntfs_getattr(void *v)
vap->va_blocksize = ip->i_mp->ntm_spc * ip->i_mp->ntm_bps;
vap->va_type = vp->v_type;
vap->va_filerev = 0;
+
+ /*
+ * Ensure that a directory link count is always 1 so that things
+ * like fts_read() do not try to be smart and end up skipping over
+ * directories. Additionally, ip->i_nlink will not be initialised
+ * until the ntnode has been loaded for the file.
+ */
+ if (vp->v_type == VDIR || ip->i_nlink < 1)
+ vap->va_nlink = 1;
+
return (0);
}