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

Diff of /trunk/src/GLIStorageDevice.py

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

Revision 113 Revision 184
212 for part in self._partitions: 212 for part in self._partitions:
213 tmppart = self._partitions[part] 213 tmppart = self._partitions[part]
214 devdic[part] = { 'mb': 0, 'start': tmppart.get_start(), 'end': tmppart.get_end(), 'type': tmppart.get_type(), 'mountpoint': tmppart.get_mountpoint(), 'mountopts': tmppart.get_mountopts(), 'format': tmppart.get_format() } 214 devdic[part] = { 'mb': 0, 'start': tmppart.get_start(), 'end': tmppart.get_end(), 'type': tmppart.get_type(), 'mountpoint': tmppart.get_mountpoint(), 'mountopts': tmppart.get_mountopts(), 'format': tmppart.get_format() }
215 return devdic 215 return devdic
216 216
217 def get_extended_partition(self):
218 for part in self._partitions:
219 tmppart = self._partitions[part]
220 if tmppart.is_extended():
221 return part
222 return 0
223
217 def get_num_sectors(self): 224 def get_num_sectors(self):
218 return int(self._total_sectors) 225 return int(self._total_sectors)
219 226
220 def get_cylinder_size(self): 227 def get_cylinder_size(self):
221 return int(self._cylinder_bytes) 228 return int(self._cylinder_bytes)
291 self._mountpoint = mountpoint 298 self._mountpoint = mountpoint
292 self._mountopts = mountopts 299 self._mountopts = mountopts
293 self._format = format 300 self._format = format
294 if blocks == 0: 301 if blocks == 0:
295 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512 302 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512
296 if existing: 303# if existing:
297 parted_part = device._parted_disk.get_partition(minor) 304# parted_part = device._parted_disk.get_partition(minor)
298 if type == "ntfs": 305# if type == "ntfs":
299 min_bytes = int(commands.getoutput("ntfsresize --info " + device._device + str(minor) + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'")) 306# min_bytes = int(commands.getoutput("ntfsresize -f --info " + device._device + str(minor) + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'"))
300 self._min_cylinders_for_resize = int(min_bytes / self._device._cylinder_bytes) + 1 307# self._min_cylinders_for_resize = int(min_bytes / self._device._cylinder_bytes) + 1
301 self._resizeable == True 308# self._resizeable == True
302 elif type == "ext2" or type == "ext3": 309# elif type == "ext2" or type == "ext3":
303 commands.system("mkdir /mnt/freespace; mount " + device._device + str(minor) + " /mnt/freespace") 310# block_size = string.strip(commands.getoutput("dumpe2fs -h " + device._device + str(minor) + " 2>&1 | grep -e '^Block size:' | sed -e 's/^Block size:\s\+//'"))
304 min_bytes = int(commands.getoutput("df -B kB " + device._device + str(minor) + " | tail -n 1 | sed -e 's:^" + device._device + str(minor) + "\s\+[0-9]\+kB\s\+::' -e 's:kB\s.\+::'")) * 1000 311# free_blocks = string.strip(commands.getoutput("dumpe2fs -h " + device._device + str(minor) + " 2>&1 | grep -e '^Free blocks:' | sed -e 's/^Free blocks:\s\+//'"))
305 commands.system("umount /mnt/freespace; rm -rf /mnt/freespace") 312# free_cyl = int(int(block_size) * int(free_blocks) / self._device._cylinder_bytes)
306 min_bytes = min_bytes + (100 * 1024 * 1024) # Add 100M just to be safe 313# free_cyl = int(free_cyl)
307 self._min_cylinders_for_resize = int(min_bytes / self._device._cylinder_bytes) + 1 314# free_cyl = free_cyl - 200 # just to be safe
315# self._min_cylinders_for_resize = (self._end - self._start + 1) - free_cyl
308 self._resizeable == True 316# self._resizeable == True
309 elif type == "fat16" or type == "fat32": 317# elif type == "fat16" or type == "fat32":
310 parted_part = self._device._parted_disk.get_partition(self._minor) 318# parted_part = self._device._parted_disk.get_partition(self._minor)
311 parted_fs = parted_part.geom.file_system_open() 319# parted_fs = parted_part.geom.file_system_open()
312 resize_constraint = parted_fs.get_resize_constraint() 320# resize_constraint = parted_fs.get_resize_constraint()
313 min_size = float(resize_constraint.min_size / self._device._sectors_in_cylinder) 321# min_size = float(resize_constraint.min_size / self._device._sectors_in_cylinder)
314 if int(min_size) != min_size: min_size = int(min_size) + 1 322# if int(min_size) != min_size: min_size = int(min_size) + 1
315 self._min_cylinders_for_resize = min_size 323# self._min_cylinders_for_resize = min_size
316 self._resizeable = True 324# self._resizeable = True
317 elif type == "": 325# elif type == "":
318 self._min_cylinders_for_resize = 1 326# self._min_cylinders_for_resize = 1
319 self._resizeable = True 327# self._resizeable = True
320 else: 328# else:
321 self._resizeable = True 329# self._resizeable = True
322 330
323 def is_extended(self): 331 def is_extended(self):
324 if self._type == "extended": 332 if self._type == "extended":
325 return True 333 return True
326 else: 334 else:
331 if part and self._device._partitions[part].is_extended() and not part == self._minor: 339 if part and self._device._partitions[part].is_extended() and not part == self._minor:
332 return True 340 return True
333 return False 341 return False
334 342
335 def get_logicals(self): 343 def get_logicals(self):
344 if not self.is_extended():
345 return None
336 logicals = [] 346 logicals = []
337 start = self._start 347 start = self._start
338 while not start > self._end: 348# while not start > self._end:
339 part = self._device.get_partition_at(start) 349# part = self._device.get_partition_at(start)
350# print "part=" + str(part)
340 if not part: break 351# if not part: break
352# logicals.append(part)
353# start = self._device._partitions[part].get_end() + 1
354 parts = self._device._partitions.keys()
355 parts.sort()
356 for part in parts:
357 if part < 5: continue
341 logicals.append(part) 358 logicals.append(part)
342 start = self._device._partitions[part].get_end() + 1
343 logicals.sort() 359 logicals.sort()
344 return logicals 360 return logicals
345 361
346 def get_extended_parent(self): 362 def get_extended_parent(self):
363 if not self.is_logical():
364 return None
365 else:
347 return self._device.get_partition_at(self._start, ignore_extended=0) 366 return self._device.get_partition_at(self._start, ignore_extended=0)
348 367
349 def set_start(self, start): 368 def set_start(self, start):
350 self._start = int(start) 369 self._start = int(start)
351 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512 370 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512
352 371
395 414
396 def get_blocks(self): 415 def get_blocks(self):
397 return int(self._blocks) 416 return int(self._blocks)
398 417
399 def get_min_cylinders_for_resize(self): 418 def get_min_cylinders_for_resize(self):
400# min_size = self._start + 1
401# if not self._format:
402# parted_part = self._device._parted_disk.get_partition(self._minor)
403# parted_fs = parted_part.geom.file_system_open()
404# resize_constraint = parted_fs.get_resize_constraint()
405# min_size = float(resize_constraint.min_size / self._device._sectors_in_cylinder)
406# if int(min_size) != min_size: min_size = int(min_size) + 1
407# min_size = min_size + self._start
408#################################################
409 if self.is_extended(): 419 if self.is_extended():
410 min_size = self._start 420 min_size = self._start
411 for part in self._device._partitions: 421 for part in self._device._partitions:
412 if part < 5: continue 422 if part < 5: continue
413 min_size = part.get_end() 423 min_size = part.get_end()

Legend:
Removed from v.113  
changed lines
  Added in v.184

  ViewVC Help
Powered by ViewVC 1.1.20