From nobody Tue Oct 28 21:06:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513609513901454.448127382027; Mon, 18 Dec 2017 07:05:13 -0800 (PST) Received: from localhost ([::1]:43591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwyZ-0007pu-Su for importer@patchew.org; Mon, 18 Dec 2017 10:05:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwiK-0000Re-AK for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:48:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQwiG-0007ui-I8 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:48:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQwiG-0007tb-CZ for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:48:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A1432DACC6; Mon, 18 Dec 2017 14:48:15 +0000 (UTC) Received: from localhost (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DA078093B; Mon, 18 Dec 2017 14:48:11 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 18 Dec 2017 14:47:58 +0000 Message-Id: <20171218144800.27337-3-stefanha@redhat.com> In-Reply-To: <20171218144800.27337-1-stefanha@redhat.com> References: <20171218144800.27337-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Dec 2017 14:48:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] trace: Generalize searching for debugfs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Namhyung Kim , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Namhyung Kim The find_debugfs() can be shared to find a different filesystem like tracefs. So make it more general and rename to find_mount(). Signed-off-by: Namhyung Kim Signed-off-by: Stefan Hajnoczi --- trace/ftrace.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/trace/ftrace.c b/trace/ftrace.c index bfa38e71f0..213cb2205f 100644 --- a/trace/ftrace.c +++ b/trace/ftrace.c @@ -15,7 +15,7 @@ =20 int trace_marker_fd; =20 -static int find_debugfs(char *debugfs) +static int find_mount(char *mount_point, const char *fstype) { char type[100]; FILE *fp; @@ -27,8 +27,8 @@ static int find_debugfs(char *debugfs) } =20 while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", - debugfs, type) =3D=3D 2) { - if (strcmp(type, "debugfs") =3D=3D 0) { + mount_point, type) =3D=3D 2) { + if (strcmp(type, fstype) =3D=3D 0) { ret =3D 1; break; } @@ -40,14 +40,14 @@ static int find_debugfs(char *debugfs) =20 bool ftrace_init(void) { - char debugfs[PATH_MAX]; + char mount_point[PATH_MAX]; char path[PATH_MAX]; int debugfs_found; int trace_fd =3D -1; =20 - debugfs_found =3D find_debugfs(debugfs); + debugfs_found =3D find_mount(mount_point, "debugfs"); if (debugfs_found) { - snprintf(path, PATH_MAX, "%s/tracing/tracing_on", debugfs); + snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point); trace_fd =3D open(path, O_WRONLY); if (trace_fd < 0) { if (errno =3D=3D EACCES) { @@ -66,7 +66,7 @@ bool ftrace_init(void) } close(trace_fd); } - snprintf(path, PATH_MAX, "%s/tracing/trace_marker", debugfs); + snprintf(path, PATH_MAX, "%s/tracing/trace_marker", mount_point); trace_marker_fd =3D open(path, O_WRONLY); if (trace_marker_fd < 0) { perror("Could not open ftrace 'trace_marker' file"); --=20 2.14.3