From nobody@FreeBSD.org  Thu Aug 29 18:31:41 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id EB8159A8
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Aug 2013 18:31:41 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id D98722F2B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Aug 2013 18:31:41 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r7TIVfZE032387
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Aug 2013 18:31:41 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r7TIVfOH032386;
	Thu, 29 Aug 2013 18:31:41 GMT
	(envelope-from nobody)
Message-Id: <201308291831.r7TIVfOH032386@oldred.freebsd.org>
Date: Thu, 29 Aug 2013 18:31:41 GMT
From: Jan Beich <jbeich@tormail.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] devel/android-tools-adb: get rid of /proc dependency
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         181659
>Category:       ports
>Synopsis:       [patch] devel/android-tools-adb: get rid of /proc dependency
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kevlo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 29 18:40:00 UTC 2013
>Closed-Date:    Tue Sep 03 09:56:31 UTC 2013
>Last-Modified:  Tue Sep 03 09:56:31 UTC 2013
>Originator:     Jan Beich
>Release:        
>Organization:
>Environment:
/proc is empty (default)

>Description:

>How-To-Repeat:
$ adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
ADB server didn't ACK
* failed to start daemon *
Exit 255

>Fix:
--- no_procfs.diff begins here ---
--- get_my_path_freebsd.c~
+++ get_my_path_freebsd.c
@@ -18,19 +18,18 @@
  */
 
 #include <sys/types.h>
+#include <sys/sysctl.h>
 #include <unistd.h>
-#include <limits.h>
-#include <stdio.h>
 
 void
 get_my_path(char *exe, size_t maxLen)
 {
-    char proc[64];
+    int mib[] = {
+        CTL_KERN,
+        KERN_PROC,
+        KERN_PROC_PATHNAME,
+        getpid()
+    };
 
-    snprintf(proc, sizeof(proc), "/proc/%d/file", getpid());
-
-    int err = readlink(proc, exe, maxLen - 1);
-
-    exe[err > 0 ? err : 0] = '\0';
+    sysctl(mib, sizeof(mib)/sizeof(mib[0]), exe, &maxLen, NULL, 0);
 }
-
--- no_procfs.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->kevlo 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Aug 29 18:40:10 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/181659: commit references a PR
Date: Tue,  3 Sep 2013 09:49:25 +0000 (UTC)

 Author: kevlo
 Date: Tue Sep  3 09:49:17 2013
 New Revision: 326130
 URL: http://svnweb.freebsd.org/changeset/ports/326130
 
 Log:
   Get rid of /proc dependency.
   
   PR:	ports/181659
   Submitted by:	Jan Beich <jbeich at tormail dot org>
 
 Added:
   head/devel/android-tools-adb/files/patch-get_my_path_freebsd.c   (contents, props changed)
 Modified:
   head/devel/android-tools-adb/Makefile
 
 Modified: head/devel/android-tools-adb/Makefile
 ==============================================================================
 --- head/devel/android-tools-adb/Makefile	Tue Sep  3 08:49:46 2013	(r326129)
 +++ head/devel/android-tools-adb/Makefile	Tue Sep  3 09:49:17 2013	(r326130)
 @@ -2,6 +2,7 @@
  
  PORTNAME=	android-tools-adb
  PORTVERSION=	4.3
 +PORTREVISION=	1
  CATEGORIES=	devel
  DISTNAME=	android-platform_system_core-${GH_COMMIT}
  
 
 Added: head/devel/android-tools-adb/files/patch-get_my_path_freebsd.c
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/devel/android-tools-adb/files/patch-get_my_path_freebsd.c	Tue Sep  3 09:49:17 2013	(r326130)
 @@ -0,0 +1,30 @@
 +--- get_my_path_freebsd.c.orig	2013-09-03 17:33:27.000000000 +0800
 ++++ get_my_path_freebsd.c	2013-09-03 17:41:13.000000000 +0800
 +@@ -18,19 +18,18 @@
 +  */
 + 
 + #include <sys/types.h>
 ++#include <sys/sysctl.h>
 + #include <unistd.h>
 +-#include <limits.h>
 +-#include <stdio.h>
 + 
 + void
 + get_my_path(char *exe, size_t maxLen)
 + {
 +-    char proc[64];
 ++    int mib[4] = {
 ++        CTL_KERN,
 ++        KERN_PROC,
 ++        KERN_PROC_PATHNAME,
 ++        getpid()
 ++    };
 + 
 +-    snprintf(proc, sizeof(proc), "/proc/%d/file", getpid());
 +-
 +-    int err = readlink(proc, exe, maxLen - 1);
 +-
 +-    exe[err > 0 ? err : 0] = '\0';
 ++    sysctl(mib, 4, exe, &maxLen, NULL, 0);
 + }
 +-
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: kevlo 
State-Changed-When: Tue Sep 3 09:56:18 UTC 2013 
State-Changed-Why:  
Committed, thanks. 

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