lib/ramdo/ramdisk/linux_wrapper.rb in ramdo-0.1.3 vs lib/ramdo/ramdisk/linux_wrapper.rb in ramdo-0.1.4
- old
+ new
@@ -1,21 +1,17 @@
module Ramdo
module Ramdisk
class LinuxWrapper
def initialize
- @shm_path = "/dev/shm"
- end
-
- def list
- disks = []
-
- found_shm = false
line = Cocaine::CommandLine.new("cat", "/proc/mounts")
line.run.each_line do |line|
- found_shm ||= line =~ /^tmpfs \/dev\/shm tmpfs/
+ @shm_path = Regexp.last_match[1] if line =~ /(\/shm)[\s]tmpfs[\s]rw/
end
- raise GeneralRamdiskException.new("#{@shm_path} not found") unless found_shm
+ raise GeneralRamdiskException.new("shm path not found") unless @shm_path
+ end
+ def list
+ disks = []
Dir.glob(@shm_path + '/*').each do |dir|
if dir =~ Instance::NAME_PATTERN
disks << Instance.new(path: dir, device: @shm_path, size: Filesize.from("1 GB"))
end
end