/[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.3 by slords, Mon Aug 1 04:14:22 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 1497  MAILADDR root Line 1520  MAILADDR root
1520              try:              try:
1521                  entry.origfsystem.migrateFileSystem(entry, self.messageWindow,                  entry.origfsystem.migrateFileSystem(entry, self.messageWindow,
1522                                                      chroot)                                                      chroot)
1523                    if entry.fsystem.isCheckable():
1524                        self.checkEntry(entry, chroot)
1525              except SystemError:              except SystemError:
1526                  if self.messageWindow:                  if self.messageWindow:
1527                      self.messageWindow(_("Error"),                      self.messageWindow(_("Error"),
# Line 2540  def ext2FormatFilesystem(argList, messag Line 2565  def ext2FormatFilesystem(argList, messag
2565          status = None          status = None
2566      os.close(fd)      os.close(fd)
2567    
2568        w and w.pop()
2569    
2570        # *shrug*  no clue why this would happen, but hope that things are fine
2571        if status is None:
2572            return 0
2573        
2574        if os.WIFEXITED(status) and (os.WEXITSTATUS(status) == 0):
2575            return 0
2576    
2577        return 1
2578    
2579    def fsckFilesystem(argList, messageFile, windowCreator, mntpoint):
2580        if windowCreator:
2581            w = windowCreator(_("Checking"),
2582                              _("Checking %s file system...") % (mntpoint,), 100)
2583        else:
2584            w = None
2585    
2586        fd = os.open(messageFile, os.O_RDWR | os.O_CREAT | os.O_APPEND)
2587        p = os.pipe()
2588        childpid = os.fork()
2589        if not childpid:
2590            os.close(p[0])
2591            os.dup2(p[1], 1)
2592            os.dup2(fd, 2)
2593            os.close(p[1])
2594            os.close(fd)
2595            os.execv(argList[0], argList)
2596            log("failed to exec %s", argList)
2597            os._exit(1)
2598                                
2599        os.close(p[1])
2600    
2601        # ignoring SIGCHLD would be cleaner then ignoring EINTR, but
2602        # we can't use signal() in this thread?
2603    
2604        s = 'a'
2605        num = ''
2606        sync = 0
2607        while s:
2608            try:
2609                s = os.read(p[0], 1)
2610                os.write(fd, s)
2611    
2612                if s != ' ':
2613                    try:
2614                        num = num + s
2615                    except:
2616                        pass
2617                else:
2618                    if num and num[:1] != '(' and num[-1] == '%':
2619                        try:
2620                            val = int(num[:string.find(num, ".")])
2621                        except (IndexError, TypeError):
2622                            pass
2623                        else:
2624                            w and w.set(val)
2625                    num = ''
2626            except OSError, args:
2627                (errno, str) = args
2628                if (errno != 4):
2629                    raise IOError, args
2630    
2631        try:
2632            (pid, status) = os.waitpid(childpid, 0)
2633        except OSError, (num, msg):
2634            log("exception from waitpid while checking: %s %s" %(num, msg))
2635            status = None
2636        os.close(fd)
2637    
2638      w and w.pop()      w and w.pop()
2639    
2640      # *shrug*  no clue why this would happen, but hope that things are fine      # *shrug*  no clue why this would happen, but hope that things are fine


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