How can i fix on APL2 the generated error code AP211-10 - host

A procedure on APL2 returns the error AP211-10 when it tries to execute a sentence VLIST. When it writes the file, it seems not to have enough space. Where do we have to change the parameter?
In the IBM doc AP211-10 means a problem in I/O file. And it seems related with the common error B37.
The expected result is the creation of the file correctly but actually the file created is corrupted and it is not possible to open on APL2.

Related

Writing in the executable while running the program

I'm writing a C program and I would like to be able to store data inside the executable file.
I tried making a function to write a single byte at the end of the file but it looks like it can't open the file because it reaches the printf and then gives "segmentation fault".
void writeByte(char c){
FILE *f;
f = fopen("game","wb");
if(f == 0)
printf("\nFile not found\n");
fseek(f,-1,SEEK_END);
fwrite(&c,1,sizeof(char),f);
fclose(f);
}
The file is in the correct directory and the name is correct. When I try to read the last byte instead of writing it works without problems.
Edit: I know I should abort the program instead of trying to write anyway but my main problem is that the program can't open the file despite being in the same directory.
There are several unrelated problems in your code and the problem you're trying to solve.
First you lack proper error handling. If any function that can fail (like e.g. fopen) fails, you should act accordingly. If, for example you did
#include <error.h>
#include <errno.h>
...
f = fopen("game","wb");
if ( f == NULL ) {
error(1,errno,"File could not be opened");
}
...
You would have recieved an useful error message like
./game: File could not be opened: Text file busy
You printed a message, which is not even correct (the file not beeing able to be opened is somthing different, than not beeing found) and continued the program which resulted in a segmentation fault because you dereferenced the NULL pointer stored in f after the failure of fopen.
Second As the message tells us (at least on my linux machine), the file is busy. That means, that my operating system does not allow me to open the executable I'm running in write mode. The answers to this question lists numerous source of the explanation of this error message. There might be ways to get around this and open a running executable in write mode, but I doubt this is easy and I doubt that this would solve your problem because:...
Third Executable files are stored in a special binary format (usually ELF on Linux). They are not designed to be manually modified. I don't know what happens if you just append data to it, but you could run into serious problems if your not very careful and know what you're doing.
If you just try to store data, use another plain and fresh file. If you're hoping to append code to an executable, you really should gather some background information about ELF files (e.g. from man elf) before continuing.

LuaSockets library will not correctly load

So, I've been annoyingly trying to work with LuaSockets2.0.2, and when I try to use it, I get the following error:
lua5.1: /media/pi/Cruzer/Lua/flywheels.lua:7: module 'luasocket.c' not found:
no field package.preload['luasocket.c']
no file './luasocket/c.lua'
no file '/usr/local/share/lua/5.1/luasocket/c.lua'
no file '/usr/local/share/lua/5.1/luasocket/c/init.lua'
no file '/usr/local/lib/lua/5.1/luasocket/c.lua'
no file '/usr/local/lib/lua/5.1/luasocket/c/init.lua'
no file '/usr/share/lua/5.1/luasocket/c.lua'
no file '/usr/share/lua/5.1/luasocket/c/init.lua'
no file './luasocket/c.so'
no file '/usr/local/lib/lua/5.1/luasocket/c.so'
no file '/usr/lib/arm-linux-gnueabihf/lua/5.1/luasocket/c.so'
no file '/usr/lib/lua/5.1/luasocket/c.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './luasocket.so'
no file '/usr/local/lib/lua/5.1/luasocket.so'
no file '/usr/lib/arm-linux-gnueabihf/lua/5.1/luasocket.so'
no file '/usr/lib/lua/5.1/luasocket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/media/pi/Cruzer/Lua/flywheels.lua:7: in main chunk
[C]: ?
Running it with only Lua gives me the same problem. I read through the LuaSocket documentation, checked over my third-edition Lua book, and tried to do a handful of other things, but I didn't get any different results.
I'm trying to make something that will allow me to send a TCP message to an IP to first see if it's up, and second, see if it will send back data, as it's for an experiment/project thing I'm doing. I'm also using a Raspberry Pi 2+.
I understand that it says it's missing these Lua files. local socket = require("sockets") gives me a similar error, and trying require("socket") or require("sockets.lua") all still give me an error. Nothing currently appears to work, so what should I do?

Why RegSaveKey() fails with an error code 5 (access is denied) if the key to be saved is HKEY_LOCAL_MACHINE?

