dvalters / fuse-netcdf

ESoWC project to develop a Python utility to mount NetCDF files as a file-system in user space. (FUSE)
Other
8 stars 3 forks source link

Pass internal error back to user? #30

Open dvalters opened 6 years ago

dvalters commented 6 years ago

Not sure if this is actually possible - but it would be nice from an end-user perspective if the internal errors were presented to the user when trying to do a 'not allowed' operation such as trying to create a directory inside a variable directory. e.g.:

[dvalters@helmsdale mntpnt4]$ ll
total 0
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 bazbar
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 blh
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 cp
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 e
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 foobar
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 hcc
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 latitude
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 lcc
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 longitude
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 lsp
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 mcc
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 msl
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 p10u
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 p10v
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 p2d
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 p2t
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 tcc
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 tco3
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 tcw
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 tcwv
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 time
drwxr-xr-x. 1 dvalters dvalters 4096 Aug 23 11:32 tp
[dvalters@helmsdale mntpnt4]$ cd foobar/
[dvalters@helmsdale foobar]$ mkdir foobar2
mkdir: cannot create directory ‘foobar2’: Bad address
[dvalters@helmsdale foobar]$ 

The internal error (in debug mode) is more useful:

mkdir(u'/foobar/foobar2', 509L)
CREATING directory: /foobar/foobar2
Attempting mkdir with /foobar/foobar2
Traceback (most recent call last):
  File "/home/dvalters/venvs/fusenetcdf27/lib/python2.7/site-packages/fuse.py", line 495, in _wrapper
    return func(*args, **kwargs) or 0
  File "/home/dvalters/venvs/fusenetcdf27/lib/python2.7/site-packages/fuse.py", line 527, in mkdir
    return self.operations('mkdir', path.decode(self.encoding), mode)
  File "/home/dvalters/venvs/fusenetcdf27/lib/python2.7/site-packages/fuse.py", line 800, in __call__
    return getattr(self, op)(*args)
  File "../fusenetcdf/fusenetcdf.py", line 417, in newfunc
    result = attr(*args, **kwargs)
  File "../fusenetcdf/fusenetcdf.py", line 488, in mkdir
    return self.ncfs.mkdir(path, mode)
  File "../fusenetcdf/fusenetcdf.py", line 363, in mkdir
    % path)
InternalError: Cannot create a variable (directory) here: /foobar/foobar2
getattr(u'/foobar', None)
blazk commented 6 years ago

This would not be possible, the system can only report errors defined in errno.h (and python module errno). In this case maybe "Permission denied" error?