Mounted Drives
Posted
#1
(In Topic #358)
Guru

All you need to do is paste the code into a 'Graphical Application' and run it. All it does is look at the drives and display the drive you click on in a DirChooser. There is a timer so that if you plug in (or remove) a USB drive /Mount (or unmount) a drive it should change the display. It will only display mounted drives.
I look forward to your comments.
Code (gambas)
- ' Gambas class file
- DirChooser1 As DirChooser
- BuildForm
- HSplit1.Layout = [70, 30]
- TimerGetData_Timer
- TimerGetData.Start
- GridViewDrives[siRow, siCol].Background = Color.LightGray
- With GridViewDrives
- .Clear
- .Columns.Count = 7
- .Rows.Count = 0
- GridViewDrives.Columns[siCol].Title = sHeader[siCol]
- GridViewDrives.Columns.Width = -1
- GridViewDrives.Height = (GridViewDrives.Rows[0].Height * sDriveToWorkWith.Count) + 35
- siChange = sDriveToWorkWith.Count
- sDriveToWorkWith.Clear
- sData = ""
- sHold = sData
- Until sData = sHold
- sDriveToWorkWith.Add(sData & "`" & sPart2)
- LabelPath.Text = DirChooser1.SelectedPath
- .Height = 575
- .Width = 1100
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .Layout = [70, 30]
- .Padding = 2
- .Height = 28
- .delay = 250
Posted
Administrator

One small change to line 79 allowed your code to find all my partitions, including the Raid partitions.
changed to:
Posted
Guru

If sDrives[siLoop] Begins "/dev/" Then
This solved one issue but unfortunately I ended up with all sorts of irrelevant stuff so have a go with this code.
Code (gambas)
- ' Gambas class file
- DirChooser1 As DirChooser
- BuildForm
- TimerGetData_Timer
- TimerGetData.Start
- GridViewDrives[siRow, siCol].Background = Color.LightGray
- With GridViewDrives
- .Clear
- .Columns.Count = 7
- .Rows.Count = 0
- GridViewDrives.Columns[siCol].Title = sHeader[siCol]
- GridViewDrives.Columns.Width = -1
- GridViewDrives.Height = (GridViewDrives.Rows[0].Height * sDriveToWorkWith.Count) + 35
- siChange = sDriveToWorkWith.Count
- sDriveToWorkWith.Clear
- sData = ""
- sHold = sData
- Until sData = sHold
- sDriveToWorkWith.Add(sData & "`" & sPart2)
- LabelPath.Text = DirChooser1.SelectedPath
- .Height = 575
- .Width = 1100
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .Layout = [70, 30]
- .Padding = 2
- .Height = 28
- .delay = 250
Posted
Administrator

Here's the output of df if it helps any.
Code
$ df -aTh
Filesystem Type Size Used Avail Use% Mounted on
sysfs sysfs 0 0 0 - /sys
proc proc 0 0 0 - /proc
udev devtmpfs 7.8G 0 7.8G 0% /dev
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 1.6G 58M 1.6G 4% /run
/dev/sdd2 ext4 110G 8.0G 96G 8% /
securityfs securityfs 0 0 0 - /sys/kernel/security
tmpfs tmpfs 7.9G 54M 7.8G 1% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
cgroup2 cgroup2 0 0 0 - /sys/fs/cgroup/unified
cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore pstore 0 0 0 - /sys/fs/pstore
efivarfs efivarfs 0 0 0 - /sys/firmware/efi/efivars
bpf bpf 0 0 0 - /sys/fs/bpf
cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices
cgroup cgroup 0 0 0 - /sys/fs/cgroup/freezer
cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids
cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup cgroup 0 0 0 - /sys/fs/cgroup/rdma
cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory
cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup cgroup 0 0 0 - /sys/fs/cgroup/blkio
systemd-1 - - - - - /proc/sys/fs/binfmt_misc
mqueue mqueue 0 0 0 - /dev/mqueue
debugfs debugfs 0 0 0 - /sys/kernel/debug
hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages
/dev/sde2 ext4 720G 516M 682G 1% /Recovery
/dev/md0 ext4 196G 62M 186G 1% /Shared
/dev/md1 ext4 720G 160G 524G 24% /Storage
/dev/sdd1 vfat 285M 5.1M 280M 2% /boot/efi
/dev/sde3 ext4 55G 3.4G 49G 7% /home
tmpfs tmpfs 1.6G 12K 1.6G 1% /run/user/1000
fusectl fusectl 0 0 0 - /sys/fs/fuse/connections
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
sunrpc rpc_pipefs 0 0 0 - /run/rpc_pipefs
nfsd nfsd 0 0 0 - /proc/fs/nfsd
binfmt_misc binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
1 guest and 0 members have just viewed this.


