Reputation: 1175
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)?
Upvotes: 5
Views: 438
Reputation: 1175
https://github.com/nodejs/help/issues/2459
Are there undocumented limitations to fs.writeFileSync that I am unaware of?
Nothing specific to fs.writeFileSync(), you can get the same error with a plain C program.
/sys/kernel/config/usb_gadget is not a real file, it's a communication channel with the kernel's usb gadget driver. It's that driver that is returning the error.
(I could point you to the line of code if you're really interested. It's drivers/usb/gadget/configfs.c in the kernel source tree in any case.)
Upvotes: 4