I'm trying to use the create_proc_entry() function to create a directory under /proc. When I try to compile the code, I get the following error: implicit declaration of function 'create_proc_entry' .
These are the headers I have included in my .c file:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#include <linux/uaccess.h>
The kernel version on the machine I'm trying to compile for is: 3.10.33-g7954807-dirty
Am i missing any headers necessary to call this method? Or is the method deprecated in my version of the kernel?
/proc filesystem has been refactored in 3.10, the function you are looking for has been removed, you should use the full featured proc_create function family. Note that the signatures are different.
3.10 version:
http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.10
3.9 version:
http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.9
You can find greater explanation of using full featured /proc functions in the book Linux Device Drivers 4, or, if you want shorter solution, check this link (https://github.com/jesstess/ldd4/blob/master/scull/main.c) where you can see how the struct file_operations has been used. You do not have to setup to all fields of the struct.
Related
I'm learning to create kernel modules on Raspbian Jessie based on The Linux Kernel Module Programming Guide
Currently I'm on hello-5.c part. I tried to add static u8 myByte = 'X'; but u8 is not recognized. Then I changed u8 with uint8_t which is the same thing AFAIK and uint8_t is recognized as a data-type.
The older version of the tutorial here stated static u8 myByte = 'X';, so I want to reuse it with the newer tutorial.
The older tutorial included these:
#define MODULE
#define LINUX
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
While the newer tutorial included these;
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/stat.h>
I've tried using the old one, but the define part generates errors, so I used the newer tutorial.
So, why uint8_t can be recognized while u8 cannot in the newer version?
Because u8 is not a standard type, while uint8_t is (typedef'd in C99 and later <stdint.h>). If you want to use u8, include a header with an appropriate typedef, or typedef it in your code.
I'm using QtCreator 3.3.2 on Ubuntu 14.04(i386), and Qt4.8.6.
The problem is just like what the title said and with a similar error:
'sleep' was not declared in this scope.
And these are headers included.
#include <QMessageBox>
#include <QDateTime>
#include <QDir>
#include <QDate>
#include <QTime>
#include <QFileDialog>
#include <QTextStream>
#include <QStringList>
#include <QFile>
#include <QIODevice>
#include <QFileInfo>
#include <QtGlobal>
Weird thing is there were no problems when I used Ubuntu 12.04 and QtCreator2.4.1(Qt4.8.0);
You should use nanosleep which is available in #include <ctime>.
Also you might need to include unistd.h for sleep and so on which I do not recommend.
All I can think of is that in your previous installation these files were auto included or macro'd.
nanosleep or man nanosleep
I am trying to compile a c++ project.
I get an error that mutex.h is missing.
1) Where in linux in read hat all include are ?
2) Where do I include it in eclispe ?
Spasiva
You don't mention which type of mutex you are trying to use:
If it's the pthread mutex, then:
#include <pthread.h>
If it's the C++11 mutex, then:
#include <mutex>
(you'll also need to compile with -std=c++11).
I am using QtMultimedia module in my application. However, the following code, which passes in Windows, fails on ubuntu.
#include <QtMultimedia/QAbstractVideoSurface>
#include <QtMultimedia/QVideoFrame>
according to this question, QtMultimediaKit must be installed. However, the location of headers differ, and code that passes looks like:
#include <QtMultimediaKit/QAbstractVideoSurface>
#include <QtMultimediaKit/QVideoFrame>
It is admittedly a minor difference, but it prevents me from interchangeably compiling in Windows and ubuntu. My guess is, i should use some form of macro expression, in lines of:
#ifdef WIN_MACRO
#include <QtMultimedia/QAbstractVideoSurface>
#include <QtMultimedia/QVideoFrame>
#else
#include <QtMultimediaKit/QAbstractVideoSurface>
#include <QtMultimediaKit/QVideoFrame>
#endif
to make the code compile on both systems. If that is correct, what should the macro be? If not - how can the problem be solved?
There is a macro in the Qt libraries that should help you. Try:
#ifdef Q_OS_WIN
I am trying to compile a driver. Version of my kernel is 3.2.0-27-generic.
I left only includes that I need:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/dmi.h>
These headers are found. But when I try to compile I get error that asm/cache.h file is not found.
When I dug dipper I found that there is no such folder as "asm", but asm-generic and it contains required headers.
It's structure of folder with headers:
Why was it renamed? Because of it I can't compile another drivers. If I rename "asm-geneic "to "asm" it will lead to other missing headers. What's wrong here?
asm/cache.h is architecture dependent, there are different asm directory for different architectures
arch/powerpc/include/asm/
arch/x86/include/asm/
arch/arm/include/asm
[...]
You can't rename include/asm-generic to include/asm because your problem is that you can't reach the architecture asm folder. Try to check your .config file or set manually the ARCH variable.