Giter VIP home page Giter VIP logo

rfusefs's People

Contributors

acuve avatar javawizard avatar lwoggardner 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rfusefs's Issues

How to enable the raw_read handler?

Hi

I'd like to use raw_read handler but never call this method.
According to the source code, it appears that I have to set :use_raw_file_access to enable by PathMapperFS initializer. But I could not find interfaces to enable it on my original code.

Any advices?
Thanks.

rfusefs gem is missing essential *.rb files

The .gemspec for the rfusefs gem does not select all required library files. So the gem generated from this .gemspec fails due to missing files, even for the most basic examples, with errors like cannot load such file -- fuse/fusedir (LoadError).

The gem appears to work properly after changing the selector for s.files from 'lib/**.rb' to 'lib/**/*.rb' in order to also include ruby files from all subdirectories.

raw_read >2GB broken

I hacked up the Hello World to simply mirror one specific (large) file. When I mount my filesystem and try to cat the file, cat fails:

scottj@fuseplay:~/mount$ cat Foo.ISO > /dev/null
cat: Foo.ISO: Invalid argument

I added some debug messages to the Ruby and found this sequence right before the failure:

reading /Foo.ISO off=2147221504 sz=131072 fh=#<File:0x000000013d2498>
reading /Foo.ISO off=2147352576 sz=131072 fh=#<File:0x000000013d2498>
reading /Foo.ISO off=-2147483648 sz=131072 fh=#<File:0x000000013d2498>
reading /Foo.ISO off=-2147352576 sz=131072 fh=#<File:0x000000013d2498>
reading /Foo.ISO off=-2147221504 sz=131072 fh=#<File:0x000000013d2498>
reading /Foo.ISO off=-2147483648 sz=4096 fh=#<File:0x000000013d2498>
closing /Foo.ISO fh=#<File:0x000000013d2498>

Entire program:

#!/usr/bin/ruby

require 'rfusefs'

class HelloDir

  def contents(path)
    ['Foo.ISO']
  end

  def file?(path)
    path == '/Foo.ISO'
  end

  def size(path)
    42163830784
  end

  def raw_open(path, mode, rfusefs = nil)
    puts "opening #{path} mode=#{mode}"
    raise unless rfusefs
    if (path == '/Foo.ISO')
      return open("/mnt/fileserv/Foo/Foo.ISO", 'rb')
    end
  end

  def raw_read(path, off, sz, fh)
    puts "reading #{path} off=#{off} sz=#{sz} fh=#{fh}"
    raise unless fh
    raise unless path == '/Foo.ISO'
    fh.seek(off, IO::SEEK_SET)
    return fh.read(sz)
  end

  def raw_close(path, fh)
    puts "closing #{path} fh=#{fh}"
    raise unless fh
    raise unless path == '/Foo.ISO'
    fh.close if fh
  end

end

# Usage: #{$0} mountpoint [mount_options]
FuseFS.main() { |options| HelloDir.new }

