From nobody@FreeBSD.org  Wed Nov  7 18:25:24 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 8FF83599
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Nov 2012 18:25:24 +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 775608FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Nov 2012 18:25:24 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qA7IPOOi072923
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 7 Nov 2012 18:25:24 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qA7IPOCY072896;
	Wed, 7 Nov 2012 18:25:24 GMT
	(envelope-from nobody)
Message-Id: <201211071825.qA7IPOCY072896@red.freebsd.org>
Date: Wed, 7 Nov 2012 18:25:24 GMT
From: Fernando <fernando.apesteguia@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ftw.3 manual page example addition
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         173448
>Category:       docs
>Synopsis:       [patch] ftw.3 manual page example addition
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    keramida
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 07 18:30:00 UTC 2012
>Closed-Date:    
>Last-Modified:  Fri Feb 21 17:40:01 UTC 2014
>Originator:     Fernando
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD beastie 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
While having a look at the ftw(3) man page, I noticed we lacked an example. The attached patch adds a small yet clear example on how to use this function.
>How-To-Repeat:
man ftw
>Fix:
Apply the attached patch if it is found to be suitable.

Patch attached with submission follows:

--- /usr/src/lib/libc/gen/ftw.3	2012-01-03 04:26:08.000000000 +0100
+++ ftw_man/ftw.3	2012-11-07 19:18:48.000000000 +0100
@@ -155,6 +155,54 @@
 will stop processing the tree and return the value from
 .Fa fn .
 Both functions return \-1 if an error is detected.
+.Sh EXAMPLES
+Following there is a small example that shows how
+.Nm
+works. It traverses the file tree starting at the directory pointed
+by the only program argument and shows the complete path and a brief
+indicator about the file type.
+.Bd -literal
+#include <ftw.h>
+#include <stdio.h>
+
+int
+ftw_callback(const char *path, const struct stat *sb, int typeflag)
+{
+	char type;
+
+	switch(typeflag) {
+	case FTW_F: 
+		type = 'F';
+		break;
+	case FTW_D:
+		type = 'D';
+		break;
+	case FTW_DNR:
+		type = '-';
+		break;
+	case FTW_NS:
+		type = 'X';
+		break;
+	}
+
+	printf("[%c] %s\n", type, path);
+
+	return (0);
+}
+
+int
+main(int argc, char **argv)
+{
+
+	if (argc != 2) {
+		printf("Usage %s <directory>\n", argv[0]);
+		return (0);
+	} else {
+		return (ftw(argv[1], ftw_callback, /*UNUSED*/ 10));
+	}
+
+}
+.Ed
 .Sh ERRORS
 The
 .Fn ftw


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-doc->keramida 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Wed Feb 20 10:00:51 UTC 2013 
Responsible-Changed-Why:  
I'll take care of this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173448 

From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= <fernando.apesteguia@gmail.com>
To: bug-followup@FreeBSD.org, fernando.apesteguia@gmail.com
Cc:  
Subject: Re: docs/173448: [patch] ftw.3 manual page example addition
Date: Fri, 21 Feb 2014 18:30:51 +0100

 --e89a8f3bae5dc4c36d04f2edfb75
 Content-Type: text/plain; charset=ISO-8859-1
 
 Any progress on this?
 
 --e89a8f3bae5dc4c36d04f2edfb75
 Content-Type: text/html; charset=ISO-8859-1
 
 <div dir="ltr">Any progress on this?<br></div>
 
 --e89a8f3bae5dc4c36d04f2edfb75--
>Unformatted:
