Module: LinuxMount

Defined in:
lib/fs/modules/LinuxMount.rb

Defined Under Namespace

Classes: PathNode

Constant Summary collapse

FSTAB_FILE_NAME =
"/etc/fstab"

Instance Method Summary collapse

Instance Method Details

#fileSymLink?(p) ⇒ Boolean

Given a path to a file, return true if it’s a symbolic link. Otherwise, return false.

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fs/modules/LinuxMount.rb', line 22

def fileSymLink?(p)
  #
  # We can't just expand the links in the whole path,
  # because then, the target file will no longer be a link.
  # So, we expand the path to the target file, then open
  # the target file through that path to obtain the link data.
  #
  np = normalizePath(p)
  d = File.dirname(np)
  f = File.basename(np)

  # Expand the path to the target file.
  exp_dir = expandLinks(d)

  # Get the file system where the target file resides, and it's local path.
  fs, lp = getFsPathBase(File.join(exp_dir, f))
  fs.fileSymLink?(lp)
end

#fs_initObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fs/modules/LinuxMount.rb', line 6

def fs_init
  @guestOS = "Linux"

  @rootFS = MiqFS.getFS(@rootVolume)
  raise "LinuxMount: could not mount root volume" unless @rootFS

  assign_device_letters
  fs_spec_hash = build_fstab_spec
  build_os_names
  build_mount_point_tree(fs_spec_hash)
end

#getLinkPath(p) ⇒ Object

Given a path to a symbolic link, return the full path to where the link points.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fs/modules/LinuxMount.rb', line 45

def getLinkPath(p)
  #
  # We can't just expand the links in the whole path,
  # because then, the target file will no longer be a link.
  # So, we expand the path to the target file, then open
  # the target file through that path to obtain the link data.
  #
  np = normalizePath(p)
  d = File.dirname(np)
  f = File.basename(np)

  # Expand the path to the target file.
  exp_dir = expandLinks(d)

  # Get the file system where the target file resides, and it's local path.
  fs, lp = getFsPathBase(File.join(exp_dir, f))
  # Read the link data from the file, through its file system.
  sp = getSymLink(fs, lp)
  # Construct and return the full path to the link target.
  return(sp) if sp[0, 1] == '/'
  normalizePath(File.join(exp_dir, sp))
end