- From 0f621332a78d3ee2758c4445edbddae07aacbebf Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 4 Mar 2025 12:53:18 +0100
- Subject: [PATCH 1/3] daemon: Remove comment about Windows issue in
- |query_sparsefile_datasections()|
- Remove comment about Windows issue in |query_sparsefile_datasections()|,
- this was a misinterpretation how the API should work.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/fsctl.c | 34 ++++++++++++++--------------------
- 1 file changed, 14 insertions(+), 20 deletions(-)
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index bc74363..87937cc 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -178,29 +178,23 @@ int query_sparsefile_datasections(nfs41_open_state *state,
- outbuffer[i].Length.QuadPart = data_size;
- }
- else {
- - error_more_data = true;
- -
- - /* Windows bug:
- - * Technically we should continue until we reach
- - * |end_offset| to return the correct size of the
- - * buffer with |DeviceIoControl(...,
- - * FSCTL_QUERY_ALLOCATED_RANGES,...)| ==
- - * |ERROR_MORE_DATA|.
- + /*
- + * Return |ERROR_MORE_DATA| if we reach end of the
- + * caller-supplied record array and still have more
- + * data sections (i.e. no EOF from
- + + |NFS4_CONTENT_HOLE|/|NFS4_CONTENT_DATA| yet).
- *
- - * Unfortunaely Win10 fsutil will then return
- - * random values after the first 64 entries, so the
- - * best we can do for bug-by-bug compatibility is
- - * to do the same: Stop counting here, and
- - * therefore return
- - * |out_maxrecords*sizeof(FILE_ALLOCATED_RANGE_BUFFER)|,
- - * which is exactly the same number of bytes of the
- - * original buffer passed as argument
- + * FIXME: We should also implement |out_maxrecords==0|,
- + * and then return the size for an array to store
- + * all records.
- + * This can still be too small if between the first
- + * FSCTL call (to get the needed size of the array)
- + * and second FSCTL call to enumerate the
- + * |FILE_ALLOCATED_RANGE_BUFFER| someone adds more
- + * data sections.
- */
- -#define WINDOWS_FSUTILSPARSEQUERYRANGE_MOREDATA_BUG 1
- -
- -#ifdef WINDOWS_FSUTILSPARSEQUERYRANGE_MOREDATA_BUG
- + error_more_data = true;
- break;
- -#endif /* WINDOWS_FSUTILSPARSEQUERYRANGE_MOREDATA_BUG */
- }
- (*res_num_records)++;
- --
- 2.45.1
- From c636968805c73f9c224fd8f14c557bb23d7ba155 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Mar 2025 09:59:55 +0100
- Subject: [PATCH 2/3] sys: Add more argument checks in FSCTL code
- Add more argument checks in FSCTL code.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_fsctl.c | 43 ++++++++++++++++++++++++++++++++++---------
- 1 file changed, 34 insertions(+), 9 deletions(-)
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 274bf29..ede33e3 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -76,8 +76,31 @@ NTSTATUS check_nfs41_queryallocatedranges_args(
- XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- const USHORT HeaderLen = sizeof(FILE_ALLOCATED_RANGE_BUFFER);
- + __notnull PFILE_ALLOCATED_RANGE_BUFFER in_range_buffer =
- + (PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pInputBuffer;
- +
- + if (FsCtl->pInputBuffer == NULL) {
- + status = STATUS_INVALID_USER_BUFFER;
- + goto out;
- + }
- +
- + if (FsCtl->InputBufferLength <
- + sizeof(FILE_ALLOCATED_RANGE_BUFFER)) {
- + DbgP("check_nfs41_queryallocatedranges_args: "
- + "in_range_buffer to small\n");
- + status = STATUS_BUFFER_TOO_SMALL;
- + goto out;
- + }
- +
- + if ((in_range_buffer->FileOffset.QuadPart < 0LL) ||
- + (in_range_buffer->Length.QuadPart < 0LL) ||
- + (in_range_buffer->Length.QuadPart >
- + (MAXLONGLONG - in_range_buffer->FileOffset.QuadPart))) {
- + status = STATUS_INVALID_PARAMETER;
- + goto out;
- + }
- - if (!FsCtl->pOutputBuffer) {
- + if (FsCtl->pOutputBuffer == NULL) {
- status = STATUS_INVALID_USER_BUFFER;
- goto out;
- }
- @@ -87,6 +110,7 @@ NTSTATUS check_nfs41_queryallocatedranges_args(
- status = STATUS_BUFFER_TOO_SMALL;
- goto out;
- }
- +
- out:
- return status;
- }
- @@ -116,18 +140,14 @@ NTSTATUS nfs41_QueryAllocatedRanges(
- RxContext->IoStatusBlock.Information = 0;
- status = check_nfs41_queryallocatedranges_args(RxContext);
- - if (status)
- - goto out;
- -
- - if (FsCtl->InputBufferLength <
- - sizeof(FILE_ALLOCATED_RANGE_BUFFER)) {
- + if (status) {
- DbgP("nfs41_QueryAllocatedRanges: "
- - "in_range_buffer to small\n");
- - status = STATUS_BUFFER_TOO_SMALL;
- + "check_nfs41_queryallocatedranges_args() failed with status=0x%lx\n",
- + (long)status);
- goto out;
- }
- - DbgP("nfs41_QueryAllocatedRanges/REAL: "
- + DbgP("nfs41_QueryAllocatedRanges: "
- "in_range_buffer=(FileOffset=%lld,Length=%lld)\n",
- (long long)in_range_buffer->FileOffset.QuadPart,
- (long long)in_range_buffer->Length.QuadPart);
- @@ -443,6 +463,11 @@ NTSTATUS nfs41_SetZeroData(
- if (status)
- goto out;
- + if (FsCtl->pInputBuffer == NULL) {
- + status = STATUS_INVALID_USER_BUFFER;
- + goto out;
- + }
- +
- if (FsCtl->InputBufferLength <
- sizeof(FILE_ZERO_DATA_INFORMATION)) {
- DbgP("nfs41_SetZeroData: "
- --
- 2.45.1
- From c12d0baaeefaae252f1a78cf5137fa65e8fdce40 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Mar 2025 12:50:01 +0100
- Subject: [PATCH 3/3] cygwin,tests: Add lssparse(1) utility to test the POSIX
- SEEK_DATA/SEEK_HOLE sparse file API
- Add lssparse(1) utility to test the POSIX SEEK_DATA/SEEK_HOLE
- sparse file API
- (see https://pubs.opengroup.org/onlinepubs/9799919799/functions/lseek.html).
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 4 +
- cygwin/Makefile.install | 7 +
- tests/lssparse/Makefile | 23 +++
- tests/lssparse/lssparse.c | 238 ++++++++++++++++++++++++++
- tests/sparsefiles/testsparsefile1.ksh | 65 ++++---
- 5 files changed, 317 insertions(+), 20 deletions(-)
- create mode 100644 tests/lssparse/Makefile
- create mode 100644 tests/lssparse/lssparse.c
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index a239eb1..9ae5b84 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -20,6 +20,7 @@ VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
- # trigger "build_testutils" target when these binaries are needed
- $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
- + $(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.exe \
- $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
- $(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.exe: build_testutils
- @@ -63,6 +64,7 @@ build_arm_64bit_debug:
- build_testutils:
- (cd "$(PROJECT_BASEDIR_DIR)/tests/ea" && make all)
- + (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winsg" && make all)
- @@ -96,6 +98,7 @@ build64: \
- clean:
- rm -vRf $$(find "$(PROJECT_BASEDIR_DIR)/build.vc19" -name Debug -o -name Release)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/ea" && make clean)
- + (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winsg" && make clean)
- @@ -104,6 +107,7 @@ installdest_util: \
- $(PROJECT_BASEDIR_DIR)/etc_netconfig \
- $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf \
- $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
- + $(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.exe \
- $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
- $(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.exe \
- $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash
- diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
- index c722344..1a1005a 100644
- --- a/cygwin/Makefile.install
- +++ b/cygwin/Makefile.install
- @@ -103,6 +103,13 @@ installdest:
- else \
- (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 ; \
- else \
- diff --git a/tests/lssparse/Makefile b/tests/lssparse/Makefile
- new file mode 100644
- index 0000000..199d5d2
- --- /dev/null
- +++ b/tests/lssparse/Makefile
- @@ -0,0 +1,23 @@
- +#
- +# Makefile for lssparse
- +#
- +
- +# POSIX Makefile
- +
- +all: lssparse.i686.exe 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
- +
- +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
- +
- +lssparse.exe: lssparse.x86_64.exe
- + ln -s lssparse.x86_64.exe lssparse.exe
- +
- +clean:
- + rm -fv \
- + lssparse.i686.exe \
- + lssparse.x86_64.exe \
- + lssparse.exe \
- +# EOF.
- diff --git a/tests/lssparse/lssparse.c b/tests/lssparse/lssparse.c
- new file mode 100644
- index 0000000..4adb200
- --- /dev/null
- +++ b/tests/lssparse/lssparse.c
- @@ -0,0 +1,238 @@
- +
- +/*
- + * MIT License
- + *
- + * Copyright (c) 2011-2012 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.
- + */
- +
- +/*
- + * lssparse.c - print sparse file hole+data layout information
- + *
- + * Written by Roland Mainz <roland.mainz@nrubsig.org>
- + */
- +
- +#include <stdio.h>
- +#include <stdlib.h>
- +#include <stdbool.h>
- +#include <string.h>
- +#include <fcntl.h>
- +#include <unistd.h>
- +#include <errno.h>
- +
- +#define EXIT_USAGE (2)
- +
- +static
- +void usage(const char *progname)
- +{
- + (void)fprintf(stderr, "Usage: %s [-h] <sparse_file>\n"
- + " -h: Display this help message\n"
- + " -x: Print offsets in hexadecimal (base 16)\n"
- + " -d: Print offsets in decimal (base 10)\n"
- + " -H: Print hole information\n",
- + progname);
- +}
- +
- +typedef enum _printbase {
- + pb_hex = 1,
- + pb_dec = 2
- +} printbase;
- +
- +int main(int argc, char *argv[])
- +{
- + /* Arguments */
- + const char *progname = argv[0];
- + printbase pb = pb_hex;
- + bool print_holes = false;
- + const char *filename;
- +
- + int retval;
- + int opt;
- + int fd;
- +
- + size_t i;
- + off_t offset = 0;
- + off_t data_start;
- + off_t hole_start;
- + off_t hole_end;
- + off_t file_size;
- + off_t data_len;
- + off_t hole_len;
- +
- + while ((opt = getopt(argc, argv, "hxdH")) != -1) {
- + switch (opt) {
- + case '?':
- + case 'h':
- + usage(progname);
- + return EXIT_USAGE;
- + case 'x':
- + pb = pb_hex;
- + break;
- + case 'd':
- + pb = pb_dec;
- + break;
- + case 'H':
- + print_holes = true;
- + break;
- + default:
- + break;
- + }
- + }
- +
- + if (optind >= argc) {
- + usage(progname);
- + return EXIT_USAGE;
- + }
- +
- + filename = argv[optind];
- +
- + fd = open(filename, O_RDONLY);
- + if (fd == -1) {
- + (void)fprintf(stderr, "%s: Open file failed with [%s]\n",
- + progname,
- + strerror(errno));
- + return EXIT_FAILURE;
- + }
- +
- + /* Get file size */
- + file_size = lseek(fd, 0, SEEK_END);
- + if (file_size == -1) {
- + (void)fprintf(stderr, "%s: Cannot seek [%s]\n",
- + progname,
- + strerror(errno));
- + return EXIT_FAILURE;
- + }
- + (void)lseek(fd, 0, SEEK_SET);
- +
- +
- + /*
- + * Loop over hole&&data sections
- + *
- + * This loop must handle:
- + * - normal files with no holes
- + * - sparse files which start with data
- + * - sparse files which start with a hole
- + * - sparse files with multiple holes
- + * - sparse files which end with data
- + * - sparse files which end with a hole
- + *
- + * Note we start with index |1| for compatibility
- + * with SUN's original sparse file debuggung tools
- + * and Win32's
- + * $ /cygdrive/c/Windows/system32/fsutil sparse queryrange ... #
- + * output
- + */
- + for (i=1 ;;) {
- + data_start = lseek(fd, offset, SEEK_DATA);
- + if (data_start == -1)
- + break;
- + hole_start = lseek(fd, data_start, SEEK_HOLE);
- +
- + if (hole_start == -1) {
- + if (errno == ENXIO) {
- + /* No more holes ? Use file site as pos of next hole */
- + hole_start = file_size;
- + } else {
- + (void)fprintf(stderr,
- + "%s: lseek(..., SEEK_HOLE, ...) failed with [%s]\n",
- + progname,
- + strerror(errno));
- + retval = EXIT_FAILURE;
- + goto done;
- + }
- + }
- +
- + if (print_holes && (i == 0) && (data_start > 0)) {
- + (void)printf((pb == pb_hex)?
- + "Hole range[%ld]: offset=0x%llx,\tlength=0x%llx\n":
- + "Hole range[%ld]: offset=%lld,\tlength=%lld\n",
- + (long)i,
- + (long long)0,
- + (long long)data_start);
- + i++;
- + }
- +
- + data_len = hole_start - data_start;
- +
- + (void)printf((pb == pb_hex)?
- + "Data range[%ld]: offset=0x%llx,\tlength=0x%llx\n":
- + "Data range[%ld]: offset=%lld,\tlength=%lld\n",
- + (long)i,
- + (long long)data_start,
- + (long long)data_len);
- + i++;
- +
- + hole_end = lseek(fd, hole_start, SEEK_DATA);
- +
- + if (hole_end == -1) {
- + if (errno == ENXIO) {
- + /* No more holes ? */
- + hole_end = file_size;
- + } else {
- + (void)fprintf(stderr,
- + "%s: lseek(..., SEEK_DATA, ...) failed with [%s]\n",
- + progname,
- + strerror(errno));
- + retval = EXIT_FAILURE;
- + goto done;
- + }
- + }
- +
- + hole_len = hole_end - hole_start;
- +
- + if (print_holes && (hole_len > 0LL)) {
- + (void)printf((pb == pb_hex)?
- + "Hole range[%ld]: offset=0x%llx,\tlength=0x%llx\n":
- + "Hole range[%ld]: offset=%lld,\tlength=%lld\n",
- + (long)i,
- + (long long)hole_start,
- + (long long)hole_len);
- + i++;
- + }
- +
- + offset = hole_end;
- + }
- +
- + if ((data_start == -1) && (errno == ENXIO) && (offset == 0)) {
- + if (print_holes) {
- + (void)printf((pb == pb_hex)?
- + "Hole range[%ld]: offset=0x%llx,\tlength=0x%llx\n":
- + "Hole range[%ld]: offset=%lld,\tlength=%lld\n",
- + (long)0,
- + (long long)0LL,
- + (long long)file_size);
- + }
- +
- + retval = EXIT_SUCCESS;
- + } else if ((data_start == -1) && (errno != ENXIO)) {
- + (void)fprintf(stderr,
- + "%s: lseek(..., SEEK_DATA, ...) failed with [%s]\n",
- + progname,
- + strerror(errno));
- + retval = EXIT_FAILURE;
- + }
- + else {
- + retval = EXIT_SUCCESS;
- + }
- +
- +done:
- + (void)close(fd);
- + return retval;
- +}
- diff --git a/tests/sparsefiles/testsparsefile1.ksh b/tests/sparsefiles/testsparsefile1.ksh
- index 2427af2..ee45def 100644
- --- a/tests/sparsefiles/testsparsefile1.ksh
- +++ b/tests/sparsefiles/testsparsefile1.ksh
- @@ -47,22 +47,27 @@ 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)"
- #
- # test whether the file is OK
- #
- - if (( (fsutil_num_data_sections != 0) || (winfsinfo_num_data_sections != 0) )) ; then
- - printf "# TEST failed, found fsutil=%d/winfsinfo=%d data sections, expected %d\n" \
- + if (( (fsutil_num_data_sections != 0) || \
- + (winfsinfo_num_data_sections != 0) || \
- + (lssparse_num_data_sections != 0) )) ; then
- + printf "# TEST failed, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections, expected %d\n" \
- fsutil_num_data_sections \
- winfsinfo_num_data_sections \
- + lssparse_num_data_sections \
- 0
- return 1
- fi
- - printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d data sections\n#\n" \
- + printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections\n#\n" \
- "$0" \
- fsutil_num_data_sections \
- - winfsinfo_num_data_sections
- + winfsinfo_num_data_sections \
- + lssparse_num_data_sections
- return 0
- }
- @@ -84,22 +89,27 @@ 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)"
- #
- # test whether the file is OK
- #
- - if (( (fsutil_num_data_sections != 0) || (winfsinfo_num_data_sections != 0) )) ; then
- - printf "# TEST failed, found fsutil=%d/winfsinfo=%d data sections, expected %d\n" \
- + if (( (fsutil_num_data_sections != 0) || \
- + (winfsinfo_num_data_sections != 0) || \
- + (lssparse_num_data_sections != 0) )) ; then
- + printf "# TEST failed, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections, expected %d\n" \
- fsutil_num_data_sections \
- winfsinfo_num_data_sections \
- + lssparse_num_data_sections \
- 0
- return 1
- fi
- - printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d data sections\n#\n" \
- + printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections\n#\n" \
- "$0" \
- fsutil_num_data_sections \
- - winfsinfo_num_data_sections
- + winfsinfo_num_data_sections \
- + lssparse_num_data_sections
- return 0
- }
- @@ -119,22 +129,27 @@ 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)"
- #
- # test whether the file is OK
- #
- - if (( (fsutil_num_data_sections != 1) || (winfsinfo_num_data_sections != 1) )) ; then
- - printf "# TEST failed, found fsutil=%d/winfsinfo=%d data sections, expected %d\n" \
- + if (( (fsutil_num_data_sections != 1) || \
- + (winfsinfo_num_data_sections != 1) || \
- + (lssparse_num_data_sections != 1) )) ; then
- + printf "# TEST failed, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections, expected %d\n" \
- fsutil_num_data_sections \
- winfsinfo_num_data_sections \
- + lssparse_num_data_sections \
- 1
- return 1
- fi
- - printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d data sections\n#\n" \
- + printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections\n#\n" \
- "$0" \
- fsutil_num_data_sections \
- - winfsinfo_num_data_sections
- + winfsinfo_num_data_sections \
- + lssparse_num_data_sections
- return 0
- }
- @@ -203,24 +218,29 @@ 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)"
- #
- # test whether the file is OK
- #
- if (( (fsutil_num_data_sections != (c.end_data_section-c.start_data_section)) || \
- - (winfsinfo_num_data_sections != (c.end_data_section-c.start_data_section)) )) ; then
- - printf "# TEST failed, found fsutil=%d/winfsinfo=%d data sections, expected %d\n" \
- + (winfsinfo_num_data_sections != (c.end_data_section-c.start_data_section)) || \
- + (lssparse_num_data_sections != (c.end_data_section-c.start_data_section)) )) ; then
- + printf "# TEST failed, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections, expected %d\n" \
- fsutil_num_data_sections \
- winfsinfo_num_data_sections \
- + lssparse_num_data_sections \
- $((c.end_data_section-c.start_data_section))
- return 1
- fi
- - printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d data sections\n#\n" \
- + printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections\n#\n" \
- "$0" \
- fsutil_num_data_sections \
- - winfsinfo_num_data_sections
- + winfsinfo_num_data_sections \
- + lssparse_num_data_sections
- +
- return 0
- }
- @@ -246,22 +266,27 @@ 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)"
- #
- # test whether the file is OK
- #
- - if (( (fsutil_num_data_sections != 2) || (winfsinfo_num_data_sections != 2) )) ; then
- - printf "# TEST failed, found fsutil=%d/winfsinfo=%d data sections, expected %d\n" \
- + if (( (fsutil_num_data_sections != 2) || \
- + (winfsinfo_num_data_sections != 2) || \
- + (lssparse_num_data_sections != 2) )) ; then
- + printf "# TEST failed, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections, expected %d\n" \
- fsutil_num_data_sections \
- winfsinfo_num_data_sections \
- + lssparse_num_data_sections \
- 2
- return 1
- fi
- - printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d data sections\n#\n" \
- + printf "\n#\n# TEST %q OK, found fsutil=%d/winfsinfo=%d/lssparse=%d data sections\n#\n" \
- "$0" \
- fsutil_num_data_sections \
- - winfsinfo_num_data_sections
- + winfsinfo_num_data_sections \
- + lssparse_num_data_sections
- return 0
- }
- --
- 2.45.1
msnfs41client: Patches to fix comment about QueryAllocatedRanges API bug, adding lssparse+misc, 2025-03-05
Posted by Anonymous on Wed 5th Mar 2025 11:58
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.