machinekit-hal icon indicating copy to clipboard operation
machinekit-hal copied to clipboard

sysfs pci enable vs enabled

Open ArcEye opened this issue 7 years ago • 1 comments

Issue by jepler Thu Oct 30 12:29:33 2014 Originally opened as https://github.com/machinekit/machinekit/issues/352


Over in LinuxCNC we ran into a problem running POSIX realtime on newer realtime kernels, such as 3.14, becaues of an accidental incompatible change in the kernel: the sysfs "enable" file was renamed "enabled". I suspect this will affect you as well when your uesrs try newer kernels.

Our patch for the issue is not finalized and would not apply on machinekit anyway, but in its current form it involves a function that looks somehting like this:

char *get_sys_enable_path(const rtapi_pci_dev *dev, char *path, size_t npath) {
    snprintf(path, npath, "%s/enable", dev->sys_path);
    // kernel 3.12 renamed this file to "enabled"... doh
    if(access(path, F_OK) < 0)
        snprintf(path, npath, "%s/enabled", dev->sys_path);
    return path;
}

with opens of the file changed to use the new function

-    snprintf(path, sizeof(path), "%s/enable", dev->sys_path);
-    stream = fopen(path, "w");
+    stream = fopen(get_sys_enable_path(dev, path, sizeof(path)), "w");

Finally, just waiting (or patching your kernels) may suffice. I raised the issue with kernel developers and quickly got a note that they will fix it in various stable kernels: http://thread.gmane.org/gmane.linux.kernel/1817337/focus=36499

I hope this information is helpful to you.

ArcEye avatar Aug 04 '18 14:08 ArcEye

Comment by ArcEye Wed Aug 1 14:31:07 2018


Retain for evaluation, but suspect long overtaken by developments in rt kernels, now on 4.18-rt

ArcEye avatar Aug 04 '18 14:08 ArcEye