[GRASS5] [bug #3586] (grass) r.proj error: closecell: can't move file

this bug's URL: http://intevation.de/rt/webrt?serial_num=3586
-------------------------------------------------------------------------

Subject: r.proj error: closecell: can't move file

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 6.0.1

When using r.proj for larger files (cca 300MB+), r.proj ends with this error:

Allocating memory and reading input map... 100%
Projecting... 100%
WARNING: closecell: can't move
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.1
         to null file
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell_misc/landsat_rgb_composite/null
WARNING: closecell: can't move
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.0
         to cell file
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell/landsat_rgb_composite
WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]
WARNING: can't write range file for [landsat_rgb_composite in PERMANENT]
WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]

Each time I move the files manually (mv <source> <dest>) and they seem to be OK. The filesystem is vfat.

Miroslav ©ulc

-------------------------------------------- Managed by Request Tracker

Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=3586
-------------------------------------------------------------------------

Subject: r.proj error: closecell: can't move file

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 6.0.1

When using r.proj for larger files (cca 300MB+), r.proj ends with this error:

Allocating memory and reading input map... 100%
Projecting... 100%
WARNING: closecell: can't move
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.1
         to null file
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell_misc/landsat_rgb_composite/null
WARNING: closecell: can't move
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.0
         to cell file
         /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell/landsat_rgb_composite
WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]
WARNING: can't write range file for [landsat_rgb_composite in PERMANENT]
WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]

Each time I move the files manually (mv <source> <dest>) and they seem to be OK. The filesystem is vfat.

Except that I can't see why this would happen only for large files I think the problem is because a Linux Grass version is run with data files on a vfat file system. We do not check file system types at run time, only platform at compile time. So something, using link() instead of CopyFile(), is breaking ?.

If so, not only r.proj is affected.

From closecell.c:

#ifdef __MINGW32__
             if ( CopyFile ( FCB.null_temp_name, path, FALSE ) == 0 ) {
#else
             if(link (FCB.null_temp_name, path) < 0) {
#endif
                 sprintf(command, "mv %s %s", FCB.null_temp_name, path);
                 if(system(command)) {
                     sprintf(buf,"closecell: can't move %s\nto null file %s",
                     FCB.null_temp_name, path);
                     G_warning (buf);
                     stat = -1;
                 }
             } else {
                 remove ( FCB.null_temp_name );
             }
         } else {
             remove ( FCB.null_temp_name );
             remove ( path );
         } /* null_cur_row > 0 */

Morten Hulden wrote:

Request Tracker wrote:
> this bug's URL: http://intevation.de/rt/webrt?serial_num=3586
> -------------------------------------------------------------------------
>
> Subject: r.proj error: closecell: can't move file
>
> Platform: GNU/Linux/i386
> grass obtained from: Trento Italy site
> grass binary for platform: Compiled from Sources
> GRASS Version: 6.0.1
>
> When using r.proj for larger files (cca 300MB+), r.proj ends with this error:
>
> Allocating memory and reading input map... 100%
> Projecting... 100%
> WARNING: closecell: can't move
> /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.1
> to null file
> /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell_misc/landsat_rgb_composite/null
> WARNING: closecell: can't move
> /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/.tmp/centaur/11061.0
> to cell file
> /home/fordfrog/data/mapy/cr-jtsk/PERMANENT/cell/landsat_rgb_composite
> WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]
> WARNING: can't write range file for [landsat_rgb_composite in PERMANENT]
> WARNING: unable to find [landsat_rgb_composite] in [PERMANENT]
>
> Each time I move the files manually (mv <source> <dest>) and they seem to be OK. The filesystem is vfat.

Except that I can't see why this would happen only for large files I
think the problem is because a Linux Grass version is run with data
files on a vfat file system. We do not check file system types at run
time, only platform at compile time. So something, using link() instead
of CopyFile(), is breaking ?.

If so, not only r.proj is affected.

From closecell.c:

#ifdef __MINGW32__
             if ( CopyFile ( FCB.null_temp_name, path, FALSE ) == 0 ) {
#else
             if(link (FCB.null_temp_name, path) < 0) {
#endif
                 sprintf(command, "mv %s %s", FCB.null_temp_name, path);
                 if(system(command)) {
                     sprintf(buf,"closecell: can't move %s\nto null file
%s",
                     FCB.null_temp_name, path);
                     G_warning (buf);
                     stat = -1;
                 }
             } else {
                 remove ( FCB.null_temp_name );
             }
         } else {
             remove ( FCB.null_temp_name );
             remove ( path );
         } /* null_cur_row > 0 */

This should be using rename() rather than link()+remove(). And the use
of system("mv ....") should be removed.

--
Glynn Clements <glynn@gclements.plus.com>