Trouble modifying fcntl.h
hello , i need to modify the kernel header fcntl.h (and other files but for now it's sufficient) . I must add a new variable to handle files.
/* BEGIN */ #define O_SESSION 040 /* END */ After i modified it i recompiled the kernel. I started with my new kernel and tried to use the new variable in a c files . /* BEGIN */ #include <fcntl.h> #include... . . main{ int fd fd = open(argv[1], O_RDWR | O_SESSION); /* END */ When i compile the c file , the answer is that the variable i defined (O_SESSION) is undeclared. So what is my error? Can anyone help me? Thank you and sorry for my poor english. |
The syntax for open system call is ...
fd=-open(pathname,flags,modes); you swapped the flags and modes. check that ! example Code:
fdl=open("/etc/passwd",O_RDONLY); |
Quote:
|
If it is only problem with header, but not with headers then compare with original source code.
download kernel source code archive. |
Yes but if i want change a kernel header what is the way?
I think i must recompile the kernel if a change a kernel header. Is that right?? |
if you want to change the kernel make a backup copy ! and then compile ....
compiling your kernel this article may help you ! |
When you compile programs, they refer to the kernel-headers or libc-headers which are packaged separately from the kernel sources.
You could explicitly point the sources at your modified headers in the kernel sources using -I/path/to/modified/files. But that is not really correct because the headers in the kernel sources are not sanitized for external use. The libc-headers are sanitized headers which are used to compile your glibc version and it is these headers which are referred to by (nearly) all sources at compile time. You'll find these headers under /usr/include/asm, /usr/include/asm-generic and /usr/inlcude/linux. |
Quote:
i see that in usr/include/asm there is the same header i need "fcntl.h" . But that header is different from the header i modified and recompiled in my new kernel. Do you suggest to overwrite that header with the one i modified in the kernel ? thank you |
It would be better to modify that one -but keep a backup of the roiginal. These installed ehaders are the ones that define the functions for nearly all the software compiled on your system. That is why you should not upgrade them to match the kernel version you are running. Kernel-headers should only be upgraded when the glibc version is updated and the version of headers should, again, match those used to compile glibc with -not necessarily the version of the kernel you are running.
If the software you are compiling is a kernel module, then you should use the header from the kernel sources, but otherwsie use the installed one. |
I think one would normally implement an ioctl within a file-system module rather than altering the fcntl header.
Kevin Barry |
All times are GMT -5. The time now is 07:03 AM. |