1 /* Check if internal buffer reallocation work for large paths (BZ #28126)
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <support/check.h>
25 #include <support/support.h>
26 #include <support/temp_file.h>
27 #include <support/xunistd.h>
31 my_func (const char *file
, const struct stat
*sb
, int flag
)
36 static const char folder
[NAME_MAX
] = { [0 ... 253] = 'a', [254] = '\0' };
38 #define NSUBFOLDERS 16
39 static int nsubfolders
;
45 for (int i
= 0; i
< nsubfolders
; i
++)
52 #define CLEANUP_HANDLER do_cleanup
55 check_mkdir (const char *path
)
57 int r
= mkdir (path
, 0777);
58 /* Some filesystem such as overlayfs does not support larger path required
59 to trigger the internal buffer reallocation. */
62 if (errno
== ENAMETOOLONG
)
63 FAIL_UNSUPPORTED ("the filesystem does not support the required"
66 FAIL_EXIT1 ("mkdir (\"%s\", 0%o): %m", folder
, 0777);
73 char *tempdir
= support_create_temp_directory ("tst-bz28126");
75 /* Create path with various subfolders to force an internal buffer
76 reallocation within ntfw. */
77 char *path
= xasprintf ("%s/%s", tempdir
, folder
);
81 for (int i
= 0; i
< NSUBFOLDERS
- 1; i
++)
88 TEST_COMPARE (ftw (tempdir
, my_func
, 20), 0);
97 #include <support/test-driver.c>