deleted: new_partition/finddisk.sh new file: new_partition/interface_partition.py deleted: new_partition/list-devices deleted: new_partition/new_partition.py deleted: new_partition/parted_devices modified: new_partition/parted_devices.py new file: new_partition/partition_data.py
61 lines
1.3 KiB
Python
Executable File
61 lines
1.3 KiB
Python
Executable File
#!/usr/bin/python
|
|
#
|
|
# pythonlized partman-base/parted_devices.c
|
|
#
|
|
|
|
import parted
|
|
import os,fcntl,array
|
|
import re
|
|
|
|
'''is cdrom return 0'''
|
|
def is_cdrom(path):
|
|
CDROM_GET_CAPABILITY = 0x5331
|
|
ret = 1
|
|
|
|
'''h: array type code, mean signed short '''
|
|
buf= array.array('h', [0])
|
|
fd = os.open(path, os.O_RDONLY | os.O_NONBLOCK)
|
|
try:
|
|
ret = fcntl.ioctl(fd, CDROM_GET_CAPABILITY, buf)
|
|
ret = buf[0]
|
|
except IOError:
|
|
pass
|
|
|
|
return ret
|
|
|
|
'''is floppy return true'''
|
|
def is_floppy(path):
|
|
return path == "/dev/floppy" or path == "/dev/fd";
|
|
|
|
'''is device mapper return true,
|
|
filter /dev/mapper, we don't use /dev/mapper in installer -- bqin'''
|
|
def is_devicemapper(path):
|
|
return (path.startswith("/dev/mapper"))
|
|
|
|
def process_device(dev):
|
|
if dev.readOnly == 1:
|
|
return
|
|
if not is_cdrom(dev.path) or is_floppy(dev.path) or is_devicemapper(dev.path):
|
|
return
|
|
if dev.path == "/dev/ramzswap" or dev.path == "/dev/zram":
|
|
return
|
|
return dev.path
|
|
|
|
|
|
def get_disks():
|
|
disk_list = []
|
|
|
|
device_list = parted.getAllDevices()
|
|
|
|
for i in range(len(device_list)):
|
|
item = process_device(device_list[i])
|
|
if item:
|
|
disk_list.append(item)
|
|
|
|
return disk_list
|
|
|
|
|
|
if __name__ == "__main__":
|
|
for i in get_disks():
|
|
print i
|