readv from Socket returns ENOENT - linux

What can be the reason for a Linux socket to set the error to ENOENT on readv() ?
The socket in question is non-blocking and runs on Ubuntu 10.04

errno is only set when a system call returns -1. You should only read it after checking the return value of readv.

Related

Node.js: Writing to system files with fs.writeFileSync

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)?
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.)

When can fcntl() in Linux set errno to EIO?

When calling fcntl() with F_SETLKW, -1 is being returned and errno is being set to EIO. The man page for fcntl on Linux does not indicate that it can set errno to EIO. Various UNIX man pages I have found online reference that it is an input/output error.
What kinds of i/o issues in Linux can cause this errno value when calling fcntl()?

Child process spawn: Unknown system errno 740

If I execute just this one line:
require('child_process').spawn('C:\\Users\\me\\AppData\\Local\\Temp\\1131128-16232-bid56z__some_installer.exe').on('close', function (code) { });
Then I get an exception:
Error: spawn Unknown system errno 740
I'm at a loss. Can someone help me shed some light on this?
On Windows, error 740 (ERROR_ELEVATION_REQUIRED) means that the software needs to run as administrator. Run it with runas.

How to resolve error when read system call returns EIO on Linux

I have a file that was created by some other program (MySQL), but when MySQL starts up, it fails. So I make a strace on the start procedure and I see the following error:
read(3, 0x1310000, 32768) = -1 EIO (Input/output error)
As you can see, it returns -1 as error code and EIO as the errno. So I think it is a hardware failure (disk sector bad?); am I right? If so, how can I detect the problem? I have used smartctl and it tells HEATH. By the way, the filesystem is ext4.

Why a mismatch between errno 34 and code ENOENT

So if I run this simple call in node.js v0.6.7 on OS X 10.6.8 with a bogus path, I get an error, as expected.
var fs = require("fs");
fs.stat("/tmp/foo", function(error, stat) {
return console.log(error);
});
It prints this output:
{ [Error: ENOENT, no such file or directory '/tmp/foo'] errno: 34, code: 'ENOENT', path: '/tmp/foo' }
My question is, according to /usr/include/sys/errno.h on my system, ENOENT should have code 2, so why is this error saying errno 34 (ERANGE in errno.h), but pairing it with the error message from ENOENT?
node.js translates system errnos to internal "errnos" (see deps/uv/include/uv.h and uv_translate_sys_error in deps/uv/src/unix/error.c or deps/uv/src/win/error.c for a mapping) as to achieve a common representation for error-conditions under Windows and Unix.
34 is the node.js-errno for ENOENT, so everything is alright.
It seems that node.js changed the errno with 0.12.0. ENOENT is -2now.
So it is probably better to check for code === 'ENOENT'
because you haven't created the folder /tmp/foo yet and it's looking for that folder
(when i added a few error handling lines to my code, the console spat out the same error code and it was because i had not yet created the directory i was telling it to save my images to)

Resources