From rodrigc@crodrigues.org  Sat Mar 26 19:20:47 2005
Return-Path: <rodrigc@crodrigues.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id DB5AA16A4CE; Sat, 26 Mar 2005 19:20:47 +0000 (GMT)
Received: from rwcrmhc14.comcast.net (rwcrmhc14.comcast.net [216.148.227.89])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 748E043D53; Sat, 26 Mar 2005 19:20:47 +0000 (GMT)
	(envelope-from rodrigc@crodrigues.org)
Received: from h00609772adf0.ne.client2.attbi.com ([66.30.114.143])
          by comcast.net (rwcrmhc14) with ESMTP
          id <2005032619204601400au6oee>; Sat, 26 Mar 2005 19:20:46 +0000
Received: from h00609772adf0.ne.client2.attbi.com (localhost.127.in-addr.arpa [127.0.0.1])
	by h00609772adf0.ne.client2.attbi.com (8.13.3/8.13.1) with ESMTP id j2QJKUvP001127;
	Sat, 26 Mar 2005 14:20:34 -0500 (EST)
	(envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com)
Received: (from rodrigc@localhost)
	by h00609772adf0.ne.client2.attbi.com (8.13.3/8.13.1/Submit) id j2QJKJZT001126;
	Sat, 26 Mar 2005 14:20:19 -0500 (EST)
	(envelope-from rodrigc)
Message-Id: <200503261920.j2QJKJZT001126@h00609772adf0.ne.client2.attbi.com>
Date: Sat, 26 Mar 2005 14:20:19 -0500 (EST)
From: Craig Rodrigues <rodrigc@crodrigues.org>
Reply-To: Craig Rodrigues <rodrigc@crodrigues.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: rwatson@freebsd.org, kan@freebsd.org, rodrigc@crodrigues.org
Subject: exttatr_list_file() wrongly documented in exattr(2) man page
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         79261
>Category:       docs
>Synopsis:       exttatr_list_file() wrongly documented in exattr(2) man page
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 26 19:30:03 GMT 2005
>Closed-Date:    Fri Jun 10 16:56:34 GMT 2005
>Last-Modified:  Fri Jun 10 16:56:34 GMT 2005
>Originator:     Craig Rodrigues
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD dibbler.crodrigues.org 6.0-CURRENT FreeBSD 6.0-CURRENT #28: Sat Mar 26 13:25:05 EST 2005 rodrigc@dibbler.crodrigues.org:/opt/home/rodrigc/xfs/xfs_kernel/sys/i386/compile/XFS_KERNEL i386


	
>Description:
	While implementing extended attribute for the FreeBSD port of the
	XFS file system, I ran across the following in the extattr(2) man
	page:
	The extattr_list_file() returns a list of attributes present in the 
	requested namespace, separated by ASCII 0 (nul) characters.

	However, when I implemented this system call for XFS,
	the /usr/sbin/lsextattr utility did not work.  After looking at
	the source code for lsexttatr, I found the following code:

    234                         for (i = 0; i < error; i += buf[i] + 1)
    235                             printf("%s%*.*s", i ? "\t" : "",
    236                                 buf[i], buf[i], buf + i + 1);

	lsextattr expects to receive a buffer of extended attribute
	names.  Each name is preceded by one byte which contains
	the length of the attribute name.  Each attribute name
	is *NOT* NULL terminated in the buffer.

	I suggest that the man page for extattr(2) be changed
	to reflect the reality of what lsextattr expects.
	
>How-To-Repeat:
	
>Fix:

--- extattr_get_file.2.orig	Sat Mar 26 14:16:50 2005
+++ extattr_get_file.2	Sat Mar 26 14:19:11 2005
@@ -97,8 +97,10 @@
 system call deletes the extended attribute specified.
 The
 .Fn extattr_list_file
-returns a list of attributes present in the requested namespace, separated
-by ASCII 0 (nul) characters.
+returns a list of attributes present in the requested namespace.
+Each list entry consists of a single byte containing the length
+of the attribute name, followed by the attribute name.  The
+attribute name is not terminated by ASCII 0 (nul).
 The
 .Fn extattr_get_file ,
 and
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-doc->rwatson 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Wed Jun 8 13:52:07 GMT 2005 
Responsible-Changed-Why:  
Robert, can you take a look at this minor fix to the extattr_get_file.2 
man page? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79261 
Responsible-Changed-From-To: rwatson->rodrigc 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Wed Jun 8 14:47:05 GMT 2005 
Responsible-Changed-Why:  
This patch looks good to me.  I prefer the documented API to the implemented 
one, but I'm realistic.  FYI, I chatted with Apple folk at WWDC about 
adopting their API, and obviously they'd like that.  I have some initial 
code fragments to add the new system calls, but no implementation yet.  I'll 
drop them in perforce today sometime and point you at it? 



http://www.freebsd.org/cgi/query-pr.cgi?pr=79261 
State-Changed-From-To: open->closed 
State-Changed-By: rodrigc 
State-Changed-When: Fri Jun 10 16:54:40 GMT 2005 
State-Changed-Why:  
Committed the patch. 

Well, I don't have a strong feeling for how the API 
for listing extended attributes is implemented, just as long 
as it is documented correctly in the man page. :) 
The existing FreeBSD API is pretty close to the one that SGI 
implemented for XFS (the original API, not the hacks they 
had to do to get extended attributes to work with Linux). 

I'll take a look at your stuff in Perforce in a few days, 
and will hopefully get back to XFS work. :) :) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79261 
>Unformatted:
