/[smeserver]/cdrom.image/updates/fsset.py
ViewVC logotype

Diff of /cdrom.image/updates/fsset.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.1 by gordonr, Sat Jul 2 06:33:16 2005 UTC Revision 1.6 by slords, Wed Nov 23 22:49:43 2005 UTC
# Line 141  class FileSystemType: Line 141  class FileSystemType:
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
# Line 270  class FileSystemType: Line 271  class FileSystemType:
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"
# Line 280  class FileSystemType: Line 285  class FileSystemType:
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    
# Line 507  class extFileSystem(FileSystemType): Line 515  class extFileSystem(FileSystemType):
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
# Line 536  class extFileSystem(FileSystemType): Line 545  class extFileSystem(FileSystemType):
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
# Line 1224  MAILADDR root Line 1242  MAILADDR root
1242    
1243          if bootDev.getName() == "RAIDDevice":          if bootDev.getName() == "RAIDDevice":
1244              ret['boot'] = (bootDev.device, N_("RAID Device"))              ret['boot'] = (bootDev.device, N_("RAID Device"))
1245                ret['mbr'] = (bl.drivelist[0], N_("Master Boot Record (MBR)"))
1246              return ret              return ret
1247    
1248          if iutil.getPPCMacGen() == "NewWorld":          if iutil.getPPCMacGen() == "NewWorld":
# Line 1375  MAILADDR root Line 1394  MAILADDR root
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                    
# Line 1440  MAILADDR root Line 1463  MAILADDR root
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)
# Line 1484  MAILADDR root Line 1526  MAILADDR root
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
# Line 1930  class RAIDDevice(Device): Line 1977  class RAIDDevice(Device):
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,))
# Line 2550  def ext2FormatFilesystem(argList, messag Line 2597  def ext2FormatFilesystem(argList, messag
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")


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed