You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Tyler MacDonald <ty...@yi.org> on 2006/06/28 22:59:02 UTC
sparse files?
On my linux system, the following test code instantaniously creates a 1
gigabyte file... I'm guessing on Win32 it will either:
1) Grind away for 5 minutes creating a file full of zeroes,
2) Not work at all, or
3) If I'm really lucky, have the same behaviour as on linux.
Test code attached... would anybody with access to a win32 box be able to
give it a try and let me know what happened? (And specify if they're using
cygwin, visual studio, or whatever?)
Thanks,
Tyler
Re: sparse files?
Posted by Tyler MacDonald <ty...@yi.org>.
Michael Greene <gr...@cox.net> wrote:
> Might not help you, but with my OS/2 build it instantaneously creates
> the 1 gig file. Compiler used - Open Watcom 1.5.
Nice to know, thanks! :-)
- Tyler
Re: sparse files?
Posted by Michael Greene <gr...@cox.net>.
Tyler MacDonald wrote:
> On my linux system, the following test code instantaniously creates a 1
> gigabyte file... I'm guessing on Win32 it will either:
>
> 1) Grind away for 5 minutes creating a file full of zeroes,
>
> 2) Not work at all, or
>
> 3) If I'm really lucky, have the same behaviour as on linux.
>
> Test code attached... would anybody with access to a win32 box be able to
> give it a try and let me know what happened? (And specify if they're using
> cygwin, visual studio, or whatever?)
>
> Thanks,
> Tyler
>
Might not help you, but with my OS/2 build it instantaneously creates
the 1 gig file. Compiler used - Open Watcom 1.5.
Michael
Re: sparse files?
Posted by Tyler MacDonald <ty...@yi.org>.
Garrett Rooney <ro...@electricjellyfish.net> wrote:
> > ... Is there any reason that shouldn't be added to APR? It would
> >seem that would make something running under Win32/APR behave more like
> >Unix/APR and therefore encourage the P is for Portability...
> Because it's impossible to implement portably. There's no good way to
> figure out that a specific filesystem is actually capable of using
> sparse files.
So what happens on windows when you use the sparse file flag on a
filesystem that doesn't support sparse files?
Thanks,
Tyler
Re: sparse files?
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 6/28/06, Tyler MacDonald <ty...@yi.org> wrote:
> William A. Rowe, Jr. <wr...@rowe-clan.net> wrote:
> > Unless it's opened with Win32 API SPARSEFILE flag, yes it will grind away.
>
> ... Is there any reason that shouldn't be added to APR? It would
> seem that would make something running under Win32/APR behave more like
> Unix/APR and therefore encourage the P is for Portability...
Because it's impossible to implement portably. There's no good way to
figure out that a specific filesystem is actually capable of using
sparse files.
-garrett
Re: sparse files?
Posted by Tyler MacDonald <ty...@yi.org>.
William A. Rowe, Jr. <wr...@rowe-clan.net> wrote:
> Unless it's opened with Win32 API SPARSEFILE flag, yes it will grind away.
... Is there any reason that shouldn't be added to APR? It would
seem that would make something running under Win32/APR behave more like
Unix/APR and therefore encourage the P is for Portability...
- Tyler
Re: sparse files?
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Unless it's opened with Win32 API SPARSEFILE flag, yes it will grind away.
Tyler MacDonald wrote:
> On my linux system, the following test code instantaniously creates a 1
> gigabyte file... I'm guessing on Win32 it will either:
>
> 1) Grind away for 5 minutes creating a file full of zeroes,
>
> 2) Not work at all, or
>
> 3) If I'm really lucky, have the same behaviour as on linux.
>
> Test code attached... would anybody with access to a win32 box be able to
> give it a try and let me know what happened? (And specify if they're using
> cygwin, visual studio, or whatever?)
>
> Thanks,
> Tyler
>
>
>
> ------------------------------------------------------------------------
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <apr.h>
> #include <apr_pools.h>
> #include <apr_file_io.h>
>
> #if APR_MAJOR_VERSION == 0
> #define APR_FOPEN_READ APR_READ
> #define APR_FOPEN_WRITE APR_WRITE
> #define APR_FPROT_OS_DEFAULT APR_OS_DEFAULT
> #endif
>
> int main (int argc, const char* const* argv) {
> apr_pool_t *pool;
> apr_file_t *f;
> apr_off_t offs;
> int ret;
>
> if(apr_app_initialize(&argc, &argv, NULL) != APR_SUCCESS) {
> fprintf(stderr, "apr_app_initialize() failed!\n");
> fflush(stderr);
> exit(20);
> }
>
> atexit(apr_terminate);
>
> if(apr_pool_initialize() != APR_SUCCESS) {
> fprintf(stderr, "apr_pool_initialize() failed!\n");
> fflush(stderr);
> exit(2);
> }
>
> if(apr_pool_create(&pool, NULL) != APR_SUCCESS) {
> fprintf(stderr, "apr_pool_create() failed!\n");
> fflush(stderr);
> exit(3);
> }
>
> apr_file_open(
> &f, "test-sparse",
> APR_READ | APR_WRITE | APR_CREATE, APR_FPROT_OS_DEFAULT,
> pool
> );
>
> offs = 1048576000;
>
> apr_file_seek(f, APR_SET, &offs);
> apr_file_putc('x', f);
> apr_file_close(f);
>
> exit(0);
> }