undefined method `backtrace' for nil:NilClass

I implemented a simple fs managing kindle collection.

Got this error message a thousand times when trying to access the directory that lists all documents.

In my tests and specs everything works fine with a small amount of documents.

ERROR: Exception nil not an Errno:: !respond_to?(:errno) 
ERROR: Exception in exception!
ERROR: Exception #<NoMethodError: undefined method `backtrace' for nil:NilClass> not an Errno:: !respond_to?(:errno) 
/home/arthur/.rvm/gems/ruby-1.9.3-p125@kindlefs/gems/rfusefs-0.8.0/lib/rfusefs.rb:104:in `process'
/home/arthur/.rvm/gems/ruby-1.9.3-p125@kindlefs/gems/rfusefs-0.8.0/lib/rfusefs.rb:104:in `run'
bin/kindlefs:28:in `<main>'

Did you ever see one of those?

An odd action when creating files

Hi

I'm confused about an odd event when creating a new file with rfusefs.
I'd like to hook all open, close, read and write events within a specific path
I wrote a simple code that allows us to map the specific path into another path like the PathMapperFS
but our code can even do renaming files, creating new files and making new directories.

our code is as follows:

#!/home/kazushi/bin/bin/ruby

require 'rubygems'
require 'rfusefs'
require 'fusefs/pathmapper'
require 'fusefs/dirlink'
require 'fusefs/metadir'

HOME = "/home/kazushi/fusetest"

class LoggerDir < FuseFS::FuseDir

  def initialize(dir)
    @base = dir
    @openfiles = Hash.new()
  end

  def can_mkdir?(path)
    true
  end

  def can_rmdir?(path)
    true
  end

  def can_delete?(path)
    true
  end

  def can_write?(path)
    true
  end

  def directory?(path)
    File.directory?(File.join(@base,path))
  end

  def file?(path)
    File.file?(File.join(@base,path))
  end

  def contents(path)
    fn = File.join(@base,path)
    ret = Dir.entries(fn).map { |file|
      file = file.sub(/^#{fn}\/?/,'')
      if ['..','.'].include?(file)
        nil
      else
        file
      end
    }.compact.sort
    p ret
  end

  def mkdir(path)
    puts "######################## MKDIR #{path} #############################"
    Dir.mkdir(unmap(path))
  end

  def size(path)
    puts "######################## SIZE #{path} #############################"
    File.size(unmap(path))
  end

  def rmdir(path)
    ##
    ## hack!!!
    ##    
    puts "######################## REMOVE DIR #{path} #############################"
    `rm -Rf #{unmap(path)}`
  end

  def delete(path)
    ##
    ## hack!!!
    ## 
    puts "######################## DELETE FILE #{path} #############################"
    `rm -f #{unmap(path)}`
  end

  def rename(from_path, to_path, to_fusefs = self)
    puts "######################## RENAME from #{from_path} to #{to_path} #############################"
    File.rename("#{unmap(from_path)}", "#{unmap(to_path)}")
  end

  def touch(path, modtime)
    puts "#{path} has been pushed like a button!"
    ##
    ## hack
    ##
    `touch #{unmap(path)}`
  end

  ##
  ## raw method
  ##
  def raw_open(path,mode,rfusefs)
    puts "######################## RAW_OPEN #{path} #############################"
    real_path = unmap(path)
    file = File.new(real_path, LoggerDir.open_mode(mode))
    @openfiles[path] = file
    return file
  end

  # @!visibility private
  def raw_read(path,off,sz,file=nil)
    puts "###################################### RAW_READ #{path} ##################################"
    file = @openfiles[path]
    file.sysseek(off)
    file.sysread(sz)
  end

  # @!visibility private
  def raw_write(path,offset,sz,buf,file=nil)
    puts "####################################### RAW_WRITE #{path} #{buf} #####################################"
    file = @openfiles[path]
    file.sysseek(offset)
    file.syswrite(buf[0,sz])
  end

  # @!visibility private
  def raw_close(path,file=nil)
    puts "####################################### RAW_CLOSE #{path} #{file} #####################################"
    file = @openfiles.delete(path)
    file.close if file
  end

  def self.open_mode(raw_mode)
    case raw_mode
    when "r"
      "r"
    when "ra"
      "r" #not really sensible..
    when "rw"
      "r+"
    when "rwa"
      "a+"
    when "w"
      "w"
    when "wa"
      "a"
    end
  end

  ##
  ##
  ## Warning private
  ##
  ##
  private 
  def unmap(path)
    "#{@base}#{path}"
  end

end

root = LoggerDir.new(HOME)

unless ARGV.length > 0 && File.directory?(ARGV[0])
  puts "Usage: #{$0} <mountpoint> <mountoptions>"
  exit
end

FuseFS.start(root, *ARGV)

To map /home/kazushi/fusetest into /mnt/fuse, we can simply enter

$ ./simple_code.rb /mnt/fuse -d

Now, we can look all of the entries from /home/kazushi/fusetest in /mnt/fuse
We can rename files, create files, create directories in /mnt/fuse then these actions
immediately apply to the mapped directory /home/kazushi/fusetest

However, we can not create a file in /mnt/fuse. Although we can create an empty file by 'touch' command within /mnt/fuse and can write some text lines to the file by 'cat' command, this additions do not appear within /mnt/fuse. 'ls -alF' within /mnt/fuse shows that the file is zero (empty) and 'cat' command does not show anything even if edited the file. Oddly, the file in the original path (/home/kazushi/fusetest) appear this additions. Only the file in the mapped path keeps zero in size. Node that I do not anything during this action within /home/kazushi/fusetest

One we stop and re-execute (remount?) the script then the file within /mnt/fuse becomes not empty. We can look the additions by cat and emacs something. I wish to immediately apply any additions within /mnt/fuse to /mnt/fuse self without re-executing...

According to the script log, it have never called the size method for a file that is created by 'touch' and edited within /mnt/fuse. All of entries within /mnt/fuse calls the size method after calling getattr but only the file does not call the size method. Actually, the file is listed by the contents(readdir) method...

