141 |
def __init__(self): |
def __init__(self): |
142 |
self.deviceArguments = {} |
self.deviceArguments = {} |
143 |
self.formattable = 0 |
self.formattable = 0 |
|
self.checkable = 0 |
|
144 |
self.checked = 0 |
self.checked = 0 |
145 |
self.name = "" |
self.name = "" |
146 |
self.linuxnativefs = 0 |
self.linuxnativefs = 0 |
270 |
if self.isFormattable(): |
if self.isFormattable(): |
271 |
raise RuntimeError, "formatDevice method not defined" |
raise RuntimeError, "formatDevice method not defined" |
272 |
|
|
|
def checkDevice(self, entry, progress, chroot='/'): |
|
|
if self.isCheckable(): |
|
|
raise RuntimeError, "checkDevice method not defined" |
|
|
|
|
273 |
def migrateFileSystem(self, device, message, chroot='/'): |
def migrateFileSystem(self, device, message, chroot='/'): |
274 |
if self.isMigratable(): |
if self.isMigratable(): |
275 |
raise RuntimeError, "migrateFileSystem method not defined" |
raise RuntimeError, "migrateFileSystem method not defined" |
280 |
def isFormattable(self): |
def isFormattable(self): |
281 |
return self.formattable |
return self.formattable |
282 |
|
|
|
def isCheckable(self): |
|
|
return self.checkable |
|
|
|
|
283 |
def isLinuxNativeFS(self): |
def isLinuxNativeFS(self): |
284 |
return self.linuxnativefs |
return self.linuxnativefs |
285 |
|
|
507 |
FileSystemType.__init__(self) |
FileSystemType.__init__(self) |
508 |
self.partedFileSystemType = None |
self.partedFileSystemType = None |
509 |
self.formattable = 1 |
self.formattable = 1 |
|
self.checkable = 1 |
|
510 |
self.checked = 1 |
self.checked = 1 |
511 |
self.linuxnativefs = 1 |
self.linuxnativefs = 1 |
512 |
self.maxSizeMB = 8 * 1024 * 1024 |
self.maxSizeMB = 8 * 1024 * 1024 |
536 |
entry.mountpoint) |
entry.mountpoint) |
537 |
if rc: |
if rc: |
538 |
raise SystemError |
raise SystemError |
|
|
|
|
def checkDevice(self, entry, progress, chroot='/'): |
|
|
devicePath = entry.device.setupDevice(chroot) |
|
|
args = [ "/usr/sbin/e2fsck", "-p", "-f", "-C0", devicePath] |
|
|
|
|
|
rc = fsckFilesystem(args, "/dev/tty5", |
|
|
progress, entry.mountpoint) |
|
|
if rc: |
|
|
raise SystemError |
|
539 |
|
|
540 |
# this is only for ext3 filesystems, but migration is a method |
# this is only for ext3 filesystems, but migration is a method |
541 |
# of the ext2 fstype, so it needs to be here. FIXME should be moved |
# of the ext2 fstype, so it needs to be here. FIXME should be moved |
735 |
|
|
736 |
def labelDevice(self, entry, chroot): |
def labelDevice(self, entry, chroot): |
737 |
file = entry.device.setupDevice(chroot) |
file = entry.device.setupDevice(chroot) |
738 |
label = labelFactory.createLabel("SWAP-%s" %entry.device.getDevice(), |
devName = entry.device.getDevice() |
739 |
self.maxLabelChars) |
# we'll keep the SWAP-* naming for all devs but Compaq SMART2 |
740 |
|
# nodes (#170500) |
741 |
|
if devName[0:6] == "cciss/": |
742 |
|
swapLabel = "SW-%s" % (devName) |
743 |
|
else: |
744 |
|
swapLabel = "SWAP-%s" % (devName) |
745 |
|
label = labelFactory.createLabel("%s" %swapLabel, self.maxLabelChars) |
746 |
rc = iutil.execWithRedirect ("/usr/sbin/mkswap", |
rc = iutil.execWithRedirect ("/usr/sbin/mkswap", |
747 |
[ "mkswap", '-v1', "-L", label, file ], |
[ "mkswap", '-v1', "-L", label, file ], |
748 |
stdout = "/dev/tty5", |
stdout = "/dev/tty5", |
831 |
def __init__(self): |
def __init__(self): |
832 |
FileSystemType.__init__(self) |
FileSystemType.__init__(self) |
833 |
self.partedFileSystemType = None |
self.partedFileSystemType = None |
834 |
|
self.partedPartitionFlags = [ parted.PARTITION_BOOT ] |
835 |
self.checked = 0 |
self.checked = 0 |
836 |
self.name = "PPC PReP Boot" |
self.name = "PPC PReP Boot" |
837 |
self.maxSizeMB = 10 |
self.maxSizeMB = 10 |
1187 |
|
|
1188 |
f.close() |
f.close() |
1189 |
|
|
1190 |
# return the "boot" devicce |
# return the "boot" device |
1191 |
def getBootDev(self): |
def getBootDev(self): |
1192 |
mntDict = {} |
mntDict = {} |
1193 |
bootDev = None |
bootDev = None |
1383 |
log("formatting %s as %s" %(entry.mountpoint, entry.fsystem.name)) |
log("formatting %s as %s" %(entry.mountpoint, entry.fsystem.name)) |
1384 |
entry.fsystem.formatDevice(entry, self.progressWindow, chroot) |
entry.fsystem.formatDevice(entry, self.progressWindow, chroot) |
1385 |
|
|
|
def checkEntry(self, entry, chroot): |
|
|
log("checking %s type %s" %(entry.mountpoint, entry.fsystem.name)) |
|
|
entry.fsystem.checkDevice(entry, self.progressWindow, chroot) |
|
|
|
|
1386 |
def badblocksEntry(self, entry, chroot): |
def badblocksEntry(self, entry, chroot): |
1387 |
entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot) |
entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot) |
1388 |
|
|
1448 |
formatted = [] |
formatted = [] |
1449 |
notformatted = [] |
notformatted = [] |
1450 |
for entry in self.entries: |
for entry in self.entries: |
|
if (entry.mountpoint != '/boot'): |
|
|
continue |
|
|
try: |
|
|
self.formatEntry(entry, chroot) |
|
|
formatted.append(entry) |
|
|
except SystemError: |
|
|
if self.messageWindow: |
|
|
self.messageWindow(_("Error"), |
|
|
_("An error occurred trying to " |
|
|
"format %s. This problem is " |
|
|
"serious, and the install cannot " |
|
|
"continue.\n\n" |
|
|
"Press <Enter> to reboot your system.") |
|
|
% (entry.device.getDevice(),)) |
|
|
sys.exit(0) |
|
|
|
|
|
for entry in self.entries: |
|
|
if (entry.mountpoint == '/boot'): |
|
|
continue |
|
1451 |
if (not entry.fsystem.isFormattable() or not entry.getFormat() |
if (not entry.fsystem.isFormattable() or not entry.getFormat() |
1452 |
or entry.isMounted()): |
or entry.isMounted()): |
1453 |
notformatted.append(entry) |
notformatted.append(entry) |
1492 |
def haveMigratedFilesystems(self): |
def haveMigratedFilesystems(self): |
1493 |
return self.migratedfs |
return self.migratedfs |
1494 |
|
|
|
def checkFilesystems (self, chroot='/'): |
|
|
for entry in self.entries: |
|
|
if entry.fsystem.isCheckable(): |
|
|
self.checkEntry(entry, chroot) |
|
|
|
|
1495 |
def migrateFilesystems (self, chroot='/'): |
def migrateFilesystems (self, chroot='/'): |
1496 |
if self.migratedfs: |
if self.migratedfs: |
1497 |
return |
return |
1913 |
device) |
device) |
1914 |
entry = entry + " spare-disk %d\n" % (i,) |
entry = entry + " spare-disk %d\n" % (i,) |
1915 |
i = i + 1 |
i = i + 1 |
1916 |
if self.numDisks == 1: |
if self.numDisks == 1: |
1917 |
entry = entry + " device dev/null\n" |
entry = entry + " device dev/null\n" |
1918 |
entry = entry + " failed-disk 1\n" |
entry = entry + " failed-disk 1\n" |
1919 |
return entry |
return entry |
1930 |
PartitionDevice(device).setupDevice(chroot, |
PartitionDevice(device).setupDevice(chroot, |
1931 |
devPrefix=devPrefix) |
devPrefix=devPrefix) |
1932 |
|
|
1933 |
args = ["/usr/sbin/mdadm", "--create", "/dev/%s" %(self.device,), |
args = ["/usr/sbin/mdadm", "--create", "/dev/%s" %(self.device,), |
1934 |
"--run", "--chunk=%s" %(self.chunksize,), |
"--run", "--chunk=%s" %(self.chunksize,), |
1935 |
"--level=%s" %(self.level,), |
"--level=%s" %(self.level,), |
1936 |
] |
] |
1937 |
|
|
1938 |
if self.spares > 0: |
if self.spares > 0: |
1939 |
args.append("--spare-devices=%s" %(self.spares,),) |
args.append("--spare-devices=%s" %(self.spares,),) |
1940 |
|
|
1941 |
if self.numDisks == 1 and self.level == 1: |
if self.numDisks == 1 and self.level == 1: |
1942 |
args.append("--raid-devices=2") |
args.append("--raid-devices=2") |
1943 |
else: |
else: |
1944 |
args.append("--raid-devices=%s" %(self.numDisks,),) |
args.append("--raid-devices=%s" %(self.numDisks,),) |
1945 |
|
|
1946 |
args.extend(map(devify, self.members)) |
args.extend(map(devify, self.members)) |
2558 |
return 0 |
return 0 |
2559 |
|
|
2560 |
return 1 |
return 1 |
|
|
|
|
def fsckFilesystem(argList, messageFile, windowCreator, mntpoint): |
|
|
if windowCreator: |
|
|
w = windowCreator(_("Checking"), |
|
|
_("Checking %s file system...") % (mntpoint,), 100) |
|
|
else: |
|
|
w = None |
|
|
|
|
|
fd = os.open(messageFile, os.O_RDWR | os.O_CREAT | os.O_APPEND) |
|
|
p = os.pipe() |
|
|
childpid = os.fork() |
|
|
if not childpid: |
|
|
os.close(p[0]) |
|
|
os.dup2(p[1], 1) |
|
|
os.dup2(fd, 2) |
|
|
os.close(p[1]) |
|
|
os.close(fd) |
|
|
os.execv(argList[0], argList) |
|
|
log("failed to exec %s", argList) |
|
|
os._exit(1) |
|
|
|
|
|
os.close(p[1]) |
|
|
|
|
|
# ignoring SIGCHLD would be cleaner then ignoring EINTR, but |
|
|
# we can't use signal() in this thread? |
|
|
|
|
|
s = 'a' |
|
|
num = '' |
|
|
sync = 0 |
|
|
while s: |
|
|
try: |
|
|
s = os.read(p[0], 1) |
|
|
os.write(fd, s) |
|
|
|
|
|
if s != ' ': |
|
|
try: |
|
|
num = num + s |
|
|
except: |
|
|
pass |
|
|
else: |
|
|
if num and num[:1] != '(' and num[-1] == '%': |
|
|
try: |
|
|
val = int(num[:string.find(num, ".")]) |
|
|
except (IndexError, TypeError): |
|
|
pass |
|
|
else: |
|
|
w and w.set(val) |
|
|
num = '' |
|
|
except OSError, args: |
|
|
(errno, str) = args |
|
|
if (errno != 4): |
|
|
raise IOError, args |
|
|
|
|
|
try: |
|
|
(pid, status) = os.waitpid(childpid, 0) |
|
|
except OSError, (num, msg): |
|
|
log("exception from waitpid while checking: %s %s" %(num, msg)) |
|
|
status = None |
|
|
os.close(fd) |
|
|
|
|
|
w and w.pop() |
|
|
|
|
|
# *shrug* no clue why this would happen, but hope that things are fine |
|
|
if status is None: |
|
|
return 0 |
|
|
|
|
|
if os.WIFEXITED(status) and ((os.WEXITSTATUS(status) == 0) or (os.WEXITSTATUS(status) == 1)): |
|
|
return 0 |
|
|
|
|
|
return 1 |
|
2561 |
|
|
2562 |
if __name__ == "__main__": |
if __name__ == "__main__": |
2563 |
log.open("foo") |
log.open("foo") |