midwire
8/19/2014 - 1:14 AM

Get the device name where a file resides

Get the device name where a file resides

class File

  class Stat
    def self.device_name(file)
      Dir['/dev/*'].inject({}) { |h, v|
        h.update(File.stat(v).rdev => v)
      }.values_at(File.stat(file).dev).first || nil
    end
  end

end