From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16E5BA04A6; Wed, 9 Feb 2022 10:18:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 860B141101; Wed, 9 Feb 2022 10:18:55 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id D5D27410FD for ; Wed, 9 Feb 2022 10:18:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644398334; x=1675934334; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=OR/isYo246OZ2MbtJLtRvzeLHU/GLayJCTt/CiJ/9YU=; b=Mu3D+bdRvgzj1nvIqDfZAYsneHXepARISZt3QqnEzEL8y0RkOM1rA0q/ hv/bvjPaJKA+LTOVSdrkmtQIwWo42cuNqBt2Y90BDmBTT/8nQPmgjjvGI secGig3eq1loiJzQEUWPubylxHUx08eMMh42EsiE3FGH5cxMlY906jx0X CWeIt4E6iZdrfuvCLyYFS+VzJunJU/CovJJG+8oFnR0DuxSfdsNS+t4Ed ZCL9yUaYzDWWJcrrT02zgWSSiQip+ODYu4hr/e6PGzJz78vegAx0er3vm jntSES4axdt2Q+cnHxHPYY8o32Gr54bkE9SGgyEwIINMdtLQ7eDI5UmPJ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10252"; a="229813170" X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="229813170" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 01:18:16 -0800 X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="622216110" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.19.97]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 09 Feb 2022 01:18:15 -0800 Date: Wed, 9 Feb 2022 09:18:11 +0000 From: Bruce Richardson To: Stephen Hemminger Cc: dev@dpdk.org Subject: Re: [PATCH v3 3/3] eal: move common filesystem setup code into one file Message-ID: References: <20211223233907.181033-1-stephen@networkplumber.org> <20220209065403.168475-1-stephen@networkplumber.org> <20220209065403.168475-4-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220209065403.168475-4-stephen@networkplumber.org> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Feb 08, 2022 at 10:54:03PM -0800, Stephen Hemminger wrote: > Both Linux and FreeBSD have same code for creating runtime > directory and reading sysfs files. Put them in the new lib/eal/unix > subdirectory. > > Signed-off-by: Stephen Hemminger LGTM, apart from one minor nit inline below. Acked-by: Bruce Richardson > --- > lib/eal/freebsd/eal.c | 88 --------------------------- > lib/eal/linux/eal.c | 90 ---------------------------- > lib/eal/unix/eal_filesystem.c | 110 ++++++++++++++++++++++++++++++++++ > lib/eal/unix/meson.build | 1 + > 4 files changed, 111 insertions(+), 178 deletions(-) > create mode 100644 lib/eal/unix/eal_filesystem.c > > + > + /* create the path if it doesn't exist. no "mkdir -p" here, so do it > + * step by step. > + */ > + ret = mkdir(tmp, 0700); > + if (ret < 0 && errno != EEXIST) { > + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n", > + tmp, strerror(errno)); > + return -1; > + } > + > + ret = mkdir(run_dir, 0700); > + if (ret < 0 && errno != EEXIST) { > + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n", > + run_dir, strerror(errno)); > + return -1; > + } > + > + if (eal_set_runtime_dir(run_dir)) > + return -1; > + > + return 0; > +} Missing a blank line here between the two functions. > +/* parse a sysfs (or other) file containing one integer value */ > +int > +eal_parse_sysfs_value(const char *filename, unsigned long *val) > +{ > + FILE *f; > + char buf[BUFSIZ]; > + char *end = NULL; > + > + if ((f = fopen(filename, "r")) == NULL) { > + RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n", > + __func__, filename); > + return -1; > + } > + > + if (fgets(buf, sizeof(buf), f) == NULL) { > + RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n", > + __func__, filename); > + fclose(f); > + return -1; > + } > + *val = strtoul(buf, &end, 0); > + if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) { > + RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n", > + __func__, filename); > + fclose(f); > + return -1; > + } > + fclose(f); > + return 0; > +} > diff --git a/lib/eal/unix/meson.build b/lib/eal/unix/meson.build > index e3ecd3e956b2..a22ea7cabc46 100644 > --- a/lib/eal/unix/meson.build > +++ b/lib/eal/unix/meson.build > @@ -6,5 +6,6 @@ sources += files( > 'eal_unix_memory.c', > 'eal_unix_timer.c', > 'eal_firmware.c', > + 'eal_filesystem.c', > 'rte_thread.c', > ) > -- > 2.34.1 >