From nobody@FreeBSD.org  Tue Jun 28 07:09:36 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2064B106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Jun 2011 07:09:36 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 103F38FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Jun 2011 07:09:36 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p5S79ZR2071011
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Jun 2011 07:09:35 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p5S79ZJO071010;
	Tue, 28 Jun 2011 07:09:35 GMT
	(envelope-from nobody)
Message-Id: <201106280709.p5S79ZJO071010@red.freebsd.org>
Date: Tue, 28 Jun 2011 07:09:35 GMT
From: Will DeVries <william.devries@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] The UDF file system under counts the number of entries in directories by one.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         158376
>Category:       kern
>Synopsis:       [udf] [patch] The UDF file system under counts the number of entries in directories by one.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 28 07:10:09 UTC 2011
>Closed-Date:    
>Last-Modified:  Tue Jun 28 14:13:18 UTC 2011
>Originator:     Will DeVries
>Release:        9.0-current
>Organization:
>Environment:
9.0-current
>Description:
The UDF file system does not include '.' in the count of items in a directory.  This was not accounted for in the code for vop_getattr.

>How-To-Repeat:
This issue can been seen by mounting a UDF file system and comparing the count given by ls -l for the number of entries in the mount point to the actual number of entries.  (The count will be one less then the actual number of entries.  '.' is excluded from the count.)
>Fix:


Patch attached with submission follows:

--- sys/fs/udf/udf_vnops.c.old	2011-06-27 15:56:54.000000000 -0700
+++ sys/fs/udf/udf_vnops.c	2011-06-27 16:05:51.000000000 -0700
@@ -316,6 +316,9 @@
 	vap->va_ctime = vap->va_mtime; /* XXX Stored as an Extended Attribute */
 	vap->va_rdev = NODEV;
 	if (vp->v_type & VDIR) {
+		/* UDF doesn't include '.' as entry in directories. */
+		vap->va_nlink++;
+
 		/*
 		 * Directories that are recorded within their ICB will show
 		 * as having 0 blocks recorded.  Since tradition dictates


>Release-Note:
>Audit-Trail:

From: William Dean DeVries <william.devries@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/158376: [patch] The UDF file system under counts the number
 of entries in directories by one.
Date: Tue, 28 Jun 2011 00:39:03 -0700

 Err, I have this all wrong.  I don't know where I came up with
 directories entry counts.  The UDF file system under counts the number
 of links to directories by one.  It does not count for '.', which
 doesn't actually exist in the file system but presented in the by
 system.  A directory in the udf filesystem with one subdirectory and
 no other links to the directory would have a link count of 2.  This
 arrangement under udf would have a link count of 3.
>Unformatted:
