Creating system call in Minix3 - minix

I have a problem about system call in minix3.I have to create a system call which is called "deneme" and when i execute this system call, it should print the content of top command (for example. PID,usernama,size ..).
Can anyone prepare a list for the steps.I made somethings but I get error in makefile files.

Related

Code executed using load()() cannot access functions from its caller

So I am writing and testing my new OS kernel and just finished the part where it loads up /bin/init.lua, I tested it, it loads up init.lua, andddd it exit mid-execution. I have a function in init.lua where it prints out test message, but it need to access two specific function from the kernel but it cannot seem to access it. Any idea how to make a code executed by load()() be able to access functions from its caller?
Just in case you need to see the source code: https://github.com/WattanaGaming/OCLinux/blob/master/boot/kernel/OCLinux.lua#L86

attempt to index field '' (a nil value)

I was trying to run this script done by SethBling, but it gives me this error:
LuaInterface.LuaScriptException: DP1.state
LuaInterface.LuaScriptException: [string "main"]:337: attempt to index field 'neurons' (a nil value)
This is the code
In case this didn't solve your problem try this:
"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load." from JaRetroYT over on reddit.
A flamanis posted this comment on youtube. I followed the instructions and got it working.
HOW TO GET IT TO WORK! THIS ALL TAKES PLACE INSIDE THE FOLDER YOUR BIZHAWK EMULATOR IS IN.
Execpt this part: Before EVER opening the lua console on BizHawk,
(If you have, instructions on how to reset your stuff will be at the
bottom) go onto the level you want to have it learn, and when the
level starts up, click on file. Go down and open the menu of save
state, at the bottom click the create named state, and then finally
name it DP1, however put it after all the slashes and whatever so just
delete the gamestate.whatever jargon that it auto names it. After
doing that, either move that file from the SNES/State folder to where
you have your lua file, or the other way around. and then load up the
lua file into the console, and boom you're good.
IF YOU ALREADY TRIED TO RUN THE LUA FILE AND IT ERRORS: You either need to delete your save, or edit the lua file slightly. If you want to do the delete save approach, then go into the SNES folder and then into the SaveRAM
folder and delete your file for the game. THIS DOES NOT DELETE THE
EMULATION, just the save. If you want to edit the lua file, then at
the top, the very top line, (create a new one if you want to, just
make sure it's before any other text) add this: pool = nil that's it.
It will reset the data so that it can run again. You still need that
save state though. You will probably want to edit the file again after
you've started running it and remove that line or it will restart
every time you turn it on.
Alrighty, I said I'd answer this better, and sometimes people do just google randomly for their solutions.
Soo, Bizhawk emulator has a way to run Lua scripts, which is nice.
So Seth's program assumes a few things about how the game is set up, and how the user (that is you) has done certain things beforehand.
The main thing that you need to do beforehand is create what is known as a save state. This is a point in the game that you can instantly reload back to, and how the program restarts the level so that each 'run' is essentially the exact same. This differs slightly from normal games where you 'load' the game, because games back around SMB weren't as 'random' as games now. So saving the game and loading it should give the same exact result with the same inputs every time.
You should create the save state right at the very start of the level. To create this illustrious save state you want to click on the file button at the top of your screen to open the drop down, and then select save state and create a new one. This should create a save state that you can then load to return to that exact moment in the game.
To have the program be able to load your save state to run you can do one of two things
1: Rename the actual save state file name to be just DP1.savestate
2: Modify the Lua file and change the DP1.savestate part to be the name of your save state
Then you just need to move them into the same folder, and you should be golden.
If you attempted to run the file before making a save state, it will have tried to run and errored with attempt to index field 'neurons' (a nil value) or something similar. (It's been a while, it could have stopped on the first run because it couldn't find the save state, so this might just only happen on the 2nd and further runs)
What this means is that it essentially created it's "brain" but left it completely empty. Which is bad. There's two ways to fix this, and they're fairly straightforward.
1: You need to delete the actual game save, otherwise known as the SaveRAM. The file that you need to delete can be found in the folder for whatever console you're running, in Seth's video he was using the SNES, so that's the folder you'd want to go into. Inside that folder is then the SaveRAM folder, you can either just delete that folder, or go into it and delete the one for the game you were running.
2: You need to edit the Lua file to reset itself, all this requires is putting the text pool = nil at the very top. This will then delete the "brain" before anything else happens, which will let the program create a new one. Fair warning: This is not just a one time effect, if you restart the program at this point you will lose your entire progress. What you need to do is after it starts running, stop it and edit the file again, and remove the line you just added. This will stop it from deleting it's "brain" every time the program starts, and you should be able to freely run the game.
I do hope that there are still people who look at Seth's video and wants to make it run themselves, good luck to you guys, and happy gaming.
"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load."
from JaRetroYT over on reddit.
Move the savestate and lua script to the main folder for the emulator (where EmuHawk.exe is)

Run lua dissector and tap in tshark at the same time

I have a custom dissector (written in Lua) that I am using in many aspects of my current project.
I would also like to write a tap to perform some specific calculations for a particular task. I would like to keep this separate from the general purpose dissector for purposes of modularity.
Is there a way to invoke a dissector and a tap, both written in Lua, from the tshark command line? More generally, can an arbitrary number of Lua scripts be invoked, and if so, will they get invoked in the correct order?
EDIT:
I have tried invoking the two scripts from the command line:
tshark -Xlua_script:my_diss.lua -Xlua_script:my_tap.lua -r my.pcap
But I get an error:
tshark: Lua: Error during loading:
[string "my_tap.lua"]:9: bad argument #1 to 'new' (Field_new: a field with this name must exist)
The field name that this line refers to is created in my_diss.lua, but it is apparently not visible when my_tap.lua is being loaded.
That would require that the "initialize Lua" code in libwireshark be told which Lua scripts are dissectors and which Lua scripts are taps, and load them at the appropriate time so that, for example, all dissectors are loaded before all taps.
That means Wireshark would have to be changed; please file an bug at the Wireshark Bugzilla for this.
This is now supported in the wireshark codebase (version 1.8.5). I built from source and was able to get the desired behavior.
The relevant issue is: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6020
The relevant commit is: http://anonsvn.wireshark.org/viewvc?view=revision&revision=47877

I just want to call some specific function in my Lua script. How to do that?

I just want to call some specific function in my Lua script.
A simple script:
msg("hello")
function showamsgbox()
msg("123")
end
I just want to let my C app call showamsgbox() only but not to run msg("hello") beacuse it will show a msgbox when i load this script! So how to do that to keep this situation away?
PS:it is just example.sometimes i want to let users make thier own plugins in my program.but I do not want them write something outside the functions(i want to use functions to decide what to do.for example function OnLoad() means it will be run when i load it ).If there is something outside functions i cannot control them!
You can't. The script defines two variables when run: a and geta. Recall that function geta()...end is the same as geta=function()...end.
The a = 9 will be called when the script is initially evaluated in a lua_State.
If you reuse that lua_State instance, you can retrieve the function and invoke it without re-initializing a.
It seems that you want to sandbox scripts. Just give them a suitable, separate environment before running them. It may be an empty one or it may contain references to the functions you want them to use. They can write at will in their environment and it will not affect yours. Then just get the value of OnLoad or whatever user function you want to call and call it.

Change directory using os:cmd/1

I am trying to change the directory in the command line from a gen_server using
os:cmd("cd d:\temp").
but nothing happense, the return is just an empty list and I remain in the same directory.
any ideas?
Try using file:set_cwd(Dir) to change your current dir.
cmd() runs a sub-shell, which you're telling to change directory, then the sub-shell exits, having changed nothing about its parent process's environment.
You want to use cd() instead, if you're in the shell, or file:set_cwd() at runtime within an Erlang program.
Another option, if you want to run another program and have its working directory be different from the one Erlang is using is to pass the {cd, Dir} tuple to open_port().

Resources