1
# Copyright 2008 Amazon.com, Inc. or its affiliates. All Rights
2
# Reserved. Licensed under the Amazon Software License (the
3
# "License"). You may not use this file except in compliance with the
4
# License. A copy of the License is located at
5
# http://aws.amazon.com/asl or in the "license" file accompanying this
6
# file. This file is distributed on an "AS IS" BASIS, WITHOUT
7
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
8
# the License for the specific language governing permissions and
9
# limitations under the License.
14
LOCAL_FS_TYPES = ['ext2', 'ext3', 'xfs', 'jfs', 'reiserfs', 'tmpfs']
17
REGEX = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$/
18
attr_reader :device # mounted device.
19
attr_reader :mpoint # mount point.
20
attr_reader :fstype # file system type.
21
attr_reader :options # options
22
attr_reader :value # entire line
25
def initialize(dev, mnt_point, fs_type, opts, line)
34
return nil if line[0,1] == '#'
35
if (m = REGEX.match(line))
37
return Entry.new(parts[0], parts[1], parts[2], parts[3], line.strip)
53
LOCATION = '/etc/mtab'
55
def initialize(filename = LOCATION)
57
f = File.new(filename, File::RDONLY)
58
rescue SystemCallError => e
59
raise FileError(filename, "could not open #{filename} to read mount table", e)
62
f.readlines.each do |line|
63
entry = Entry.parse(line)
64
@entries[entry.mpoint] = entry unless entry.nil?