class SystemInfo
Public Class Methods
deallocate(ramdisk)
click to toggle source
# File lib/ramdisk.rb, line 29 def self.deallocate(ramdisk) raise "Deallocate called with nil device." if ramdisk.nil? `hdiutil detach #{ramdisk}` device = ramdisk[/\/*([^\/]*)$/,1] return "\"#{device}\" unmounted.\n\"#{device}\" ejected.\n" end
hdiutil(sectors)
click to toggle source
# File lib/ramdisk.rb, line 5 def self.hdiutil(sectors) `hdiutil attach -nomount ram://#{sectors}` end
mount(mountpoint, ramdisk)
click to toggle source
# File lib/ramdisk.rb, line 13 def self.mount(mountpoint, ramdisk) system("mount -o noatime -t hfs #{ramdisk} #{mountpoint}") end
newfs_hfs(diskname, ramdisk)
click to toggle source
# File lib/ramdisk.rb, line 9 def self.newfs_hfs(diskname, ramdisk) `newfs_hfs -v '#{diskname}' #{ramdisk}` end
ramdisks()
click to toggle source
# File lib/ramdisk.rb, line 55 def self.ramdisks # cannot be ||= because state may have changed. @@ramdisks = read_hdutil end
read_hdutil()
click to toggle source
# File lib/ramdisk.rb, line 36 def self.read_hdutil plist = Plist::parse_xml(`hdiutil info -plist`) diskImages = [] plist.each do |n| diskImages.concat n[1] if n[0] == "images" end response = [] diskImages.each do |i| if i["image-path"] =~ /^ram\:\/\// response.push([i["system-entities"][0]["dev-entry"], i["system-entities"][0]["mount-point"]]) end end response end
sudomount(mountpoint, ramdisk)
click to toggle source
# File lib/ramdisk.rb, line 17 def self.sudomount(mountpoint, ramdisk) system("sudo mount -o noatime -t hfs #{ramdisk} #{mountpoint}") end
sudounmount(mountpoint, ramdisk)
click to toggle source
# File lib/ramdisk.rb, line 25 def self.sudounmount(mountpoint, ramdisk) system("sudo hdiutil eject -force #{mountpoint}") end
unmount(mountpoint)
click to toggle source
# File lib/ramdisk.rb, line 21 def self.unmount(mountpoint) system("umount -f #{mountpoint}") end