Character Driver Unload Fails - driver

I was looking for an inbuilt character driver in Linux, I found the relevant driver in the device (/dev) list, The character device is with Major number 4 (tty), but I'm unable to unload that character driver, I tried using following command
rmmod Modulet1
But when I try this it gives me an error:
Error: Module Modulet1 is not currently loaded
Could someone assist me with this issue?
I was also looking for associated driver code for this module; does anyone have any idea about this?

You can not unload a built-in module. Built in modules are compiled along with the kernel and loaded on kernel boot up. Only loadable module can be insmoded and rmmoded.
Also, lsmod doesn't show you the in-built modules.
For this particular driver, look into this file: http://lxr.free-electrons.com/source/drivers/tty/tty_io.c
Before you go through that code, you might want to look into the tty driver structure: http://www.linuxjournal.com/article/5896

Related

wireshark lua debug.getinfo is nil

I'm currently writing some dissector for Wireshark in Lua. The Lua code has become quite large. Because of that I'm splitting it up into multiple files (modules). I got that working. By the way my goal is that the user just needs to copy the files into the plugins directory so that the dissector is automatically loaded every time Wireshark is started.
Now, to gain access to the other files from the "main file" I need to do this:
package.prepend_path(".\plugins\3.3\modulesDir")
local mymodule= require "module"
This works fine, but it has some disadvantages. Most importantly if a user uses a different version of Wireshark I need to change the path in the Lua code. Same if it's a different directory (Linuy, Mac OS).
To get around this I did some research on how to get the path of the current Lua file and came up with this:
local moduleDir = debug.getinfo(2, "S").source:sub(2)
moduleDir = moduleDir:match("(.*[/\\])")
This works platform indepedently, so it looks to be the perfect solution for what I want. If I execute this using Wireshark > Tools > Lua > Evaluate it work perfectly fine.
BUT: If I do it in the Lua file (which is my dissector) then I get the error "attempt to index a nil value". I tried various different versions of this line but it always appears that the debug table is nil. I'm using Wireshark version 3.3.
Has anyone an idea how to get it running? Or a different approach to getting the directory where the Lua file is in? Thanks in advance.
If you are looking for "global configuration directory" then you can use Dir.global_config_path(). Here you have that init.lua is in this path, and here lua function dtails.
On Windows, I have my Lua files in the "Personal Lua Plugins" directory, which when you look at Wireshark's "Help -> About Wireshark -> Folders" dialog, is just %APPDATA%\Wireshark\plugins. So, perhaps you can just move your folder from path\to\plugins\3.3\modulesDir to just path\to\plugins\modulesDir?
I believe you will then only require:
package.prepend_path("modulesDir")
And this will allow your Lua dissector and modules to work not only with the Wireshark 3.3 development version, but also future releases as well. And if your dissector can't work with older versions of Wireshark for some reason, you can always do something like:
if get_version() < "3.3" then
return
end
Lastly, have a look at how Hadriel Kaplan solved this for his protobuf.lua dissector, where his required modules are in the "modules" directory. It's basically as I've described above. See: https://github.com/128technology/protobuf_dissector

.kmod and .ko - difference?

Have been using Ndisgen to try to generate a .ko kernel module for an rtl8192se driver for my Freebsd 9 netbook having followed instructions found on several different dev blogger sites.
Somehow, i've just not been able to generate a file with extension .ko. Instead, i keep getting a .kmod file.
Question is, what is the difference between these ?
I have also attempted kldload for this .kmod file. When i check it via kldstat, ok, i see it there but, when i then check with dmesg and pciconf -lv, my realtek card is still not hooked up.
So i reckon i really need to generate the .ko file in the first place, but what am i doing wrong or missing, such that only a kmod is generated?
Any pointers would be appreciated! thanks! :)
Update::
There was a message I had ignored.
My bad!
the message after conversion was :
"...Cleaning up... rm: machine: is a directory cleanup failed.Exiting"
That's all because i had pasted a copy of the "/usr/include/machine" folder with all the headers i thought was required in the path where I was converting the driver.
But i ignored it thinking, well since ndisgen had already created a .kmod file(which was what I had assumed was also a kernel module, just not in .ko form) then it was alright.
SO finally, since it's complaining that it's a directory and can't be cleaned, i then created a symbolic link to that folder instead.
Et voila! the clean was successful and now i have the .ko file! :D
The ndisgen script renames the .ko file to .kmod temporarily to do some cleanup.
If that cleanup works, it should rename it back to a .ko file. See the drvgen function /usr/src/usr.sbin/ndiscvt/ndisgen.sh.
I'm assuming that something goes wrong in between both renames. Do you get any error messages?
Keep in mind that if you load the driver, it should show up as the ndis0 device!
Looks like you are getting a NetBSD kernel module, not a FreeBSD one. See these posts:
hubertf's NetBSD Blog
Modern net bsd kernel module
Is the source code that you are using available publicly for us to try follow your steps?

