From: Stephen Hemminger <stephen@networkplumber.org>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, andremue@linux.microsoft.com,
Tyler Retzlaff <roretzla@linux.microsoft.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Subject: Re: [PATCH v4 1/4] eal: add basename function for common path manipulation
Date: Fri, 1 Aug 2025 14:56:11 -0700 [thread overview]
Message-ID: <20250801145611.7a2ef22f@hermes.local> (raw)
In-Reply-To: <20250731160041.914837-2-bruce.richardson@intel.com>
On Thu, 31 Jul 2025 16:00:38 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:
> There is no standard, cross-platform function to get the basename of a
> file path across all the supported DPDK platforms, Linux, BSD and
> Windows. Both Linux and BSD have a "basename" function in standard
> library, except:
> * Linux has two different basename functions, a POSIX version (which may
> or may not modify args), and a GNU one which is guaranteed *not* to
> modify the input arg and returns pointer to internal storage.
> * FreeBSD has just the one basename function, but, to be different, it is
> guaranteed *always* to modify the argument and re-use it for output.
> * Windows just doesn't have a basename function, but provides _split_path
> as a similar function, but with many differences over basename, e.g.
> splitting off extension, returning empty basename if path ends in "/"
> etc. etc.
>
> Therefore, rather than just trying to implement basename for windows,
> which opens the question as to whether to emulate GNU and *never* modify
> arg, or emulate BSD and *always* modify arg, this patchset introduces
> "rte_basename" which should have defined behaviour on all platforms. The
> patch also introduces a set of test cases to confirm consistent behaviour
> on all platforms too.
>
> The behaviour is as in doxygen docs. Essentially:
> - does not modify input path buffer
> - returns output in a separate output buffer
> - uses snprintf and strlcpy style return value to indicate truncation
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
What about existing uses of basename()
0 main.c main 553 char *token = strtok(basename(rst_path),
".");
1 process.h get_current_prefix 220 snprintf(prefix, size, "%s",
basename(dirname(buf)));
2 mlx5_common_auxiliary.c mlx5_auxiliary_get_pci_str 85 base = basename(sysfs_pci);
3 idxd_bus.c is_for_this_process_use 271 prefix = basename(runtime_dir);
4 bnxt_tf_pmd_shim.c ulp_pmd_get_mac_by_pci 156 intf_name = basename(gres.gl_pathv[0]);
5 eal_common_proc.c rte_mp_channel_init 628 strlcpy(mp_filter, basename(path),
sizeof(mp_filter));
next prev parent reply other threads:[~2025-08-01 21:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 14:05 [PATCH] app/testpmd: allow multiple cmdline-file parameters Bruce Richardson
2025-07-04 18:34 ` [PATCH v2 0/3] improve cmdline file handling in testpmd Bruce Richardson
2025-07-04 18:34 ` [PATCH v2 1/3] app/testpmd: explicitly set command echoing on file load Bruce Richardson
2025-07-04 18:34 ` [PATCH v2 2/3] app/testpmd: allow multiple commandline file parameters Bruce Richardson
2025-07-04 18:34 ` [PATCH v2 3/3] app/testpmd: improve output when processing cmdline files Bruce Richardson
2025-07-07 11:17 ` [PATCH v3 0/3] improve cmdline file handling in testpmd Bruce Richardson
2025-07-07 11:17 ` [PATCH v3 1/3] app/testpmd: explicitly set command echoing on file load Bruce Richardson
2025-07-07 11:17 ` [PATCH v3 2/3] app/testpmd: allow multiple commandline file parameters Bruce Richardson
2025-07-07 11:17 ` [PATCH v3 3/3] app/testpmd: improve output when processing cmdline files Bruce Richardson
2025-07-29 4:24 ` Stephen Hemminger
2025-07-31 16:00 ` [PATCH v4 0/4] improve cmdline file handling in testpmd Bruce Richardson
2025-07-31 16:00 ` [PATCH v4 1/4] eal: add basename function for common path manipulation Bruce Richardson
2025-08-01 14:25 ` Andre Muezerie
2025-08-01 21:56 ` Stephen Hemminger [this message]
2025-07-31 16:00 ` [PATCH v4 2/4] app/testpmd: explicitly set command echoing on file load Bruce Richardson
2025-07-31 16:00 ` [PATCH v4 3/4] app/testpmd: allow multiple commandline file parameters Bruce Richardson
2025-07-31 16:00 ` [PATCH v4 4/4] app/testpmd: improve output when processing cmdline files Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250801145611.7a2ef22f@hermes.local \
--to=stephen@networkplumber.org \
--cc=andremue@linux.microsoft.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=roretzla@linux.microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).