Recent

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

devEric69

  • Hero Member
  • *****
  • Posts: 648
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: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

devEric69

  • Hero Member
  • *****
  • Posts: 648
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: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018