Recent

Author Topic: [Solved]Linux: list of all the existing the UNC network shortcuts ("smb://...")?  (Read 519 times)

devEric69

  • Full Member
  • ***
  • Posts: 150
Hello,

I am under Linux \ Ubuntu desktop 18.04, on which I've created 2 UNC network shortcuts (one to another Linux machine and one to a Windows machine), both are therefore operational and of the type "smb://@IP/rep_shared".

Now, I would like to store all these shortcuts in a TStringList for example, but I don't see which text file to iterate to get them back (I found that it would be stored in the /etc/mtab or /etc/fstab file, but that's not the case).
Does anyone know a file to iterate in Laz. to get them, or another method (currently, I type these Samba addresses into the Nemo file manager, and they are created if the target machine is turned on, what I find practical;or am I totally forced to enter them manually in fstab, which I find more "static")?

« Last Edit: June 17, 2019, 05:22:21 pm by devEric69 »
use: Ubuntu 18.04 + Laz. 1.8.5 + FPC 3.0.5 (64 bits).

devEric69

  • Full Member
  • ***
  • Posts: 150
Well, finally, I create in the etc/fstab file, the network shortcuts that I find useful for starting the machine, aka permanent mounting points. Then, I iterate this file (bulk use of JclFileUtils and JclSysUtils where I commented all the functions not compiling because they are strictly dedicated to Windows, to be able to use _PATH_MNTAB, GetAvailableFileSystems, ..., and getmntent_r which returns each line of the fstab as a record).
- entries with a MNT_FSNAME='UUID=.../...' are " volume mount points " ('/',' /home',' swap', etc).
- entries with a MNT_FSNAME='//x.x.x.x.x.x/rep_shared' are " UNC network shortcuts mount points " created with the command "mount -t cifs .../...".
« Last Edit: June 17, 2019, 05:27:28 pm by devEric69 »
use: Ubuntu 18.04 + Laz. 1.8.5 + FPC 3.0.5 (64 bits).

lucamar

  • Hero Member
  • *****
  • Posts: 2084
Wouldn't it be easier and less error prone to just parse the output of mount or udisks?

Or you could also interate the mount points root (v.g. /media/) checking the type of each "file".
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.