141 |
def __init__(self): |
def __init__(self): |
142 |
self.deviceArguments = {} |
self.deviceArguments = {} |
143 |
self.formattable = 0 |
self.formattable = 0 |
144 |
|
self.checkable = 0 |
145 |
self.checked = 0 |
self.checked = 0 |
146 |
self.name = "" |
self.name = "" |
147 |
self.linuxnativefs = 0 |
self.linuxnativefs = 0 |
271 |
if self.isFormattable(): |
if self.isFormattable(): |
272 |
raise RuntimeError, "formatDevice method not defined" |
raise RuntimeError, "formatDevice method not defined" |
273 |
|
|
274 |
|
def checkDevice(self, entry, progress, chroot='/'): |
275 |
|
if self.isCheckable(): |
276 |
|
raise RuntimeError, "checkDevice method not defined" |
277 |
|
|
278 |
def migrateFileSystem(self, device, message, chroot='/'): |
def migrateFileSystem(self, device, message, chroot='/'): |
279 |
if self.isMigratable(): |
if self.isMigratable(): |
280 |
raise RuntimeError, "migrateFileSystem method not defined" |
raise RuntimeError, "migrateFileSystem method not defined" |
285 |
def isFormattable(self): |
def isFormattable(self): |
286 |
return self.formattable |
return self.formattable |
287 |
|
|
288 |
|
def isCheckable(self): |
289 |
|
return self.checkable |
290 |
|
|
291 |
def isLinuxNativeFS(self): |
def isLinuxNativeFS(self): |
292 |
return self.linuxnativefs |
return self.linuxnativefs |
293 |
|
|
515 |
FileSystemType.__init__(self) |
FileSystemType.__init__(self) |
516 |
self.partedFileSystemType = None |
self.partedFileSystemType = None |
517 |
self.formattable = 1 |
self.formattable = 1 |
518 |
|
self.checkable = 1 |
519 |
self.checked = 1 |
self.checked = 1 |
520 |
self.linuxnativefs = 1 |
self.linuxnativefs = 1 |
521 |
self.maxSizeMB = 8 * 1024 * 1024 |
self.maxSizeMB = 8 * 1024 * 1024 |
545 |
entry.mountpoint) |
entry.mountpoint) |
546 |
if rc: |
if rc: |
547 |
raise SystemError |
raise SystemError |
548 |
|
|
549 |
|
def checkDevice(self, entry, progress, chroot='/'): |
550 |
|
devicePath = entry.device.setupDevice(chroot) |
551 |
|
args = [ "/usr/sbin/e2fsck", "-p", "-f", "-C0", devicePath] |
552 |
|
|
553 |
|
rc = fsckFilesystem(args, "/dev/tty5", |
554 |
|
progress, entry.mountpoint) |
555 |
|
if rc: |
556 |
|
raise SystemError |
557 |
|
|
558 |
# this is only for ext3 filesystems, but migration is a method |
# this is only for ext3 filesystems, but migration is a method |
559 |
# 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 |
1394 |
log("formatting %s as %s" %(entry.mountpoint, entry.fsystem.name)) |
log("formatting %s as %s" %(entry.mountpoint, entry.fsystem.name)) |
1395 |
entry.fsystem.formatDevice(entry, self.progressWindow, chroot) |
entry.fsystem.formatDevice(entry, self.progressWindow, chroot) |
1396 |
|
|
1397 |
|
def checkEntry(self, entry, chroot): |
1398 |
|
log("checking %s type %s" %(entry.mountpoint, entry.fsystem.name)) |
1399 |
|
entry.fsystem.checkDevice(entry, self.progressWindow, chroot) |
1400 |
|
|
1401 |
def badblocksEntry(self, entry, chroot): |
def badblocksEntry(self, entry, chroot): |
1402 |
entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot) |
entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot) |
1403 |
|
|
1463 |
formatted = [] |
formatted = [] |
1464 |
notformatted = [] |
notformatted = [] |
1465 |
for entry in self.entries: |
for entry in self.entries: |
1466 |
|
if (entry.mountpoint != '/boot'): |
1467 |
|
continue |
1468 |
|
try: |
1469 |
|
self.formatEntry(entry, chroot) |
1470 |
|
formatted.append(entry) |
1471 |
|
except SystemError: |
1472 |
|
if self.messageWindow: |
1473 |
|
self.messageWindow(_("Error"), |
1474 |
|
_("An error occurred trying to " |
1475 |
|
"format %s. This problem is " |
1476 |
|
"serious, and the install cannot " |
1477 |
|
"continue.\n\n" |
1478 |
|
"Press <Enter> to reboot your system.") |
1479 |
|
% (entry.device.getDevice(),)) |
1480 |
|
sys.exit(0) |
1481 |
|
|
1482 |
|
for entry in self.entries: |
1483 |
|
if (entry.mountpoint == '/boot'): |
1484 |
|
continue |
1485 |
if (not entry.fsystem.isFormattable() or not entry.getFormat() |
if (not entry.fsystem.isFormattable() or not entry.getFormat() |
1486 |
or entry.isMounted()): |
or entry.isMounted()): |
1487 |
notformatted.append(entry) |
notformatted.append(entry) |
1526 |
def haveMigratedFilesystems(self): |
def haveMigratedFilesystems(self): |
1527 |
return self.migratedfs |
return self.migratedfs |
1528 |
|
|
1529 |
|
def checkFilesystems (self, chroot='/'): |
1530 |
|
for entry in self.entries: |
1531 |
|
if entry.fsystem.isCheckable(): |
1532 |
|
self.checkEntry(entry, chroot) |
1533 |
|
|
1534 |
def migrateFilesystems (self, chroot='/'): |
def migrateFilesystems (self, chroot='/'): |
1535 |
if self.migratedfs: |
if self.migratedfs: |
1536 |
return |
return |
1977 |
if self.spares > 0: |
if self.spares > 0: |
1978 |
args.append("--spare-devices=%s" %(self.spares,),) |
args.append("--spare-devices=%s" %(self.spares,),) |
1979 |
|
|
1980 |
if self.numDisks == 1: |
if self.numDisks == 1 and self.level == 1: |
1981 |
args.append("--raid-devices=2") |
args.append("--raid-devices=2") |
1982 |
else: |
else: |
1983 |
args.append("--raid-devices=%s" %(self.numDisks,),) |
args.append("--raid-devices=%s" %(self.numDisks,),) |
1984 |
|
|
1985 |
args.extend(map(devify, self.members)) |
args.extend(map(devify, self.members)) |
1986 |
|
|
1987 |
if self.numDisks == 1: |
if self.numDisks == 1 and self.level == 1: |
1988 |
args.append("missing") |
args.append("missing") |
1989 |
|
|
1990 |
log("going to run: %s" %(args,)) |
log("going to run: %s" %(args,)) |
2597 |
return 0 |
return 0 |
2598 |
|
|
2599 |
return 1 |
return 1 |
2600 |
|
|
2601 |
|
def fsckFilesystem(argList, messageFile, windowCreator, mntpoint): |
2602 |
|
if windowCreator: |
2603 |
|
w = windowCreator(_("Checking"), |
2604 |
|
_("Checking %s file system...") % (mntpoint,), 100) |
2605 |
|
else: |
2606 |
|
w = None |
2607 |
|
|
2608 |
|
fd = os.open(messageFile, os.O_RDWR | os.O_CREAT | os.O_APPEND) |
2609 |
|
p = os.pipe() |
2610 |
|
childpid = os.fork() |
2611 |
|
if not childpid: |
2612 |
|
os.close(p[0]) |
2613 |
|
os.dup2(p[1], 1) |
2614 |
|
os.dup2(fd, 2) |
2615 |
|
os.close(p[1]) |
2616 |
|
os.close(fd) |
2617 |
|
os.execv(argList[0], argList) |
2618 |
|
log("failed to exec %s", argList) |
2619 |
|
os._exit(1) |
2620 |
|
|
2621 |
|
os.close(p[1]) |
2622 |
|
|
2623 |
|
# ignoring SIGCHLD would be cleaner then ignoring EINTR, but |
2624 |
|
# we can't use signal() in this thread? |
2625 |
|
|
2626 |
|
s = 'a' |
2627 |
|
num = '' |
2628 |
|
sync = 0 |
2629 |
|
while s: |
2630 |
|
try: |
2631 |
|
s = os.read(p[0], 1) |
2632 |
|
os.write(fd, s) |
2633 |
|
|
2634 |
|
if s != ' ': |
2635 |
|
try: |
2636 |
|
num = num + s |
2637 |
|
except: |
2638 |
|
pass |
2639 |
|
else: |
2640 |
|
if num and num[:1] != '(' and num[-1] == '%': |
2641 |
|
try: |
2642 |
|
val = int(num[:string.find(num, ".")]) |
2643 |
|
except (IndexError, TypeError): |
2644 |
|
pass |
2645 |
|
else: |
2646 |
|
w and w.set(val) |
2647 |
|
num = '' |
2648 |
|
except OSError, args: |
2649 |
|
(errno, str) = args |
2650 |
|
if (errno != 4): |
2651 |
|
raise IOError, args |
2652 |
|
|
2653 |
|
try: |
2654 |
|
(pid, status) = os.waitpid(childpid, 0) |
2655 |
|
except OSError, (num, msg): |
2656 |
|
log("exception from waitpid while checking: %s %s" %(num, msg)) |
2657 |
|
status = None |
2658 |
|
os.close(fd) |
2659 |
|
|
2660 |
|
w and w.pop() |
2661 |
|
|
2662 |
|
# *shrug* no clue why this would happen, but hope that things are fine |
2663 |
|
if status is None: |
2664 |
|
return 0 |
2665 |
|
|
2666 |
|
if os.WIFEXITED(status) and ((os.WEXITSTATUS(status) == 0) or (os.WEXITSTATUS(status) == 1)): |
2667 |
|
return 0 |
2668 |
|
|
2669 |
|
return 1 |
2670 |
|
|
2671 |
if __name__ == "__main__": |
if __name__ == "__main__": |
2672 |
log.open("foo") |
log.open("foo") |