I am trying to write to a system file under /sys/kernel/config/usb_gadget
with fs.writeFileSync
but when writing ""
as the contents, the file remains unchanged (with original contents in tact) and results in
Error: EBUSY: resource busy or locked, write
at Object.writeSync (fs.js:581:3)
at Object.writeFileSync (fs.js:1275:26)
at Socket.<anonymous> (/opt/sterling/ip-kvm-interface/app.js:249:6)
at Socket.emit (events.js:210:5)
at /opt/sterling/ip-kvm-interface/node_modules/socket.io/lib/socket.js:528:12
at processTicksAndRejections (internal/process/task_queues.js:75:11) {
errno: -16,
syscall: 'write',
code: 'EBUSY'
}
when writing some other contents. Permissions for the destination write file are 777.
Is fs.writeFileSync
incapable of writing to files under sys
or am I missing something else?
Using fsuser /sys/kernel/config/usb_gadget/kvm-gadget/UDC
returns nothing (even when Node process is running) and lsof | grep /sys/kernel/config/usb_gadget/kvm-gadget/UDC
also returns nothing.
Am I going to have to spawn
an echo
process to get this to work (not preferred but crossed my mind - since not sure how I would convert it to synchronous task)?