* [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency
@ 2025-10-03 17:56 Ian Rogers
2025-10-03 17:56 ` [PATCH v2 2/2] tools build: Remove get_current_dir_name Ian Rogers
2025-10-03 18:29 ` [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Arnaldo Carvalho de Melo
0 siblings, 2 replies; 5+ messages in thread
From: Ian Rogers @ 2025-10-03 17:56 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, linux-kernel, linux-perf-users
get_current_dir_name is a GNU extension not supported on, for example,
Android. There is only one use of it so let's just switch to getcwd to
avoid build and other complexity.
Signed-off-by: Ian Rogers <irogers@google.com>
---
v2: Fix free of oldcwd on errout.
---
tools/perf/Makefile.config | 4 ----
tools/perf/util/Build | 1 -
tools/perf/util/get_current_dir_name.c | 18 ------------------
tools/perf/util/get_current_dir_name.h | 8 --------
tools/perf/util/namespaces.c | 7 +++----
5 files changed, 3 insertions(+), 35 deletions(-)
delete mode 100644 tools/perf/util/get_current_dir_name.c
delete mode 100644 tools/perf/util/get_current_dir_name.h
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0f4b297fbacc..6cdb96576cb8 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -417,10 +417,6 @@ ifeq ($(feature-eventfd), 1)
CFLAGS += -DHAVE_EVENTFD_SUPPORT
endif
-ifeq ($(feature-get_current_dir_name), 1)
- CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
-endif
-
ifeq ($(feature-gettid), 1)
CFLAGS += -DHAVE_GETTID
endif
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 5ead46dc98e7..9464eceb764b 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -23,7 +23,6 @@ perf-util-y += evsel_fprintf.o
perf-util-y += perf_event_attr_fprintf.o
perf-util-y += evswitch.o
perf-util-y += find_bit.o
-perf-util-y += get_current_dir_name.o
perf-util-y += levenshtein.o
perf-util-y += mmap.o
perf-util-y += memswap.o
diff --git a/tools/perf/util/get_current_dir_name.c b/tools/perf/util/get_current_dir_name.c
deleted file mode 100644
index e68935e9ac8c..000000000000
--- a/tools/perf/util/get_current_dir_name.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1
-// Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
-//
-#ifndef HAVE_GET_CURRENT_DIR_NAME
-#include "get_current_dir_name.h"
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
-
-/* Android's 'bionic' library, for one, doesn't have this */
-
-char *get_current_dir_name(void)
-{
- char pwd[PATH_MAX];
-
- return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
-}
-#endif // HAVE_GET_CURRENT_DIR_NAME
diff --git a/tools/perf/util/get_current_dir_name.h b/tools/perf/util/get_current_dir_name.h
deleted file mode 100644
index 69f7d5537d32..000000000000
--- a/tools/perf/util/get_current_dir_name.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1
-// Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
-//
-#ifndef __PERF_GET_CURRENT_DIR_NAME_H
-#ifndef HAVE_GET_CURRENT_DIR_NAME
-char *get_current_dir_name(void);
-#endif // HAVE_GET_CURRENT_DIR_NAME
-#endif // __PERF_GET_CURRENT_DIR_NAME_H
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
index 68f5de2d79c7..01502570b32d 100644
--- a/tools/perf/util/namespaces.c
+++ b/tools/perf/util/namespaces.c
@@ -6,7 +6,6 @@
#include "namespaces.h"
#include "event.h"
-#include "get_current_dir_name.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -293,14 +292,14 @@ void nsinfo__mountns_enter(struct nsinfo *nsi,
if (!nsi || !nsinfo__need_setns(nsi))
return;
- if (snprintf(curpath, PATH_MAX, "/proc/self/ns/mnt") >= PATH_MAX)
+ if (!getcwd(curpath, sizeof(curpath)))
return;
- oldcwd = get_current_dir_name();
+ oldcwd = strdup(curpath);
if (!oldcwd)
return;
- oldns = open(curpath, O_RDONLY);
+ oldns = open("/proc/self/ns/mnt", O_RDONLY);
if (oldns < 0)
goto errout;
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] tools build: Remove get_current_dir_name
2025-10-03 17:56 [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Ian Rogers
@ 2025-10-03 17:56 ` Ian Rogers
2025-10-03 19:48 ` Arnaldo Carvalho de Melo
2025-10-03 18:29 ` [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Arnaldo Carvalho de Melo
1 sibling, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2025-10-03 17:56 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, linux-kernel, linux-perf-users
As perf no longer tests for this feature, and it was the only user,
remove the feature test.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/build/Makefile.feature | 1 -
tools/build/feature/Makefile | 4 ----
tools/build/feature/test-all.c | 4 ----
tools/build/feature/test-get_current_dir_name.c | 11 -----------
4 files changed, 20 deletions(-)
delete mode 100644 tools/build/feature/test-get_current_dir_name.c
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 9c1a69d26f51..9399f591bd69 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -68,7 +68,6 @@ FEATURE_TESTS_BASIC := \
libdw \
eventfd \
fortify-source \
- get_current_dir_name \
gettid \
glibc \
libbfd \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b41a42818d8a..d13d2a1f44fe 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -8,7 +8,6 @@ FILES= \
test-libdw.bin \
test-eventfd.bin \
test-fortify-source.bin \
- test-get_current_dir_name.bin \
test-glibc.bin \
test-gtk2.bin \
test-gtk2-infobar.bin \
@@ -147,9 +146,6 @@ $(OUTPUT)test-libelf.bin:
$(OUTPUT)test-eventfd.bin:
$(BUILD)
-$(OUTPUT)test-get_current_dir_name.bin:
- $(BUILD)
-
$(OUTPUT)test-glibc.bin:
$(BUILD)
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index e1847db6f8e6..778883a32afb 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -22,10 +22,6 @@
# include "test-libelf.c"
#undef main
-#define main main_test_get_current_dir_name
-# include "test-get_current_dir_name.c"
-#undef main
-
#define main main_test_gettid
# include "test-gettid.c"
#undef main
diff --git a/tools/build/feature/test-get_current_dir_name.c b/tools/build/feature/test-get_current_dir_name.c
deleted file mode 100644
index c3c201691b4f..000000000000
--- a/tools/build/feature/test-get_current_dir_name.c
+++ /dev/null
@@ -1,11 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <stdlib.h>
-
-int main(void)
-{
- free(get_current_dir_name());
- return 0;
-}
-#undef _GNU_SOURCE
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] tools build: Remove get_current_dir_name
2025-10-03 17:56 ` [PATCH v2 2/2] tools build: Remove get_current_dir_name Ian Rogers
@ 2025-10-03 19:48 ` Arnaldo Carvalho de Melo
2025-10-03 21:29 ` Ian Rogers
0 siblings, 1 reply; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-03 19:48 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, linux-kernel, linux-perf-users
On Fri, Oct 03, 2025 at 10:56:13AM -0700, Ian Rogers wrote:
> As perf no longer tests for this feature, and it was the only user,
> remove the feature test.
You forgot to remove this:
⬢ [acme@toolbx perf-tools-next]$ git diff
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 71ba7001dc25c6bb..8a354b81417c6fcc 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -151,7 +151,6 @@ int main(int argc, char *argv[])
main_test_libpython();
main_test_hello();
main_test_libelf();
- main_test_get_current_dir_name();
main_test_gettid();
main_test_glibc();
main_test_libdw();
⬢ [acme@toolbx perf-tools-next]$
That results, when building with this alias:
alias m='rm -rf ~/libexec/perf-core/ ; make CORESIGHT=1 -k O=/tmp/build/$(basename $PWD)/ -C tools/perf install-bin && perf test python && cat /tmp/build/$(basename $PWD)/feature/test-all.make.output'
that needs to be on the makefiles somewhere, shows that test-all.bin is
failing to build:
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
88: 'import perf' in python : FAILED!
test-all.c: In function ‘main’:
test-all.c:154:9: error: implicit declaration of function ‘main_test_get_current_dir_name’; did you mean ‘get_current_dir_name’? [-Wimplicit-function-declaration]
154 | main_test_get_current_dir_name();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| get_current_dir_name
⬢ [acme@toolbx perf-tools-next]$
I fixed this up already,
Thanks,
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/build/Makefile.feature | 1 -
> tools/build/feature/Makefile | 4 ----
> tools/build/feature/test-all.c | 4 ----
> tools/build/feature/test-get_current_dir_name.c | 11 -----------
> 4 files changed, 20 deletions(-)
> delete mode 100644 tools/build/feature/test-get_current_dir_name.c
>
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 9c1a69d26f51..9399f591bd69 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -68,7 +68,6 @@ FEATURE_TESTS_BASIC := \
> libdw \
> eventfd \
> fortify-source \
> - get_current_dir_name \
> gettid \
> glibc \
> libbfd \
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index b41a42818d8a..d13d2a1f44fe 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -8,7 +8,6 @@ FILES= \
> test-libdw.bin \
> test-eventfd.bin \
> test-fortify-source.bin \
> - test-get_current_dir_name.bin \
> test-glibc.bin \
> test-gtk2.bin \
> test-gtk2-infobar.bin \
> @@ -147,9 +146,6 @@ $(OUTPUT)test-libelf.bin:
> $(OUTPUT)test-eventfd.bin:
> $(BUILD)
>
> -$(OUTPUT)test-get_current_dir_name.bin:
> - $(BUILD)
> -
> $(OUTPUT)test-glibc.bin:
> $(BUILD)
>
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index e1847db6f8e6..778883a32afb 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -22,10 +22,6 @@
> # include "test-libelf.c"
> #undef main
>
> -#define main main_test_get_current_dir_name
> -# include "test-get_current_dir_name.c"
> -#undef main
> -
> #define main main_test_gettid
> # include "test-gettid.c"
> #undef main
> diff --git a/tools/build/feature/test-get_current_dir_name.c b/tools/build/feature/test-get_current_dir_name.c
> deleted file mode 100644
> index c3c201691b4f..000000000000
> --- a/tools/build/feature/test-get_current_dir_name.c
> +++ /dev/null
> @@ -1,11 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -#include <unistd.h>
> -#include <stdlib.h>
> -
> -int main(void)
> -{
> - free(get_current_dir_name());
> - return 0;
> -}
> -#undef _GNU_SOURCE
> --
> 2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] tools build: Remove get_current_dir_name
2025-10-03 19:48 ` Arnaldo Carvalho de Melo
@ 2025-10-03 21:29 ` Ian Rogers
0 siblings, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2025-10-03 21:29 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, linux-kernel, linux-perf-users
On Fri, Oct 3, 2025 at 12:48 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Fri, Oct 03, 2025 at 10:56:13AM -0700, Ian Rogers wrote:
> > As perf no longer tests for this feature, and it was the only user,
> > remove the feature test.
>
> You forgot to remove this:
>
> ⬢ [acme@toolbx perf-tools-next]$ git diff
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index 71ba7001dc25c6bb..8a354b81417c6fcc 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -151,7 +151,6 @@ int main(int argc, char *argv[])
> main_test_libpython();
> main_test_hello();
> main_test_libelf();
> - main_test_get_current_dir_name();
> main_test_gettid();
> main_test_glibc();
> main_test_libdw();
> ⬢ [acme@toolbx perf-tools-next]$
>
> That results, when building with this alias:
>
> alias m='rm -rf ~/libexec/perf-core/ ; make CORESIGHT=1 -k O=/tmp/build/$(basename $PWD)/ -C tools/perf install-bin && perf test python && cat /tmp/build/$(basename $PWD)/feature/test-all.make.output'
>
> that needs to be on the makefiles somewhere, shows that test-all.bin is
> failing to build:
>
> make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
> 88: 'import perf' in python : FAILED!
> test-all.c: In function ‘main’:
> test-all.c:154:9: error: implicit declaration of function ‘main_test_get_current_dir_name’; did you mean ‘get_current_dir_name’? [-Wimplicit-function-declaration]
> 154 | main_test_get_current_dir_name();
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | get_current_dir_name
> ⬢ [acme@toolbx perf-tools-next]$
>
> I fixed this up already,
Sorry for that. Thanks for fixing it up!
Ian
> Thanks,
>
> - Arnaldo
>
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > tools/build/Makefile.feature | 1 -
> > tools/build/feature/Makefile | 4 ----
> > tools/build/feature/test-all.c | 4 ----
> > tools/build/feature/test-get_current_dir_name.c | 11 -----------
> > 4 files changed, 20 deletions(-)
> > delete mode 100644 tools/build/feature/test-get_current_dir_name.c
> >
> > diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> > index 9c1a69d26f51..9399f591bd69 100644
> > --- a/tools/build/Makefile.feature
> > +++ b/tools/build/Makefile.feature
> > @@ -68,7 +68,6 @@ FEATURE_TESTS_BASIC := \
> > libdw \
> > eventfd \
> > fortify-source \
> > - get_current_dir_name \
> > gettid \
> > glibc \
> > libbfd \
> > diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> > index b41a42818d8a..d13d2a1f44fe 100644
> > --- a/tools/build/feature/Makefile
> > +++ b/tools/build/feature/Makefile
> > @@ -8,7 +8,6 @@ FILES= \
> > test-libdw.bin \
> > test-eventfd.bin \
> > test-fortify-source.bin \
> > - test-get_current_dir_name.bin \
> > test-glibc.bin \
> > test-gtk2.bin \
> > test-gtk2-infobar.bin \
> > @@ -147,9 +146,6 @@ $(OUTPUT)test-libelf.bin:
> > $(OUTPUT)test-eventfd.bin:
> > $(BUILD)
> >
> > -$(OUTPUT)test-get_current_dir_name.bin:
> > - $(BUILD)
> > -
> > $(OUTPUT)test-glibc.bin:
> > $(BUILD)
> >
> > diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> > index e1847db6f8e6..778883a32afb 100644
> > --- a/tools/build/feature/test-all.c
> > +++ b/tools/build/feature/test-all.c
> > @@ -22,10 +22,6 @@
> > # include "test-libelf.c"
> > #undef main
> >
> > -#define main main_test_get_current_dir_name
> > -# include "test-get_current_dir_name.c"
> > -#undef main
> > -
> > #define main main_test_gettid
> > # include "test-gettid.c"
> > #undef main
> > diff --git a/tools/build/feature/test-get_current_dir_name.c b/tools/build/feature/test-get_current_dir_name.c
> > deleted file mode 100644
> > index c3c201691b4f..000000000000
> > --- a/tools/build/feature/test-get_current_dir_name.c
> > +++ /dev/null
> > @@ -1,11 +0,0 @@
> > -// SPDX-License-Identifier: GPL-2.0
> > -#define _GNU_SOURCE
> > -#include <unistd.h>
> > -#include <stdlib.h>
> > -
> > -int main(void)
> > -{
> > - free(get_current_dir_name());
> > - return 0;
> > -}
> > -#undef _GNU_SOURCE
> > --
> > 2.51.0.618.g983fd99d29-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency
2025-10-03 17:56 [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Ian Rogers
2025-10-03 17:56 ` [PATCH v2 2/2] tools build: Remove get_current_dir_name Ian Rogers
@ 2025-10-03 18:29 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-03 18:29 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, linux-kernel, linux-perf-users
On Fri, Oct 03, 2025 at 10:56:12AM -0700, Ian Rogers wrote:
> get_current_dir_name is a GNU extension not supported on, for example,
> Android. There is only one use of it so let's just switch to getcwd to
> avoid build and other complexity.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> v2: Fix free of oldcwd on errout.
Simple enough, applied both patches to perf-tools-next.
I'll now have to try and pick as few patches as possible so as to have
what is in perf-tools-next sit over the weekend on linux-next to then
send a pull req for 6.18.
- Arnaldo
> ---
> tools/perf/Makefile.config | 4 ----
> tools/perf/util/Build | 1 -
> tools/perf/util/get_current_dir_name.c | 18 ------------------
> tools/perf/util/get_current_dir_name.h | 8 --------
> tools/perf/util/namespaces.c | 7 +++----
> 5 files changed, 3 insertions(+), 35 deletions(-)
> delete mode 100644 tools/perf/util/get_current_dir_name.c
> delete mode 100644 tools/perf/util/get_current_dir_name.h
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 0f4b297fbacc..6cdb96576cb8 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -417,10 +417,6 @@ ifeq ($(feature-eventfd), 1)
> CFLAGS += -DHAVE_EVENTFD_SUPPORT
> endif
>
> -ifeq ($(feature-get_current_dir_name), 1)
> - CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
> -endif
> -
> ifeq ($(feature-gettid), 1)
> CFLAGS += -DHAVE_GETTID
> endif
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 5ead46dc98e7..9464eceb764b 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -23,7 +23,6 @@ perf-util-y += evsel_fprintf.o
> perf-util-y += perf_event_attr_fprintf.o
> perf-util-y += evswitch.o
> perf-util-y += find_bit.o
> -perf-util-y += get_current_dir_name.o
> perf-util-y += levenshtein.o
> perf-util-y += mmap.o
> perf-util-y += memswap.o
> diff --git a/tools/perf/util/get_current_dir_name.c b/tools/perf/util/get_current_dir_name.c
> deleted file mode 100644
> index e68935e9ac8c..000000000000
> --- a/tools/perf/util/get_current_dir_name.c
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -// SPDX-License-Identifier: LGPL-2.1
> -// Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
> -//
> -#ifndef HAVE_GET_CURRENT_DIR_NAME
> -#include "get_current_dir_name.h"
> -#include <limits.h>
> -#include <string.h>
> -#include <unistd.h>
> -
> -/* Android's 'bionic' library, for one, doesn't have this */
> -
> -char *get_current_dir_name(void)
> -{
> - char pwd[PATH_MAX];
> -
> - return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
> -}
> -#endif // HAVE_GET_CURRENT_DIR_NAME
> diff --git a/tools/perf/util/get_current_dir_name.h b/tools/perf/util/get_current_dir_name.h
> deleted file mode 100644
> index 69f7d5537d32..000000000000
> --- a/tools/perf/util/get_current_dir_name.h
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: LGPL-2.1
> -// Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
> -//
> -#ifndef __PERF_GET_CURRENT_DIR_NAME_H
> -#ifndef HAVE_GET_CURRENT_DIR_NAME
> -char *get_current_dir_name(void);
> -#endif // HAVE_GET_CURRENT_DIR_NAME
> -#endif // __PERF_GET_CURRENT_DIR_NAME_H
> diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
> index 68f5de2d79c7..01502570b32d 100644
> --- a/tools/perf/util/namespaces.c
> +++ b/tools/perf/util/namespaces.c
> @@ -6,7 +6,6 @@
>
> #include "namespaces.h"
> #include "event.h"
> -#include "get_current_dir_name.h"
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> @@ -293,14 +292,14 @@ void nsinfo__mountns_enter(struct nsinfo *nsi,
> if (!nsi || !nsinfo__need_setns(nsi))
> return;
>
> - if (snprintf(curpath, PATH_MAX, "/proc/self/ns/mnt") >= PATH_MAX)
> + if (!getcwd(curpath, sizeof(curpath)))
> return;
>
> - oldcwd = get_current_dir_name();
> + oldcwd = strdup(curpath);
> if (!oldcwd)
> return;
>
> - oldns = open(curpath, O_RDONLY);
> + oldns = open("/proc/self/ns/mnt", O_RDONLY);
> if (oldns < 0)
> goto errout;
>
> --
> 2.51.0.618.g983fd99d29-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-03 21:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 17:56 [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Ian Rogers
2025-10-03 17:56 ` [PATCH v2 2/2] tools build: Remove get_current_dir_name Ian Rogers
2025-10-03 19:48 ` Arnaldo Carvalho de Melo
2025-10-03 21:29 ` Ian Rogers
2025-10-03 18:29 ` [PATCH v2 1/2] perf namespaces: Avoid get_current_dir_name dependency Arnaldo Carvalho de Melo
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).