# Monkeypatch the create() method, to add sparse volumes support class ZFS # Create filesystem def create(opts={}) return nil if exist? cmd = [ZFS.zfs_path].flatten + ['create'] cmd << '-p' if opts[:parents] cmd << '-s' if opts[:volume] and opts[:sparse] cmd += opts[:zfsopts].map{|el| ['-o', el]}.flatten if opts[:zfsopts] cmd += ['-V', opts[:volume]] if opts[:volume] cmd << name out, status = Open3.capture2e(*cmd) if status.success? and out.empty? return self elsif out.match(/dataset already exists\n$/) nil else raise Exception, "something went wrong: #{out}, #{status}" end end end