[GRASS-dev] Maximum safe map name size?

Hamish hamish_b at yahoo.com
Fri Jul 2 03:19:56 EDT 2010


Hi Joel,

[sorry about yahoo's broken linewrap..]

Joel Pitt wrote:
> So I've been getting into all sorts of strife with
> hard-coded limits
> on filename lengths in GRASS. Not hard-coded in a sense
> that they are
> enforced (that wouldn't be an issue, because then I'd know
> about it!),
> but in the sense that there are all these fixed buffer
> limits in
> modules which don't gracefully handle filenames that get
> too long.
> Instead it fails with cryptic messages, and since I've
> built a large
> simulation framework/pipeline around GRASS, it makes
> everything else
> fall over too.
> 
> I've been having trouble with r.random and r.reclass:
> 
> http://trac.osgeo.org/grass/ticket/800
> 
> I "fixed" those, but now the cell header for the reclassed
> map results in:
> 
> WARNING: Unable to open raster map
> 
> whenever I try to access it. Except, the header in cellhd
> looks
> exactly the same as another file that's reclassed and works
> fine. The
> only difference is that the working one reclasses a map
> with a short
> name.
> 
> I can try to start fixing this (hints on where this process
> happens in
> the libs appreciated), but basically I'm wondering, is all
> of GRASS
> like this? If so, I don't have the time to fix what may be
> a huge job,
> but can we at least make the libraries responsible for
> writing maps
> complain (or fail) when a provided map name is too long?


include/gis.h defines:

/* File/directory name lengths */
#define GNAME_MAX 256
#define GMAPSET_MAX 256

#define GPATH_MAX 4096


but little checks that you haven't exceeded that. We think we've
updated most of the code to use those constants instead of local
ad hoc (smaller) constants, but there will still be many we
missed. If so, the thing to do is to file a bug report and/or
patch. (thanks for ticket #800)

snprintf() stuff is still a bit of an unresolved sore spot but
seems to me not so impossible to fix. maybe a better solution
is in grass7 already, I'm not sure, but at least the ugly write-
to-file hack is removed there AFAIK.

how long are your map+mapset names?

as you found, on top of that, grass 6 titles (cats+hist) are
going to be limited to RECORD_LEN chars. an update of the meta-
data backend remains a major TODO for grass 7.


Hamish

ps- c++ //comments are disfavoured in favour of /* c */ ones.
see the SUBMITTING file.


      


More information about the grass-dev mailing list