/[fuse.before_github]/perl-llin/Fuse.xs
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /perl-llin/Fuse.xs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

perl/trunk/Fuse.xs revision 18 by dpavlin, Wed Dec 21 15:33:37 2005 UTC perl-llin/Fuse.xs revision 28 by dpavlin, Mon Jan 2 22:39:32 2006 UTC
# Line 30  static inline void create_perl_context() Line 30  static inline void create_perl_context()
30  #include <fuse/fuse.h>  #include <fuse/fuse.h>
31    
32  #undef DEBUGf  #undef DEBUGf
33  #if 0  #if 1
34  #define DEBUGf(f, a...) fprintf(stderr, "%s:%d (%i): " f,__BASE_FILE__,__LINE__,sp-PL_stack_base ,##a )  #define DEBUGf(f, a...) fprintf(stderr, "%s:%d (%i): " f,__BASE_FILE__,__LINE__,sp-PL_stack_base ,##a )
35  #else  #else
36  #define DEBUGf(a...)  #define DEBUGf(a...)
# Line 501  int _PLfuse_read (const char *file, char Line 501  int _PLfuse_read (const char *file, char
501                                  rv = 0;                                  rv = 0;
502                          }                          }
503                          if(rv > buflen)                          if(rv > buflen)
504                                  croak("%i: read() handler returned more than buflen! (%i > %i)",getpid(),rv,buflen);                                  croak("read() handler returned more than buflen! (%i > %i)",rv,buflen);
505                          if(rv)                          if(rv)
506                                  memcpy(buf,SvPV_nolen(mysv),rv);                                  memcpy(buf,SvPV_nolen(mysv),rv);
507                  }                  }
# Line 541  int _PLfuse_write (const char *file, con Line 541  int _PLfuse_write (const char *file, con
541          return rv;          return rv;
542  }  }
543    
544  int _PLfuse_statfs (const char *file, struct statfs *st) {  /* FIXME check for old fuse API (< 21?) and use statfs here */
545    int _PLfuse_statfs (const char *file, struct statvfs *st) {
546          int rv;          int rv;
547          char *rvstr;          char *rvstr;
548          FUSE_CONTEXT_PRE;          FUSE_CONTEXT_PRE;
# Line 553  int _PLfuse_statfs (const char *file, st Line 554  int _PLfuse_statfs (const char *file, st
554          PUTBACK;          PUTBACK;
555          rv = call_sv(_PLfuse_callbacks[17],G_ARRAY);          rv = call_sv(_PLfuse_callbacks[17],G_ARRAY);
556          SPAGAIN;          SPAGAIN;
557          if(rv > 5) {          DEBUGf("statfs got %i params\n",rv);
558            if(rv == 6 || rv == 7) {
559                  st->f_bsize    = POPi;                  st->f_bsize    = POPi;
560                  st->f_bfree    = POPi;                  st->f_bfree = st->f_bavail = POPi;
561                  st->f_blocks   = POPi;                  st->f_blocks   = POPi;
562                  st->f_ffree    = POPi;                  st->f_ffree = st->f_favail  = POPi;
563                  st->f_files    = POPi;                  st->f_files    = POPi;
564                  st->f_namelen  = POPi;                  st->f_namemax  = POPi;
565                  if(rv > 6)                  /* zero all other */
566                    st->f_frsize = 4096;
567                    st->f_fsid = 0;
568                    st->f_flag = 0;
569    
570                    if(rv == 7)
571                          rv = POPi;                          rv = POPi;
572                  else                  else
573                          rv = 0;                          rv = 0;
# Line 857  PROTOTYPES: DISABLE Line 864  PROTOTYPES: DISABLE
864  void  void
865  perl_fuse_main(...)  perl_fuse_main(...)
866          PREINIT:          PREINIT:
867          struct fuse_operations fops = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};          struct fuse_operations fops =
868                    {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
869                     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
870          int i, fd, varnum = 0, debug, threaded, have_mnt;          int i, fd, varnum = 0, debug, threaded, have_mnt;
871          char *mountpoint;          char *mountpoint;
872          char *mountopts;          char *mountopts;
# Line 885  perl_fuse_main(...) Line 894  perl_fuse_main(...)
894          mountopts = SvPV_nolen(ST(3));          mountopts = SvPV_nolen(ST(3));
895          for(i=0;i<N_CALLBACKS;i++) {          for(i=0;i<N_CALLBACKS;i++) {
896                  SV *var = ST(i+4);                  SV *var = ST(i+4);
897          /* allow symbolic references, or real code references. */                  /* allow symbolic references, or real code references. */
898                  if((var != &PL_sv_undef) && (SvPOK(var) || (SvROK(var) && SvTYPE(SvRV(var)) == SVt_PVCV))) {                  if(SvOK(var) && (SvPOK(var) || (SvROK(var) && SvTYPE(SvRV(var)) == SVt_PVCV))) {
899                          void **tmp1 = (void**)&_available_ops, **tmp2 = (void**)&fops;                          void **tmp1 = (void**)&_available_ops, **tmp2 = (void**)&fops;
900                          tmp2[i] = tmp1[i];                          tmp2[i] = tmp1[i];
901    #ifdef FUSE_USE_ITHREADS
902                          if(threaded)                          if(threaded)
903                  /* note: under 5.8.7, this croaks for code references. */                  /* note: under 5.8.7, this croaks for code references. */
904                  SvSHARE(var);                  SvSHARE(var);
905    #endif
906                          _PLfuse_callbacks[i] = var;                          _PLfuse_callbacks[i] = var;
907                    } else
908                    if(SvOK(var)) {
909                            croak("invalid callback passed to perl_fuse_main "
910                                  "(%s is not a string, code ref, or undef).\n",
911                                  i+4,SvPVbyte_nolen(var));
912                  }                  }
913          }          }
914          /* FIXME: need to pass fusermount arguments */          /* FIXME: need to pass fusermount arguments */

Legend:
Removed from v.18  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26