Giter Site home page Giter Site logo

libnfs-python's Introduction

This module is an NFS client for python.
This project is hosted at https://github.com/sahlberg/libnfs-python

This module depends on the libnfs library.
You must first install libnfs before you can use this module.
Libnfs can be found at https://github.com/sahlberg/libnfs


The two main classes in this module are NFS and NFSFH.
NFS represents an NFS context that describes a mount point.
NFSFH is the main class that implements a file-like object for NFS files.


LICENSE
=======
This module is distributed under LGPL version 2.1.
Please see COPYING for the full text of this license.


Context-full access
===================
In the context-full mode you will first need to mount an NFS share and create
an NFS context before you can access any files. This NFS context is then used
for all future access to files in that mount point.

The benefit with this mode is that since performing the actual NFS mount is
very expensive you only need to perform it once, when creating the NFS object
and can reuse the mount for any future files you want to access.

In this mode absolute paths are relative to the mount point for the NFS object.

Example:
--------
import libnfs
nfs = libnfs.NFS('nfs://127.0.0.1/data/tmp/')
a = nfs.open('/foo-test', mode='w+')
a.write("Test string")
a.close()
print nfs.open('/foo-test', mode='r').read()


Context-free access
===================
This module also provides a mode where you can directly open and access
a file-like object without first having to instantiate a NFS mount.
In this case the file-like object will internally create an NFS mount
for the duration of the lifespan of the file-like object.

In this mode you invoke the libnfs.open() function with an NFS url
that points to a file :

Example:
--------
import libnfs
a = libnfs.open('nfs://127.0.0.1/data/tmp/foo-test', mode='w+')
a.write("Test string")
a.close()
print libnfs.open('nfs://127.0.0.1/data/tmp/foo-test', mode='r').read()

In the example above we create two instances of a file-like object. First
we create and write to the file and second time we read the file back and
print it. This is however both expensive and potentially poor performing.
The reason is that when we use context-free file-like objects we have to
create an NFS mount internally for each object and this is expensive.

Basically, when creating an NFS mount, the NFS protocol requires that we
perform the following operations/roundtrips :

Creating an NFS context:
------------------------
1, Establish TCP connection to portmapper (TCP port 111) on the server.
2, Send a Portmapper NULL command to verify we are connected to a genuine
   Portmapper and that it is alive.
3, Send a Portmapper GetPort command to fetch which port the MOUNT daemon
   is running on.
   Close the TCP connection.
4, Establish a TCP connection to the MOUNT daemon
5, Send a MOUNT NULL command to verify the MOUNT daemon is alive.
6, Send a MOUNT MNT command to fetch the NFS file handle for the mount point.
   Close the TCP connection.
7, Establish TCP connection to portmapper (TCP port 111) on the server.
8, Send a Portmapper NULL command to verify we are connected to a genuine
   Portmapper and that it is alive.
9, Send a Portmapper GetPort command to fetch which port the DAEMON daemon
   is running on.
   Close the TCP connection.
10, Establish a TCP connection to the NFS daemon
11, Send a NFS NULL command to verify the NFS daemon is alive.
12, Send a NFS FSINFO command to fetch some basic information about the
    filesystem we just mounted.
13, Send a NFS GETATTR command to fetch some information about the root
    directory for this mount.

When using context-free handles we have to perform these steps every time
a new file-like object is created making it very expensive.

The benefit with context-free handles is that they are very convenient to use.
Just pass an NFS url to the libnfs.open() function and you have a file-like
object. The drawback is that every context-free handle have to perform their
own NFS mount internally. If you plan to access multiple/many files you
should consider using context-full handles instead.


MAILING LIST
============
A libnfs-python mailing list is available at
http://groups.google.com/group/libnfs-python
Announcements of new versions of libnfs-python will be posted to this list.

libnfs-python's People

Contributors

