xaroth / libzfs-python Goto Github PK
View Code? Open in Web Editor NEWPython CFFI bindings for libzfs
License: MIT License
Python CFFI bindings for libzfs
License: MIT License
Some packages depend on libzfs in their install_requires. It would be neat if we could have a source tarball available through PyPI so the setup.py from those projects can find it.
It seems that NVList.update() method is unusable now, because internally it calls NVList.add() with 2 parameters, but actual NVList.add() requires 3 parameters. It is not clear whether it would be possible to infer proper data types from python types at all.
So, is this unfinished work-in-progress code or is this dead code? Or am I missing something?
I see the following code
config = libzfs.zpool_get_config(self.hdl, ffi.new_handle(None))
here https://github.com/Xaroth/libzfs-python/blob/master/libzfs/zpool.py#L133
As far as I can see from the CFFI documentation ffi.new_handle(None) produces a cdata object representing a void* pointer and that pointer is associated with None. Not sure if that makes sense at all to associate with None. But what worries me more is that the produced void* pointer is passed as the second argument to zpool_get_config() which actually interprets it as a pointer to a pointer, nvlist_t** and assigns a value to that pointer. I am not sure if it is safe to do that via a pointer returned from ffi.new_handle(). My impression is that such a pointer is never meant to be dereferenced. I think that it can only passed between python and C code and used with ffi.from_handle().
Perhaps ffi.NULL would be better to use here?
I'm using the latest version of zfsonlinux
from the official PPA on an Ubuntu 15.10 system. Unfortunately, it seems as though there is a problem with the way that the bindings manager generates header.h
from libzfs.h
; cffi
blows up when trying to process this line (which is obviously malformed):
typedef struct zfs_perm_node { avl_node_t z_node; char z_pname[ typedef struct zfs_allow_node { avl_node_t z_node; char z_key[ typedef struct zfs_allow { struct zfs_allow *z_next; char z_setpoint[ typedef struct zfs_handle zfs_handle_t;
(Perhaps it's having trouble with the brackets in the definitions of e.g. z_pname
?)
At some point in May, I had been using the then-current versions of zfsonlinux
and libzfs-python
with Ubuntu 15.04 without any trouble. I've tried older and newer versions of libzfs-python
, cffi
, etc. (everything except libzfs-dev
) without any change.
I'd love to have releases tagged and packaged for PyPI for easy install via pip
on administrated systems. This would greatly simplify the current deployment from source only model.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.