The app works fine for me on Win2k SP1 Pro. I tried it on 2 NTFS
partitions. One is compressed, the other not. It worked on both.
NTFS is the only MS FS that supports sparseness. It works on all
versions on Win2k.
Perhaps you were attempting to do this on a FAT drive?
-----Original Message-----
From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
Sent: Wednesday, March 14, 2001 7:33 AM
To: File Systems Developers
Cc: xxxxx@lists.osr.com
Subject: [ntfsd] RE: FSCTL_SET_SPARSE failure
Peter,
Did you use the program with the sparse option?
example:
mkfile file-1 1234567890 1
mkfile file-2 1234567890 1
mkfile file-3 1234567890 1
mkfile file-4 1234567890 1
^— this sets the file to be sparse…
You can keep going…
Just make sure you set the sparse argument at the end.
-----Original Message-----
From: Peter J. Braam [mailto:xxxxx@mountainviewdata.com]
Sent: Tuesday, March 13, 2001 3:23 PM
To: Danilo Almeida; xxxxx@lists.osr.com
Subject: RE: [ntfsd] FSCTL_SET_SPARSE failure
Hi Danilo,
Your program fails for me too. I wonder if W2K professional supports
sparse
files or if it is a W2K server feature. Is compression turned on on
your
file systems, or any other flag I may have forgotten to set?
Thanks for your help!
-----Original Message-----
From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
Sent: Tuesday, March 13, 2001 11:56 AM
To: braam@cs.cmu.edu
Cc: File Systems Developers
Subject: RE: [ntfsd] FSCTL_SET_SPARSE failure
Peter,
Included is a program that has worked for me. I have never used
filemon
with it, but I have made huge files that have taken up no space.
/* mkfile */
#define _WIN32_WINNT 0x0500
#include <windows.h>
> #include <stdio.h>
>
> int
> main(
> int argc,
> char* argv
> )
> {
> DWORD error = 0;
> bool created = false;
> HANDLE h = 0;
> LARGE_INTEGER l;
> char* fname = 0;
> char* ssize = 0;
>
> l.QuadPart = 0;
>
> if (argc < 3) {
> fprintf(stderr, “usage: %s filename size [sparse]\n”,
argv[0]);
> return 1;
> }
> fname = argv[1];
> ssize = argv[2];
>
> if (!sscanf(ssize, “%I64u”, &l.QuadPart)) {
> fprintf(stderr, “Invalid number: %s\n”, ssize);
> return 1;
> }
> printf(“Name: %s\n”
> “Size: %I64u\n”,
> fname,
> l.QuadPart);
>
> h = CreateFile(fname,
> GENERIC_WRITE, // access
> FILE_SHARE_DELETE, // share mode
> 0, // sec
> CREATE_NEW, // disp
> 0, // flags and attribs
> 0);
> if (h == INVALID_HANDLE_VALUE) {
> DWORD error = GetLastError();
> fprintf(stderr, “Error creating file (%u)\n”, error);
> return error;
> }
> created = true;
>
> if (argc >= 4) {
> DWORD dwReturnedBytes=0;
> if (!DeviceIoControl(h,
> FSCTL_SET_SPARSE, NULL, 0,
> NULL, 0, &dwReturnedBytes,
> NULL)) {
> error = GetLastError();
> fprintf(stderr, “Error making file sparse (%u)\n”, error);
> goto cleanup;
> }
> fprintf(stderr, “File sparsed…\n”);
> }
>
> if (!SetFilePointerEx(h, l, 0, FILE_BEGIN)) {
> error = GetLastError();
> fprintf(stderr, “Error setting file pointer (%u)\n”, error);
> goto cleanup;
> }
> if (!SetEndOfFile(h)) {
> error = GetLastError();
> fprintf(stderr, “Error setting file pointer (%u)\n”, error);
> goto cleanup;
> }
> if (!CloseHandle(h)) {
> error = GetLastError();
> fprintf(stderr, “Error closing file (%u)\n”, error);
> goto cleanup;
> }
> return 0;
> cleanup:
> if (error && created) {
> if (!DeleteFile(fname)) {
> fprintf(stderr, “Error deleting file (%u)\n”,
GetLastError());
> }
> }
> return error;
> }
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Peter J. Braam
> Sent: Tuesday, March 13, 2001 2:00 PM
> To: File Systems Developers
> Subject: [ntfsd] FSCTL_SET_SPARSE failure
>
>
>
> Hi,
>
> I tried the following three lines of code:
>
> HANDLE hstream = CreateFile(szPathName, GENERIC_READ |
GENERIC_WRITE,
> 0, NULL, CREATE_ALWAYS, 0, NULL);
>
> rc = DeviceIoControl(hstream, FSCTL_SET_SPARSE, NULL, 0,
> NULL, 0, NULL, NULL);
>
> This is on an NTFS file system which claims to
> FILE_SUPPORTS_SPARSE_FILES. It’s from a clean Win2k Professional
> installation.
>
> The ioctl returns 0. Lasterror says nothing but filemon says:
>
> FSCTL_SET_SPARSE C:\TMP\SparseFile INVALID DEVICE
> REQUEST
>
> The file system has the compression tick box “off”.
>
> Does anyone know what is going on here? I thought I would get
success.
>
> How do I create a sparse file?
>
> Thanks.
>
> - Peter -
>
>
—
You are currently subscribed to ntfsd as: xxxxx@microsoft.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com</stdio.h></windows.h>