Forum > Linux

[SOLVED] Accessing Disks in Linux seems no longer possible with FileOpen

(1/4) > >>

Hi guys

I have a program which, for some years, has been able to access disks in a Linux system (when run as root) using FileOpen which was written in FPC 3.0.4. I am still currently using FPC3.0.4 though I appreciate I really need to get round to updating to FPC 3.2.0.

Anyway, here is my FPC 3.0.4 example:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---hSelectedDisk : THandle;...    hSelectedDisk := FileOpen(SourceDevice, fmOpenRead OR fmShareDenyNone);if hSelectedDisk = -1 then    begin     ShowMessage('Could not get exclusive disk access ' +     'OS error and code : ' + SysErrorMessageUTF8(GetLastOSError));    end    else    .... 
However, users began to report access violation errors and having looked into it today, it seems FileOpen constantly returns -1 when trying to access /dev/sd devices now, even when run as root. I'm assuming this is something new to Linux where it is no longer possible to obtain a handle to physical disks using whatever powers FileOpen uses? 

Is there a new (new to me at least as I am clearly out of date) way to do this now? Have I missed some news somewhere (quite probably), or is it just no longer possible in FPC? Is FPC 3.2.0 the way to go to achieve this? 


Minimal standalone test program please. I've got a laptop next to me with a fairly old Debian on it so might be able to at least confirm your observation.

It would probably also be useful if you could get an idea of the kernel/distro version that the behaviour changed. As specific points, is it related to Linux starting to call all discs /dev/sd (rather than the older /dev/hd for IDE/ATA), or is it related to the introduction of support for SATA or something even newer?


Small correction with regards to your error description: fmShareDenyNone does not mean exclusive access.

Hi guys

I’ve just looked at another program where I use this which I know does work and I noticed it just hash fnOpenRead without the share sent etc. So I’ll make a change and see if it is related to the share permissions system. Perhaps that has changed in more recent times and that kind of access is no longer possible. I’ll report back later...

I'd not be at all surprised if it were something that the kernel has tightened up, I was looking at an ICMP library a few days ago which appears to not be available to root by default.

It might be worth your while investigating whether POSIX capabilities are relevant, but I /thought/ that by default all were enabled for the root user.



[0] Message Index

[#] Next page

Go to full version