/[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 188
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)
285 self._minor = int(minor) 292 self._minor = int(minor)
286 self._bootflag = bootflag 293 self._bootflag = bootflag
287 self._start = int(start) 294 self._start = int(start)
288 self._end = int(end) 295 self._end = int(end)
289 self._blocks = int(blocks) 296 self._blocks = int(blocks)
297 if type == "": type = "unknown"
290 self._type = type 298 self._type = type
291 self._mountpoint = mountpoint 299 self._mountpoint = mountpoint
292 self._mountopts = mountopts 300 self._mountopts = mountopts
293 self._format = format 301 self._format = format
294 if blocks == 0: 302 if blocks == 0:
295 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512 303 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512
296 if existing: 304# if existing:
297 parted_part = device._parted_disk.get_partition(minor) 305# parted_part = device._parted_disk.get_partition(minor)
298 if type == "ntfs": 306# 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 .\+//'")) 307# 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 308# self._min_cylinders_for_resize = int(min_bytes / self._device._cylinder_bytes) + 1
301 self._resizeable == True 309# self._resizeable == True
302 elif type == "ext2" or type == "ext3": 310# elif type == "ext2" or type == "ext3":
303 commands.system("mkdir /mnt/freespace; mount " + device._device + str(minor) + " /mnt/freespace") 311# 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 312# 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") 313# 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 314# free_cyl = int(free_cyl)
307 self._min_cylinders_for_resize = int(min_bytes / self._device._cylinder_bytes) + 1 315# free_cyl = free_cyl - 200 # just to be safe
316# self._min_cylinders_for_resize = (self._end - self._start + 1) - free_cyl
308 self._resizeable == True 317# self._resizeable == True
309 elif type == "fat16" or type == "fat32": 318# elif type == "fat16" or type == "fat32":
310 parted_part = self._device._parted_disk.get_partition(self._minor) 319# parted_part = self._device._parted_disk.get_partition(self._minor)
311 parted_fs = parted_part.geom.file_system_open() 320# parted_fs = parted_part.geom.file_system_open()
312 resize_constraint = parted_fs.get_resize_constraint() 321# resize_constraint = parted_fs.get_resize_constraint()
313 min_size = float(resize_constraint.min_size / self._device._sectors_in_cylinder) 322# 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 323# if int(min_size) != min_size: min_size = int(min_size) + 1
315 self._min_cylinders_for_resize = min_size 324# self._min_cylinders_for_resize = min_size
316 self._resizeable = True 325# self._resizeable = True
317 elif type == "": 326# elif type == "":
318 self._min_cylinders_for_resize = 1 327# self._min_cylinders_for_resize = 1
319 self._resizeable = True 328# self._resizeable = True
320 else: 329# else:
321 self._resizeable = True 330# self._resizeable = True
322 331
323 def is_extended(self): 332 def is_extended(self):
324 if self._type == "extended": 333 if self._type == "extended":
325 return True 334 return True
326 else: 335 else:
331 if part and self._device._partitions[part].is_extended() and not part == self._minor: 340 if part and self._device._partitions[part].is_extended() and not part == self._minor:
332 return True 341 return True
333 return False 342 return False
334 343
335 def get_logicals(self): 344 def get_logicals(self):
345 if not self.is_extended():
346 return None
336 logicals = [] 347 logicals = []
337 start = self._start 348 start = self._start
338 while not start > self._end: 349# while not start > self._end:
339 part = self._device.get_partition_at(start) 350# part = self._device.get_partition_at(start)
351# print "part=" + str(part)
340 if not part: break 352# if not part: break
353# logicals.append(part)
354# start = self._device._partitions[part].get_end() + 1
355 parts = self._device._partitions.keys()
356 parts.sort()
357 for part in parts:
358 if part < 5: continue
341 logicals.append(part) 359 logicals.append(part)
342 start = self._device._partitions[part].get_end() + 1
343 logicals.sort() 360 logicals.sort()
344 return logicals 361 return logicals
345 362
346 def get_extended_parent(self): 363 def get_extended_parent(self):
364 if not self.is_logical():
365 return None
366 else:
347 return self._device.get_partition_at(self._start, ignore_extended=0) 367 return self._device.get_partition_at(self._start, ignore_extended=0)
348 368
349 def set_start(self, start): 369 def set_start(self, start):
350 self._start = int(start) 370 self._start = int(start)
351 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512 371 self._blocks = ((self._end - self._start) * self._device.get_cylinder_size()) / 512
352 372
395 415
396 def get_blocks(self): 416 def get_blocks(self):
397 return int(self._blocks) 417 return int(self._blocks)
398 418
399 def get_min_cylinders_for_resize(self): 419 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(): 420 if self.is_extended():
410 min_size = self._start 421 min_size = self._start
411 for part in self._device._partitions: 422 for part in self._device._partitions:
412 if part < 5: continue 423 if part < 5: continue
413 min_size = part.get_end() 424 min_size = part.get_end()

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

  ViewVC Help
Powered by ViewVC 1.1.20