One possible solution is to check /proc/mounts if it contains exact path that you expected to be mounted.
I looked into file /proc/mounts and it seems to work. But I'm afraid to "disturb" the Operating System when I open that file while reading:
function isMounted: boolean;
var f1: text;
s: ansistring;
begin
assign(f1,'/proc/mounts'); reset(f1);
while not eof(f1) do
begin
readln(f1, s);
if pos(' /media/C ', s) > 0 then begin close(f1); exit(true); end;
end;
close(f1); exit(false);
end;
What do the experts say? Is this "dangerous" or not?Or you could use fpStatFS() and check the result for congruence.
I tried function fpStatFS from Unit Unix:
procedure Test_fpStatFS;
var info: TStatFs;
i: longint;
begin
fillchar(info,sizeof(info),0);
i:=fpStatFS('/media/C/', @info);
writeln('i=', i);
end;
Result 'i' was always 0.
if mounted =>
INFO={FSTYPE = 1702057286, BSIZE = 4096, BLOCKS = 1048233, BFREE = 106248, BAVAIL = 106248, FILES = 457760, FFREE = 438097, FSID = {0, 0}, NAMELEN = 255, FRSIZE = 4096, SPARE = {4142, 0, 0, 0, 0}}
if not mounted =>
INFO={FSTYPE = 61267, BSIZE = 4096, BLOCKS = 6417977, BFREE = 1245557, BAVAIL = 913781, FILES = 1638400, FFREE = 1111304, FSID = {-1900541924, -1966772697}, NAMELEN = 255, FRSIZE = 4096, SPARE = {4128, 0, 0, 0, 0}}
How do you think that I can distinguish mounted state and not mounted state?