2mf avatar captainupdates avatar fredrik-eriksson avatar jbd avatar m-radzikowski avatar poojashahuraj avatar sahlberg avatar tokibito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libnfs-python's Issues

Support build from swig in install.py

As a developer, I want to use a single step build process, so that I can install directly from the swig input file.

$ python ./setup.py install
running install
running build_ext
building 'libnfs._libnfs' extension
swigging libnfs/libnfs.i to libnfs/libnfs_wrap.c
swig -python -shadow -threads -o libnfs/libnfs_wrap.c libnfs/libnfs.i
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/libnfs
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c libnfs/libnfs_wrap.c -o build/temp.linux-x86_64-2.7/libnfs/libnfs_wrap.o -g
...

symbol not found in flat namespace '_free_nfs_srvr_list'

Still have this issue after installing libnfs-python on M1 Mac and debugging in VS Code:
dlopen(~/lib/python3.9/site-packages/libnfs/_libnfs.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_free_nfs_srvr_list'

Didn't found NFS?

I start the program and it stops at the open() function. In the libnfs library it is nfs_open(). I think it hangs on wait_for_nfs_reply().

Why is this happening?

In the screenshot the code of the program and the mounted server
Error

fatal error C1083: Cannot open include file: 'nfsc/libnfs.h' - Problem with libnfs installation

Hello,

I try to install libnfs package via anaconda by
pip install linbnfs

I got the following error:
fatal error C1083: Cannot open include file: 'nfsc/libnfs.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe' failed with exit code 2

the entire error is (in case it helps):
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\i_macheras\Anaconda3\envs\env_libnfs\include -IC:\Users\i_macheras\Anaconda3\envs\env_libnfs\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt" /Tclibnfs/libnfs_wrap.c /Fobuild\temp.win-amd64-cpython-39\Release\libnfs/libnfs_wrap.obj
libnfs_wrap.c
libnfs/libnfs_wrap.c(2969): fatal error C1083: Cannot open include file: 'nfsc/libnfs.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe' failed with exit code 2
[end of output]

I also installed vs_BuildTools (2).exe since I got another error previously.

How could I handle the above-mentioned error?

weither close nfs connetion

I use it to check whether NFS is writable, I do not see NFS close the connection

      nfs = libnfs.NFS("nfs://{server}{path}".format(server=nfs_server, path=nfs_path))
      f = nfs.open("/test_nfs_rw.file", "w")
      f.write(str(time.time()))
      f.close()

Have you closed the connection?

Problem while getting mtime value for nfsdirent

I've following code for reading NFS directory contents

python

import libnfs
nfsh = libnfs.NFS('nfs://<SERVER_IP>/folder1/')
d = libnfs.new_NFSDirHandle()
ret = libnfs.nfs_opendir(nfsh._nfs, '/', d)
if ret == -libnfs.errno.ENOENT:
raise IOError(libnfs.errno.ENOENT, 'No such file or directory');
d = libnfs.NFSDirHandle_value(d)
dirEntry = libnfs.nfs_readdir(nfsh._nfs, d)
print dirEntry.name
abc --> attribute printed correctly
print dirEntry.mtime
<Swig Object of type 'struct timeval *' at 0x9aeb70>swig/python detected a memory leak of type 'struct timeval *', no destructor found.

I tried to access the mtime through various ways but was unable to do so. All other attributes except mtime, atime, ctime are printed correctly. For the time attributes only I get the above mentioned error.

Can you please help in understanding what's wrong here?

utils/nfs-ls.py is hanging

Hello,

If I run nfs-ls from libnfs using my user, I've got this expected result (secure mount):

$ nfs-ls nfs://127.0.0.1/usr
Failed to mount nfs share : mount_cb: RPC error: Mount failed with error MNT3ERR_ACCES(13) Permission denied(13)

It is working as root.

If I try nfs-ls.py, it is working as root, but it hangs with an unprivileged user:

$ python utils/nfs-ls.py nfs://127.0.0.1/usr
nfs <libnfs.NFS object at 0x7feeb93da040>

It hangs here. Here is the traceback after hitting ctrl-c:

nfs <libnfs.NFS object at 0x7feeb93da040>
^CTraceback (most recent call last):
  File "utils/nfs-ls.py", line 31, in <module>
    ls(sys.argv[1])
  File "utils/nfs-ls.py", line 21, in ls
    for ent in nfs.listdir("."):
  File "/home/jbdenis/Code/libnfs-python/env/lib/python3.8/site-packages/libnfs/__init__.py", line 223, in listdir
    ret = nfs_opendir(self._nfs, path, d)
  File "/home/jbdenis/Code/libnfs-python/env/lib/python3.8/site-packages/libnfs/libnfs.py", line 327, in nfs_opendir
    return _libnfs.nfs_opendir(nfs, path, nfsdir)
KeyboardInterrupt

Is that working as expected or should it be considered as a bug ?

Using python 2.7, it looks the same, with an additional segmentation fault:

$ python utils/nfs-ls.py nfs://127.0.0.1/usr
('nfs', <libnfs.NFS object at 0x7f72b6d4bcd0>)
^CTraceback (most recent call last):
  File "utils/nfs-ls.py", line 31, in <module>
    ls(sys.argv[1])
  File "utils/nfs-ls.py", line 21, in ls
    for ent in nfs.listdir("."):
  File "/home/jbdenis/Code/libnfs-python/env/lib/python2.7/site-packages/libnfs/__init__.py", line 223, in listdir
    ret = nfs_opendir(self._nfs, path, d)
  File "/home/jbdenis/Code/libnfs-python/env/lib/python2.7/site-packages/libnfs/libnfs.py", line 327, in nfs_opendir
    return _libnfs.nfs_opendir(nfs, path, nfsdir)
KeyboardInterrupt
Segmentation fault

Thank you !

Cannot install this library on Mac OS High Sierra

pip install libnfs fails on mac with the below error

gcc -fno-strict-aliasing -I/anaconda2/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda2/include/python2.7 -c libnfs/libnfs_wrap.c -o build/temp.macosx-10.6-x86_64-2.7/libnfs/libnfs_wrap.o
libnfs/libnfs_wrap.c:2969:10: fatal error: 'nfsc/libnfs.h' file not found
#include <nfsc/libnfs.h>
^~~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1


Command "/anaconda2/bin/python -u -c "import setuptools, tokenize;file='/private/tmp/pip-install-pKcqdD/libnfs/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/tmp/pip-record-OYInwq/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-pKcqdD/libnfs/

Support nfs_mkdir2()

As a developer, I want to use the nfs_mkdir2() entry point so that I can provide directory permissions when the directory is created.

cannot generate libnfs_wrap.c

Sorry to bother you but I am a newbie in swig and can't figure this out.

I am running ubuntu 14.04. I already installed libnfs, swig and pcre (apt-get install pcregrep libnfs-dev swig) but it seems the libnfs_wrap.c is not getting generated

Running setup.py does not seem to generate the same output as seen here
http://rickhau.github.io/blog/2015/05/08/install-libnfs-python-library/

swig is installed in /usr/local/bin, so is pcre-config

Is something missing in my setup ?

$ sudo python setup.py install

running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/libnfs
copying libnfs/init.py -> build/lib.linux-x86_64-2.7/libnfs
running build_ext
building 'libnfs._libnfs' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/libnfs
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c libnfs/libnfs_wrap.c -o build/temp.linux-x86_64-2.7/libnfs/libnfs_wrap.o
x86_64-linux-gnu-gcc: error: libnfs/libnfs_wrap.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

$ ls -lR build/

build/:
total 8
drwxr-xr-x 3 root root 4096 Dec 2 09:32 lib.linux-x86_64-2.7
drwxr-xr-x 3 root root 4096 Dec 2 09:32 temp.linux-x86_64-2.7

build/lib.linux-x86_64-2.7:
total 4
drwxr-xr-x 2 root root 4096 Dec 2 09:32 libnfs

build/lib.linux-x86_64-2.7/libnfs:
total 8
-rw-r--r-- 1 root root 7649 Dec 2 09:02 init.py

build/temp.linux-x86_64-2.7:
total 4
drwxr-xr-x 2 root root 4096 Dec 2 09:32 libnfs

build/temp.linux-x86_64-2.7/libnfs:
total 0

Include debug symbols

As a developer, I want to the debugging symbols to be included with _libnfs.so, so that I can use application development tools (eg valgrind) and core inspection tools (eg gdb) with my libnfs Python application.

pip install libnfs report error

pip install libnfs report compile error :
libnfs/libnfs_wrap.c:2969:10: fatal error: nfsc/libnfs.h: No such file or directory

Failed to build libnfs
Installing collected packages: zope.interface, hyperlink, attrs, incremental, constantly, Automat, PyHamcrest, Twisted, w3lib, cssselect, lxml, parsel, pycparser, cffi, cryptography, pyOpenSSL, queuelib, protego, PyDispatcher, pyasn1, pyasn1-modules, service-identity, scrapy, libnfs
Running setup.py install for libnfs: started
Running setup.py install for libnfs: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fqvp0su9/libnfs/setup.py'"'"'; file='"'"'/tmp/pip-install-fqvp0su9/libnfs/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-xov7g5fi/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-fqvp0su9/libnfs/
Complete output (20 lines):
/usr/local/lib/python3.7/site-packages/setuptools/dist.py:475: UserWarning: Normalizing '1.0-4' to '1.0.post4'
normalized_version,
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/libnfs
copying libnfs/libnfs.py -> build/lib.linux-x86_64-3.7/libnfs
copying libnfs/init.py -> build/lib.linux-x86_64-3.7/libnfs
running build_ext
building 'libnfs._libnfs' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/libnfs
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c libnfs/libnfs_wrap.c -o build/temp.linux-x86_64-3.7/libnfs/libnfs_wrap.o
libnfs/libnfs_wrap.c:2969:10: fatal error: nfsc/libnfs.h: No such file or directory
#include <nfsc/libnfs.h>
^~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fqvp0su9/libnfs/setup.py'"'"'; file='"'"'/tmp/pip-install-fqvp0su9/libnfs/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-xov7g5fi/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
The command '/bin/sh -c pip install libnfs' returned a non-zero code: 1

Attribute Error

Hello,
im trying to achieve a rather simple procedure, where I copy a local image onto a nfs server.
The server can be reached and I can create and modify files on it just as the readme indicates. However I'm not able to transfer a local file to the server using this library.

Target concept:
targetFile = nfsHandle.open(path+"/"+filename, 'w')
sourcefile = open(filename.jpg, 'r')
shutil.copyfileobj( photo , targetFile )

If I use the approach above, I get an error message complaining: "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte". If I use 'wb' and 'rb'. it complains that 'byte' does not have the method 'encode'.
I've tried to convert the image file handler into a bytearray, but it keeps getting back to the utf-8 message.

Either there is a bug, where the codec=none is always overwritten with utf-8, images are not supported (encoding/decoding an image with utf-8 seems kind of ... , or I have a deep misunderstanding of this issue.

Can someone have a look at this ?

Thanks & with best regards

Unable to change default port

libnfs.NFS('nfs://127.0.0.1:3000/tmp')

The above code does not work. Could you fix this to be able to connect to another port?

Thanks

Support struct timeval parameters to nfs_utimes() and nfs_lutimes()

As a Python developer, I want to use nfs_utimes() and nfs_lutimes(), so that I can set file modification times.

The current implementation does not provide a way to configure the pair of timeval parameters to nfs_times() or nfs_utimes().

Using SWIG carrays.i allows the following:

tv1 = libnfs.timeval()
tv1.tv_sec = 1
tv1.tv_usec = 2

tv2 = libnfs.timeval()
tv2.tv_sec = 3
tv2.tv_usec = 4

tva = libnfs.new_TimeValArray(2)
libnfs.TimeValArray_setitem(tva, 0, tv1)
libnfs.TimeValArray_setitem(tva, 1, tv2)

libnfs.nfs_utimes(None, None, tva)

Can not install this library on Fedora 20

Hi, sahlberg

I used the following steps to install this python library but failed the installation. Would you mind shedding me some light on this? Any advice is highly appreciated.

  1. $ git clone https://github.com/sahlberg/libnfs-python.git
  2. $ cd libnfs-python
  3. $ sudo python setup.py install

Then, it comes to the following error.

Error message:
libnfs/libnfs_wrap.c:2969:25: fatal error: nfsc/libnfs.h: No such file or directory
#include <nfsc/libnfs.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
[fitbranded@localhost libnfs-python]$

It seems to require nfsc/libnfs.h to proceed the compilation.
If I made any step wrong, please let me know.

Thank you.

Register and upload package to PyPI

Currently, this Github repository is the only source to retrieve a copy of this amazing lib. It would help a great deal to have this tool available through PyPI, the community preferred source of Python packages.

NFS.listdir waits indefinitely

[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libnfs as nfs
>>> x = nfs.NFS('nfs://192.168.10.165/volume1/data/')
>>> x.listdir('.')

The share is at the same time mounted via os and it works fine.

OS: Ubuntu 20.04
libnfs (os): 4.0.0-1
libnfs (python): 1.0.post4

Fails to connect to Amazon ElasticFileSystem (EFS)

Hi There,
I'm trying to connect to EFS using libnfs. My EC2 instance is able to mount EFS using the standard NFS tools, but when I attempt to test using:
LD_LIBRARY_PATH=/usr/local/lib LD_NFS_DEBUG=9 LD_PRELOAD=./ld_nfs.so cp /etc/hosts nfs://fs-XXXXXXX.efs.us-west-2.amazonaws.com/test.txt
It hangs when trying to connect to rpc/portmapper on port 111 of the EFS host.
(strace: connect(3, {sa_family=AF_INET, sin_port=htons(111), sin_addr=inet_addr("10.0.0.XXX")}, 16) = -1 EINPROGRESS (Operation now in progress) )
EFS only listens on port 2049, and this doesn't appear to be a problem for the native nfs tools. Is there a trick to tell it to skip the portmap part?
I saw in another ticket that examples/portmap-client might be used to manually set portmap - perhaps it would help for me to do this. Could you possibly give me the specific syntax?
Also, eventually, I'm hoping to access this using a lambda function without root access, so a solution that doesn't require root is highly desirable.

Thank you in advance for your help!!

NFS object does not have attribute isdir, isfile ect.

nfs = libnfs.NFS('nfs://{SERVER}/{RESOURCE}/')
nfs.isdir("/{DIR}/)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NFS' object has no attribute 'isdir'
dir(nfs)
['__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_nfs', '_url', 'listdir', 'lstat', 'mkdir', 'open', 'rmdir', 'stat', 'unlink']

can't open nfs server file ValueError: open failed: Input/output error

can't open nfs server file
File "/app/server.py", line 44, in init
self.nfs_connect()
File "/app/server.py", line 325, in nfs_connect
a = self.nfs.open('/nfstest.txt', mode='w+')
File "/usr/local/lib/python3.7/site-packages/libnfs/init.py", line 187, in open
return NFSFH(self._nfs, path, mode=mode, codec=codec)
File "/usr/local/lib/python3.7/site-packages/libnfs/init.py", line 81, in init
raise ValueError(_errmsg)
ValueError: open failed: Input/output error

libnfs_wrap.c Fails to Compile on Ubuntu 14.04

After sudo apt-get install libnfs-dev I think I must have a libnfs version different from the one used here to generate libnfs_wrap.c. Any suggestion to clean it up?

building 'libnfs._libnfs' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c libnfs/libnfs_wrap.c -o build/temp.linux-x86_64-2.7/libnfs/libnfs_wrap.o
libnfs/libnfs_wrap.c:2975:26: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
   static struct nfsfh * *new_NFSFileHandle() { 
                          ^
libnfs/libnfs_wrap.c:2996:20: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
   static uint64_t *new_uint64_t_ptr() { 
                    ^
libnfs/libnfs_wrap.c: In function ‘_wrap_nfs_url_server_set’:
libnfs/libnfs_wrap.c:3708:11: error: dereferencing pointer to incomplete type
   if (arg1->server) free((char*)arg1->server);
           ^
libnfs/libnfs_wrap.c:3708:37: error: dereferencing pointer to incomplete type
   if (arg1->server) free((char*)arg1->server);
                                     ^
libnfs/libnfs_wrap.c:3711:9: error: dereferencing pointer to incomplete type
     arg1->server = (char *)(char *)memcpy((char *)malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size));
         ^
libnfs/libnfs_wrap.c:3713:9: error: dereferencing pointer to incomplete type
     arg1->server = 0;
         ^
libnfs/libnfs_wrap.c: In function ‘_wrap_nfs_url_server_get’:
libnfs/libnfs_wrap.c:3738:28: error: dereferencing pointer to incomplete type
   result = (char *) ((arg1)->server);
                            ^
...

module hangs forever in nfs.open

Hi.
Thank you for providing this library.
I am investigating an issue with kodi and my NFS server.
NFS server is ubuntu 22.04 running nfs-kernel-server and /etc/exports is

/media/nfs	192.168.0.0/24(rw,async,all_squash,no_subtree_check,insecure)

I'm using libnfs-pyhton from pip package on ubuntu 22.04 (client)
I try to run the example 1:

import libnfs
nfs = libnfs.NFS('nfs://192.168.0.7:/media/nfs/')
a = nfs.open('/foo-test', mode='w+')
a.write("Test string")
a.close()
print(nfs.open('/foo-test', mode='r').read())

but the code freeze. a keyboard interrupt says

Traceback (most recent call last):
  File "/tmp/toto.py", line 3, in <module>
    a = nfs.open('/foo-test', mode='w+')
  File "/usr/local/lib/python3.10/dist-packages/libnfs/__init__.py", line 187, in open
    return NFSFH(self._nfs, path, mode=mode, codec=codec)
  File "/usr/local/lib/python3.10/dist-packages/libnfs/__init__.py", line 74, in __init__
    _status = nfs_open(self._nfs, path, _mode, self._nfsfh)
KeyboardInterrupt

It seems the libnfs-dev from ubuntu 22.04 is version 4.0.0
Is there any reason why this should not work ?
Do I have to build the libnfs 5.0.0 myself to get it working ?

As a side problem, I am investigating Kodi hanging on when trying to read NFS file. As far as I understood, kodi uses libnfs. And I can reproduce the problem of kodi freezing when trying to read NFS file with the simple example above.

Could give me some hints ?

Thanks

Support nfs_readlink2()

As a developer, I want to use the nfs_readlink2() entry point so that I can read symlinks efficiently. As a side benefit, I want to obtain correct results from nfs_getcwd():

extern void nfs_getcwd(struct nfs_context *nfs, const char **cwd);
extern int nfs_readlink2(struct nfs_context *nfs, const char *path, char **buf);

Ability to configure nfs blksize

Hello,

We are investigating an issue with libnfs-python where we constantly get throttled with the hit the IOPS limit which is currently set to 512 on our customer's NFS server. We see a direct correlation with the bandwitdh on the nfs-server which rounds out o about 20 MBPS.

Upon investigating the libnfs library, it looks like the value is being set directly in the header-file.

Is there a way to increase the size of the blksize to ensure that we don't run into these issues.

Thanks,
Shaunak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.