This question is independent of the programming language used.
Tested in Windows 7 SP1 and Windows 10 version 1803.
Symptomps
RegSaveKey() fails with an error code 5 (access is denied) if the key to be saved is HKEY_LOCAL_MACHINE.
This error does not occur if a subkey is specified, e.g. HKEY_LOCAL_MACHINE\SYSTEM.
This error also does not occur if the key is HKEY_CURRENT_USER.
First Sample
Here, I use AutoIt to rapidly write a sample code that reproduce the error. I have also compiled the sample code to .EXE to make people easily look at the problem.
Second sample
REG.EXE, which is a built-in Windows tool written using Visual C++ (that's why the tags include C), have exactly the same problem as mentioned above. This is not surprising since according to my investigation, REG.EXE SAVE command actually use the undocumented NtSaveKey(). By the way, RegSaveKey() is internally make a call to NtSaveKey().
REG.EXE SAVE "HKLM" "HKLM.hiv" /Y
The above command fails with an error "Access is denied". Note that I run the command as Administrator.
Question
What is the cause of this error? Is there a way to make RegSaveKey() works for HKEY_LOCAL_MACHINE (without specifying a subkey)?
Update
My further test shows that regedit.exe have the same problem as mentioned above.
Exporting HKEY_LOCAL_MACHINE to a .HIV file fails; however, exporting it to a .REG file succeeds.
Exporting HKEY_LOCAL_MACHINE\<subkey> to a .HIV file succeeds.
Exporting HKEY_CURRENT_USER to a .HIV file succeeds.
Exporting HKEY_CURRENT_USER\<subkey> to a .HIV file succeeds.
All APIs that save a registry key internally call CmSaveKey. In the source code for this function, we see the following block of code at the beginning:
//
// Disallow attempts to "save" the master hive
//
Hive = KeyControlBlock->KeyHive;
if (Hive == &CmpMasterHive->Hive) {
return STATUS_ACCESS_DENIED;
}
HKEY_LOCAL_MACHINE (i.e. "\Registry\Machine") is in the master hive, so CmSaveKey returns STATUS_ACCESS_DENIED (0xc0000022) to the caller. The Windows subsystem translates this status code to ERROR_ACCESS_DENIED (5).

Error listing directory: Invalid Argument to date encode [3082-80-91]

Currently working with WinSCP through the command line. Simple process that when run, copies remote files to local directory. I get a good way through the first-time download of files when I encounter this error:
Error listing directory '/FE_HDD_SyncFolder/Diags Old PC and Tape/DIAGS NON DG/QAPLUS 5.5 pc diags'.
Unexpected directory listing line 'EMM386.EXE////120926/0/0/3082/80/91/40/24/1/1/1'.
Invalid argument to date encode [3082-80-91]
(A)bort, (R)etry, (S)kip: Abort
I am unsure what it means and I can't find any other questions here that give a straight answer to what this error means. Is the [3082-80-91] the error code or the date that the code is reaching and reading it as invalid?
Let me know if you need anything else to answer the question.
Thanks again!
EDIT: Tried doing it though the client. I get the same error. With the client I can skip the file causing the error. I did that and the rest seems to be downloading just fin. Maybe it's just that specific file that is causing the error? Still don't know what the error is so if someone could lend a hand still, I'd appreciate it.

Possible reasons of linux open call returning EINVAL

I am trying to make a system call in my source code as follows.
int file;
file = open(argv[index], O_RDONLY);
Where the command line arguement is a path to a binary file in my filesystem. But this call throws me an EINVAL error. I have checked the existence of file and the required permissions to access it.
Any suggestions on what circumstances the EINVAL error will be thrown out.
The official documentation suggests that this is because your implementation of open() does not support synchronized IO for the file you are trying to open.
Cause of failure:
There were two processes say (process-1 and process-2) that were executing in close sequel and was trying to open this binary file. Since my system (embedded device) will crash after this open call, the debugs splitted out weren't proper and it made me to suspect the process-1. But the actual culprit is process-2 who was opening the binary with O_RDWR flag. But my file system (network mount) was mounted as "read only file system".
Points to be taken care:
Refining the perror prints it should be the right cause of the problem as "Read Only File System". So my initial perror description must be a uncleared value of any of the previous erroneous call. One learning here is to use perror with care, so as avoid analysing misleading error message.
Possible circumstances the EINVAL error will be thrown out:
The open call will show an EINVAL if we use O_SYNC (or) related flags for the file which we are not supposed to use. I conclude this based on the documentation as previously mentioned by Rafe.
If you are sure that argv[index] actually contains the filename and that O_RDONLY hasn't been overridden somehow (O_RDONLY should equal 0), check your system log via the dmesg command and make sure that nothing funky has happened in-kernel.

Resources