Class: Yast::StorageInitClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/StorageInit.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CreateInterface(readonly)



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File '../../src/modules/StorageInit.rb', line 59

def CreateInterface(readonly)

  while @sint == nil
    Builtins.y2milestone("ro:%1", readonly )
    env = ::Storage::Environment.new(readonly)
    Builtins.y2milestone("ro:%1 test:%2 auto:%3 instsys:%4", 
                  env.readonly, env.testmode, env.autodetect, 
    env.instsys )
	env.testmode = Mode.test;
	env.autodetect = !Mode.test;
	env.instsys = Stage.initial || Mode.repair;
    Builtins.y2milestone("ro:%1 test:%2 auto:%3 instsys:%4", 
                  env.readonly, env.testmode, env.autodetect, 
    env.instsys )

    locker_pid = 0
    @sint, locker_pid = ::Storage::createStorageInterfacePid(env)

    if @sint.kind_of?(Fixnum)
	  locker_pid = @sint
	  @sint = nil
      locker_name = GetProcessName(locker_pid)
      Builtins.y2milestone(
        "locker_pid:%1 locker_name:%2",
        locker_pid,
        locker_name
      )

      if locker_name == nil
        if !Popup.AnyQuestion(
            Label.ErrorMsg,
            # error popup
            _(
              "The storage subsystem is locked by an unknown application.\nYou must quit that application before you can continue."
            ),
            Label.ContinueButton,
            Label.CancelButton,
            :focus_no
          )
          break
        end
      else
        if !Popup.AnyQuestion(
            Label.ErrorMsg,
            # error popup
            Builtins.sformat(
              _(
                "The storage subsystem is locked by the application \"%1\" (%2).\nYou must quit that application before you can continue."
              ),
              locker_name,
              locker_pid
            ),
            Label.ContinueButton,
            Label.CancelButton,
            :focus_no
          )
          break
        end
      end
    end
  end
  Builtins.y2milestone("sint:%1", @sint)
  @sint
end

- (Object) GetProcessName(pid)



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File '../../src/modules/StorageInit.rb', line 44

def GetProcessName(pid)
  name = Convert.to_string(
    SCR.Read(
      path(".target.symlink"),
      Ops.add(Ops.add("/proc/", Builtins.tostring(pid)), "/exe")
    )
  )
  return nil if name == nil

  pos = Builtins.findlastof(name, "/")
  return name if pos == nil

  Builtins.substring(name, Ops.add(pos, 1))
end

- (Object) main



32
33
34
35
36
37
38
39
40
41
42
# File '../../src/modules/StorageInit.rb', line 32

def main

  textdomain "storage"

  Yast.import "Popup"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "Label"

  @sint = nil
end