- From 6bbd6456f71987867be0023865034c7754553558 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 18 Mar 2025 13:48:38 +0100
- Subject: [PATCH 1/7] cygwin,tests: Add tests for sparse file *.exe
- Add tests for sparse file *.exe.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile.install | 1 +
- tests/sparsefiles/testsparseexe1.ksh | 171 +++++++++++++++++++++++++++
- 2 files changed, 172 insertions(+)
- create mode 100644 tests/sparsefiles/testsparseexe1.ksh
- diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
- index 1a1005a..b5b3de9 100644
- --- a/cygwin/Makefile.install
- +++ b/cygwin/Makefile.install
- @@ -122,6 +122,7 @@ installdest:
- fi
- cp $(PROJECT_BASEDIR_DIR)/tests/nfsbuildtest/nfsbuildtest.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/nfsbuildtest.ksh93
- cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparsefile1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparsefile1.ksh
- + cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparseexe1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparseexe1.ksh
- cp $(PROJECT_BASEDIR_DIR)/tests/fstest_make_numtree1/fstest_make_numtree1.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/fstest_make_numtree1.ksh93
- cp $(PROJECT_BASEDIR_DIR)/tests/wintartests/wintartest_comparewinvsgnu001.bash $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/wintartest_comparewinvsgnu001.bash
- cp $(PROJECT_BASEDIR_DIR)/tests/wintartests/wintartest_seq001.bash $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/wintartest_seq001.bash
- diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
- new file mode 100644
- index 0000000..ccc8d70
- --- /dev/null
- +++ b/tests/sparsefiles/testsparseexe1.ksh
- @@ -0,0 +1,171 @@
- +#!/bin/ksh93
- +
- +#
- +# MIT License
- +#
- +# Copyright (c) 2025 Roland Mainz <roland.mainz@nrubsig.org>
- +#
- +# Permission is hereby granted, free of charge, to any person obtaining a copy
- +# of this software and associated documentation files (the "Software"), to deal
- +# in the Software without restriction, including without limitation the rights
- +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- +# copies of the Software, and to permit persons to whom the Software is
- +# furnished to do so, subject to the following conditions:
- +#
- +# The above copyright notice and this permission notice shall be included in all
- +# copies or substantial portions of the Software.
- +#
- +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- +# SOFTWARE.
- +#
- +
- +#
- +# testsparseexe1.ksh - test whether sparse file *.exe work
- +#
- +# Written by Roland Mainz <roland.mainz@nrubsig.org>
- +#
- +
- +integer nulldata_array_size=1024*1024*64
- +
- +function generate_test_src
- +{
- + printf '#include <stdio.h>\n'
- + printf '#include <stdlib.h>\n'
- +
- + printf '\nint main(int ac, char *av[])\n'
- + printf '{\n'
- +
- + printf 'volatile char nulldata_array[%d] = {\n' nulldata_array_size
- + for ((i = nulldata_array_size ; i >= 64 ; i-= 64 )) ; do
- + printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
- + printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
- + done
- + if (( i > 0 )) ; then
- + printf '\t'
- + for (( ; i > 0 ; i-- )) ; do
- + printf '0,'
- + done
- + printf '\n'
- + fi
- + printf '};\n'
- +
- + printf '\tlong long sum = 0LL;\n'
- + printf '\tsize_t i;\n'
- + printf '\tfor (i = 0 ; i < %d ; i++) {\n' nulldata_array_size
- + printf '\t\tsum += nulldata_array[i];'
- + printf '\t}\n'
- + printf '\t(void)printf("sum = %%lld\\n", sum);\n'
- + printf '\treturn 0;\n'
- + printf '}\n'
- +
- + return 0
- +}
- +
- +
- +function test_sparseexe1
- +{
- + #set -o xtrace
- + set -o errexit
- + set -o nounset
- +
- + compound res
- + integer res.errors=0
- +
- + printf '#### %s: Begin...\n' "$0"
- +
- + rm -f \
- + 'sparseexe_orig.exe' \
- + 'sparseexe_sparse.exe' \
- + 'sparseexe.c'
- +
- + print '# generate source...'
- + generate_test_src | cat >'sparseexe.c'
- +
- + print '# compile source...'
- + gcc -Wl,--stack,$((1024*1024*256)) -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
- +
- + print $'# copy *.exe, and turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
- + # explicitly use /usr/bin/cp and not the AST cp builtin
- + /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
- +
- + print '# collect data...'
- + integer res.sparseexe_orig_blocks=$(stat --printf '%b\n' 'sparseexe_orig.exe')
- + integer res.sparseexe_sparse_blocks=$(stat --printf '%b\n' 'sparseexe_sparse.exe')
- + integer res.sparseexe_orig_filesize=$(stat --printf '%s\n' 'sparseexe_orig.exe')
- + integer res.sparseexe_sparse_filesize=$(stat --printf '%s\n' 'sparseexe_sparse.exe')
- +
- + compound res.testrun=(
- + typeset stderr=''
- + typeset stdout=''
- + integer res=-1
- + )
- +
- + set +o errexit
- +
- + res.testrun.stderr="${ { res.testrun.stdout="${ ./sparseexe_sparse.exe ; (( res.testrun.res=$? )) ; }" ; } 2>&1 ; }"
- +
- + print '# print results...'
- + print -v res
- + ls -ls 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
- +
- + if (( res.testrun.res == 0 )) ; then
- + printf 'test file return exit code 0: OK\n'
- + else
- + printf 'ERROR: test file return exit code %d\n' res.testrun.res
- + (( res.errors++ ))
- + fi
- +
- + if [[ "${res.testrun.stdout}" == ~(E)sum\ =\ 0 ]] ; then
- + printf 'test file stdout %s: OK\n' "${res.testrun.stdout}"
- + else
- + printf 'ERROR: test file stdout output %q, expected "sum = 0"\n' "${res.testrun.stdout}"
- + (( res.errors++ ))
- + fi
- +
- + if [[ "${res.testrun.stderr}" == '' ]] ; then
- + printf 'test file stderr empty: OK\n'
- + else
- + printf 'ERROR: test file stderr output %q\n' "${res.testrun.stderr}"
- + (( res.errors++ ))
- + fi
- +
- + if (( res.sparseexe_orig_filesize == res.sparseexe_sparse_filesize )) ; then
- + printf 'test file sizes: OK\n'
- + else
- + printf '# ERROR: sparseexe_orig.exe and sparseexe_sparse.exe file size differ\n'
- + (( res.errors++ ))
- + fi
- +
- + if (( (res.sparseexe_orig_blocks/10.) > res.sparseexe_sparse_blocks )) ; then
- + printf 'test file number of blocks: OK, sparseexe_sparse.exe has less filesystem blocks\n'
- + else
- + printf '# ERROR: sparseexe_sparse.exe consumes too many filesystem blocks\n'
- + (( res.errors++ ))
- + fi
- +
- + if (( res.errors == 0 )) ; then
- + printf '#### %s: All tests OK\n' "$0"
- + exit 0
- + else
- + printf '#### %s tests FAILED\n' res.errors
- + return 1
- + fi
- +
- + # not reached
- +}
- +
- +#
- +# main
- +#
- +builtin cat
- +builtin rm
- +
- +test_sparseexe1
- +
- +# EOF.
- +
- --
- 2.45.1
- From e7bff874067628b393b9e304a61f3801b9f09a2f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 18 Mar 2025 14:20:31 +0100
- Subject: [PATCH 2/7] daemon: Add |BITMAP4_MAXCOUNT| to define the size of
- |bitmap4.arr|
- Add |BITMAP4_MAXCOUNT| to define the size of |bitmap4.arr| instead
- of a hardcoded integer.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_types.h | 3 ++-
- daemon/nfs41_xdr.c | 14 ++++++++------
- 2 files changed, 10 insertions(+), 7 deletions(-)
- diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
- index c589baf..804cee8 100644
- --- a/daemon/nfs41_types.h
- +++ b/daemon/nfs41_types.h
- @@ -89,9 +89,10 @@ typedef struct __multi_addr4 {
- uint32_t count;
- } multi_addr4;
- +#define BITMAP4_MAXCOUNT (3)
- typedef struct __bitmap4 {
- uint32_t count;
- - uint32_t arr[3];
- + uint32_t arr[BITMAP4_MAXCOUNT];
- } bitmap4;
- typedef struct __nfstime4 {
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index c4b0c0f..bbf2153 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -54,9 +54,10 @@ bool_t xdr_bitmap4(
- uint32_t i;
- if (xdr->x_op == XDR_ENCODE) {
- - if (bitmap->count > 3) {
- - eprintf("encode_bitmap4: count (%d) must be <= 3\n",
- - bitmap->count);
- + if (bitmap->count > BITMAP4_MAXCOUNT) {
- + eprintf("encode_bitmap4: count (%d) must be <= %d\n",
- + bitmap->count,
- + BITMAP4_MAXCOUNT);
- return FALSE;
- }
- if (!xdr_u_int32_t(xdr, &bitmap->count))
- @@ -69,9 +70,10 @@ bool_t xdr_bitmap4(
- } else if (xdr->x_op == XDR_DECODE) {
- if (!xdr_u_int32_t(xdr, &bitmap->count))
- return FALSE;
- - if (bitmap->count > 3) {
- - eprintf("decode_bitmap4: count (%d) must be <= 3\n",
- - bitmap->count);
- + if (bitmap->count > BITMAP4_MAXCOUNT) {
- + eprintf("decode_bitmap4: count (%d) must be <= %d\n",
- + bitmap->count,
- + BITMAP4_MAXCOUNT);
- return FALSE;
- }
- --
- 2.45.1
- From dc214c885fcf935bd2d317d60f2e65166523fb35 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 18 Mar 2025 14:35:44 +0100
- Subject: [PATCH 3/7] cygwin: nfs_umount.exe should also use the SegmentHeap
- allocator
- nfs_umount.exe should also use the SegmentHeap allocator
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index e812c83..4a391dd 100755
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -167,6 +167,8 @@ function nfsclient_install
- regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe/FrontEndHeapDebugOptions' 0x08
- regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
- regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe/FrontEndHeapDebugOptions' 0x08
- + regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_umount.exe'
- + regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_umount.exe/FrontEndHeapDebugOptions' 0x08
- if ! $use_secureboot ; then
- # make sure we can load the kernel driver
- --
- 2.45.1
- From c424ce32dbc2c853947f0cd9700a49415acb1b36 Mon Sep 17 00:00:00 2001
- From: Martin Wege <martin.l.wege@gmail.com>
- Date: Tue, 18 Mar 2025 15:25:14 +0100
- Subject: [PATCH 4/7] daemon: Add |mempcpy()| implementation
- Add |mempcpy()| implementation.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 6 ++++--
- daemon/util.h | 7 +++++++
- 2 files changed, 11 insertions(+), 2 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index c098ba7..2021d78 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -1115,7 +1115,9 @@ add_domain:
- */
- EASSERT(!isdigit(who_out[0]));
- - (void)memcpy(who_out+who_size, "@", sizeof(char));
- + char *wp;
- +
- + wp = mempcpy(who_out+who_size, "@", sizeof(char));
- #ifdef NFS41_DRIVER_WS2022_HACKS
- /* Fixup |domain| for Windows Sever 2022 NFSv4.1 server */
- @@ -1133,7 +1135,7 @@ add_domain:
- (int)who_size+1, who_out, domain));
- }
- #endif /* NFS41_DRIVER_WS2022_HACKS */
- - (void)memcpy(who_out+who_size+1, domain, strlen(domain)+1);
- + (void)memcpy(wp, domain, strlen(domain)+1);
- /* no_add_domain: */
- status = ERROR_SUCCESS;
- diff --git a/daemon/util.h b/daemon/util.h
- index 3498725..242dfb9 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -57,6 +57,13 @@ typedef ULONGLONG util_reltimestamp;
- char *stpcpy(char *restrict s1, const char *restrict s2);
- +static __inline
- +void *mempcpy(void *restrict dest, const void *restrict src, size_t n)
- +{
- + (void)memcpy(dest, src, n);
- + return (void *)((char *)dest + n);
- +}
- +
- int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name);
- --
- 2.45.1
- From 4c63db6124e98c77e5218173e3386fa68642e736 Mon Sep 17 00:00:00 2001
- From: Cedric Blancher <cedric.blancher@gmail.com>
- Date: Tue, 18 Mar 2025 17:48:59 +0100
- Subject: [PATCH 5/7] tests: nfsbuildtest bash build does not work with Windows
- 10/32bit+Cygwin 3.3/32bit+gcc 11.3.0
- nfsbuildtest bash build does not work on Windows 10/32bit,
- Cygwin 3.3/32bit with gcc (GCC) 11.3.0 - gcc fails because
- -std gnu17 support was buggy with that version of gcc.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/nfsbuildtest/nfsbuildtest.ksh93 | 8 ++++++--
- 1 file changed, 6 insertions(+), 2 deletions(-)
- diff --git a/tests/nfsbuildtest/nfsbuildtest.ksh93 b/tests/nfsbuildtest/nfsbuildtest.ksh93
- index 17eaef3..f211850 100644
- --- a/tests/nfsbuildtest/nfsbuildtest.ksh93
- +++ b/tests/nfsbuildtest/nfsbuildtest.ksh93
- @@ -302,8 +302,12 @@ function bash_build
- (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
- fi
- - # workaround for gcc 15.0 used in Cygwin 3.6
- - export CFLAGS="-std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int"
- + if is_cygwin && (( (cygwin_vers.major*1000+cygwin_vers.minor) >= 3005 )) ; then
- + # workaround for gcc 15.0 used in Cygwin 3.6
- + export CFLAGS="-std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int"
- + else
- + export CFLAGS="-std=gnu99"
- + fi
- if $config_use_posix_ksh93_builtins ; then
- CONFIG_SHELL=/usr/bin/ksh93 ksh93 ./configure "${configure_options[@]}"
- --
- 2.45.1
- From ffc838db9844ddcc57c44572b0744878f4b3e63e Mon Sep 17 00:00:00 2001
- From: Cedric Blancher <cedric.blancher@gmail.com>
- Date: Tue, 18 Mar 2025 18:25:05 +0100
- Subject: [PATCH 6/7] cygwin,tests: Modify tests to work without
- lssparse.exe+fallocate.exe (both require Cygwin 3.6)
- Modify tests to work without lssparse.exe+fallocate.exe.
- lssparse.exe and fallocate.exe require Cygwin 3.6 (which
- introduced lseek(..., SEEK_HOLE, ...) and lseek(..., SEEK_DATA, ...)),
- and are therefore not available on Cygwin 3.3/32bit (which was the
- last Cygwin release supporting 32bit kernels).
- Note that the Win32 API FSCTL_QUERY_ALLOCATED_RANGES and
- "fsutil sparse ..." work fine on Windows 32bit kernels, just
- Cygwin 3.3 has no sparse file API in lseek().
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile.install | 3 --
- tests/lssparse/Makefile | 8 ++--
- tests/sparsefiles/testsparsefile1.ksh | 63 ++++++++++++++++++++++++---
- 3 files changed, 60 insertions(+), 14 deletions(-)
- diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
- index b5b3de9..e274aa5 100644
- --- a/cygwin/Makefile.install
- +++ b/cygwin/Makefile.install
- @@ -104,11 +104,8 @@ installdest:
- (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf winfsinfo.i686.exe winfsinfo.exe) \
- fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.x86_64.exe
- - cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.i686.exe
- if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf lssparse.x86_64.exe lssparse.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf lssparse.i686.exe lssparse.exe) \
- fi
- if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.exe ; \
- diff --git a/tests/lssparse/Makefile b/tests/lssparse/Makefile
- index 199d5d2..4f92fc1 100644
- --- a/tests/lssparse/Makefile
- +++ b/tests/lssparse/Makefile
- @@ -4,10 +4,11 @@
- # POSIX Makefile
- -all: lssparse.i686.exe lssparse.x86_64.exe lssparse.exe
- +all: lssparse.x86_64.exe lssparse.exe
- -lssparse.i686.exe: lssparse.c
- - gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.i686.exe
- +# Cygwin 3.6 does not support 32bit builds anymore
- +#lssparse.i686.exe: lssparse.c
- +# gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.i686.exe
- lssparse.x86_64.exe: lssparse.c
- gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.x86_64.exe
- @@ -17,7 +18,6 @@ lssparse.exe: lssparse.x86_64.exe
- clean:
- rm -fv \
- - lssparse.i686.exe \
- lssparse.x86_64.exe \
- lssparse.exe \
- # EOF.
- diff --git a/tests/sparsefiles/testsparsefile1.ksh b/tests/sparsefiles/testsparsefile1.ksh
- index ee45def..d9e2b02 100644
- --- a/tests/sparsefiles/testsparsefile1.ksh
- +++ b/tests/sparsefiles/testsparsefile1.ksh
- @@ -47,7 +47,13 @@ function test_sparse_holeonly_dd
- integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_hole_only' | wc -l)"
- integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_hole_only' | wc -l)"
- - integer lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only' | wc -l)"
- + integer lssparse_num_data_sections
- + if $has_lssparse ; then
- + lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only' | wc -l)"
- + else
- + # hack
- + (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
- + fi
- #
- # test whether the file is OK
- @@ -89,7 +95,13 @@ function test_sparse_holeonly_truncate
- integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_hole_only_trunc' | wc -l)"
- integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_hole_only_trunc' | wc -l)"
- - integer lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only_trunc' | wc -l)"
- + integer lssparse_num_data_sections
- + if $has_lssparse ; then
- + lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only_trunc' | wc -l)"
- + else
- + # hack
- + (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
- + fi
- #
- # test whether the file is OK
- @@ -129,7 +141,13 @@ function test_normal_file
- integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'test_normal_file' | wc -l)"
- integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'test_normal_file' | wc -l)"
- - integer lssparse_num_data_sections="$(lssparse 'test_normal_file' | wc -l)"
- + integer lssparse_num_data_sections
- + if $has_lssparse ; then
- + lssparse_num_data_sections="$(lssparse 'test_normal_file' | wc -l)"
- + else
- + # hack
- + (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
- + fi
- #
- # test whether the file is OK
- @@ -218,8 +236,13 @@ function test_multihole_sparsefile1
- integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'mysparsefile' | wc -l)"
- integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'mysparsefile' | wc -l)"
- - integer lssparse_num_data_sections="$(lssparse 'mysparsefile' | wc -l)"
- -
- + integer lssparse_num_data_sections
- + if $has_lssparse ; then
- + lssparse_num_data_sections="$(lssparse 'mysparsefile' | wc -l)"
- + else
- + # hack
- + (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
- + fi
- #
- # test whether the file is OK
- @@ -266,7 +289,13 @@ function test_sparse_punchhole1
- integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_punchhole' | wc -l)"
- integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_punchhole' | wc -l)"
- - integer lssparse_num_data_sections="$(lssparse 'sparse_file_punchhole' | wc -l)"
- + integer lssparse_num_data_sections
- + if $has_lssparse ; then
- + lssparse_num_data_sections="$(lssparse 'sparse_file_punchhole' | wc -l)"
- + else
- + # hack
- + (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
- + fi
- #
- # test whether the file is OK
- @@ -301,6 +330,22 @@ builtin basename
- builtin rm
- builtin wc
- +typeset has_lssparse
- +typeset has_fallocate
- +
- +if which lssparse.exe 2>'/dev/null' ; then
- + has_lssparse=true
- +else
- + printf '#\n# NOTE: Skipping lssparse tests.\n#\n'
- + has_lssparse=false
- +fi
- +if which fallocate.exe 2>'/dev/null' ; then
- + has_fallocate=true
- +else
- + printf '#\n# NOTE: Skipping fallocate tests.\n#\n'
- + has_fallocate=false
- +fi
- +
- test_sparse_holeonly_dd
- test_sparse_holeonly_truncate
- test_normal_file
- @@ -316,7 +361,11 @@ test_multihole_sparsefile1 1024 1 4 true
- # fsutil uses 64 entries per queryrange, so we test this here
- test_multihole_sparsefile1 1024 2 256 false
- -test_sparse_punchhole1
- +if $has_fallocate ; then
- + test_sparse_punchhole1
- +else
- + printf '# NOTE: test_sparse_punchhole1 SKIPPED, no fallocate.exe\n'
- +fi
- printf '#\n# done\n#\n\n'
- --
- 2.45.1
- From f9e373543d83494d184199267d01187c11deb1d3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 18 Mar 2025 19:18:01 +0100
- Subject: [PATCH 7/7] tests: Adjust "testsparseexe1" for Cygwin versions
- without cp --sparse=always support
- Adjust testsparseexe1.ksh for Cygwin versions without
- $ cp --sparse=always ... # support.
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/sparsefiles/testsparseexe1.ksh | 36 ++++++++++++++++++++--------
- 1 file changed, 26 insertions(+), 10 deletions(-)
- diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
- index ccc8d70..5088baf 100644
- --- a/tests/sparsefiles/testsparseexe1.ksh
- +++ b/tests/sparsefiles/testsparseexe1.ksh
- @@ -30,17 +30,15 @@
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- -integer nulldata_array_size=1024*1024*64
- +integer nulldata_array_size=1024*1024*16
- function generate_test_src
- {
- printf '#include <stdio.h>\n'
- printf '#include <stdlib.h>\n'
- + printf '\n'
- - printf '\nint main(int ac, char *av[])\n'
- - printf '{\n'
- -
- - printf 'volatile char nulldata_array[%d] = {\n' nulldata_array_size
- + printf 'volatile char __attribute__((section(".noinit"))) nulldata_array[%d] = {\n' nulldata_array_size
- for ((i = nulldata_array_size ; i >= 64 ; i-= 64 )) ; do
- printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
- printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
- @@ -54,6 +52,12 @@ function generate_test_src
- fi
- printf '};\n'
- + printf '\nint main(int ac, char *av[])\n'
- + printf '{\n'
- +
- + printf '\t(void)ac; /* not used */\n'
- + printf '\t(void)av; /* not used */\n'
- +
- printf '\tlong long sum = 0LL;\n'
- printf '\tsize_t i;\n'
- printf '\tfor (i = 0 ; i < %d ; i++) {\n' nulldata_array_size
- @@ -87,11 +91,23 @@ function test_sparseexe1
- generate_test_src | cat >'sparseexe.c'
- print '# compile source...'
- - gcc -Wl,--stack,$((1024*1024*256)) -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
- -
- - print $'# copy *.exe, and turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
- - # explicitly use /usr/bin/cp and not the AST cp builtin
- - /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
- + gcc -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
- +
- + #
- + # HACK: Test for fallocate.exe to determinate whether the system's
- + # /usr/bin/cp.exe has sparse file support (which depends on
- + # SEEK_HOLE+SEEK_DATA.
- + #
- + if which -a 'fallocate.exe' 2>'/dev/null' ; then
- + print $'# copy *.exe via cp --sparse=always, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
- + # explicitly use /usr/bin/cp and not the AST cp builtin
- + /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
- + else
- + print $'# copy *.exe via dd conv=sparse, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
- + # explicitly use /usr/bin/cp and not the AST cp builtin
- + dd if='sparseexe_orig.exe' of='sparseexe_sparse.exe' conv=sparse
- + chmod a+x 'sparseexe_sparse.exe'
- + fi
- print '# collect data...'
- integer res.sparseexe_orig_blocks=$(stat --printf '%b\n' 'sparseexe_orig.exe')
- --
- 2.45.1
msnfs41client: Tests for *.exe binaries which are sparse files+cleanup+misc, 2025-03-18
Posted by Anonymous on Tue 18th Mar 2025 18:28
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.