$ cd /mnt/fuse/
$ ls -lF
total 0
-rw-rw-rw- 0 kazushi kazushi 3145728000 Jan  1  1970 1ghuge.img
-rw-rw-rw- 0 kazushi kazushi 4294967296 Jan  1  1970 CentOS-6.4-x86_64.img
drwxrwxrwx 1 kazushi kazushi          0 Jan  1  1970 kazushi/
-rw-rw-rw- 0 kazushi kazushi   20971520 Jan  1  1970 linux-0.2.img

it's good

$ touch 777
$ ls -lF
total 0
-rw-rw-rw- 0 kazushi kazushi 3145728000 Jan  1  1970 1ghuge.img
-rw-rw-r-- 0 kazushi kazushi          0 Feb 18 09:01 777
-rw-rw-rw- 0 kazushi kazushi 4294967296 Jan  1  1970 CentOS-6.4-x86_64.img
drwxrwxrwx 1 kazushi kazushi          0 Jan  1  1970 kazushi/
-rw-rw-rw- 0 kazushi kazushi   20971520 Jan  1  1970 linux-0.2.img

ok

$ cat > 777 
hello
hello
hello
[Ctrl-C]

$ ls -lF
total 0
-rw-rw-rw- 0 kazushi kazushi 3145728000 Jan  1  1970 1ghuge.img
-rw-rw-r-- 0 kazushi kazushi          0 Feb 18 09:02 777 <<<-OOPS zero byte!???
-rw-rw-rw- 0 kazushi kazushi 4294967296 Jan  1  1970 CentOS-6.4-x86_64.img
drwxrwxrwx 1 kazushi kazushi          0 Jan  1  1970 kazushi/
-rw-rw-rw- 0 kazushi kazushi   20971520 Jan  1  1970 linux-0.2.img

oops, we can not add lines!?

$ cat 777 

Yes, nothing.
Ok, I'll check the original path

$ cd /home/kazushi/fusetest
$ ls -lF
total 7286800
-rw-rw-r-- 1 kazushi kazushi 3145728000 Jan 30 15:30 1ghuge.img
-rw-rw-r-- 1 kazushi kazushi         18 Feb 18 09:01 777 <<<- What? 18 bytes in size!? in here
-rw-r--r-- 1 kazushi kazushi 4294967296 Jan 30 14:49 CentOS-6.4-x86_64.img
drwxrwxr-x 2 kazushi kazushi       4096 Feb 18 06:09 kazushi/
-rw-rw-r-- 1 kazushi kazushi   20971520 Jan 30 15:23 linux-0.2.img
$ cat 777
hello
hello
hello

Yes, I can see you...

Any ideas?
Thanks

Can't mount as an other user

I've set user_allow_other in /etc/fuse.conf.
Also trying to start FuseFS like so:

FuseFS.start dir, mntpoint, 'allow_other'

unknown option: 'allow_other'. It is not accepting any option actually.
What am I doing wrong?

Thanks

PS: If I run the script as user www-data (it mounts as www-data but root can't access it, so I tried the allow_root options but still get unknown option error).

Missing dependency rfuse_ng

I'm trying to resolve dependencies for rfusefs, but I can not find rfuse_ng anywhere.
Tried rubygems, github, google, without success.
Any clue ?

Thanks.

Files become zero-cleared when touching to existing files

Hi

I've got another problem from issue #5
'touch' command in /mnt/fuse, which is the remapped path changes existing files to zero-cleared. 'touch' command should only change the update time. but in this case, this command also changes file size, files become zero in size.

This event is confirmed as the following code:

#!/home/kazushi/bin/bin/ruby

##
## execute in /mnt/fuse
##

require 'securerandom'
require 'fileutils'

##
## success
##
n = 100
new_fname = SecureRandom.uuid
value = SecureRandom.random_bytes(n)
File.open(new_fname, "w"){|f|
  ret = f.write(value)
}
FileUtils.touch(new_fname)
File.open(new_fname, "r"){|f|
  ret = f.read(value.size)
  puts "[1] failed write -> touch by FileUtils -> read after mounting" if ret != value
}
File.delete(new_fname)


##
## FAILED!!
## The file becomes empty by touch (utime)
##
new_fname = SecureRandom.uuid
value = SecureRandom.random_bytes(n)
File.open(new_fname, "w"){|f|
  ret = f.write(value)
}
`touch #{new_fname}`
File.open(new_fname, "r"){|f|
  ret = f.read(value.size)
  puts "[2] failed write -> touch by shell command -> read after mounting" if ret != value
}
File.delete(new_fname)

Any ideas?
Thanks

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.