this bug's URL: http://intevation.de/rt/webrt?serial_num=3362
-------------------------------------------------------------------------
Subject: r.proj works ONLY when source and target mapset names are identical
Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: cvs 21.06.2005
r.proj cannot handle a following situation
1. source
name: 452_211_scinawa
location: caves_65
mapset: PERMANENT
2. target
name: 452_211_scinawa_utm
location: caves_utm33
mapset: topo
GRASS 6.1.cvs (caves_utm33):~ > r.proj input=452_211_scinawa location=caves_65 mapset=PERMANENT output=452_211_scinawa_utm
mkdir: cannot create directory `/home/grassdata/caves_65/topo/.tmp': No such file or directory
ERROR: can't make mapset element .tmp/quercus.biol.uni.wroc.pl
(/home/grassdata/caves_65/topo/.tmp)
It is trying to create a .tmp in a non-existant mapset! Like if it couldn't read that the source mapset is PERMANENT. Somehow the source and target mapset names get mixed.
Maciek
-------------------------------------------- Managed by Request Tracker
Request Tracker wrote:
this bug's URL: http://intevation.de/rt/webrt?serial_num=3362
Subject: r.proj works ONLY when source and target mapset names are identical
mkdir: cannot create directory `/home/grassdata/caves_65/topo/.tmp': No such file or directory
ERROR: can't make mapset element .tmp/quercus.biol.uni.wroc.pl
(/home/grassdata/caves_65/topo/.tmp)
It is trying to create a .tmp in a non-existant mapset! Like if it
couldn't read that the source mapset is PERMANENT. Somehow the
source and target mapset names get mixed.
This is a very good reason not to use G_tempfile() for normal
temporary files.
There is no guarantee that the user can create files or directories
within the source location.
--
Glynn Clements <glynn@gclements.plus.com>
Glynn Clements wrote:
Request Tracker wrote:
this bug's URL: http://intevation.de/rt/webrt?serial_num=3362
Subject: r.proj works ONLY when source and target mapset names are identical
mkdir: cannot create directory `/home/grassdata/caves_65/topo/.tmp': No such file or directory
ERROR: can't make mapset element .tmp/quercus.biol.uni.wroc.pl
(/home/grassdata/caves_65/topo/.tmp)
It is trying to create a .tmp in a non-existant mapset! Like if it
couldn't read that the source mapset is PERMANENT. Somehow the
source and target mapset names get mixed.
This is a very good reason not to use G_tempfile() for normal
temporary files.
There is no guarantee that the user can create files or directories
within the source location.
So, not a r.proj specific problem then. A lot of modules may suffer from using G_tempfile().
r.proj is not calling G_tempfile() directly. In the case mentioned above suspects are datum.c, get_datum_name.c, get_ell_name.c or some other function from /lib/gis files.
What is the correct fix? To rewrite G_tempfile()?
----------------
find . -type f -name "*\.c" -exec grep -H G_tempfile {} \;
./display/d.ask/main.c: tempfile = G_tempfile();
./display/d.barscale/mouse.c: char *panel = G_tempfile();
./display/d.histogram/get_stats.c: tempfile = G_tempfile();
./display/d.profile/Range.c:temp_fname = G_tempfile();
./display/d.rast.edit/mk_tmp_file.c: tempfile = G_tempfile();
./display/d.text/main.c: wind_file_name = G_tempfile();
./display/d.text.freetype/main.c: tmpfile = G_tempfile();
./display/d.what.vect/what.c: panell = G_tempfile();
./general/g.setproj/get_stp.c: Tmp_file1 = G_tempfile();
./general/g.setproj/get_stp.c: Tmp_file2 = G_tempfile();
./general/g.setproj/get_stp.c: Tmp_file1 = G_tempfile();
./general/g.setproj/get_stp.c: Tmp_file2 = G_tempfile();
./imagery/i.ask/popup.c: tempfile1 = G_tempfile();
./imagery/i.ask/popup.c: tempfile2 = G_tempfile();
./imagery/i.class/main.c: tempfile = G_tempfile();
./imagery/i.find/main.c: tempfile = G_tempfile();
./imagery/i.ortho.photo/libes/ls_cameras.c: tempfile = G_tempfile();
./imagery/i.ortho.photo/libes/ls_elev.c: tempfile = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: tempfile1 = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: tempfile2 = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: tempfile3 = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: cell_list = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: vect_list = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: group_list = G_tempfile();
./imagery/i.ortho.photo/photo.2image/main.c: digit_points = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: tempfile1 = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: tempfile2 = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: tempfile_dot = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: cell_list = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: vect_list = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: group_list = G_tempfile();
./imagery/i.ortho.photo/photo.2target/main.c: digit_points = G_tempfile();
./imagery/i.ortho.photo/photo.rectify/write.c: temp_name = G_tempfile();
./imagery/i.pca/main.c: strcpy(temp, G_tempfile());
./imagery/i.points/main.c: tempfile1 = G_tempfile();
./imagery/i.points/main.c: tempfile2 = G_tempfile();
./imagery/i.points/main.c: cell_list = G_tempfile();
./imagery/i.points/main.c: vect_list = G_tempfile();
./imagery/i.points/main.c: group_list = G_tempfile();
./imagery/i.points/main.c: digit_points = G_tempfile();
./imagery/i.points/main.c: digit_results = G_tempfile();
./imagery/i.rectify/write.c: temp_name = G_tempfile();
./imagery/i.vpoints/main.c: tempfile1 = G_tempfile();
./imagery/i.vpoints/main.c: tempfile2 = G_tempfile();
./imagery/i.vpoints/main.c: cell_list = G_tempfile();
./imagery/i.vpoints/main.c: vect_list = G_tempfile();
./imagery/i.vpoints/main.c: group_list = G_tempfile();
./imagery/i.vpoints/main.c: digit_points = G_tempfile();
./imagery/i.vpoints/main.c: digit_results = G_tempfile();
./lib/display/popup.c: panel = G_tempfile() ;
./lib/g3d/g3dcache.c: map->cacheFileName = G_tempfile ();
./lib/g3d/g3dopen.c: map->tempName = G_tempfile ();
./lib/gis/asprintf.c: if ((fn = G_tempfile())) {
./lib/gis/datum.c: Tmp_file = G_tempfile ();
./lib/gis/get_datum_name.c: Tmp_file = G_tempfile ();
./lib/gis/get_ell_name.c: Tmp_file = G_tempfile ();
./lib/gis/get_projname.c: Tmp_file = G_tempfile ();
./lib/gis/opencell.c: tempname = G_tempfile ();
./lib/gis/put_title.c: tempfile = G_tempfile();
./lib/gis/tempfile.c: * G_tempfile()
./lib/gis/tempfile.c: * as a temporary file within the module. Successive calls to G_tempfile() will
./lib/gis/tempfile.c: * all temporary files created by G_tempfile() that have been left behind by
./lib/gis/tempfile.c:char *G_tempfile(void)
./lib/imagery/ls_groups.c: tempfile = G_tempfile();
./lib/proj/datum.c: Tmp_file = G_tempfile ();
./lib/vector/Vlib/map.c: tmp = G_tempfile();
./ps/ps.map/comment.c: PS.commentfile = G_tempfile();
./ps/ps.map/main.c: ps_mask_file = G_tempfile();
./ps/ps.map/r_plt.c: PS.plfile = G_tempfile();
./ps/ps.map/r_text.c: labels.other = G_tempfile();
./ps/ps.map/session.c: sessionfile = G_tempfile();
./raster/r.average/main.c: tempfile1 = G_tempfile();
./raster/r.average/main.c: tempfile2 = G_tempfile();
./raster/r.coin/main.c: dumpname = G_tempfile () ;
./raster/r.coin/main.c: statname = G_tempfile () ;
./raster/r.cost/main.c: in_file = G_tempfile();
./raster/r.cost/main.c: out_file = G_tempfile();
./raster/r.digit/main.c: polyfile = G_tempfile();
./raster/r.drain/main.c: tempfile1 = G_tempfile();
./raster/r.drain/main.c: tempfile2 = G_tempfile();
./raster/r.fill.dir/main.c: tempfile1 = G_tempfile();
./raster/r.fill.dir/main.c: tempfile2 = G_tempfile();
./raster/r.fill.dir/main.c: tempfile3 = G_tempfile();
./raster/r.flow/io.c: ds.sfd = open_segment_file(tmp_name(G_tempfile()), ds, TEMP);
./raster/r.in.arc/main.c: Tmp_file = G_tempfile ();
./raster/r.in.ascii/main.c: temp = G_tempfile();
./raster/r.in.ascii/main.c: Tmp_file = G_tempfile();
./raster/r.kappa/stats.c: stats_file = G_tempfile();
./raster/r.le/r.le.setup/setup.c: tempfile = G_tempfile();
./raster/r.los/main.c: in_name = G_tempfile();
./raster/r.los/main.c: out_name = G_tempfile();
./raster/r.los/main.c: patt_name = G_tempfile();
./raster/r.mfilter/perform.c: close(creat(tmp1=G_tempfile(),0666));
./raster/r.mfilter/perform.c: close(creat(tmp2=G_tempfile(),0666));
./raster/r.out.mpeg/main.c: yfiles[cnt] = G_tempfile();
./raster/r.out.mpeg/main.c: mpfilename = G_tempfile();
./raster/r.out.mpeg/main.c: tfile = G_tempfile();
./raster/r.report/stats.c: stats_file = G_tempfile();
./raster/r.resamp.rst/main.c: Tmp_file_z = G_tempfile ();
./raster/r.resamp.rst/main.c: Tmp_file_dx = G_tempfile ();
./raster/r.resamp.rst/main.c: Tmp_file_dy = G_tempfile ();
./raster/r.resamp.rst/main.c: Tmp_file_xx = G_tempfile ();
./raster/r.resamp.rst/main.c: Tmp_file_yy = G_tempfile ();
./raster/r.resamp.rst/main.c: Tmp_file_xy = G_tempfile ();
./raster/r.statistics/o_average.c: tempfile1 = G_tempfile();
./raster/r.statistics/o_average.c: tempfile2 = G_tempfile();
./raster/r.statistics/o_distrib.c: tempfile1 = G_tempfile();
./raster/r.statistics/o_distrib.c: tempfile2 = G_tempfile();
./raster/r.statistics/o_sum.c: tempfile1 = G_tempfile();
./raster/r.statistics/o_sum.c: tempfile2 = G_tempfile();
./raster/r.surf.contour/bseg_open.c: filename = G_tempfile ();
./raster/r.surf.contour/cseg_open.c: filename = G_tempfile ();
./raster/r.thin/io.c: work_file_name = G_tempfile();
./raster/r.watershed/seg/bseg_open.c: filename = G_tempfile ();
./raster/r.watershed/seg/cseg_open.c: filename = G_tempfile ();
./raster/r.watershed/seg/dseg_open.c: filename = G_tempfile ();
./raster/r.watershed/seg/sseg_open.c: filename = G_tempfile ();
./raster/wildfire/r.spreadpath/main.c: in_row_file = G_tempfile();
./raster/wildfire/r.spreadpath/main.c: in_col_file = G_tempfile();
./raster/wildfire/r.spreadpath/main.c: out_file = G_tempfile();
./raster/r.support/modhead/check_un.c: tempfile = G_tempfile();
./vector/v.in.ascii/in.c: tmp = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_z = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_dx = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_dy = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_xx = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_yy = G_tempfile();
./vector/v.surf.rst/main.c: Tmp_file_xy = G_tempfile();
./vector/v.vol.rst/main.c: Tmp_file_cell = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_z = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_dx = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_dy = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_dz = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_xx = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_yy = G_tempfile ();
./vector/v.vol.rst/main.c: Tmp_file_xy = G_tempfile ();
./visualization/xganim/main.c: tfile = G_tempfile();
On Thu, 23 Jun 2005, Morten Hulden wrote:
Glynn Clements wrote:
This is a very good reason not to use G_tempfile() for normal
temporary files.
There is no guarantee that the user can create files or directories
within the source location.
So, not a r.proj specific problem then. A lot of modules may suffer from using G_tempfile().
r.proj is not calling G_tempfile() directly. In the case mentioned above suspects are datum.c, get_datum_name.c, get_ell_name.c or some other function from /lib/gis files.
Even so, it should be creating a temp file in the current mapset, not in the location that is being projected from. Perhaps the location switching
code in r.proj might not be handling the mapset correctly. Although I tried to reproduce the problem and couldn't.
What is the correct fix? To rewrite G_tempfile()?
See
http://grass.itc.it/pipermail/grass5/2005-January/016997.html
I suspect Brad's recent changes to make G_asprintf() use G_tempfile() should be reverted?
Paul
Paul Kelly wrote:
On Thu, 23 Jun 2005, Morten Hulden wrote:
Glynn Clements wrote:
This is a very good reason not to use G_tempfile() for normal
temporary files.
There is no guarantee that the user can create files or directories
within the source location.
So, not a r.proj specific problem then. A lot of modules may suffer from using G_tempfile().
r.proj is not calling G_tempfile() directly. In the case mentioned above suspects are datum.c, get_datum_name.c, get_ell_name.c or some other function from /lib/gis files.
Even so, it should be creating a temp file in the current mapset, not in the location that is being projected from. Perhaps the location switching
code in r.proj might not be handling the mapset correctly. Although I tried to reproduce the problem and couldn't.
I could not reproduce the problem either; I was able to reproject from a mapset where I did not have write permission, but r.proj did not even try to create a .tmp directory anywhere in the source mapset.
OTOH I am running a CVS version a few weeks old. I'll update and see what happens. Although r.proj has not changed some underlying library routines may have ...
rgds
Morten
Morten Hulden wrote:
Paul Kelly wrote:
r.proj is not calling G_tempfile() directly. In the case mentioned above suspects are datum.c, get_datum_name.c, get_ell_name.c or some other function from /lib/gis files.
Even so, it should be creating a temp file in the current mapset, not in the location that is being projected from. Perhaps the location switching
code in r.proj might not be handling the mapset correctly. Although I tried to reproduce the problem and couldn't.
I could not reproduce the problem either; I was able to reproject from a mapset where I did not have write permission, but r.proj did not even try to create a .tmp directory anywhere in the source mapset.
OTOH I am running a CVS version a few weeks old. I'll update and see what happens. Although r.proj has not changed some underlying library routines may have ...
With CVS 20050623 I get the same error:
mkdir: cannot create directory `/var/local/grass/data/global_ll/morten/.tmp': No such file or directory
ERROR: can't make mapset element .tmp/xxxx.yyyyyy.zzz
(/var/local/grass/data/global_ll/morten/.tmp)
So the bug was introduced in some library routines since 20050606 (last time I updated from CVS), but not in r.proj itself.
Morten Hulden wrote:
Morten Hulden wrote:
Paul Kelly wrote:
r.proj is not calling G_tempfile() directly. In the case mentioned above suspects are datum.c, get_datum_name.c, get_ell_name.c or some other function from /lib/gis files.
Even so, it should be creating a temp file in the current mapset, not in the location that is being projected from. Perhaps the location switching
code in r.proj might not be handling the mapset correctly. Although I tried to reproduce the problem and couldn't.
I could not reproduce the problem either; I was able to reproject from a mapset where I did not have write permission, but r.proj did not even try to create a .tmp directory anywhere in the source mapset.
OTOH I am running a CVS version a few weeks old. I'll update and see what happens. Although r.proj has not changed some underlying library routines may have ...
With CVS 20050623 I get the same error:
mkdir: cannot create directory `/var/local/grass/data/global_ll/morten/.tmp': No such file or directory
ERROR: can't make mapset element .tmp/xxxx.yyyyyy.zzz
(/var/local/grass/data/global_ll/morten/.tmp)
So the bug was introduced in some library routines since 20050606 (last time I updated from CVS), but not in r.proj itself.
Paul Kelly wrote:
See
http://grass.itc.it/pipermail/grass5/2005-January/016997.html
I suspect Brad's recent changes to make G_asprintf() use G_tempfile() should be reverted?
Yes, it's in G_asprintf(). Simply changing G_tempfile() back to tmpfile() on line 37 in asprintf.c fixes it. There may be other consequences so I suggest the maintainer makes the reversion himself in cvs.
rgds
Morten
On Thu, 2005-06-23 at 03:09 +0200, Morten Hulden wrote:
>> I suspect Brad's recent changes to make G_asprintf() use G_tempfile()
>> should be reverted?
Yes, it's in G_asprintf(). Simply changing G_tempfile() back to
tmpfile() on line 37 in asprintf.c fixes it. There may be other
consequences so I suggest the maintainer makes the reversion himself in cvs.
This was my doing. I was unaware of the implications of G_tempfile().
Can someone back out the changes?
--
Brad Douglas <rez@touchofmadness.com>
On Wed, 22 Jun 2005, Brad Douglas wrote:
On Thu, 2005-06-23 at 03:09 +0200, Morten Hulden wrote:
I suspect Brad's recent changes to make G_asprintf() use G_tempfile()
should be reverted?
Yes, it's in G_asprintf(). Simply changing G_tempfile() back to
tmpfile() on line 37 in asprintf.c fixes it. There may be other
consequences so I suggest the maintainer makes the reversion himself in cvs.
This was my doing. I was unaware of the implications of G_tempfile().
Can someone back out the changes?
I have changed G_asprintf() back to use tmpfile() instead of G_tempfile() and fopen() and it seems to have fixed the r.proj bug.
Probably would need to think about systematically changing some other occurences of G_tempfile() as Glynn and Morten suggested.
Paul
Morten Hulden wrote:
>>It is trying to create a .tmp in a non-existant mapset! Like if it
>>couldn't read that the source mapset is PERMANENT. Somehow the
>>source and target mapset names get mixed.
>
>
> This is a very good reason not to use G_tempfile() for normal
> temporary files.
>
> There is no guarantee that the user can create files or directories
> within the source location.
So, not a r.proj specific problem then. A lot of modules may suffer from
using G_tempfile().
Yep, including anything which uses G_asprintf().
r.proj is not calling G_tempfile() directly. In the case mentioned above
suspects are datum.c, get_datum_name.c, get_ell_name.c or some other
function from /lib/gis files.
What is the correct fix? To rewrite G_tempfile()?
The correct fix would be to not have misused G_tempfile() extensively
throughout GRASS in the first place. Unfortunately, we're a bit too
far gone for that.
The best solution now is to:
1. Rename G_tempfile().
2. Modify legitimate callers of G_tempfile() to use the renamed
function.
3. Implement a new G_tempfile() which uses $TMPDIR or /tmp.
--
Glynn Clements <glynn@gclements.plus.com>
Paul Kelly wrote:
>>>> I suspect Brad's recent changes to make G_asprintf() use G_tempfile()
>>>> should be reverted?
>>
>> Yes, it's in G_asprintf(). Simply changing G_tempfile() back to
>> tmpfile() on line 37 in asprintf.c fixes it. There may be other
>> consequences so I suggest the maintainer makes the reversion himself in cvs.
>
> This was my doing. I was unaware of the implications of G_tempfile().
> Can someone back out the changes?
I have changed G_asprintf() back to use tmpfile() instead of G_tempfile()
and fopen() and it seems to have fixed the r.proj bug.
Probably would need to think about systematically changing some other
occurences of G_tempfile() as Glynn and Morten suggested.
I agree.
The alternative is to require any program which switches locations
using G__switch_env() to ensure that G_tempfile() doesn't get called
while the location is switched. Given that calls to G_tempfile() could
be hidden deep down in the call graph, that requirement would be
extremely hard to comply with.
--
Glynn Clements <glynn@gclements.plus.com>