How to install ndiskd extension for debugging my driver?

I have a mini port network driver installed on my PC . I want to debug kernel mode to find the mistakes of my driver . i Know i can use WinDbg tool for getting logs but i heard about the Ndiskd extension . How to install this ? Is this a tool ? or can i use with command prompt or with WinDbg ? can i get setup by setup installation procedure ? what are the requirements needed ? i tried with WinDbg but i can't get the proper logs from that . So that's why i search on internet and got about the ndiskd .
ndiskd is a debugger extension for WinDbg (or ntsd or kd, whatever you like most). Once you know this, it's just a matter on how to load the extension. There are three ways:
.load ndiskd if it is placed in WinDbgs extension directory, which it is by default on my WinDbg 6.2.9200 and 9.2.9600 installations (winxp subdirectory). Use .extpath to see which directories are searched by default.
.load <full path\ndiskd.dll>
.loadby <reference module> ndiskd
I never used the latter in kernel debugging, the only real benefit is in .loadby sos clr, so I guess you go with one of the first two options.
Once you have done that, you can access the ndiskd debugger extension by its !-commands. To explicitly call such a command, use
!ndiskd.<command>
e.g.
!ndiskd.miniport

How is saveenv implemented inside u-boot?

I am trying to figure out which part of code inside the u-boot is responsible for writing to the device from the RAM, when we do a saveenv after setenv. I could find printenv and setenv, but not saveenv. Can someone please shed some light on it?
That depends on what nonvolatile storage the platform is configured for. In any case common/nv_edit.c will be built. But (for example) if env lives in SPI flash, then saveenv() in common/env_sf.c will get built and linked. Do "grep saveenv common/*.c" and you'll see other storage options (eeprom, flash, mmc, nand etc).
CONFIG_ options for any platform are in the appropriate .h under include/configs/. Compare ENV-related options with storage options, that should lead to the right part of code for your platform.

Connection issue in JayBird

I am new to Firebird using its Java version Jaybird, But unable to connect from database (.fdb file). The problem comes like this:
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544375. unavailable database
OR
java.lang.RuntimeException: Failed to initilize Jaybird native library. This is most likley due to a failure to load the firebird client library.
Using following code:
Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
connection = DriverManager.getConnection("jdbc:firebirdsql://localhost/3050:C:/XLNKREPOS /FIRBIRDXA.FDB", "SYSDBA", "masterkey");
Having following files in build path of Eclipse project:
jaybird-full-2.1.5.jar
jaybird21.dll
fbclient.dll
fbembed.dll
Also using the JVM arguments as -Djava.library.path="D:\Shared\Firebird\Jaybird-2.1.5JDK_1.5"
Tell me what is wrong in my approach?
Thanks RRUZ for giving repsonse.
Actually there was no space after "C:/XLNKREPOS" in my connection string, It was a copy past mistake. Again & again I got the following SQL Exception:
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544375. unavailable database
And that database is no where used in other program.
Hope my this post makes you understand my problem.
Thanks
The OP is mixing two jdbc url formats supported by Jaybird.
Either use
jdbc:firebirdsql://[host]{:[port]}/[path]
or
jdbc:firebirdsql:[host]{/[port]}:[path]
{...} used to indicate optional part
I think the problem must be the connection string, there is a blank space after "C:/XLNKREPOS"
Try this
connection = DriverManager.getConnection("jdbc:firebirdsql://localhost/3050:C:/XLNKREPOS/FIRBIRDXA.FDB", "SYSDBA", "masterkey");
Bye.
When I got this error it was because I was using x64 Firebird version instead of the standard x86 version. I thought since I was running a 64bit OS that those embedded binaries corresponded to me... Hopefully that fixes your problem.
Troubleshooting Tips:
I was also able to further diagnose additional Firebird problems by adding the latest log4j jar from apache's site to my project/classpath. I then added a log4j.properties file to my default/root src directory with the following properties set inside:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%c{1},%p] %m%n
log4j.rootCategory=DEBUG, stdout
log4j.category.org.firebirdsql=DEBUG, stdout
I also had to set System.setProperty("FBLog4j", "true"); in my code.
Another thing you can do is make sure you're running the latest and greatest from their repository at http://firebird.cvs.sourceforge.net/viewvc/firebird/client-java/?view=tar
Just unzip the tarball and compile it using their supplied build script (build.bat/build.sh). After compilation look in the 'output/lib' directory and you'll find the latest version of the jaybird jar (as of right now it's 2.2.0). You'll also need the latest jaybird dll (as of right now it's 22) which is located in the 'native' directory. I went through a lot of pain trying to figure this crap out. The documentation on Firebird's site is very outdated and poorly written.
I had the same problem, it was caused by those slashes before localhost.
That URL should be:
jdbc:firebirdsql:localhost/3050:C:/XLNKREPOS/FIRBIRDXA.FDB",

Resources