How can I modify, compile and install tun.ko? - linux-kernel

I've never compiled a single kernel module. I would like to understand how to change the source of a kernel module, compile and install it on Debian SO.
Can someone illustrate the steps or tell me a tutorial about it?
Thank you and everyone.

This question is a bit confusing since a .ko file represents a kernel object. In other words, it has already been compiled.
To edit the module you would need the source code, most likely tun.c and some related files.
StackOverflow is more meant for specific questions to be answered, not a tutorial site. Please do some research about Linux modules and make an attempt to install the module yourself. Some good sites for beginners:
kernel.org
https://www.oreilly.com/library/view/linux-device-drivers/0596005903/
http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/
The last of these is the least comprehensive, but quickest to get you up and running. Once you get to the point where you have detailed questions, post them here and you will get better help.

Related

Error in Quantum Espresso configuration with libxc

Please let me know if there's a better place to ask this question. I'm new to the field and know absolutely nothing.
I'm trying to configure quantum espresso with libxc, and no matter what I do I seem to get the same error: 'configure: error: Could not find required libxc library'. I downloaded the libxc source and followed the installation instructions on this website: https://tddft.org/programs/libxc/. I can't seem to find any errors in the installation but I really have no idea what I'm doing so it's possible.
Configuring quantum espresso with the './configure' command and then making PW, everything works fine and I can use quantum espresso just find without the libxc library. Adding the --with-libxc flag, no matter what I put for --with-libxc-prefix flag, I always get the same error pictured below.
I'm working through ssh on my research group's supercomputer. This is my first time using a unix interface, I know nothing about compilers or anything like that, I have absolutely no idea how to solve this problem, I can't seem to find any solutions that work on the quantum espresso forums, and I feel extremely stuck. Any help is appreciated.
One needs to compile both programs with the same compiler. My default was using gfortran for one and ifort for the other.
A good place to ask these kinds of questions is to the mailing list listed here: https://www.quantum-espresso.org/users-forum/

Compiling and debugging erlang code- for custom ejabberd modules?

This is a very specific and niche question- but something that'll probably help people working on existing codebases.
Current Scenario
We are running ejabberd 18.01 on prod- and we can't really change this right away. Our current setup for running custom modules is this- either modify existing modules from the source code, or make our own custom modules that are compiled using the erlang compiler that's bundled in with the installer from here. We use erlide as our IDE in Eclipse.
We compile the custom files in in erlide, into a separate directory from where our ejabberd .beam files are; and then transfer the files manually from there to the ebin folder in ejabberd. This is done so that we have VCS for our modified module files.
We aren't using rebar3, and I have zero clue as to how to implement in a heavily modified existing codebase without breaking something. Our only legitimate way of debugging is to put loggers at every step of the process, compile, transfer files, and restart the server- which drastically increases dev time.
It is a genuine nightmare to work with, and resources on ejabberd as well as erlang is scarce- we mostly have the docs to go by, and barely any SO questions relevant.
Any suggestions, resources that can help me setup something to help especially for debugging, would be highly appreciated. Maybe something in vscode would be great. Transferring files I've still managed with inotify, but debugging makes me want to tear my hair out. Please help. Thank you.
P.S.- This is all on Ubuntu 20.04, if relevant. Erlang/OTP version - 20.02, erts- 9.2. Please ask for any further clarifications if required.

Installing caffe brings up some questions, depending libraries and versions

I wanted to install caffe on openSuse.
Just for the record - it worked out for me, I just don't know what's the "exact" way to do this. The things I did maybe aren't really for someone who's new to this, and also it was kind of a "bad installation". My way was the following:
First, I did
make all
This worked, until it complained that some libraries weren't found (libclbas etc.). So I used
ccmake .
to change the paths to the libraries manually. I needed to manually type the paths to the snappy, boost_python, blas, cblas and lapack libs. After doing that I did
cmake .
and then
make
and everything worked. My problem now is - why doesn't make find the libs, and is there a way to fix this? I think the problem was that I didn't have /usr/lib/libcblas.so but /usr/lib/libcblas.so.3, and similar "problems" with the other libraries.
Another thing - when I tried using ccmake/cmake right from the beginning (without the make part first), there weren't any files in my build directory (like $CAFFE_ROOT/build/examples or $CAFFE_ROOT/build/tools were empty), so the mnist tutorial for example wasn't working. That's why I first called
make all
, what may seem strange to you.
Of course I know how to fix this stuff, but I would like to know how the correct way for a "clean and simple installation" is. Did is miss anything when using make/cmake, is this some kind of inconsistency in caffe or something else? And, what is the clean way to do this?
Maybe look at the Ubuntu installation guide? http://caffe.berkeleyvision.org/install_apt.html
It mentions all the different packages you might need. I couldn't find openSuse installation instructions - but you should be able to translate the apt-get commands for your platform.

Dependency solution when make/compile error from source code

Very often we need to install software from its source code. Most of the time I just hit "make world" or "make all" then it will work like a charm. But some other time we see make errors, and we need to install other packages in order to let the make go through. This is particularly a problem for compiling low-level systems, such as a Linux kernel or Xen hypervisor.
I have one experience with Xen 3.4. Maybe it has been documented in some corner documents, but it depends on udev-125 to work properly. The weird thing is it functions well most of the time when udev version is 160+, it only breaks in certain cases! It took me a few MONTHS to find out it was because of the wrong udev version!
To make developers' life easier, when a source code is made successfully in one machine, is there some tools to record the list of packages and versions of that machine? Such a 'snapshot' should be shipped with the source code as well, so that when someone meets the make error they at least have a successful 'snapshot' for reference.
Is there such a tool already?
If your software depends on a specific version of a dependency, you should write a check for your configure script/cmakefile/etc. that tests the version of the dependency and bails out if the wrong version was found.
Comparing the output of config.log (a file created by a configure script) can also help diagnose problems like you encountered.

How to patch linux kernel to add gyroscope support

I'm trying to use MPU3000/3050 by Invensense with embedded linux (ARM-based LPC3141 board, Embedded Artists).
I found this interesting patch on the Internet
https://patchwork.kernel.org/patch/703991/
how can I implement it in my kernel?
Read this article for detailed instructions on how to apply a patch.
Warning: kernel patches are quite often highly specific to the version of Linux they were developed for, so if your kernel version is different from the one the patch was originally made for you may encounter some problems.
Edit: I had a look at this particular patch and essentially it creates a new file (mpu3050.c) and modifies drivers/input/misc/Makefile and drivers/input/misc/Kconfig. Even if everything else fails the new file should be created, and the mods to the existing files can probably be done manually.
I don't know about the details, but you should download the kernel from www.kernel.org, patch it with the 'patch' utility and configure it to compile it. You should search some manuals for the configuration.
I am not sure if you already knew this, though.

Resources