/[gli]/trunk/src/GLIStorageDevice.py
Gentoo

Diff of /trunk/src/GLIStorageDevice.py

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

Revision 825 Revision 826
367 if existing and not origminor: 367 if existing and not origminor:
368 self._orig_minor = self._minor 368 self._orig_minor = self._minor
369 self._minor = int(self._minor) 369 self._minor = int(self._minor)
370 self._orig_minor = int(self._orig_minor) 370 self._orig_minor = int(self._orig_minor)
371 if existing: 371 if existing:
372 try:
372 parted_part = device._parted_disk.get_partition(self._orig_minor) 373 parted_part = device._parted_disk.get_partition(self._orig_minor)
373 label_type = device._parted_disk.type.name 374 label_type = device._parted_disk.type.name
374 if label_type == "loop": 375 if label_type == "loop":
375 dev_node = device._device 376 dev_node = device._device
376 else: 377 else:
377 dev_node = device._device + str(self._orig_minor) 378 dev_node = device._device + str(self._orig_minor)
378# print "dev_node = " + dev_node 379# print "dev_node = " + dev_node
379 if type == "ntfs": 380 if type == "ntfs":
380 min_bytes = long(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'")) 381 min_bytes = long(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'"))
381 self._min_mb_for_resize = long(min_bytes / MEGABYTE) + 1 382 self._min_mb_for_resize = long(min_bytes / MEGABYTE) + 1
382 self._resizeable = True 383 self._resizeable = True
383 elif type == "ext2" or type == "ext3": 384 elif type == "ext2" or type == "ext3":
384 block_size = long(string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Block size:' | sed -e 's/^Block size:\s\+//'"))) 385 block_size = long(string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Block size:' | sed -e 's/^Block size:\s\+//'")))
385 free_blocks = long(string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Free blocks:' | sed -e 's/^Free blocks:\s\+//'"))) 386 free_blocks = long(string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Free blocks:' | sed -e 's/^Free blocks:\s\+//'")))
386 free_bytes = long(block_size * free_blocks) 387 free_bytes = long(block_size * free_blocks)
387 # can't hurt to pad (the +50) it a bit since this is really just a guess 388 # can't hurt to pad (the +50) it a bit since this is really just a guess
388 self._min_mb_for_resize = self._mb - long(free_bytes / MEGABYTE) + 50 389 self._min_mb_for_resize = self._mb - long(free_bytes / MEGABYTE) + 50
389 self._resizeable = True 390 self._resizeable = True
390 else: 391 else:
391 parted_part = self._device._parted_disk.get_partition(int(self._orig_minor)) 392 parted_part = self._device._parted_disk.get_partition(int(self._orig_minor))
392 try:
393 parted_fs = parted_part.geom.file_system_open() 393 parted_fs = parted_part.geom.file_system_open()
394 except:
395 self._resizeable = False
396 return
397 resize_constraint = parted_fs.get_resize_constraint() 394 resize_constraint = parted_fs.get_resize_constraint()
398 min_bytes = resize_constraint.min_size * self._device._sector_bytes 395 min_bytes = resize_constraint.min_size * self._device._sector_bytes
399 self._min_mb_for_resize = long(min_bytes / MEGABYTE) + 1 396 self._min_mb_for_resize = long(min_bytes / MEGABYTE) + 1
400 self._resizeable = True 397 self._resizeable = True
398 except:
399 self._resizeable = False
401 400
402 ## 401 ##
403 # Returns whether or not the partition is extended 402 # Returns whether or not the partition is extended
404 def is_extended(self): 403 def is_extended(self):
405 if self._type == "extended": 404 if self._type == "extended":

Legend:
Removed from v.825  
changed lines
  Added in v.826

  ViewVC Help
Powered by ViewVC 1.1.20