Programming :: Function In Kernel Space Called Form User Space
Jul 7, 2009
I wanna write a file in kernel space but from my searching I can to know that instead of writeing file in kernel space ,I can write data to user space by copy_to_user space.
But link is missing ...I dont know how will my user space will access kernel space means my function in kernel space which will do copy_to_user /....How my user space function will call my kernel level function ..
Can any one of you provide me with some example file which are doing this .I know every char driver is using it ...but i could not trace back how user level function is accessing it ...i m confused between user space and kernel space.
I am writing device driver in which i have to call callback function from kernel space, which are saving my data. But the callback functions are in userspace. While accessing them i am getting segmentation fault.
I am developing a I2C CDROM client driver. The CDROM firmware supports TOC information read through a I2C command. It sends the TOC information in burst ( Interrupts a GPIO pin when it is ready ) and my CPU does a I2C read to read the TOC. When the CDROM firmware finishes sending the last data burst , it informs my CPU that it is done with the TOC, by a flag in the last data burst. I would like to know, which is the most efficinet way I can send these TOC information to userspace?
I have the following requirement in my module. The driver gets some data from the external device. After getting 1MB of data it has to send it to the user space application. What is the best thing to implement for this in driver.? Is it ok to implement like, after getting data, the driver will send a signal to the user space application. Then the user space application sends an ioctl to read the data. Is there any alternate, that the driver directly sends the data without the user space application asks for it.?
Logical Memory Space of 4GB is divided in to 3GB User Space and 1GB Kernel Space. Always. Correct?
1. How can we change it? (just changing value of PAGE_OFFSET is okay?)
2. If system have only 256MB of memory (embedded system) and suppose Kernel Modules eat away all the memory during boot. User space will be left will no memory. Is this case possible?
I am writing a program which i dont want the kernel scheduler to preempt before certain time duration. I am using the system call sched_get_priority_max to set the maximum priority. However it is not producing results.
I manage to use the function "time" and "localtime" in gcc.But while I used it in a module in kernel space the above 2 functions are giving error.Even in kernel space time.h header file is not identified. tell the similar time function which can be used in kernel space
Is there any inbuilt function other than strncmp which can evaluate a string.my requirement is " if all 10 values are spaces print 1 else if it contains some values print 2 else print 3.if i use strlen, even space is counted.I know that i can evaluate using for loop by checking 1 by 1 char, and using strcmp function, is there any other way?
In a 32-bit system, max memory addressable is 4GB. Now Linux kernel does memory mapping division of 1GB for kernel address space and 3GB for user address space. That means 4GB of virtual address space is divided between kernel (1GB) and user (3GB).
Q1. All virtual mapping utilizes the available physical RAM without any division? I mean to say that if RAM is 512MB then a page in kernel space can lie any where RAM (leave aside old PCI dma accesses)? (How this fits to fact that kernel memory is non-pageble)
Q2. If a process is created in user space, it has visibility 4GB address space or 3GB address space?
I need a shared buffer between user and kernel space. I read that one way is to allocated buffer in kernel and then call mmap from the user space. I searched for an example but couldn't find something useful. If you know, could you please send me any links or sample code that does this..
I have written a device driver and I would like to disable an interrupt. In kernel space there is a function called "disable_irq(int irq)", but, is it possible to do it from user space?
I am looking for a way to issue ioctls to a usb driver from user space. Upon googling, I found that usbfs provides a way to do that, anyhow I can't find sample code to try that out.
Note: I have written a sample usb driver on the lines of 'Linux device drivers' book. Now I need to try ioctls with usb drivers.
I'm using vmsplice & splice to send memory buffers through a TCP socket. I have two issues using these methods:
1) According to the documentation, when using vmsplice with the flag SPLICE_F_GIFT, you cannot modify the buffer you've "given" the kernel. Currently, each time I want to send a buffer, I have to allocate a page-aligned buffer (fill it with data) and send it using vmsplice- splice. When can I deallocate this buffer? Is it possible to modify this buffer after the buffer is sent through the socket?
2) The buffer should be page-aligned both in memory and in length, but most of the time the sent messages (to the TCP socket) - are smaller than a page size - is it possible to "clear" the pipe from the remaining buffer?
Driven by my needs , i need to toggle only the flow control (RTS, CTS) bits and have nothing to do with the rest of the functionality (e.g. normaltx , rx operation). I am presuming that there exists a line discipline from user space for toggling RTS as ioctl (*file, cmd, *unsigned long ) can be used easily to toggle RTS. However, the use of IOCTL in kernel space for the same purpose brings about no change on RTS (oscilloscope shows no change). google led me to this [URL] and according to that i should make changes directly in the driver.
Code:
int x=0; int actual_module() { int k; mm_segment_t oldfs;
I want to simulate a serial protocol in user space program to test reception algorithm. The protocol is similar to UART protocol but frame format is different. The duration of 1 bit is 114,46 us. In my main function I'm creating two threads. Tx for simulating transmitting data and Rx for reception data. For measure time I use create_timer() function and signals. Each thread has its own timer and signal handler. Tx timer uses SIGUSR1 and Rx timer uses SIGUSR2. Tx thread sets the global variable and Rx reads it.
The timers are set to sample with 114,46 us period. When they reach this value signal handler should set the flag. Flag is check in thread and some operation are made. When I set the timers period for longer time (100 ms) everything works fine but when I change it to default value (114,46 us) the Rx thread doesn't receive the proper data. I am wondering if the 114,46 timer period is possible to simulate in user space? Whether the time will give me the proper resolution ? Theoretically it should provide 1 ns resolution.
I have our own C written program code which is communicating with a third party C++ written program code to run a moving device. We have successfully communicated with the third party code with wrapper functions. (Thanks to member in LQ that helped me solved this.)Now, we tried to run some functions to move the device. I think it is better for me to attach the related code first. pro.c (The source code we used to run the device)
I have linux and windowsxp on one machine. I have only 3gigs free on the windowxp machine and 20gigs free on the linux machine. I want to transfer space from the linux box to the windows machine.Is this possible and what steps would I need to follow to do this?
my home partition is an extended one, and when i want to create an unallocated space the space will stay in that extended partition. but there is also an 7 gb unallocated space which i want to merge with the other unallocated space. I also cannot extend that partition over that 7 gb. how can i overcome that problem?
i m also uploading a screenshot of gparted.[URL]..
Today I was installing a lot of software since I'm just setting up my Slackware system again after a fresh install, and I realized that my root partition has very little space left.
Here is the output of df -h:
Code:
As you can see, I have a 20G (19G here for some reason) root partition, 8G /var, and 86G of /home. I thought this would be plenty since many recent recommendations for / are 10-15G. Now, though, 17G are used up for some reason! How is this possible? I thought a full slackware install only had about 4G of software! I don't have any music or movies or any crazy huge files that I know of, and those would be in my /home directory anyway. Is there any way I can see which files are taking up all this space?
If it's necessary to allocate more space to my / partition, is it still possible to boot up a GParted live Cd, shrink /home a bit, move some partitions to the right, and expand my root partition? I would REALLY prefer I don't have to reinstall since I just spent a ton of time setting up my system again, but if worst comes to worst ... :'-(
I was trying to install Fedora 13, on to my laptop. I have 30 GB of unallocated space in extended partition. When trying to install Fedora 13, I got stuck, as the installer says that there is no free space for installation.can convert the unallocated space into free space.
i used gddrescure to clone an 80gb harddrive and this is the result ROFL.i guess you can only do this making sure the target drive is the same size, you see i didnt know lol so..i now have THIS problem.can anyone tell me how to turn my unallocated space into a usable 'free' space? i could play with gparted right now but i dont wanna do anything wrong, so if theres anyone who can tell me how to do this.
While installing OS, in partition window after OS file system structure I've left 277 GB. But after installation it shows Size - 255GB and available disk space is 242 GB.
Isn't it weired? How can I use the total amount of space in Linux? I need the whole 277GB exactly. What should be my workaround?
I have red hat linux server and it has mysql installed whenever i write on terminal command mysql -u root it shows error "ERROR 2002 (HY000): can't connect to local MYSQL server through '/var/lib/mysql/mysql.sock (111) "
And another problem is that it is showing 0 byte free space istaed of freeing the space. it may seems that both problems are dependent on each other.