<s> from __future__ import division <EOL> from ctypes import * <EOL> from ctypes . util import find_library <EOL> from errno import * <EOL> from functools import partial <EOL> from os import strerror <EOL> from platform import machine , system <EOL> from stat import S_IFDIR <EOL> from traceback import print_exc <EOL> class c_timespec ( Structure ) : <EOL> _fields_ = [ ( '<STR_LIT>' , c_long ) , ( '<STR_LIT>' , c_long ) ] <EOL> class c_utimbuf ( Structure ) : <EOL> _fields_ = [ ( '<STR_LIT>' , c_timespec ) , ( '<STR_LIT>' , c_timespec ) ] <EOL> class c_stat ( Structure ) : <EOL> pass <EOL> _system = system ( ) <EOL> if _system in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> _libiconv = CDLL ( find_library ( "<STR_LIT>" ) , RTLD_GLOBAL ) <EOL> ENOTSUP = <NUM_LIT> <EOL> c_dev_t = c_int32 <EOL> c_fsblkcnt_t = c_ulong <EOL> c_fsfilcnt_t = c_ulong <EOL> c_gid_t = c_uint32 <EOL> c_mode_t = c_uint16 <EOL> c_off_t = c_int64 <EOL> c_pid_t = c_int32 <EOL> c_uid_t = c_uint32 <EOL> setxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , <EOL> c_size_t , c_int , c_uint32 ) <EOL> getxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , <EOL> c_size_t , c_uint32 ) <EOL> c_stat . _fields_ = [ <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_uint32 ) , <EOL> ( '<STR_LIT>' , c_mode_t ) , <EOL> ( '<STR_LIT>' , c_uint16 ) , <EOL> ( '<STR_LIT>' , c_uid_t ) , <EOL> ( '<STR_LIT>' , c_gid_t ) , <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_off_t ) , <EOL> ( '<STR_LIT>' , c_int64 ) , <EOL> ( '<STR_LIT>' , c_int32 ) ] <EOL> elif _system == '<STR_LIT>' : <EOL> ENOTSUP = <NUM_LIT> <EOL> c_dev_t = c_ulonglong <EOL> c_fsblkcnt_t = c_ulonglong <EOL> c_fsfilcnt_t = c_ulonglong <EOL> c_gid_t = c_uint <EOL> c_mode_t = c_uint <EOL> c_off_t = c_longlong <EOL> c_pid_t = c_int <EOL> c_uid_t = c_uint <EOL> setxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , c_size_t , c_int ) <EOL> getxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , c_size_t ) <EOL> _machine = machine ( ) <EOL> if _machine == '<STR_LIT>' : <EOL> c_stat . _fields_ = [ <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_mode_t ) , <EOL> ( '<STR_LIT>' , c_uid_t ) , <EOL> ( '<STR_LIT>' , c_gid_t ) , <EOL> ( '<STR_LIT>' , c_int ) , <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_off_t ) , <EOL> ( '<STR_LIT>' , c_long ) , <EOL> ( '<STR_LIT>' , c_long ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) ] <EOL> elif _machine == '<STR_LIT>' : <EOL> c_stat . _fields_ = [ <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_ulonglong ) , <EOL> ( '<STR_LIT>' , c_mode_t ) , <EOL> ( '<STR_LIT>' , c_uint ) , <EOL> ( '<STR_LIT>' , c_uid_t ) , <EOL> ( '<STR_LIT>' , c_gid_t ) , <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_ushort ) , <EOL> ( '<STR_LIT>' , c_off_t ) , <EOL> ( '<STR_LIT>' , c_long ) , <EOL> ( '<STR_LIT>' , c_longlong ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) ] <EOL> else : <EOL> c_stat . _fields_ = [ <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_ushort ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_mode_t ) , <EOL> ( '<STR_LIT>' , c_uint ) , <EOL> ( '<STR_LIT>' , c_uid_t ) , <EOL> ( '<STR_LIT>' , c_gid_t ) , <EOL> ( '<STR_LIT>' , c_dev_t ) , <EOL> ( '<STR_LIT>' , c_ushort ) , <EOL> ( '<STR_LIT>' , c_off_t ) , <EOL> ( '<STR_LIT>' , c_long ) , <EOL> ( '<STR_LIT>' , c_longlong ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_timespec ) , <EOL> ( '<STR_LIT>' , c_ulonglong ) ] <EOL> else : <EOL> raise NotImplementedError ( '<STR_LIT>' % _system ) <EOL> class c_statvfs ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) ] <EOL> if _system == '<STR_LIT>' : <EOL> c_fsblkcnt_t = c_uint64 <EOL> c_fsfilcnt_t = c_uint64 <EOL> setxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , c_size_t , c_int ) <EOL> getxattr_t = CFUNCTYPE ( c_int , c_char_p , c_char_p , POINTER ( c_byte ) , c_size_t ) <EOL> class c_statvfs ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsblkcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) , <EOL> ( '<STR_LIT>' , c_fsfilcnt_t ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_ulong ) ] <EOL> class fuse_file_info ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , c_int ) , <EOL> ( '<STR_LIT>' , c_ulong ) , <EOL> ( '<STR_LIT>' , c_int ) , <EOL> ( '<STR_LIT>' , c_uint , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , c_uint , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , c_uint , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , c_uint , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , c_uint64 ) , <EOL> ( '<STR_LIT>' , c_uint64 ) ] <EOL> class fuse_context ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , c_voidp ) , <EOL> ( '<STR_LIT>' , c_uid_t ) , <EOL> ( '<STR_LIT>' , c_gid_t ) , <EOL> ( '<STR_LIT>' , c_pid_t ) , <EOL> ( '<STR_LIT>' , c_voidp ) ] <EOL> class fuse_operations ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_stat ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_byte ) , c_size_t ) ) , <EOL> ( '<STR_LIT>' , c_voidp ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_mode_t , c_dev_t ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_mode_t ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_mode_t ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_uid_t , c_gid_t ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_off_t ) ) , <EOL> ( '<STR_LIT>' , c_voidp ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_byte ) , c_size_t , c_off_t , <EOL> POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_byte ) , c_size_t , c_off_t , <EOL> POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_statvfs ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_int , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , setxattr_t ) , <EOL> ( '<STR_LIT>' , getxattr_t ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_byte ) , c_size_t ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_char_p ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_voidp , CFUNCTYPE ( c_int , c_voidp , <EOL> c_char_p , POINTER ( c_stat ) , c_off_t ) , c_off_t , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_int , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_voidp , c_voidp ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_voidp , c_voidp ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_int ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_mode_t , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_off_t , POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_stat ) , <EOL> POINTER ( fuse_file_info ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( fuse_file_info ) , c_int , c_voidp ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , POINTER ( c_utimbuf ) ) ) , <EOL> ( '<STR_LIT>' , CFUNCTYPE ( c_int , c_char_p , c_size_t , POINTER ( c_ulonglong ) ) ) ] <EOL> def time_of_timespec ( ts ) : <EOL> return ts . tv_sec + ts . tv_nsec / <NUM_LIT:10> ** <NUM_LIT:9> <EOL> def set_st_attrs ( st , attrs ) : <EOL> for key , val in attrs . items ( ) : <EOL> if key in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> timespec = getattr ( st , key + '<STR_LIT>' ) <EOL> timespec . tv_sec = int ( val ) <EOL> timespec . tv_nsec = int ( ( val - timespec . tv_sec ) * <NUM_LIT:10> ** <NUM_LIT:9> ) <EOL> elif hasattr ( st , key ) : <EOL> setattr ( st , key , val ) <EOL> _libfuse_path = find_library ( '<STR_LIT>' ) <EOL> if not _libfuse_path : <EOL> raise EnvironmentError ( '<STR_LIT>' ) <EOL> _libfuse = CDLL ( _libfuse_path ) <EOL> _libfuse . fuse_get_context . restype = POINTER ( fuse_context ) <EOL> def fuse_get_context ( ) : <EOL> """<STR_LIT>""" <EOL> ctxp = _libfuse . fuse_get_context ( ) <EOL> ctx = ctxp . contents <EOL> return ctx . uid , ctx . gid , ctx . pid <EOL> class FuseOSError ( OSError ) : <EOL> def __init__ ( self , errno ) : <EOL> super ( FuseOSError , self ) . __init__ ( errno , strerror ( errno ) ) <EOL> class FUSE ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , operations , mountpoint , raw_fi = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . operations = operations <EOL> self . raw_fi = raw_fi <EOL> args = [ '<STR_LIT>' ] <EOL> if kwargs . pop ( '<STR_LIT>' , False ) : <EOL> args . append ( '<STR_LIT>' ) <EOL> if kwargs . pop ( '<STR_LIT>' , False ) : <EOL> args . append ( '<STR_LIT>' ) <EOL> if kwargs . pop ( '<STR_LIT>' , False ) : <EOL> args . append ( '<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , operations . __class__ . __name__ ) <EOL> args . append ( '<STR_LIT>' ) <EOL> args . append ( '<STR_LIT:U+002C>' . join ( key if val == True else '<STR_LIT>' % ( key , val ) <EOL> for key , val in kwargs . items ( ) ) ) <EOL> args . append ( mountpoint ) <EOL> argv = ( c_char_p * len ( args ) ) ( * args ) <EOL> fuse_ops = fuse_operations ( ) <EOL> for name , prototype in fuse_operations . _fields_ : <EOL> if prototype != c_voidp and getattr ( operations , name , None ) : <EOL> op = partial ( self . _wrapper_ , getattr ( self , name ) ) <EOL> setattr ( fuse_ops , name , prototype ( op ) ) <EOL> err = _libfuse . fuse_main_real ( len ( args ) , argv , pointer ( fuse_ops ) , <EOL> sizeof ( fuse_ops ) , None ) <EOL> del self . operations <EOL> if err : <EOL> raise RuntimeError ( err ) <EOL> def _wrapper_ ( self , func , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return func ( * args , ** kwargs ) or <NUM_LIT:0> <EOL> except OSError , e : <EOL> return - ( e . errno or EFAULT ) <EOL> except : <EOL> print_exc ( ) <EOL> return - EFAULT <EOL> def getattr ( self , path , buf ) : <EOL> return self . fgetattr ( path , buf , None ) <EOL> def readlink ( self , path , buf , bufsize ) : <EOL> ret = self . operations ( '<STR_LIT>' , path ) <EOL> data = create_string_buffer ( ret [ : bufsize - <NUM_LIT:1> ] ) <EOL> memmove ( buf , data , len ( data ) ) <EOL> return <NUM_LIT:0> <EOL> def mknod ( self , path , mode , dev ) : <EOL> return self . operations ( '<STR_LIT>' , path , mode , dev ) <EOL> def mkdir ( self , path , mode ) : <EOL> return self . operations ( '<STR_LIT>' , path , mode ) <EOL> def unlink ( self , path ) : <EOL> return self . operations ( '<STR_LIT>' , path ) <EOL> def rmdir ( self , path ) : <EOL> return self . operations ( '<STR_LIT>' , path ) <EOL> def symlink ( self , source , target ) : <EOL> return self . operations ( '<STR_LIT>' , target , source ) <EOL> def rename ( self , old , new ) : <EOL> return self . operations ( '<STR_LIT>' , old , new ) <EOL> def link ( self , source , target ) : <EOL> return self . operations ( '<STR_LIT>' , target , source ) <EOL> def chmod ( self , path , mode ) : <EOL> return self . operations ( '<STR_LIT>' , path , mode ) <EOL> def chown ( self , path , uid , gid ) : <EOL> if c_uid_t ( uid + <NUM_LIT:1> ) . value == <NUM_LIT:0> : <EOL> uid = - <NUM_LIT:1> <EOL> if c_gid_t ( gid + <NUM_LIT:1> ) . value == <NUM_LIT:0> : <EOL> gid = - <NUM_LIT:1> <EOL> return self . operations ( '<STR_LIT>' , path , uid , gid ) <EOL> def truncate ( self , path , length ) : <EOL> return self . operations ( '<STR_LIT>' , path , length ) <EOL> def open ( self , path , fip ) : <EOL> fi = fip . contents <EOL> if self . raw_fi : <EOL> return self . operations ( '<STR_LIT>' , path , fi ) <EOL> else : <EOL> fi . fh = self . operations ( '<STR_LIT>' , path , fi . flags ) <EOL> return <NUM_LIT:0> <EOL> def read ( self , path , buf , size , offset , fip ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> ret = self . operations ( '<STR_LIT>' , path , size , offset , fh ) <EOL> if not ret : <EOL> return <NUM_LIT:0> <EOL> data = create_string_buffer ( ret [ : size ] , size ) <EOL> memmove ( buf , data , size ) <EOL> return size <EOL> def write ( self , path , buf , size , offset , fip ) : <EOL> data = string_at ( buf , size ) <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , data , offset , fh ) <EOL> def statfs ( self , path , buf ) : <EOL> stv = buf . contents <EOL> attrs = self . operations ( '<STR_LIT>' , path ) <EOL> for key , val in attrs . items ( ) : <EOL> if hasattr ( stv , key ) : <EOL> setattr ( stv , key , val ) <EOL> return <NUM_LIT:0> <EOL> def flush ( self , path , fip ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , fh ) <EOL> def release ( self , path , fip ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , fh ) <EOL> def fsync ( self , path , datasync , fip ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , datasync , fh ) <EOL> def setxattr ( self , path , name , value , size , options , * args ) : <EOL> data = string_at ( value , size ) <EOL> return self . operations ( '<STR_LIT>' , path , name , data , options , * args ) <EOL> def getxattr ( self , path , name , value , size , * args ) : <EOL> ret = self . operations ( '<STR_LIT>' , path , name , * args ) <EOL> retsize = len ( ret ) <EOL> buf = create_string_buffer ( ret , retsize ) <EOL> if bool ( value ) : <EOL> if retsize > size : <EOL> return - ERANGE <EOL> memmove ( value , buf , retsize ) <EOL> return retsize <EOL> def listxattr ( self , path , namebuf , size ) : <EOL> ret = self . operations ( '<STR_LIT>' , path ) <EOL> buf = create_string_buffer ( '<STR_LIT:\x00>' . join ( ret ) ) if ret else '<STR_LIT>' <EOL> bufsize = len ( buf ) <EOL> if bool ( namebuf ) : <EOL> if bufsize > size : <EOL> return - ERANGE <EOL> memmove ( namebuf , buf , bufsize ) <EOL> return bufsize <EOL> def removexattr ( self , path , name ) : <EOL> return self . operations ( '<STR_LIT>' , path , name ) <EOL> def opendir ( self , path , fip ) : <EOL> fip . contents . fh = self . operations ( '<STR_LIT>' , path ) <EOL> return <NUM_LIT:0> <EOL> def readdir ( self , path , buf , filler , offset , fip ) : <EOL> for item in self . operations ( '<STR_LIT>' , path , fip . contents . fh ) : <EOL> if isinstance ( item , str ) : <EOL> name , st , offset = item , None , <NUM_LIT:0> <EOL> else : <EOL> name , attrs , offset = item <EOL> if attrs : <EOL> st = c_stat ( ) <EOL> set_st_attrs ( st , attrs ) <EOL> else : <EOL> st = None <EOL> if filler ( buf , name , st , offset ) != <NUM_LIT:0> : <EOL> break <EOL> return <NUM_LIT:0> <EOL> def releasedir ( self , path , fip ) : <EOL> return self . operations ( '<STR_LIT>' , path , fip . contents . fh ) <EOL> def fsyncdir ( self , path , datasync , fip ) : <EOL> return self . operations ( '<STR_LIT>' , path , datasync , fip . contents . fh ) <EOL> def init ( self , conn ) : <EOL> return self . operations ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> def destroy ( self , private_data ) : <EOL> return self . operations ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> def access ( self , path , amode ) : <EOL> return self . operations ( '<STR_LIT>' , path , amode ) <EOL> def create ( self , path , mode , fip ) : <EOL> fi = fip . contents <EOL> if self . raw_fi : <EOL> return self . operations ( '<STR_LIT>' , path , mode , fi ) <EOL> else : <EOL> fi . fh = self . operations ( '<STR_LIT>' , path , mode ) <EOL> return <NUM_LIT:0> <EOL> def ftruncate ( self , path , length , fip ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , length , fh ) <EOL> def fgetattr ( self , path , buf , fip ) : <EOL> memset ( buf , <NUM_LIT:0> , sizeof ( c_stat ) ) <EOL> st = buf . contents <EOL> fh = fip and ( fip . contents if self . raw_fi else fip . contents . fh ) <EOL> attrs = self . operations ( '<STR_LIT>' , path , fh ) <EOL> set_st_attrs ( st , attrs ) <EOL> return <NUM_LIT:0> <EOL> def lock ( self , path , fip , cmd , lock ) : <EOL> fh = fip . contents if self . raw_fi else fip . contents . fh <EOL> return self . operations ( '<STR_LIT>' , path , fh , cmd , lock ) <EOL> def utimens ( self , path , buf ) : <EOL> if buf : <EOL> atime = time_of_timespec ( buf . contents . actime ) <EOL> mtime = time_of_timespec ( buf . contents . modtime ) <EOL> times = ( atime , mtime ) <EOL> else : <EOL> times = None <EOL> return self . operations ( '<STR_LIT>' , path , times ) <EOL> def bmap ( self , path , blocksize , idx ) : <EOL> return self . operations ( '<STR_LIT>' , path , blocksize , idx ) <EOL> class Operations ( object ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , op , * args ) : <EOL> if not hasattr ( self , op ) : <EOL> raise FuseOSError ( EFAULT ) <EOL> return getattr ( self , op ) ( * args ) <EOL> def access ( self , path , amode ) : <EOL> return <NUM_LIT:0> <EOL> bmap = None <EOL> def chmod ( self , path , mode ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def chown ( self , path , uid , gid ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def create ( self , path , mode , fi = None ) : <EOL> """<STR_LIT>""" <EOL> raise FuseOSError ( EROFS ) <EOL> def destroy ( self , path ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def flush ( self , path , fh ) : <EOL> return <NUM_LIT:0> <EOL> def fsync ( self , path , datasync , fh ) : <EOL> return <NUM_LIT:0> <EOL> def fsyncdir ( self , path , datasync , fh ) : <EOL> return <NUM_LIT:0> <EOL> def getattr ( self , path , fh = None ) : <EOL> """<STR_LIT>""" <EOL> if path != '<STR_LIT:/>' : <EOL> raise FuseOSError ( ENOENT ) <EOL> return dict ( st_mode = ( S_IFDIR | <NUM_LIT:0> <NUM_LIT> ) , st_nlink = <NUM_LIT:2> ) <EOL> def getxattr ( self , path , name , position = <NUM_LIT:0> ) : <EOL> raise FuseOSError ( ENOTSUP ) <EOL> def init ( self , path ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def link ( self , target , source ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def listxattr ( self , path ) : <EOL> return [ ] <EOL> lock = None <EOL> def mkdir ( self , path , mode ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def mknod ( self , path , mode , dev ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def open ( self , path , flags ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def opendir ( self , path ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def read ( self , path , size , offset , fh ) : <EOL> """<STR_LIT>""" <EOL> raise FuseOSError ( EIO ) <EOL> def readdir ( self , path , fh ) : <EOL> """<STR_LIT>""" <EOL> return [ '<STR_LIT:.>' , '<STR_LIT:..>' ] <EOL> def readlink ( self , path ) : <EOL> raise FuseOSError ( ENOENT ) <EOL> def release ( self , path , fh ) : <EOL> return <NUM_LIT:0> <EOL> def releasedir ( self , path , fh ) : <EOL> return <NUM_LIT:0> <EOL> def removexattr ( self , path , name ) : <EOL> raise FuseOSError ( ENOTSUP ) <EOL> def rename ( self , old , new ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def rmdir ( self , path ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def setxattr ( self , path , name , value , options , position = <NUM_LIT:0> ) : <EOL> raise FuseOSError ( ENOTSUP ) <EOL> def statfs ( self , path ) : <EOL> """<STR_LIT>""" <EOL> return { } <EOL> def symlink ( self , target , source ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def truncate ( self , path , length , fh = None ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def unlink ( self , path ) : <EOL> raise FuseOSError ( EROFS ) <EOL> def utimens ( self , path , times = None ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def write ( self , path , data , offset , fh ) : <EOL> raise FuseOSError ( EROFS ) <EOL> class LoggingMixIn : <EOL> def __call__ ( self , op , path , * args ) : <EOL> print '<STR_LIT>' , op , path , repr ( args ) <EOL> ret = '<STR_LIT>' <EOL> try : <EOL> ret = getattr ( self , op ) ( path , * args ) <EOL> return ret <EOL> except OSError , e : <EOL> ret = str ( e ) <EOL> raise <EOL> finally : <EOL> print '<STR_LIT>' , op , repr ( ret ) </s>
