From fff988e5af64cec5f49aea4656b74cb84ae9c5e0 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sat, 21 Jan 2012 11:48:23 -0600 Subject: linhes-system: add_storage.py. Change the way the drive is determined to be in use, and what the fstype of /myth is. This new method parses /proc/mounts and should be a bit more reliable. Fixes a bug where XFS partitions were not detected in use. refs #796 --- abs/core/LinHES-system/PKGBUILD | 4 +-- abs/core/LinHES-system/add_storage.py | 51 ++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 52f50e3..73fa1ef 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=2 -pkgrel=25 +pkgrel=26 arch=('i686') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -70,6 +70,6 @@ md5sums=('71a1fc9b01476b0b2c30596107eeff75' '9c2294ccfd5359583497a6b03d918a27' '859a80ddb4c234506379c605114c1343' '47e093e8cfe4b5b96602358e1f540832' - '6ca1642a98b66f0499e0d1f964987ad8' + '6faeba0aeb38e772121f751cabda8683' 'eb879fee9603a05d5420d4ce8ed9e450' 'f1870a9522c79e6b248fcbf81dec3280') diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 92a6120..28d679c 100644 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -77,12 +77,9 @@ class disk_device: def get_in_use(self): in_use = False for i in self.fs_map: - if i.startswith("["): - split_line=i.split() - device_path = split_line[5] - if self.block_path in device_path: - in_use = True - break + if self.block_path in i[0]: + in_use = True + break return in_use @@ -132,21 +129,32 @@ class disk_device: return def get_fsmap(self): - cmd = "/sbin/fsck -N" - fs_map = runcmd(cmd)[1] - fs_map = fs_map.split("\n") + #block,point,fs + fs_map=[] + + f = open('/proc/mounts','r') + mounts=f.readlines() + f.close() + for line in mounts: + temp_fs=[] + split_line=line.split() + block=split_line[0] + mountp=split_line[1] + fs=split_line[2] + block=os.path.realpath(block) + if block.startswith("/dev"): + temp_fs.append(block) + temp_fs.append(mountp) + temp_fs.append(fs) + fs_map.append(temp_fs) return fs_map def find_fstype(self,moutpoint): fstype="ext3" mp=['/myth', '/data/media'] for i in self.fs_map: - if i.startswith("["): - split_line=i.split() - #find mount_p and remove the last char - mount_p = split_line[3][:-1] - if mount_p in mp: - fstype = split_line[4].split(".")[1] + if i[1] in mp: + fstype = i[2] break return fstype @@ -377,18 +385,22 @@ def main(scan_only): #print i.mount_path #print i.is_mounted #print i.in_use + #print i.model + #print i.block_path #print "--" if search_for_match(i,known_drive_list) or i.in_use : - #print "Drive matched" - #print i.model + print " Storage is already in use or previously skipped: %s location: %s size: %s" %(i.model,i.block_path,i.device_size) continue - else: + else: + print "\n" if not scan_only: print "\n" print "-------------------------------------------------------------" + print "Found new hard drive: %s location: %s size: %s \n" %(i.model,i.block_path,i.device_size) + if prompt_to_add(i) : print "\nDisk will be added to the storage pool!" process_list.append(i) @@ -412,7 +424,8 @@ def main(scan_only): print "\nDid not find any new storage to add.\n" #BE = MythBE(db=DB) - #save new list to disk_device + + #save new list to disk_device write_known_drive_list(system_drive_list) for i in process_list: -- cgit v0.12