Markus Neteler wrote:

> Is this patch reasonable?
> 
> svn diff mapset_msc.c
> Index: mapset_msc.c
> ===================================================================
> --- mapset_msc.c        (revision 36196)
> +++ mapset_msc.c        (working copy)
> @@ -12,6 +12,7 @@
>  #include <string.h>
>  #include <unistd.h>
>  #include <stdlib.h>
> +#include <errno.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <grass/gis.h>
> @@ -56,9 +57,10 @@
>             *p = 0;
>             if (access(path, 0) != 0)
>                 G_mkdir(path);
> -           if (access(path, 0) != 0)
> -               G_fatal_error(_("Unable to make mapset element %s (%s)"),
> -                             p_element, path);
> +           if (access(path, 0) != 0) {
> +               G_fatal_error(_("Unable to make mapset element %s (%s): %s"),
> +                             p_element, path, strerror(errno));
> +           }
>             if (*element == 0)
>                 return 1;
>         }
> 
> Strangly, it says:
> 
> r.in.gdal -o --o aqua_lst1km20090130.QC_Day.tif out=aqua_lst1km20090130.QC_Day
> WARNING: Over-riding projection check
>  100%
> ERROR: Unable to make mapset element cell_misc/aqua_lst1km20090130.QC_Day
>        
> (/home/neteler/grassdata/patUTM32/modisLST005filt/cell_misc/aqua_lst1km20090130.QC_Day):
>        No such file or directory
> 
> while it should say:
> 
> mkdir 
> /home/neteler/grassdata/patUTM32/modisLST005filt/cell_misc/aqua_lst1km20090130.QC_Day
> mkdir: cannot create directory
> `/home/neteler/grassdata/patUTM32/modisLST005filt/cell_misc/aqua_lst1km20090130.QC_Day':
> Too many links

access() sets errno when it fails.

If you want the reason why mkdir() failed, you need to test the return
value from G_mkdir(), e.g.:

        if (access(path, 0) != 0)
            if (G_mkdir(path) != 0)
                G_fatal_error(_("Unable to make mapset element %s (%s): %s"),
                                p_element, path, strerror(errno));

-- 
Glynn Clements <gl...@gclements.plus.com>
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to