[gdal-dev] vsipreload: enabling VSI Virtual File API for regular I/O

Etienne Tourigny etourigny.dev at gmail.com
Tue May 28 15:44:03 PDT 2013


On Tue, May 28, 2013 at 7:35 PM, Even Rouault
<even.rouault at mines-paris.org>wrote:

>
> > I have managed to get it working buy using LD_PRELOAD=./vsipreload.so
>
> Yes for some strange reason, some systems require the ./ and some not... My
> old Ubuntu 10.04 does no, but Travis on Ubuntu 12.04 does. Perhaps some
> security measure that has been added in LD_PRELOAD mechanism.
>
> I've just adjusted the examples in the .cpp header to add ./
>
> >
> > e.g.
> > LD_PRELOAD=./vsipreload.so gdalinfo /vsicurl/
> > http://download.osgeo.org/gdal/data/netcdf/utm-big-chunks.nc
> >
> > It seems that setting LD_PRELOAD outside of the command works also, so
> this
> > mechanism would be used transparently.
> > But does it have a significant overhead and/or chances it might do damage
> > if always set?
>
> This should have no impact for I/O on regular files, except for a hopefully
> small performance hit to check if the FILE* is a regular one (and redirect
> to
> the glibc function) or one that is a VSILFILE* instead (and redirect to VSI
> implementation). On /vsiXXXX files, crashes are theoretically possible if a
> glibc function using the fake FILE* is used, but not overloaded in the .so.
>
> >
> > e.g.
> > export LD_PRELOAD=./vsipreload.so
> > gdalinfo /vsicurl/
> > http://download.osgeo.org/gdal/data/netcdf/utm-big-chunks.nc
> >
> >
> > Is there any way this could be integrated into gdal to transparently
> > support vsifile for all drivers, without setting LD_PRELOAD?
>
> None that I'm aware of. LD_PRELOAD is really something that must be
> specified
> before process launching. When GDAL code is reached, it is too late (and
> those
> limitations are really welcome for obvious security reasons).
>

It would probably best (and safer for the time being) to use aliases for
commonly-used apps that would benefit from this (gdal*, qgis, etc)

alias gdalinfo='LD_PRELOAD=/usr/local/lib/vsipreload.so gdalinfo'
alias gdalwarp='LD_PRELOAD=/usr/local/lib/vsipreload.so gdalwarp'
alias qgis='LD_PRELOAD='usr/local/lib/vsipreload.so qgis'


> > In this way this feature would be available to all gdal commands or even
> > other apps that use gdal.
> >
> > For example, /vsizip/ is used in QGIS, but it does not work with certain
> > files (e.g. netcdf ) inside archives. But if I use LD_PRELOAD it works
> for
> > netcdf files! Neat stuff!
> > e.g. LD_PRELOAD=./vsipreload.so qgis
>
> As I mentioned in another post in that thread, the use of a fuse filesystem
> could make it less hackish, although you would need permissions to mount on
> /vsizip , /vsicurl etc which might be problematic if you are not a good
> friend
> with the system administrator. You don't need to be root to mount a fuse
> filesystem, but you must have write permissions on the mount point I
> believe.
>

it seems a little more involved and less flexible


>
> >
> > great work
> > Etienne
>
> --
> Geospatial professional services
> http://even.rouault.free.fr/services.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130528/3d13400a/attachment.html>


More information about the gdal-dev mailing list